diff --git a/en/OpenHarmony-Overview.md b/en/OpenHarmony-Overview.md index 1331ac52206cf1980ce59a7def62bfd32c27e406..75dc8b66607121be43c3bcfa13398ecee5b76401 100644 --- a/en/OpenHarmony-Overview.md +++ b/en/OpenHarmony-Overview.md @@ -150,7 +150,7 @@ Currently, the OpenHarmony community supports 17 types of development boards, wh | System Type| Board Model| Chip Model|
Function Description and Use Case
| Application Scenario| Code Repository | | -------- | -------- | -------- | -------- | -------- | -------- | -| Standard system| Runhe HH-SCDAYU200| RK3568 |
Function description:
Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates the dual-core GPU and efficient NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, Wi-Fi, audio, video, and camera features, with a wide range of expansion ports to accommodate various video input and outputs. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.
Use case:
[DAYU200 Use Case](device-dev/porting/porting-dayu200-on_standard-demo.md)
| Entertainment, easy travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)
| +| Standard system| Runhe HH-SCDAYU200| RK3568 |
Function description:
Bolstered by the Rockchip RK3568, the HH-SCDAYU200 development board integrates the dual-core GPU and efficient NPU. Its quad-core 64-bit Cortex-A55 processor uses the advanced 22 nm fabrication process and is clocked at up to 2.0 GHz. The board is packed with Bluetooth, Wi-Fi, audio, video, and camera features, with a wide range of expansion ports to accommodate various video input and outputs. It comes with dual GE auto-sensing RJ45 ports, so it can be used in multi-connectivity products, such as network video recorders (NVRs) and industrial gateways.
| Entertainment, easy travel, and smart home, such as kitchen hoods, ovens, and treadmills.| [device_soc_rockchip](https://gitee.com/openharmony/device_soc_rockchip)
[device_board_hihope](https://gitee.com/openharmony/device_board_hihope)
[vendor_hihope](https://gitee.com/openharmony/vendor_hihope)
| | Small system| Hispark_Taurus | Hi3516DV300 |
Function Description:
Hi3516D V300 is the next-generation system on chip (SoC) for smart HD IP cameras. It integrates the next-generation image signal processor (ISP), H.265 video compression encoder, and high-performance NNIE engine, and delivers high performance in terms of low bit rate, high image quality, intelligent processing and analysis, and low power consumption.
| Smart device with screens, such as refrigerators with screens and head units.| [device_soc_hisilicon](https://gitee.com/openharmony/device_soc_hisilicon)
[device_board_hisilicon](https://gitee.com/openharmony/device_board_hisilicon)
[vendor_hisilicon](https://gitee.com/openharmony/vendor_hisilicon)
| | Mini system| Multi-modal V200Z-R | BES2600 |
Function description:
The multi-modal V200Z-R development board is a high-performance, multi-functional, and cost-effective AIoT SoC powered by the BES2600WM chip of Bestechnic. It integrates a quad-core ARM processor with a frequency of up to 1 GHz as well as dual-mode Wi-Fi and dual-mode Bluetooth. The board supports the 802.11 a/b/g/n/ and BT/BLE 5.2 standards. It is able to accommodate RAM of up to 42 MB and flash memory of up to 32 MB, and supports the MIPI display serial interface (DSI) and camera serial interface (CSI). It is applicable to various AIoT multi-modal VUI and GUI interaction scenarios.
Use case:
[Multi-modal V200Z-R Use Case](device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md)
| Smart hardware, and smart devices with screens, such as speakers and watches.| [device_soc_bestechnic](https://gitee.com/openharmony/device_soc_bestechnic)
[device_board_fnlink](https://gitee.com/openharmony/device_board_fnlink)
[vendor_bestechnic](https://gitee.com/openharmony/vendor_bestechnic)
| diff --git a/en/application-dev/IDL/idl-guidelines.md b/en/application-dev/IDL/idl-guidelines.md index 661b2532c49d36c79855c3e0530326ef590c7cd2..5b3a5d7990d4dfe55ddef2ad77ef7dab84033a2e 100644 --- a/en/application-dev/IDL/idl-guidelines.md +++ b/en/application-dev/IDL/idl-guidelines.md @@ -7,7 +7,7 @@ To ensure successful communications between the client and server, interfaces re ![IDL-interface-description](./figures/IDL-interface-description.png) -IDL provides the following functions: +**IDL provides the following functions:** - Declares interfaces provided by system services for external systems, and based on the interface declaration, generates C, C++, JS, or TS code for inter-process communication (IPC) or remote procedure call (RPC) proxies and stubs during compilation. @@ -17,7 +17,7 @@ IDL provides the following functions: ![IPC-RPC-communication-model](./figures/IPC-RPC-communication-model.png) -IDL has the following advantages: +**IDL has the following advantages:** - Services are defined in the form of interfaces in IDL. Therefore, you do not need to focus on implementation details. @@ -433,7 +433,7 @@ export default { console.log('ServiceAbility want:' + JSON.stringify(want)); console.log('ServiceAbility want name:' + want.bundleName) } catch(err) { - console.log("ServiceAbility error:" + err) + console.log('ServiceAbility error:' + err) } console.info('ServiceAbility onConnect end'); return new IdlTestImp('connect'); @@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility'; function callbackTestIntTransaction(result: number, ret: number): void { if (result == 0 && ret == 124) { - console.log("case 1 success "); + console.log('case 1 success'); } } function callbackTestStringTransaction(result: number): void { if (result == 0) { - console.log("case 2 success "); + console.log('case 2 success'); } } @@ -472,17 +472,17 @@ var onAbilityConnectDone = { testProxy.testStringTransaction('hello', callbackTestStringTransaction); }, onDisconnect:function (elementName) { - console.log("onDisconnectService onDisconnect"); + console.log('onDisconnectService onDisconnect'); }, onFailed:function (code) { - console.log("onDisconnectService onFailed"); + console.log('onDisconnectService onFailed'); } }; function connectAbility: void { let want = { - "bundleName":"com.example.myapplicationidl", - "abilityName": "com.example.myapplicationidl.ServiceAbility" + bundleName: 'com.example.myapplicationidl', + abilityName: 'com.example.myapplicationidl.ServiceAbility' }; let connectionId = -1; connectionId = featureAbility.connectAbility(want, onAbilityConnectDone); @@ -495,7 +495,7 @@ function connectAbility: void { You can send a class from one process to another through IPC interfaces. However, you must ensure that the peer can use the code of this class and this class supports the **marshalling** and **unmarshalling** methods. OpenHarmony uses **marshalling** and **unmarshalling** to serialize and deserialize objects into objects that can be identified by each process. -To create a class that supports the sequenceable type, perform the following operations: +**To create a class that supports the sequenceable type, perform the following operations:** 1. Implement the **marshalling** method, which obtains the current state of the object and serializes the object into a **Parcel** object. 2. Implement the **unmarshalling** method, which deserializes the object from a **Parcel** object. @@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _reply = new rpc.MessageParcel(); _data.writeInt(data); this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) { - if (result.errCode === 0) { + if (result.errCode == 0) { let _errCode = result.reply.readInt(); if (_errCode != 0) { let _returnValue = undefined; @@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _returnValue = result.reply.readInt(); callback(_errCode, _returnValue); } else { - console.log("sendRequest failed, errCode: " + result.errCode); + console.log('sendRequest failed, errCode: ' + result.errCode); } }) } @@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService { let _reply = new rpc.MessageParcel(); _data.writeString(data); this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) { - if (result.errCode === 0) { + if (result.errCode == 0) { let _errCode = result.reply.readInt(); callback(_errCode); } else { - console.log("sendRequest failed, errCode: " + result.errCode); + console.log('sendRequest failed, errCode: ' + result.errCode); } }) } @@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager'; function testIntTransactionCallback(errCode: number, returnValue: number) { - console.log("errCode: " + errCode + " returnValue: " + returnValue); + console.log('errCode: ' + errCode + ' returnValue: ' + returnValue); } function testStringTransactionCallback(errCode: number) { - console.log("errCode: " + errCode); + console.log('errCode: ' + errCode); } function jsProxyTriggerCppStub() @@ -660,6 +660,6 @@ function jsProxyTriggerCppStub() tsProxy.testIntTransaction(10, testIntTransactionCallback); // Call testStringTransaction. - tsProxy.testStringTransaction("test", testIntTransactionCallback); + tsProxy.testStringTransaction('test', testIntTransactionCallback); } ``` diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index ca2c2fda1462b991f8ea60f36b5c181783034874..dba77cf37aab62a7bb4d33b367839a0c0c88bc4e 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -8,14 +8,13 @@ - Quick Start - Getting Started - [Preparations](quick-start/start-overview.md) - - [Getting Started with eTS in Stage Model](quick-start/start-with-ets-stage.md) - - [Getting Started with eTS in FA Model](quick-start/start-with-ets-fa.md) + - [Getting Started with ArkTS in Stage Model](quick-start/start-with-ets-stage.md) + - [Getting Started with ArkTS in FA Model](quick-start/start-with-ets-fa.md) - [Getting Started with JavaScript in FA Model](quick-start/start-with-js-fa.md) - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) - [SysCap](quick-start/syscap.md) - - [HarmonyAppProvision Configuration File](quick-start/app-provision-structure.md) - Development - [Ability Development](ability/Readme-EN.md) diff --git a/en/application-dev/ability/Readme-EN.md b/en/application-dev/ability/Readme-EN.md index 0589643e0f9426f76ac25d3616a41c3b54910e2a..6a11f497d375874b96bfed77a77dce033821d6e3 100644 --- a/en/application-dev/ability/Readme-EN.md +++ b/en/application-dev/ability/Readme-EN.md @@ -1,4 +1,5 @@ # Ability Development + - [Ability Framework Overview](ability-brief.md) - [Context Usage](context-userguide.md) - FA Model @@ -19,5 +20,3 @@ - [Ability Assistant Usage](ability-assistant-guidelines.md) - [ContinuationManager Development](continuationmanager.md) - [Test Framework Usage](ability-delegator.md) - - diff --git a/en/application-dev/ability/continuationmanager.md b/en/application-dev/ability/continuationmanager.md index a1f5a66478cd53aeabe03ed9be21e08596cb2b6b..20c272e75a16c2bcf14d567c1cbc7afa28a3a69a 100644 --- a/en/application-dev/ability/continuationmanager.md +++ b/en/application-dev/ability/continuationmanager.md @@ -14,20 +14,20 @@ As the entry of the ability continuation capability, **continuationManager** is ## Available APIs | API | Description| | ---------------------------------------------------------------------------------------------- | ----------- | -| register(callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.| -| register(options: ContinuationExtraParams, callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.| -| register(options?: ContinuationExtraParams): Promise\ | Registers the continuation management service and obtains a token. This API uses a promise to return the result.| -| on(type: "deviceConnect", token: number, callback: Callback\>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.| -| on(type: "deviceDisconnect", token: number, callback: Callback\>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.| -| off(type: "deviceConnect", token: number): void | Unsubscribes from device connection events.| -| off(type: "deviceDisconnect", token: number): void | Unsubscribes from device disconnection events.| -| startDeviceManager(token: number, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.| -| startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.| -| startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.| -| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.| -| updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\ | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.| -| unregister(token: number, callback: AsyncCallback\): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.| -| unregister(token: number): Promise\ | Deregisters the continuation management service. This API uses a promise to return the result.| +| registerContinuation(callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.| +| registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\): void | Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.| +| registerContinuation(options?: ContinuationExtraParams): Promise\ | Registers the continuation management service and obtains a token. This API uses a promise to return the result.| +| on(type: "deviceSelected", token: number, callback: Callback\>): void | Subscribes to device connection events. This API uses an asynchronous callback to return the result.| +| on(type: "deviceUnselected", token: number, callback: Callback\>): void | Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.| +| off(type: "deviceSelected", token: number): void | Unsubscribes from device connection events.| +| off(type: "deviceUnselected", token: number): void | Unsubscribes from device disconnection events.| +| startContinuationDeviceManager(token: number, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API does not involve any filter parameters and uses an asynchronous callback to return the result.| +| startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void | Starts the device selection module to show the list of available devices. This API uses an asynchronous callback to return the result.| +| startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ | Starts the device selection module to show the list of available devices. This API uses a promise to return the result.| +| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void | Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.| +| updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\ | Instructs the device selection module to update the device connection state. This API uses a promise to return the result.| +| unregisterContinuation(token: number, callback: AsyncCallback\): void | Deregisters the continuation management service. This API uses an asynchronous callback to return the result.| +| unregisterContinuation(token: number): Promise\ | Deregisters the continuation management service. This API uses a promise to return the result.| ## How to Develop 1. Import the **continuationManager** module. @@ -36,7 +36,7 @@ As the entry of the ability continuation capability, **continuationManager** is import continuationManager from '@ohos.continuation.continuationManager'; ``` -2. Apply for permissions required for cross-device continuation or collaboration operations. +2. Apply for the **DISTRIBUTED_DATASYNC** permission. The permission application operation varies according to the ability model in use. In the FA mode, add the required permission in the `config.json` file, as follows: @@ -57,6 +57,7 @@ As the entry of the ability continuation capability, **continuationManager** is ```ts import abilityAccessCtrl from "@ohos.abilityAccessCtrl"; import bundle from '@ohos.bundle'; + import featureAbility from '@ohos.ability.featureAbility'; async function requestPermission() { let permissions: Array = [ @@ -124,7 +125,8 @@ As the entry of the ability continuation capability, **continuationManager** is // If the permission is not granted, call requestPermissionsFromUser to apply for the permission. if (needGrantPermission) { try { - await globalThis.abilityContext.requestPermissionsFromUser(permissions); + // globalThis.context is Ability.context, which must be assigned a value in the MainAbility.ts file in advance. + await globalThis.context.requestPermissionsFromUser(permissions); } catch (err) { console.error('app permission request permissions error' + JSON.stringify(err)); } @@ -140,13 +142,16 @@ As the entry of the ability continuation capability, **continuationManager** is ```ts let token: number = -1; // Used to save the token returned after the registration. The token will be used when listening for device connection/disconnection events, starting the device selection module, and updating the device connection state. - - continuationManager.register().then((data) => { - console.info('register finished, ' + JSON.stringify(data)); - token = data; // Obtain a token and assign a value to the token variable. - }).catch((err) => { - console.error('register failed, cause: ' + JSON.stringify(err)); - }); + try { + continuationManager.registerContinuation().then((data) => { + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; // Obtain a token and assign a value to the token variable. + }).catch((err) => { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } ``` 4. Listen for the device connection/disconnection state. @@ -156,28 +161,31 @@ As the entry of the ability continuation capability, **continuationManager** is ```ts let remoteDeviceId: string = ""; // Used to save the information about the remote device selected by the user, which will be used for cross-device continuation or collaboration. - // The token parameter is the token obtained during the registration. - continuationManager.on("deviceConnect", token, (continuationResults) => { - console.info('registerDeviceConnectCallback len: ' + continuationResults.length); - if (continuationResults.length <= 0) { - console.info('no selected device'); - return; - } - remoteDeviceId = continuationResults[0].id; // Assign the deviceId of the first selected remote device to the remoteDeviceId variable. - - // Pass the remoteDeviceId parameter to want. - let want = { - deviceId: remoteDeviceId, - bundleName: 'ohos.samples.continuationmanager', - abilityName: 'MainAbility' - }; - // To initiate multi-device collaboration, you must obtain the ohos.permission.DISTRIBUTED_DATASYNC permission. - globalThis.abilityContext.startAbility(want).then((data) => { - console.info('StartRemoteAbility finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err)); + try { + // The token parameter is the token obtained during the registration. + continuationManager.on("deviceSelected", token, (continuationResults) => { + console.info('registerDeviceSelectedCallback len: ' + continuationResults.length); + if (continuationResults.length <= 0) { + console.info('no selected device'); + return; + } + remoteDeviceId = continuationResults[0].id; // Assign the deviceId of the first selected remote device to the remoteDeviceId variable. + + // Pass the remoteDeviceId parameter to want. + let want = { + deviceId: remoteDeviceId, + bundleName: 'ohos.samples.continuationmanager', + abilityName: 'MainAbility' + }; + globalThis.abilityContext.startAbility(want).then((data) => { + console.info('StartRemoteAbility finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('StartRemoteAbility failed, cause: ' + JSON.stringify(err)); + }); }); - }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` The preceding multi-device collaboration operation is performed across devices in the stage model. For details about this operation in the FA model, see [Page Ability Development](https://gitee.com/openharmony/docs/blob/master/en/application-dev/ability/fa-pageability.md). @@ -189,35 +197,43 @@ As the entry of the ability continuation capability, **continuationManager** is let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.CONNECTED; // The token parameter is the token obtained during the registration, and the remoteDeviceId parameter is the remoteDeviceId obtained. - continuationManager.updateConnectStatus(token, remoteDeviceId, deviceConnectStatus).then((data) => { - console.info('updateConnectStatus finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); - }); + try { + continuationManager.updateContinuationState(token, remoteDeviceId, deviceConnectStatus).then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } ``` Listen for the device disconnection state so that the user can stop cross-device continuation or collaboration in time. The sample code is as follows: ```ts - // The token parameter is the token obtained during the registration. - continuationManager.on("deviceDisconnect", token, (deviceIds) => { - console.info('onDeviceDisconnect len: ' + deviceIds.length); - if (deviceIds.length <= 0) { - console.info('no unselected device'); - return; - } + try { + // The token parameter is the token obtained during the registration. + continuationManager.on("deviceUnselected", token, (continuationResults) => { + console.info('onDeviceUnselected len: ' + continuationResults.length); + if (continuationResults.length <= 0) { + console.info('no unselected device'); + return; + } - // Update the device connection state. - let unselectedDeviceId: string = deviceIds[0]; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable. - let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected. + // Update the device connection state. + let unselectedDeviceId: string = continuationResults[0].id; // Assign the deviceId of the first deselected remote device to the unselectedDeviceId variable. + let deviceConnectStatus: continuationManager.DeviceConnectState = continuationManager.DeviceConnectState.DISCONNECTING; // Device disconnected. - // The token parameter is the token obtained during the registration, and the unselectedDeviceId parameter is the unselectedDeviceId obtained. - continuationManager.updateConnectStatus(token, unselectedDeviceId, deviceConnectStatus).then((data) => { - console.info('updateConnectStatus finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err)); + // The token parameter is the token obtained during the registration, and the unselectedDeviceId parameter is the unselectedDeviceId obtained. + continuationManager.updateContinuationState(token, unselectedDeviceId, deviceConnectStatus).then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); }); - }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } ``` 5. Start the device selection module to show the list of available devices on the network. @@ -231,12 +247,16 @@ As the entry of the ability continuation capability, **continuationManager** is continuationMode: continuationManager.ContinuationMode.COLLABORATION_SINGLE // Single-choice mode of the device selection module. }; - // The token parameter is the token obtained during the registration. - continuationManager.startDeviceManager(token, continuationExtraParams).then((data) => { - console.info('startDeviceManager finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('startDeviceManager failed, cause: ' + JSON.stringify(err)); - }); + try { + // The token parameter is the token obtained during the registration. + continuationManager.startContinuationDeviceManager(token, continuationExtraParams).then((data) => { + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } ``` 6. If you do not need to perform cross-device migration or collaboration operations, you can deregister the continuation management service, by passing the token obtained during the registration. @@ -244,10 +264,14 @@ As the entry of the ability continuation capability, **continuationManager** is The sample code is as follows: ```ts - // The token parameter is the token obtained during the registration. - continuationManager.unregister(token).then((data) => { - console.info('unregister finished, ' + JSON.stringify(data)); - }).catch((err) => { - console.error('unregister failed, cause: ' + JSON.stringify(err)); - }); + try { + // The token parameter is the token obtained during the registration. + continuationManager.unregisterContinuation(token).then((data) => { + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }).catch((err) => { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } ``` diff --git a/en/application-dev/ability/fa-pageability.md b/en/application-dev/ability/fa-pageability.md index 3a2629a79996660f48dfc247b9a560ea1abe09b4..f6eb70595322d3f3308c00afcc9a5907ff87054f 100644 --- a/en/application-dev/ability/fa-pageability.md +++ b/en/application-dev/ability/fa-pageability.md @@ -1,12 +1,16 @@ # Page Ability Development ## Overview + ### Concepts -The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code. The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**. + +The Page ability implements the ArkUI and provides the capability of interacting with developers. When you create an ability in DevEco Studio, DevEco Studio automatically creates template code. + +The capabilities related to the Page ability are implemented through the **featureAbility**, and the lifecycle callbacks are implemented through the callbacks in **app.js** or **app.ets**. ### Page Ability Lifecycle -**Ability lifecycle** +Introduction to the Page ability lifecycle: The Page ability lifecycle defines all states of a Page ability, such as **INACTIVE**, **ACTIVE**, and **BACKGROUND**. @@ -27,27 +31,30 @@ Description of ability lifecycle states: - **BACKGROUND**: The Page ability runs in the background. After being re-activated, the Page ability enters the **ACTIVE** state. After being destroyed, the Page ability enters the **INITIAL** state. -**The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability.** +The following figure shows the relationship between lifecycle callbacks and lifecycle states of the Page ability. ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) You can override the lifecycle callbacks provided by the Page ability in the **app.js** or **app.ets** file. Currently, the **app.js** file provides only the **onCreate** and **onDestroy** callbacks, and the **app.ets** file provides the full lifecycle callbacks. ### Launch Type + The ability supports two launch types: singleton and multi-instance. + You can specify the launch type by setting **launchType** in the **config.json** file. -**Table 1** Introduction to startup mode +**Table 1** Startup modes | Launch Type | Description |Description | | ----------- | ------- |---------------- | | standard | Multi-instance | A new instance is started each time an ability starts.| -| singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.| +| singleton | Singleton | The ability has only one instance in the system. If an instance already exists when an ability is started, that instance is reused.| By default, **singleton** is used. ## Development Guidelines + ### Available APIs **Table 2** APIs provided by featureAbility @@ -73,23 +80,21 @@ By default, **singleton** is used. ```javascript import featureAbility from '@ohos.ability.featureAbility' featureAbility.startAbility({ - want: - { - action: "", - entities: [""], - type: "", - deviceId: "", - bundleName: "com.example.myapplication", - /* In the FA model, abilityName consists of package and ability name. */ - abilityName: "com.example.entry.secondAbility", - uri: "" - }, - }, - ); + want: { + action: "", + entities: [""], + type: "", + deviceId: "", + bundleName: "com.example.myapplication", + /* In the FA model, abilityName consists of package and ability name. */ + abilityName: "com.example.entry.secondAbility", + uri: "" + } + }); ``` ### Starting a Remote Page Ability ->Note +>NOTE > >This feature applies only to system applications, since the **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md index f3572352e718bb77493d7dd2d097d2d7a82058c9..a153f69fbfe2b71362a4b7e5808fe57c1b7a4216 100644 --- a/en/application-dev/device/device-location-info.md +++ b/en/application-dev/device/device-location-info.md @@ -66,7 +66,7 @@ To learn more about the APIs for obtaining device location information, see [Geo If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background. - You can declare the required permission in your application's configuration file. For details, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). + You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../security/accesstoken-guidelines.md). 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index 5f6e88fc07c88d3e5913058a26887e818a3cc3bc..07f3425ff5ab3c10beeac312740ff6e756c3cd85 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -1,23 +1,24 @@ # Media -- Audio - - [Audio Overview](audio-overview.md) - - [Audio Playback Development](audio-playback.md) - - [Audio Recording Development](audio-recorder.md) - - [Audio Rendering Development](audio-renderer.md) - - [Audio Stream Management Development](audio-stream-manager.md) - - [Audio Capture Development](audio-capturer.md) - - [OpenSL ES Audio Playback Development](opensles-playback.md) - - [OpenSL ES Audio Recording Development](opensles-capture.md) - - [Audio Interruption Mode Development](audio-interruptmode.md) - -- Video - - [Video Playback Development](video-playback.md) - - [Video Recording Development](video-recorder.md) - -- Image +- Audio + - [Audio Overview](audio-overview.md) + - [Audio Playback Development](audio-playback.md) + - [Audio Recording Development](audio-recorder.md) + - [Audio Rendering Development](audio-renderer.md) + - [Audio Stream Management Development](audio-stream-manager.md) + - [Audio Capture Development](audio-capturer.md) + - [OpenSL ES Audio Playback Development](opensles-playback.md) + - [OpenSL ES Audio Recording Development](opensles-capture.md) + - [Audio Interruption Mode Development](audio-interruptmode.md) + +- Video + - [Video Playback Development](video-playback.md) + - [Video Recording Development](video-recorder.md) + + +- Image - [Image Development](image.md) - -- Camera - - [Camera Development](camera.md) - - [Distributed Camera Development](remote-camera.md) + +- Camera + - [Camera Development](camera.md) + - [Distributed Camera Development](remote-camera.md) diff --git a/en/application-dev/media/audio-capturer.md b/en/application-dev/media/audio-capturer.md index 0815ef31a288440271a27a8f03fb417923a46190..539de6bb5c5a0723aa68a8994f7ee1970f393a3f 100644 --- a/en/application-dev/media/audio-capturer.md +++ b/en/application-dev/media/audio-capturer.md @@ -1,106 +1,101 @@ # Audio Capture Development -## When to Use +## Introduction -You can use the APIs provided by **AudioCapturer** to record raw audio files. +You can use the APIs provided by **AudioCapturer** to record raw audio files, thereby implementing audio data collection. -### State Check +**Status check**: During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioCapturer** instance. This is because some operations can be performed only when the audio capturer is in a given state. If the application performs an operation when the audio capturer is not in the given state, the system may throw an exception or generate other undefined behavior. -During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioCapturer** instance. This is because some operations can be performed only when the audio capturer is in a given state. If the application performs an operation when the audio capturer is not in the given state, the system may throw an exception or generate other undefined behavior. +## Working Principles -For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8). +This following figure shows the audio capturer state transitions. + +**Figure 1** Audio capturer state transitions + +![audio-capturer-state](figures/audio-capturer-state.png) + +- **PREPARED**: The audio capturer enters this state by calling **create()**. +- **RUNNING**: The audio capturer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state. +- **STOPPED**: The audio capturer in the **RUNNING** state can call **stop()** to stop playing audio data. +- **RELEASED**: The audio capturer in the **PREPARED** or **STOPPED** state can use **release()** to release all occupied hardware and software resources. It will not transit to any other state after it enters the **RELEASED** state. -**Figure 1** Audio capturer state +## Constraints -![](figures/audio-capturer-state.png) +Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details about permission configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). ## How to Develop +For details about the APIs, see [AudioCapturer in Audio Management](../reference/apis/js-apis-audio.md#audiocapturer8). + 1. Use **createAudioCapturer()** to create an **AudioCapturer** instance. - Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording status, and register a callback for notification. + Set parameters of the **AudioCapturer** instance in **audioCapturerOptions**. This instance is used to capture audio, control and obtain the recording state, and register a callback for notification. ```js - var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - var audioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 1 - } - - var audioCapturerOptions = { - streamInfo: audioStreamInfo, - capturerInfo: audioCapturerInfo - } - - let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); - var state = audioRenderer.state; - ``` - -2. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes. -If an application needs to perform some operations when the audio renderer state is updated, the application can subscribe to the state changes. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md). + import audio from '@ohos.multimedia.audio'; - ```js - audioCapturer.on('stateChange',(state) => { - console.info('AudioCapturerLog: Changed State to : ' + state) - switch (state) { - case audio.AudioState.STATE_PREPARED: - console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); - console.info('Audio State is : Prepared'); - break; - case audio.AudioState.STATE_RUNNING: - console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); - console.info('Audio State is : Running'); - break; - case audio.AudioState.STATE_STOPPED: - console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); - console.info('Audio State is : stopped'); - break; - case audio.AudioState.STATE_RELEASED: - console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); - console.info('Audio State is : released'); - break; - default: - console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); - console.info('Audio State is : invalid'); - break; - } - }); + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 // 0 is the extended flag bit of the audio capturer. The default value is 0. + } + + let audioCapturerOptions = { + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo + } + + let audioCapturer = await audio.createAudioCapturer(audioCapturerOptions); + console.log('AudioRecLog: Create audio capturer success.'); ``` -3. Use **start()** to start audio recording. +2. Use **start()** to start audio recording. The capturer state will be **STATE_RUNNING** once the audio capturer is started. The application can then begin reading buffers. ```js - await audioCapturer.start(); - if (audioCapturer.state == audio.AudioState.STATE_RUNNING) { - console.info('AudioRecLog: Capturer started'); - } else { - console.info('AudioRecLog: Capturer start failed'); - } - ``` - -4. Use **getBufferSize()** to obtain the minimum buffer size to read. + import audio from '@ohos.multimedia.audio'; + + async function startCapturer() { + let state = audioCapturer.state; + // The audio capturer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started. + if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED || + state != audio.AudioState.STATE_STOPPED) { + console.info('Capturer is not in a correct state to start'); + return; + } + await audioCapturer.start(); - ```js - var bufferSize = await audioCapturer.getBufferSize(); - console.info('AudioRecLog: buffer size: ' + bufferSize); + let state = audioCapturer.state; + if (state == audio.AudioState.STATE_RUNNING) { + console.info('AudioRecLog: Capturer started'); + } else { + console.error('AudioRecLog: Capturer start failed'); + } + } ``` -5. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application wants to stop the recording. +3. Read the captured audio data and convert it to a byte stream. Call **read()** repeatedly to read the data until the application stops the recording. The following example shows how to write recorded data into a file. ```js import fileio from '@ohos.fileio'; + + let state = audioCapturer.state; + // The read operation can be performed only when the state is STATE_RUNNING. + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Capturer is not in a correct state to read'); + return; + } - const path = '/data/data/.pulse_dir/capture_js.wav'; + const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file. let fd = fileio.openSync(path, 0o102, 0o777); if (fd !== null) { console.info('AudioRecLog: file fd created'); @@ -115,38 +110,140 @@ If an application needs to perform some operations when the audio renderer state console.info('AudioRecLog: file fd opened in append mode'); } - var numBuffersToCapture = 150; + let numBuffersToCapture = 150; // Write data for 150 times. while (numBuffersToCapture) { - var buffer = await audioCapturer.read(bufferSize, true); + let buffer = await audioCapturer.read(bufferSize, true); if (typeof(buffer) == undefined) { - console.info('read buffer failed'); + console.info('AudioRecLog: read buffer failed'); } else { - var number = fileio.writeSync(fd, buffer); - console.info('AudioRecLog: data written: ' + number); + let number = fileio.writeSync(fd, buffer); + console.info(`AudioRecLog: data written: ${number}`); } numBuffersToCapture--; } ``` -6. Once the recording is complete, call **stop()** to stop the recording. +4. Once the recording is complete, call **stop()** to stop the recording. + ```js + async function StopCapturer() { + let state = audioCapturer.state; + // The audio capturer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state. + if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { + console.info('AudioRecLog: Capturer is not running or paused'); + return; + } + + await audioCapturer.stop(); + + state = audioCapturer.state; + if (state == audio.AudioState.STATE_STOPPED) { + console.info('AudioRecLog: Capturer stopped'); + } else { + console.error('AudioRecLog: Capturer stop failed'); + } + } ``` - await audioCapturer.stop(); - if (audioCapturer.state == audio.AudioState.STATE_STOPPED) { - console.info('AudioRecLog: Capturer stopped'); - } else { - console.info('AudioRecLog: Capturer stop failed'); - } + +5. After the task is complete, call **release()** to release related resources. + + ```js + async function releaseCapturer() { + let state = audioCapturer.state; + // The audio capturer can be released only when it is not in the STATE_RELEASED or STATE_NEW state. + if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { + console.info('AudioRecLog: Capturer already released'); + return; + } + + await audioCapturer.release(); + + state = audioCapturer.state; + if (state == audio.AudioState.STATE_RELEASED) { + console.info('AudioRecLog: Capturer released'); + } else { + console.info('AudioRecLog: Capturer release failed'); + } + } ``` -7. After the task is complete, call **release()** to release related resources. +6. (Optional) Obtain the audio capturer information. + + You can use the following code to obtain the audio capturer information: ```js - await audioCapturer.release(); - if (audioCapturer.state == audio.AudioState.STATE_RELEASED) { - console.info('AudioRecLog: Capturer released'); - } else { - console.info('AudioRecLog: Capturer release failed'); - } + // Obtain the audio capturer state. + let state = audioCapturer.state; + + // Obtain the audio capturer information. + let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo(); + + // Obtain the audio stream information. + let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo(); + + // Obtain the audio stream ID. + let audioStreamId : number = await audioCapturer.getAudioStreamId(); + + // Obtain the Unix timestamp, in nanoseconds. + let audioTime : number = await audioCapturer.getAudioTime(); + + // Obtain a proper minimum buffer size. + let bufferSize : number = await audioCapturer.getBuffersize(); ``` + +7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event. + + After the mark reached event is subscribed to, when the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned. + + ```js + audioCapturer.on('markReach', (reachNumber) => { + console.info('Mark reach event Received'); + console.info(`The Capturer reached frame: ${reachNumber}`); + }); + + audioCapturer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for. + ``` + +8. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event. + + After the period reached event is subscribed to, each time the number of frames collected by the audio capturer reaches the specified value, a callback is triggered and the specified value is returned. + + ```js + audioCapturer.on('periodReach', (reachNumber) => { + console.info('Period reach event Received'); + console.info(`In this period, the Capturer reached frame: ${reachNumber}`); + }); + + audioCapturer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for. + ``` + +9. If your application needs to perform some operations when the audio capturer state is updated, it can subscribe to the state change event. When the audio capturer state is updated, the application receives a callback containing the event type. + + ```js + audioCapturer.on('stateChange', (state) => { + console.info(`AudioCapturerLog: Changed State to : ${state}`) + switch (state) { + case audio.AudioState.STATE_PREPARED: + console.info('--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('Audio State is : released'); + break; + default: + console.info('--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('Audio State is : invalid'); + break; + } + }); + ``` diff --git a/en/application-dev/media/audio-interruptmode.md b/en/application-dev/media/audio-interruptmode.md index 8be8a00cedd10ff4ecd08ee46d746d9803b3c71a..48a53bf5d5990ac88aae1271466a6aa36d52ac98 100644 --- a/en/application-dev/media/audio-interruptmode.md +++ b/en/application-dev/media/audio-interruptmode.md @@ -1,49 +1,50 @@ # Audio Interruption Mode Development -## When to Use -The audio interruption mode is used to control the playback of multiple audio streams.
-Audio applications can set the audio interruption mode to independent or shared under **AudioRenderer**.
-In shared mode, multiple audio streams share one session ID. In independent mode, each audio stream has an independent session ID. +## Introduction +The audio interruption mode is used to control the playback of multiple audio streams. + +Audio applications can set the audio interruption mode to independent or shared under **AudioRenderer**. -### Asynchronous Operations +In shared mode, multiple audio streams share one session ID. In independent mode, each audio stream has an independent session ID. -To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. +**Asynchronous operation**: To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. ## How to Develop For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8). +1. Use **createAudioRenderer()** to create an **AudioRenderer** instance. + + Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. -1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
- Set parameters of the **AudioRenderer** instance in **audioRendererOptions**.
- This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
- - ```js + This instance is used to render audio, control and obtain the rendering status, and register a callback for notification. + +```js import audio from '@ohos.multimedia.audio'; - - var audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - var audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 1 - } + var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } - var audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } + var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); ``` - -2. Set the audio interruption mode. +2. Set the audio interruption mode. + After the **AudioRenderer** instance is initialized, you can set the audio interruption mode.
```js diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md index 5227f6cdd1b9ec89818b0d1762c99267ec7eba97..92aa1cd4fc35a4b64ad9b1044c1a7bd59f24453d 100644 --- a/en/application-dev/media/audio-playback.md +++ b/en/application-dev/media/audio-playback.md @@ -1,25 +1,35 @@ # Audio Playback Development -## When to Use +## Introduction -You can use audio playback APIs to convert audio data into audible analog signals, play the signals using output devices, and manage playback tasks. +You can use audio playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, and obtain track information. -**Figure 1** Playback status +## Working Principles + +The following figures show the audio playback status changes and the interaction with external modules for audio playback. + +**Figure 1** Audio playback state transition ![en-us_image_audio_state_machine](figures/en-us_image_audio_state_machine.png) -**Note**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value. +**NOTE**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value. -**Figure 2** Layer 0 diagram of audio playback +**Figure 2** Interaction with external modules for audio playback ![en-us_image_audio_player](figures/en-us_image_audio_player.png) +**NOTE**: When a third-party application calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework and outputs the audio data decoded by the software to the audio HDI of the hardware interface layer to implement audio playback. + ## How to Develop For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md#audioplayer). +> **NOTE** +> +> The method for obtaining the path in the FA model is different from that in the stage model. **pathDir** used in the sample code below is an example. You need to obtain the path based on project requirements. For details about how to obtain the path, see [Application Sandbox Path Guidelines](../reference/apis/js-apis-fileio.md#guidelines). + ### Full-Process Scenario The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources. @@ -99,8 +109,9 @@ async function audioPlayerDemo() { setCallBack(audioPlayer); // Set the event callbacks. // 2. Set the URI of the audio file. let fdPath = 'fd://' - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. - let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements. + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command. + let path = pathDir + '/01.mp3' await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; console.info('open fd success fd is' + fdPath); @@ -118,6 +129,7 @@ async function audioPlayerDemo() { ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' + export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { @@ -139,8 +151,9 @@ export class AudioDemo { let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. - let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements. + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command. + let path = pathDir + '/01.mp3' await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; console.info('open fd success fd is' + fdPath); @@ -159,6 +172,7 @@ export class AudioDemo { ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' + export class AudioDemo { // Set the player callbacks. private isNextMusic = false; @@ -185,8 +199,9 @@ export class AudioDemo { async nextMusic(audioPlayer) { this.isNextMusic = true; let nextFdPath = 'fd://' - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. - let nextpath = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/02.mp3'; + let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements. + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command. + let nextpath = pathDir + '/02.mp3' await fileIO.open(nextpath).then((fdNumber) => { nextFdPath = nextFdPath + '' + fdNumber; console.info('open fd success fd is' + nextFdPath); @@ -202,8 +217,9 @@ export class AudioDemo { let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. - let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements. + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command. + let path = pathDir + '/01.mp3' await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; console.info('open fd success fd is' + fdPath); @@ -222,6 +238,7 @@ export class AudioDemo { ```js import media from '@ohos.multimedia.media' import fileIO from '@ohos.fileio' + export class AudioDemo { // Set the player callbacks. setCallBack(audioPlayer) { @@ -239,8 +256,9 @@ export class AudioDemo { let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance. this.setCallBack(audioPlayer); // Set the event callbacks. let fdPath = 'fd://' - // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command. - let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3'; + let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements. + // The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command. + let path = pathDir + '/01.mp3' await fileIO.open(path).then((fdNumber) => { fdPath = fdPath + '' + fdNumber; console.info('open fd success fd is' + fdPath); diff --git a/en/application-dev/media/audio-recorder.md b/en/application-dev/media/audio-recorder.md index f465db2b88118b77c9a4e64307170da07c3e8918..78650a61d0a803811394e623ab0bc46155438ba9 100644 --- a/en/application-dev/media/audio-recorder.md +++ b/en/application-dev/media/audio-recorder.md @@ -1,8 +1,12 @@ # Audio Recording Development -## When to Use +## Introduction -During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and file path for audio recording. +During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and output file path for audio recording. + +## Working Principles + +The following figures show the audio recording state transition and the interaction with external modules for audio recording. **Figure 1** Audio recording state transition @@ -10,10 +14,16 @@ During audio recording, audio signals are captured, encoded, and saved to files. -**Figure 2** Layer 0 diagram of audio recording +**Figure 2** Interaction with external modules for audio recording ![en-us_image_audio_recorder_zero](figures/en-us_image_audio_recorder_zero.png) +**NOTE**: When a third-party recording application or recorder calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework to obtain the audio data captured through the audio HDI. The framework layer then encodes the audio data through software and saves the encoded and encapsulated audio data to a file to implement audio recording. + +## Constraints + +Before developing audio recording, configure the **ohos.permission.MICROPHONE** permission for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). + ## How to Develop For details about the APIs, see [AudioRecorder in the Media API](../reference/apis/js-apis-media.md#audiorecorder). diff --git a/en/application-dev/media/audio-renderer.md b/en/application-dev/media/audio-renderer.md index 82a0753b66384e6f1a991ba97f7d6c7580936e0e..699eb7cb6cae5f198c1620e22b7c3f0df4a90813 100644 --- a/en/application-dev/media/audio-renderer.md +++ b/en/application-dev/media/audio-renderer.md @@ -1,214 +1,197 @@ # Audio Rendering Development -## When to Use +## Introduction **AudioRenderer** provides APIs for rendering audio files and controlling playback. It also supports audio interruption. You can use the APIs provided by **AudioRenderer** to play audio files in output devices and manage playback tasks. -### Audio Interruption +Before calling the APIs, be familiar with the following terms: -When an audio stream with a higher priority needs to be played, the audio renderer interrupts the stream with a lower priority. For example, if a call comes in when the user is listening to music, the music playback, which is the lower priority stream, is paused. For details, see [How to Develop](#how-to-develop). +- **Audio interruption**: When an audio stream with a higher priority needs to be played, the audio renderer interrupts the stream with a lower priority. For example, if a call comes in when the user is listening to music, the music playback, which is the lower priority stream, is paused. +- **Status check**: During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioRenderer** instance. This is because some operations can be performed only when the audio renderer is in a given state. If the application performs an operation when the audio renderer is not in the given state, the system may throw an exception or generate other undefined behavior. +- **Asynchronous operation**: To prevent the UI thread from being blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. For more information, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8). +- **Audio interruption mode**: OpenHarmony provides two audio interruption modes: **shared mode** and **independent mode**. In shared mode, all **AudioRenderer** instances created by the same application share one focus object, and there is no focus transfer inside the application. Therefore, no callback will be triggered. In independent mode, each **AudioRenderer** instance has an independent focus object, and focus preemption occurs. Focus preemption triggers focus transfer, and the **AudioRenderer** instance that originally has the focus receives a notification through the callback. By default, the shared mode is used. You can call **setInterruptMode()** to set the independent mode. -### State Check +## Working Principles -During application development, you are advised to use **on('stateChange')** to subscribe to state changes of the **AudioRenderer** instance. This is because some operations can be performed only when the audio renderer is in a given state. If the application performs an operation when the audio renderer is not in the given state, the system may throw an exception or generate other undefined behavior. +The following figure shows the audio renderer state transitions. -**Figure 1** Audio renderer state +Figure 1 Audio renderer state transitions -![](figures/audio-renderer-state.png) +![audio-renderer-state](figures/audio-renderer-state.png) -### Asynchronous Operations - -To ensure that the UI thread is not blocked, most **AudioRenderer** calls are asynchronous. Each API provides the callback and promise functions. The following examples use the promise functions. For more information, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8). +- **PREPARED**: The audio renderer enters this state by calling **create()**. +- **RUNNING**: The audio renderer enters this state by calling **start()** when it is in the **PREPARED** state or by calling **start()** when it is in the **STOPPED** state. +- **PAUSED**: The audio renderer in the **RUNNING** state can call **pause()** to pause the audio playback. After the audio playback is paused, it can call **start()** to resume the playback. +- **STOPPED**: The audio renderer in the **PAUSED** or **RUNNING** state can call **stop()** to stop the playback. +- **RELEASED**: The audio renderer in the **PREPARED**, **PAUSED**, or **STOPPED** state can use **release()** to release all occupied hardware and software resources. It will not transit to any other state after it enters the **RELEASED** state. ## How to Develop +For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8). + 1. Use **createAudioRenderer()** to create an **AudioRenderer** instance. - Set parameters of the audio renderer in **audioCapturerOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification. + + +Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification. ```js - var audioStreamInfo = { + import audio from '@ohos.multimedia.audio'; + + let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - - var audioRendererInfo = { + let audioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_SPEECH, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 1 + rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0. } - - var audioRendererOptions = { + let audioRendererOptions = { streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo - } + } let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + console.log("Create audio renderer success."); ``` -2. Use **on('interrupt')** to subscribe to audio interruption events. - - Stream-A is interrupted when Stream-B with a higher or equal priority requests to become active and use the output device. - - In some cases, the audio renderer performs forcible operations such as pausing and ducking, and notifies the application through **InterruptEvent**. In other cases, the application can choose to act on the **InterruptEvent** or ignore it. +2. Use **start()** to start audio rendering. - In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption unaware applications can use **audioRenderer.state** to check the renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9). - ```js - audioRenderer.on('interrupt', (interruptEvent) => { - console.info('InterruptEvent Received'); - console.info('InterruptType: ' + interruptEvent.eventType); - console.info('InterruptForceType: ' + interruptEvent.forceType); - console.info('AInterruptHint: ' + interruptEvent.hintType); + async function startRenderer() { + let state = audioRenderer.state; + // The audio renderer should be in the STATE_PREPARED, STATE_PAUSED, or STATE_STOPPED state after being started. + if (state != audio.AudioState.STATE_PREPARED && state != audio.AudioState.STATE_PAUSED && + state != audio.AudioState.STATE_STOPPED) { + console.info('Renderer is not in a correct state to start'); + return; + } - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - // Force Pause: Action was taken by framework. - // Halt the write calls to avoid data loss. - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - isPlay = false; - break; - // Force Stop: Action was taken by framework. - // Halt the write calls to avoid data loss. - case audio.InterruptHint.INTERRUPT_HINT_STOP: - isPlay = false; - break; - // Force Duck: Action was taken by framework, - // just notifying the app that volume has been reduced. - case audio.InterruptHint.INTERRUPT_HINT_DUCK: - break; - // Force Unduck: Action was taken by framework, - // just notifying the app that volume has been restored. - case audio.InterruptHint.INTERRUPT_HINT_UNDUCK: - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - // Share Resume: Action is to be taken by App. - // Resume the force paused stream if required. - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - startRenderer(); - break; - // Share Pause: Stream has been interrupted, - // It can choose to pause or play concurrently. - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - isPlay = false; - pauseRenderer(); - break; - } - } - }); - ``` - -3. Use **start()** to start audio rendering. + await audioRenderer.start(); + state = audioRenderer.state; + if (state == audio.AudioState.STATE_RUNNING) { + console.info('Renderer started'); + } else { + console.error('Renderer start failed'); + } + } + ``` The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers. - ```js - async function startRenderer() { - var state = audioRenderer.state; - // The state should be prepared, paused, or stopped. - if (state != audio.AudioState.STATE_PREPARED || state != audio.AudioState.STATE_PAUSED || - state != audio.AudioState.STATE_STOPPED) { - console.info('Renderer is not in a correct state to start'); - return; - } - - await audioRenderer.start(); - - state = audioRenderer.state; - if (state == audio.AudioState.STATE_RUNNING) { - console.info('Renderer started'); - } else { - console.error('Renderer start failed'); - } - } - ``` -4. Call **write()** to write data to the buffer. +3. Call **write()** to write data to the buffer. Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer. ```js - async function writeBuffer(buf) { - var state = audioRenderer.state; - if (state != audio.AudioState.STATE_RUNNING) { - console.error('Renderer is not running, do not write'); - isPlay = false; - return; - } - let writtenbytes = await audioRenderer.write(buf); - - console.info('Actual written bytes: ' + writtenbytes); - if (writtenbytes < 0) { - console.error('Write buffer failed. check the state of renderer'); - } - } - - // Reasonable minimum buffer size for renderer. However, the renderer can accept other read sizes as well. - const bufferSize = await audioRenderer.getBufferSize(); - const path = '/data/file_example_WAV_2MG.wav'; - let ss = fileio.createStreamSync(path, 'r'); - const totalSize = 2146166; // file_example_WAV_2MG.wav - let rlen = 0; - let discardHeader = new ArrayBuffer(44); - ss.readSync(discardHeader); - rlen += 44; - - var id = setInterval(() => { - if (isPlay || isRelease) { - if (rlen >= totalSize || isRelease) { - ss.closeSync(); - stopRenderer(); - clearInterval(id); - } - let buf = new ArrayBuffer(bufferSize); - rlen += ss.readSync(buf); - console.info('Total bytes read from file: ' + rlen); - writeBuffer(buf); - } else { - console.info('check after next interval'); - } - } , 30); // interval to be set based on audio file format + import fileio from '@ohos.fileio'; + import audio from '@ohos.multimedia.audio'; + + async function writeBuffer(buf) { + // The write operation can be performed only when the state is STATE_RUNNING. + if (audioRenderer.state != audio.AudioState.STATE_RUNNING) { + console.error('Renderer is not running, do not write'); + return; + } + let writtenbytes = await audioRenderer.write(buf); + console.info(`Actual written bytes: ${writtenbytes} `); + if (writtenbytes < 0) { + console.error('Write buffer failed. check the state of renderer'); + } + } + + // Set a proper buffer size for the audio renderer. You can also select a buffer of another size. + const bufferSize = await audioRenderer.getBufferSize(); + let dir = globalThis.fileDir; // You must use the sandbox path. + const path = dir + '/file_example_WAV_2MG.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav + console.info(`file path: ${ path}`); + let ss = fileio.createStreamSync(path, 'r'); + const totalSize = fileio.statSync(path).size; // Size of the file to render. + let discardHeader = new ArrayBuffer(bufferSize); + ss.readSync(discardHeader); + let rlen = 0; + rlen += bufferSize; + + let id = setInterval(() => { + if (audioRenderer.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state. + ss.closeSync(); + await audioRenderer.stop(); + clearInterval(id); + } + if (audioRenderer.state == audio.AudioState.STATE_RUNNING) { + if (rlen >= totalSize) { // The rendering stops if the file finishes reading. + ss.closeSync(); + await audioRenderer.stop(); + clearInterval(id); + } + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`Total bytes read from file: ${rlen}`); + writeBuffer(buf); + } else { + console.info('check after next interval'); + } + }, 30); // The timer interval is set based on the audio format. The unit is millisecond. ``` -5. (Optional) Call **pause()** or **stop()** to pause or stop rendering. +4. (Optional) Call **pause()** or **stop()** to pause or stop rendering. ```js async function pauseRenderer() { - var state = audioRenderer.state; - if (state != audio.AudioState.STATE_RUNNING) { - console.info('Renderer is not running'); - return; - } - - await audioRenderer.pause(); - - state = audioRenderer.state; - if (state == audio.AudioState.STATE_PAUSED) { - console.info('Renderer paused'); - } else { - console.error('Renderer pause failed'); - } + let state = audioRenderer.state; + // The audio renderer can be paused only when it is in the STATE_RUNNING state. + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Renderer is not running'); + return; + } + + await audioRenderer.pause(); + + state = audioRenderer.state; + if (state == audio.AudioState.STATE_PAUSED) { + console.info('Renderer paused'); + } else { + console.error('Renderer pause failed'); + } } - + async function stopRenderer() { - var state = audioRenderer.state; - if (state != audio.AudioState.STATE_RUNNING || state != audio.AudioState.STATE_PAUSED) { - console.info('Renderer is not running or paused'); - return; - } - - await audioRenderer.stop(); - - state = audioRenderer.state; - if (state == audio.AudioState.STATE_STOPPED) { - console.info('Renderer stopped'); - } else { - console.error('Renderer stop failed'); - } - } + let state = audioRenderer.state; + // The audio renderer can be stopped only when it is in STATE_RUNNING or STATE_PAUSED state. + if (state != audio.AudioState.STATE_RUNNING && state != audio.AudioState.STATE_PAUSED) { + console.info('Renderer is not running or paused'); + return; + } + + await audioRenderer.stop(); + + state = audioRenderer.state; + if (state == audio.AudioState.STATE_STOPPED) { + console.info('Renderer stopped'); + } else { + console.error('Renderer stop failed'); + } + } + ``` + +5. (Optional) Call **drain()** to clear the buffer. + + ```js + async function drainRenderer() { + let state = audioRenderer.state; + // drain() can be used only when the audio renderer is in the STATE_RUNNING state. + if (state != audio.AudioState.STATE_RUNNING) { + console.info('Renderer is not running'); + return; + } + + await audioRenderer.drain(); + + state = audioRenderer.state; + } ``` 6. After the task is complete, call **release()** to release related resources. @@ -217,19 +200,349 @@ To ensure that the UI thread is not blocked, most **AudioRenderer** calls are as ```js async function releaseRenderer() { - if (state_ == RELEASED || state_ == NEW) { - console.info('Resourced already released'); - return; - } + let state = audioRenderer.state; + // The audio renderer can be released only when it is not in the STATE_RELEASED or STATE_NEW state. + if (state == audio.AudioState.STATE_RELEASED || state == audio.AudioState.STATE_NEW) { + console.info('Renderer already released'); + return; + } + + await audioRenderer.release(); + + state = audioRenderer.state; + if (state == audio.AudioState.STATE_RELEASED) { + console.info('Renderer released'); + } else { + console.info('Renderer release failed'); + } + } + ``` - await audioRenderer.release(); +7. (Optional) Obtain the audio renderer information. + + You can use the following code to obtain the audio renderer information: - state = audioRenderer.state; - if (state == STATE_RELEASED) { - console.info('Renderer released'); - } else { - console.info('Renderer release failed'); - } + ```js + // Obtain the audio renderer state. + let state = audioRenderer.state; + + // Obtain the audio renderer information. + let audioRendererInfo : audio.AudioRendererInfo = await audioRenderer.getRendererInfo(); - } + // Obtain the audio stream information. + let audioStreamInfo : audio.AudioStreamInfo = await audioRenderer.getStreamInfo(); + + // Obtain the audio stream ID. + let audioStreamId : number = await audioRenderer.getAudioStreamId(); + + // Obtain the Unix timestamp, in nanoseconds. + let audioTime : number = await audioRenderer.getAudioTime(); + + // Obtain a proper minimum buffer size. + let bufferSize : number = await audioRenderer.getBuffersize(); + + // Obtain the audio renderer rate. + let renderRate : audio.AudioRendererRate = await audioRenderer.getRenderRate(); ``` + +8. (Optional) Set the audio renderer information. + + You can use the following code to set the audio renderer information: + + ```js + // Set the audio renderer rate to RENDER_RATE_NORMAL. + let renderRate : audio.AudioRendererRate = audio.AudioRendererRate.RENDER_RATE_NORMAL; + await audioRenderer.setRenderRate(renderRate); + + // Set the interruption mode of the audio renderer to SHARE_MODE. + let interruptMode : audio.InterruptMode = audio.InterruptMode.SHARE_MODE; + await audioRenderer.setInterruptMode(interruptMode); + + // Set the volume of the stream to 10. + let volume : number = 10; + await audioRenderer.setVolume(volume); + ``` + +9. (Optional) Use **on('audioInterrupt')** to subscribe to the audio interruption event, and use **off('audioInterrupt')** to unsubscribe from the event. + + Audio interruption means that Stream A will be interrupted when Stream B with a higher or equal priority requests to become active and use the output device. + + In some cases, the audio renderer performs forcible operations such as pausing and ducking, and notifies the application through **InterruptEvent**. In other cases, the application can choose to act on the **InterruptEvent** or ignore it. + + In the case of audio interruption, the application may encounter write failures. To avoid such failures, interruption-unaware applications can use **audioRenderer.state** to check the audio renderer state before writing audio data. The applications can obtain more details by subscribing to the audio interruption events. For details, see [InterruptEvent](../reference/apis/js-apis-audio.md#interruptevent9). + + It should be noted that the audio interruption event subscription of the **AudioRenderer** module is slightly different from **on('interrupt')** in [AudioManager](../reference/apis/js-apis-audio.md#audiomanager). The **on('interrupt')** and **off('interrupt')** APIs are deprecated since API version 9. In the **AudioRenderer** module, you only need to call **on('audioInterrupt')** to listen for focus change events. When the **AudioRenderer** instance created by the application performs actions such as start, stop, and pause, it requests the focus, which triggers focus transfer and in return enables the related **AudioRenderer** instance to receive a notification through the callback. For instances other than **AudioRenderer**, such as frequency modulation (FM) and voice wakeup, the application does not create an instance. In this case, the application can call **on('interrupt')** in **AudioManager** to receive a focus change notification. + + ```js + audioRenderer.on('audioInterrupt', (interruptEvent) => { + console.info('InterruptEvent Received'); + console.info(`InterruptType: ${interruptEvent.eventType}`); + console.info(`InterruptForceType: ${interruptEvent.forceType}`); + console.info(`AInterruptHint: ${interruptEvent.hintType}`); + + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + // Forcible pausing initiated by the audio framework. To prevent data loss, stop the write operation. + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + isPlay = false; + break; + // Forcible stopping initiated by the audio framework. To prevent data loss, stop the write operation. + case audio.InterruptHint.INTERRUPT_HINT_STOP: + isPlay = false; + break; + // Forcible ducking initiated by the audio framework. + case audio.InterruptHint.INTERRUPT_HINT_DUCK: + break; + // Undocking initiated by the audio framework. + case audio.InterruptHint.INTERRUPT_HINT_UNDUCK: + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + // Notify the application that the rendering starts. + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + startRenderer(); + break; + // Notify the application that the audio stream is interrupted. The application determines whether to continue. (In this example, the application pauses the rendering.) + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + isPlay = false; + pauseRenderer(); + break; + } + } + }); + + audioRenderer.off('audioInterrupt'); // Unsubscribe from the audio interruption event. This event will no longer be received. + ``` + +10. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event. + + After the mark reached event is subscribed to, when the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned. + + ```js + audioRenderer.on('markReach', (reachNumber) => { + console.info('Mark reach event Received'); + console.info(`The renderer reached frame: ${reachNumber}`); + }); + + audioRenderer.off('markReach'); // Unsubscribe from the mark reached event. This event will no longer be listened for. + ``` + +11. (Optional) Use **on('periodReach')** to subscribe to the period reached event, and use **off('periodReach')** to unsubscribe from the event. + + After the period reached event is subscribed to, each time the number of frames rendered by the audio renderer reaches the specified value, a callback is triggered and the specified value is returned. + + ```js + audioRenderer.on('periodReach', (reachNumber) => { + console.info('Period reach event Received'); + console.info(`In this period, the renderer reached frame: ${reachNumber} `); + }); + + audioRenderer.off('periodReach'); // Unsubscribe from the period reached event. This event will no longer be listened for. + ``` + +12. (Optional) Use **on('stateChange')** to subscribe to audio renderer state changes. + + After the **stateChange** event is subscribed to, when the audio renderer state changes, a callback is triggered and the audio renderer state is returned. + + ```js + audioRenderer.on('stateChange', (audioState) => { + console.info('State change event Received'); + console.info(`Current renderer state is: ${audioState}`); + }); + ``` + +13. (Optional) Handle exceptions of **on()**. + + If the string or the parameter type passed in **on()** is incorrect , the application throws an exception. In this case, you can use **try catch** to capture the exception. + + ```js + try { + audioRenderer.on('invalidInput', () => { // The string does not match. + }) + } catch (err) { + console.info(`Call on function error, ${err}`); // The application throws exception 401. + } + try { + audioRenderer.on(1, () => { // The type of the input parameter is incorrect. + }) + } catch (err) { + console.info(`Call on function error, ${err}`); // The application throws exception 6800101. + } + ``` + +14. (Optional) Refer to the complete example of **on('audioInterrupt')**. + + Create **AudioRender1** and **AudioRender2** in an application, configure the independent interruption mode, and call **on('audioInterrupt')** to subscribe to audio interruption events. At the beginning, **AudioRender1** has the focus. When **AudioRender2** attempts to obtain the focus, **AudioRenderer1** receives a focus transfer notification and the related log information is printed. If the shared mode is used, the log information will not be printed during application running. + + ```js + async runningAudioRender1(){ + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0. + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + // 1.1 Create an instance. + audioRenderer1 = await audio.createAudioRenderer(audioRendererOptions); + console.info("Create audio renderer 1 success."); + + // 1.2 Set the independent mode. + audioRenderer1.setInterruptMode(1).then( data => { + console.info('audioRenderer1 setInterruptMode Success!'); + }).catch((err) => { + console.error(`audioRenderer1 setInterruptMode Fail: ${err}`); + }); + + // 1.3 Set the listener. + audioRenderer1.on('audioInterrupt', async(interruptEvent) => { + console.info(`audioRenderer1 on audioInterrupt : ${JSON.stringify(interruptEvent)}`) + }); + + // 1.4 Start rendering. + await audioRenderer1.start(); + console.info('startAudioRender1 success'); + + // 1.5 Obtain the buffer size, which is the proper minimum buffer size of the audio renderer. You can also select a buffer of another size. + const bufferSize = await audioRenderer1.getBufferSize(); + console.info(`audio bufferSize: ${bufferSize}`); + + // 1.6 Obtain the original audio data file. + let dir = globalThis.fileDir; // You must use the sandbox path. + const path1 = dir + '/music001_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav + console.info(`audioRender1 file path: ${ path1}`); + let ss1 = await fileio.createStream(path1,'r'); + const totalSize1 = fileio.statSync(path1).size; // Size of the file to render. + console.info(`totalSize1 -------: ${totalSize1}`); + let discardHeader = new ArrayBuffer(bufferSize); + ss1.readSync(discardHeader); + let rlen = 0; + rlen += bufferSize; + + // 1.7 Render the original audio data in the buffer by using audioRenderer. + let id = setInterval(async () => { + if (audioRenderer1.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state. + ss1.closeSync(); + audioRenderer1.stop(); + clearInterval(id); + } + if (audioRenderer1.state == audio.AudioState.STATE_RUNNING) { + if (rlen >= totalSize1) { // The rendering stops if the file finishes reading. + ss1.closeSync(); + await audioRenderer1.stop(); + clearInterval(id); + } + let buf = new ArrayBuffer(bufferSize); + rlen += ss1.readSync(buf); + console.info(`Total bytes read from file: ${rlen}`); + await writeBuffer(buf, that.audioRenderer1); + } else { + console.info('check after next interval'); + } + }, 30); // The timer interval is set based on the audio format. The unit is millisecond. + } + + async runningAudioRender2(){ + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0. + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + // 2.1 Create another instance. + audioRenderer2 = await audio.createAudioRenderer(audioRendererOptions); + console.info("Create audio renderer 2 success."); + + // 2.2 Set the independent mode. + audioRenderer2.setInterruptMode(1).then( data => { + console.info('audioRenderer2 setInterruptMode Success!'); + }).catch((err) => { + console.error(`audioRenderer2 setInterruptMode Fail: ${err}`); + }); + + // 2.3 Set the listener. + audioRenderer2.on('audioInterrupt', async(interruptEvent) => { + console.info(`audioRenderer2 on audioInterrupt : ${JSON.stringify(interruptEvent)}`) + }); + + // 2.4 Start rendering. + await audioRenderer2.start(); + console.info('startAudioRender2 success'); + + // 2.5 Obtain the buffer size. + const bufferSize = await audioRenderer2.getBufferSize(); + console.info(`audio bufferSize: ${bufferSize}`); + + // 2.6 Read the original audio data file. + let dir = globalThis.fileDir; // You must use the sandbox path. + const path2 = dir + '/music002_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav + console.error(`audioRender1 file path: ${ path2}`); + let ss2 = await fileio.createStream(path2,'r'); + const totalSize2 = fileio.statSync(path2).size; // Size of the file to render. + console.error(`totalSize2 -------: ${totalSize2}`); + let discardHeader2 = new ArrayBuffer(bufferSize); + ss2.readSync(discardHeader2); + let rlen = 0; + rlen += bufferSize; + + // 2.7 Render the original audio data in the buffer by using audioRenderer. + let id = setInterval(async () => { + if (audioRenderer2.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state. + ss2.closeSync(); + that.audioRenderer2.stop(); + clearInterval(id); + } + if (audioRenderer1.state == audio.AudioState.STATE_RUNNING) { + if (rlen >= totalSize2) { // The rendering stops if the file finishes reading. + ss2.closeSync(); + await audioRenderer2.stop(); + clearInterval(id); + } + let buf = new ArrayBuffer(bufferSize); + rlen += ss2.readSync(buf); + console.info(`Total bytes read from file: ${rlen}`); + await writeBuffer(buf, that.audioRenderer2); + } else { + console.info('check after next interval'); + } + }, 30); // The timer interval is set based on the audio format. The unit is millisecond. + } + + async writeBuffer(buf, audioRender) { + let writtenbytes; + await audioRender.write(buf).then((value) => { + writtenbytes = value; + console.info(`Actual written bytes: ${writtenbytes} `); + }); + if (typeof(writtenbytes) != 'number' || writtenbytes < 0) { + console.error('get Write buffer failed. check the state of renderer'); + } + } + + // Integrated invoking entry. + async test(){ + await runningAudioRender1(); + await runningAudioRender2(); + } + + ``` diff --git a/en/application-dev/media/audio-stream-manager.md b/en/application-dev/media/audio-stream-manager.md index eb89957e9b8793b149c368445f1232bf0ff3b563..44ec37cd11f3666131214e5e908a1ce761fea111 100644 --- a/en/application-dev/media/audio-stream-manager.md +++ b/en/application-dev/media/audio-stream-manager.md @@ -1,57 +1,61 @@ # Audio Stream Management Development -## When to Use +## Introduction You can use **AudioStreamManager** to manage audio streams. -### Development Process +## Working Principles -During application development, use **getStreamManager()** to create an **AudioStreamManager** instance. Then, you can call **on('audioRendererChange')** or **on('audioCapturerChange')** to listen for status, client, and audio attribute changes of the audio playback or recording application. To cancel the listening for these changes, call **off('audioRendererChange')** or **off('audioCapturerChange')**. You can call **getCurrentAudioRendererInfoArray()** to obtain information about the audio playback application, such as the unique audio stream ID, UID of the audio playback client, and audio status. Similarly, you can call **getCurrentAudioCapturerInfoArray()** to obtain information about the audio recording application. The figure below shows the invoking relationship. +The following figure shows the calling relationship of **AudioStreamManager** APIs. -For details about the APIs, see [AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9). +**Figure 1** AudioStreamManager API calling relationship -**Figure 1** Audio stream management invoking relationship +![en-us_image_audio_stream_manager](figures/en-us_image_audio_stream_manager.png) -![](figures/en-us_image_audio_stream_manager.png) +**NOTE**: During application development, use **getStreamManager()** to create an **AudioStreamManager** instance. Then, you can call **on('audioRendererChange')** or **on('audioCapturerChange')** to listen for status, client, and audio attribute changes of the audio playback or recording application. To cancel the listening for these changes, call **off('audioRendererChange')** or **off('audioCapturerChange')**. You can call **getCurrentAudioRendererInfoArray()** to obtain information about the audio playback application, such as the unique audio stream ID, UID of the audio playback client, and audio status. Similarly, you can call **getCurrentAudioCapturerInfoArray()** to obtain information about the audio recording application. ## How to Develop +For details about the APIs, see [AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9). + 1. Create an **AudioStreamManager** instance. Before using **AudioStreamManager** APIs, you must use **getStreamManager()** to create an **AudioStreamManager** instance. ```js - var audioStreamManager = audio.getStreamManager(); + var audioManager = audio.getAudioManager(); + var audioStreamManager = audioManager.getStreamManager(); ``` 2. (Optional) Call **on('audioRendererChange')** to listen for audio renderer changes. -If an application needs to receive notifications when the audio playback application status, audio playback client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md). - ```js - audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; - console.info('## RendererChange on is called for ' + i + ' ##'); - console.info('StreamId for ' + i + ' is:' + AudioRendererChangeInfo.streamId); - console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); - console.info('Content for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); - console.info('Stream for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.usage); - console.info('Flag ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); - console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); - var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; - for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { - console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); - console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); - console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); - console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); - console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); - console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); - console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); - console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); - } - } - }); - ``` + If an application needs to receive notifications when the audio playback application status, audio playback client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md). + + ```js + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('## RendererChange on is called for ' + i + ' ##'); + console.info('StreamId for ' + i + ' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream for ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + }); + ``` 3. (Optional) Call **off('audioRendererChange')** to cancel listening for audio renderer changes. @@ -61,30 +65,31 @@ If an application needs to receive notifications when the audio playback applica ``` 4. (Optional) Call **on('audioCapturerChange')** to listen for audio capturer changes. -If an application needs to receive notifications when the audio recording application status, audio recording client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md). - ```js - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(' ## audioCapturerChange on is called for element ' + i + ' ##'); - console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); - console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); - console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); - console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); - console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); - console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); - console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); - console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); - console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); - console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); - console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); - console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); - } - } - }); - ``` + If an application needs to receive notifications when the audio recording application status, audio recording client, or audio attribute changes, it can subscribe to this event. For more events that can be subscribed to, see [Audio Management](../reference/apis/js-apis-audio.md). + + ```js + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(' ## audioCapturerChange on is called for element ' + i + ' ##'); + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + }); + ``` 5. (Optional) Call **off('audioCapturerChange')** to cancel listening for audio capturer changes. @@ -94,65 +99,66 @@ If an application needs to receive notifications when the audio recording applic ``` 6. (Optional) Call **getCurrentAudioRendererInfoArray()** to obtain information about the current audio renderer. -This API can be used to obtain the unique ID of the audio stream, UID of the audio playback client, audio status, and other information about the audio player. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly. - - ```js - await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { - console.info('######### Get Promise is called ##########'); - if (AudioRendererChangeInfoArray != null) { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; - console.info('StreamId for ' + i +' is:' + AudioRendererChangeInfo.streamId); - console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); - console.info('Content ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); - console.info('Stream' + i +' is:' + AudioRendererChangeInfo.rendererInfo.usage); - console.info('Flag' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); - console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); - var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; - for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { - console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); - console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); - console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); - console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); - console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); - console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); - console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); - console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); - } - } - } - }).catch((err) => { - console.log('getCurrentAudioRendererInfoArray :ERROR: ' + err.message); - }); - ``` + + This API can be used to obtain the unique ID of the audio stream, UID of the audio playback client, audio status, and other information about the audio player. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly. + + ```js + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info('StreamId for ' + i +' is:' + AudioRendererChangeInfo.streamId); + console.info('ClientUid for ' + i + ' is:' + AudioRendererChangeInfo.clientUid); + console.info('Content ' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.content); + console.info('Stream' + i +' is:' + AudioRendererChangeInfo.rendererInfo.usage); + console.info('Flag' + i + ' is:' + AudioRendererChangeInfo.rendererInfo.rendererFlags); + console.info('State for ' + i + ' is:' + AudioRendererChangeInfo.rendererState); + var devDescriptor = AudioRendererChangeInfo.deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].name); + console.info('Address:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioRendererChangeInfo.deviceDescriptors[j].channelMasks); + } + } + } + }).catch((err) => { + console.log('getCurrentAudioRendererInfoArray :ERROR: ' + err.message); + }); + ``` 7. (Optional) Call **getCurrentAudioCapturerInfoArray()** to obtain information about the current audio capturer. -This API can be used to obtain the unique ID of the audio stream, UID of the audio recording client, audio status, and other information about the audio capturer. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly. - - ```js - await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { - console.info('getCurrentAudioCapturerInfoArray: **** Get Promise Called ****'); - if (AudioCapturerChangeInfoArray != null) { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); - console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); - console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); - console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); - console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); - var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); - console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); - console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); - console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name) - console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); - console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); - console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); - console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); - } - } - } - }).catch((err) => { - console.log('getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); - }); - ``` + This API can be used to obtain the unique ID of the audio stream, UID of the audio recording client, audio status, and other information about the audio capturer. Before calling this API, a third-party application must have the **ohos.permission.USE_BLUETOOTH** permission configured, for the device name and device address to be displayed correctly. + + ```js + await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('getCurrentAudioCapturerInfoArray: **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info('StreamId for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].streamId); + console.info('ClientUid for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].clientUid); + console.info('Source for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.source); + console.info('Flag ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags); + console.info('State for ' + i + 'is:' + AudioCapturerChangeInfoArray[i].capturerState); + var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info('Id:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id); + console.info('Type:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType); + console.info('Role:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole); + console.info('Name:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name) + console.info('Address:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address); + console.info('SampleRates:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]); + console.info('ChannelCounts' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]); + console.info('ChannelMask:' + i + ':' + AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks); + } + } + } + }).catch((err) => { + console.log('getCurrentAudioCapturerInfoArray :ERROR: ' + err.message); + }); + ``` diff --git a/en/application-dev/media/camera.md b/en/application-dev/media/camera.md index 06439dd049be835cdf5a96a35e2a2a42012ee6f8..25e5e573057661487895bc003c143393287b4829 100644 --- a/en/application-dev/media/camera.md +++ b/en/application-dev/media/camera.md @@ -2,7 +2,13 @@ ## When to Use -You can use the camera module to develop basic camera functions, including previewing, photographing, and video recording. +With the APIs provided by the **Camera** module, you can access and operate camera devices and develop new functions. Common operations include preview, photographing, and video recording. You can also implement flash control, exposure time control, focus mode control, zooming control, and many others. + +Before calling camera APIs, be familiar with the following concepts: + +- **Static camera capabilities**: A series of parameters used to describe inherent capabilities of a camera, such as orientation and supported resolution. +- **Physical camera**: An independent camera device. The physical camera ID is a string that uniquely identifies a physical camera. +- **Asynchronous operation**: To prevent the UI thread from being blocked, most **Camera** calls are asynchronous. Each API provides the callback and promise functions. ## How to Develop @@ -12,152 +18,298 @@ For details about the APIs, see [Camera Management](../reference/apis/js-apis-ca ### Full-Process Scenario -The full process includes creating an instance, setting parameters, managing sessions, taking photos, recording videos, and releasing resources. +The full process includes applying for permissions, creating an instance, setting parameters, managing sessions, taking photos, recording videos, and releasing resources. + +#### Applying for Permissions + +You must apply for the permission for your application to access the camera device and other functions. The following table lists camera-related permissions. + +| Permission| Attribute Value | +| -------- | ------------------------------ | +| Camera| ohos.permission.CAMERA | +| Call recording| ohos.permission.MICROPHONE | +| Storage| ohos.permission.WRITE_MEDIA | +| Read| ohos.permission.READ_MEDIA | +| Location| ohos.permission.MEDIA_LOCATION | -The method for creating an XComponent is also provided. For details, see [XComponent Creation](#xcomponent-creation). +The code snippet is as follows: -For details about the APIs used to save images, see [Image Processing](../reference/apis/js-apis-image.md). +```typescript +const PERMISSIONS: Array = [ + 'ohos.permission.CAMERA', + 'ohos.permission.MICROPHONE', + 'ohos.permission.MEDIA_LOCATION', + 'ohos.permission.READ_MEDIA', + 'ohos.permission.WRITE_MEDIA' +] + +function applyPermission() { + console.info('[permission] get permission'); + globalThis.abilityContext.requestPermissionFromUser(PERMISSIONS) + } +``` #### Creating an Instance -```js +You must create an independent **CameraManager** instance before performing camera operations. If this operation fails, the camera may be occupied or unusable. If the camera is occupied, wait until it is released. You can call **getSupportedCameras()** to obtain the list of cameras supported by the current device. The list stores all camera IDs of the current device. If the list is not empty, each ID in the list can be used to create an independent camera instance. If the list is empty, no camera is available for the current device and subsequent operations cannot be performed. The camera has preview, shooting, video recording, and metadata streams. You can use **getSupportedOutputCapability()** to obtain the output stream capabilities of the camera and configure them in the **profile** field in **CameraOutputCapability**. The procedure for creating a **CameraManager** instance is as follows: + +```typescript import camera from '@ohos.multimedia.camera' import image from '@ohos.multimedia.image' import media from '@ohos.multimedia.media' -import featureAbility from '@ohos.ability.featureAbility' // Create a CameraManager object. -let cameraManager -await camera.getCameraManager(globalThis.Context, (err, manager) => { - if (err) { - console.error('Failed to get the CameraManager instance ${err.message}'); - return; - } - console.log('Callback returned with the CameraManager instance'); - cameraManager = manager -}) - -// Register a callback to listen for camera status changes and obtain the updated camera status information. -cameraManager.on('cameraStatus', (cameraStatusInfo) => { - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); -}) +context: any = getContext(this) +let cameraManager = await camera.getCameraManager(this.context) +if (!cameraManager) { + console.error('Failed to get the CameraManager instance'); +} // Obtain the camera list. -let cameraArray -await cameraManager.getCameras((err, cameras) => { - if (err) { - console.error('Failed to get the cameras. ${err.message}'); - return; - } - console.log('Callback returned with an array of supported cameras: ' + cameras.length); - cameraArray = cameras -}) +let cameraArray = await cameraManager.getSupportedCameras() +if (!cameraArray) { + console.error('Failed to get the cameras'); +} -for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) { - console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID. - console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position. - console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type. - console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // Obtain the camera connection type. +for (let index = 0; index < cameraArray.length; index++) { + console.log('cameraId : ' + cameraArray[index].cameraId) // Obtain the camera ID. + console.log('cameraPosition : ' + cameraArray[index].cameraPosition) // Obtain the camera position. + console.log('cameraType : ' + cameraArray[index].cameraType) // Obtain the camera type. + console.log('connectionType : ' + cameraArray[index].connectionType) // Obtain the camera connection type. } // Create a camera input stream. -let cameraInput -await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => { - console.log('Promise returned with the CameraInput instance'); - cameraInput = input -}) +let cameraInput = await cameraManager.createCameraInput(cameraArray[0]) + +// Obtain the output stream capabilities supported by the camera. +let cameraOutputCap = await cameraManager.getSupportedOutputCapability(cameraArray[0]); +if (!cameraOutputCap) { + console.error("outputCapability outputCapability == null || undefined") +} else { + console.info("outputCapability: " + JSON.stringify(cameraOutputCap)); +} -// Create a preview output stream. -let previewOutput -camera.createPreviewOutput((globalThis.surfaceId), (err, output) => { - if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with previewOutput instance'); - previewOutput = output -}); +let previewProfilesArray = cameraOutputCap.GetPreviewProfiles(); +if (!previewProfilesArray) { + console.error("createOutput previewProfilesArray == null || undefined") +} + +let photoProfilesArray = cameraOutputCap.GetPhotoProfiles(); +if (!photoProfilesArray) { + console.error("createOutput photoProfilesArray == null || undefined") +} + +let videoProfilesArray = cameraOutputCap.GetVideoProfiles(); +if (!videoProfilesArray) { + console.error("createOutput videoProfilesArray == null || undefined") +} + +let metadataObjectTypesArray = cameraOutputCap.GetSupportedMetadataObjectType(); +if (!metadataObjectTypesArray) { + console.error("createOutput metadataObjectTypesArray == null || undefined") +} + +// Create a preview stream. For details about the surfaceId parameter, see the XComponent section. The preview stream is the surface provided by the XComponent. +let previewOutput = await cameraManager.createPreviewOutput(previewProfilesArray[0], surfaceId) +if (!previewOutput) { + console.error("Failed to create the PreviewOutput instance.") +} -// Create an ImageReceiver object and set image parameters. +// Create an ImageReceiver object and set photo parameters. The resolution is set based on the photographing resolutions supported by the current device, which are obtained by photoProfilesArray. let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8) // Obtain the surface ID for displaying the photos. let photoSurfaceId = await imageReceiver.getReceivingSurfaceId() // Create a photographing output stream. -let photoOutput -camera.createPhotoOutput((photoSurfaceId), (err, output) => { - if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback returned with the PhotoOutput instance.'); - photoOutput = output -}); +let photoOutput = await cameraManager.createPhotoOutput(photoProfilesArray[0], photoSurfaceId) +if (!photoOutput) { + console.error('Failed to create the PhotoOutput instance.'); + return; +} // Define video recording parameters. -let videoProfile = { - audioBitrate : 48000, - audioChannels : 2, - audioCodec : 'audio/mp4a-latm', - audioSampleRate : 48000, - fileFormat : 'mp4', - videoBitrate : 48000, - videoCodec : 'video/mp4v-es', - videoFrameWidth : 640, - videoFrameHeight : 480, - videoFrameRate : 30 -} let videoConfig = { - audioSourceType : 1, - videoSourceType : 0, - profile : videoProfile, - url : 'file:///data/media/01.mp4', - orientationHint : 0, - location : { latitude : 30, longitude : 130 }, + audioSourceType: 1, + videoSourceType: 1, + profile: { + audioBitrate: 48000, + audioChannels: 2, + audioCodec: 'audio/mp4v-es', + audioSampleRate: 48000, + durationTime: 1000, + fileFormat: 'mp4', + videoBitrate: 48000, + videoCodec: 'video/mp4v-es', + videoFrameWidth: 640, + videoFrameHeight: 480, + videoFrameRate: 30 + }, + url: 'file:///data/media/01.mp4', + orientationHint: 0, + maxSize: 100, + maxDuration: 500, + rotation: 0 } // Create a video recording output stream. let videoRecorder -await media.createVideoRecorder().then((recorder) => { +media.createVideoRecorder().then((recorder) => { console.log('createVideoRecorder called') videoRecorder = recorder }) // Set video recording parameters. -await videoRecorder.prepare(videoConfig) +videoRecorder.prepare(videoConfig) // Obtain the surface ID for video recording. -await videoRecorder.getInputSurface().then((id) => { +let videoSurfaceId +videoRecorder.getInputSurface().then((id) => { console.log('getInputSurface called') videoSurfaceId = id }) -``` -For details about how to create a video recorder, see [Video Recording Development](./video-recorder.md). -```js + // Create a VideoOutput object. -let videoOutput -camera.createVideoOutput((surfaceId), (err, output) => { - if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); - return; +let videoOutput = await cameraManager.createVideoOutput(videoProfilesArray[0], videoSurfaceId) +if (!videoOutput) { + console.error('Failed to create the videoOutput instance.'); + return; +} +``` +Surfaces must be created in advance for the preview, shooting, and video recording stream. The preview stream is the surface provided by the **XComponent**, the shooting stream is the surface provided by **ImageReceiver**, and the video recording stream is the surface provided by **VideoRecorder**. + +**XComponent** + +```typescript +mXComponentController: XComponentController = new XComponentController // Create an XComponentController. + +build() { + Flex() { + XComponent({ // Create an XComponent. + id: '', + type: 'surface', + libraryname: '', + controller: this.mXComponentController + }) + .onload(() => { // Set the onload callback. + // Set the surface width and height (1920 x 1080). For details about how to set the preview size, see the preview resolutions supported by the current device, which are obtained by previewProfilesArray. + this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}) + // Obtain the surface ID. + globalThis.surfaceId = mXComponentController.getXComponentSurfaceId() + }) + .width('1920px') // Set the width of the XComponent. + .height('1080px') // Set the height of the XComponent. } - console.log('Callback returned with the VideoOutput instance'); - videoOutput = output -}); +} +``` + +**ImageReceiver** + +```typescript +function getImageReceiverSurfaceId() { + let receiver = image.createImageReceiver(640, 480, 4, 8) + console.log(TAG + 'before ImageReceiver check') + if (receiver !== undefined) { + console.log('ImageReceiver is ok') + surfaceId1 = receiver.getReceivingSurfaceId() + console.log('ImageReceived id: ' + JSON.stringify(surfaceId1)) + } else { + console.log('ImageReceiver is not ok') + } + } +``` + +**VideoRecorder** + +```typescript +function getVideoRecorderSurface() { + await getFd('CameraManager.mp4'); + mVideoConfig.url = mFdPath; + media.createVideoRecorder((err, recorder) => { + console.info('Entering create video receiver') + mVideoRecorder = recorder + console.info('videoRecorder is :' + JSON.stringify(mVideoRecorder)) + console.info('videoRecorder.prepare called.') + mVideoRecorder.prepare(mVideoConfig, (err) => { + console.info('videoRecorder.prepare success.') + mVideoRecorder.getInputSurface((err, id) => { + console.info('getInputSurface called') + mVideoSurface = id + console.info('getInputSurface surfaceId: ' + JSON.stringify(mVideoSurface)) + }) + }) + }) + } +``` + +#### Managing Sessions + +##### Creating a Session + +```typescript +// Create a session. +let captureSession = await camera.createCaptureSession() +if (!captureSession) { + console.error('Failed to create the CaptureSession instance.'); + return; +} +console.log('Callback returned with the CaptureSession instance.' + session); + +// Start configuration for the session. +await captureSession.beginConfig() + +// Add the camera input stream to the session. +await captureSession.addInput(cameraInput) + +// Add the preview input stream to the session. +await captureSession.addOutput(previewOutput) + +// Add the photographing output stream to the session. +await captureSession.addOutput(photoOutput) + +// Commit the session configuration. +await captureSession.commitConfig() + +// Start the session. +await captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); +}) +``` +##### Switching a Session + +```typescript +// Stop the session. +await captureSession.stop() + +// Start configuration for the session. +await captureSession.beginConfig() + +// Remove the photographing output stream from the session. +await captureSession.removeOutput(photoOutput) + +// Add a video recording output stream to the session. +await captureSession.addOutput(videoOutput) + +// Commit the session configuration. +await captureSession.commitConfig() + +// Start the session. +await captureSession.start().then(() => { + console.log('Promise returned to indicate the session start success.'); +}) ``` #### Setting Parameters -```js +```typescript // Check whether the camera has flash. -let flashStatus -await cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); - flashStatus = status -}) -if(flashStatus) { +let flashStatus = await captureSession.hasFlash() +if (!flashStatus) { + console.error('Failed to check whether the device has the flash mode.'); +} +console.log('Promise returned with the flash light support status:' + flashStatus); + +if (flashStatus) { // Check whether the auto flash mode is supported. let flashModeStatus - cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { + captureSession.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, async (err, status) => { if (err) { console.error('Failed to check whether the flash mode is supported. ${err.message}'); return; @@ -167,7 +319,7 @@ if(flashStatus) { }) if(flashModeStatus) { // Set the flash mode to auto. - cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { + captureSession.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, async (err) => { if (err) { console.error('Failed to set the flash mode ${err.message}'); return; @@ -179,7 +331,7 @@ if(flashStatus) { // Check whether the continuous auto focus is supported. let focusModeStatus -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err, status) => { +captureSession.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err, status) => { if (err) { console.error('Failed to check whether the focus mode is supported. ${err.message}'); return; @@ -187,9 +339,9 @@ cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (e console.log('Callback returned with the focus mode support status: ' + status); focusModeStatus = status }) -if(focusModeStatus) { +if (focusModeStatus) { // Set the focus mode to continuous auto focus. - cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err) => { + captureSession.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, async (err) => { if (err) { console.error('Failed to set the focus mode ${err.message}'); return; @@ -199,18 +351,14 @@ if(focusModeStatus) { } // Obtain the zoom ratio range supported by the camera. -let zoomRatioRange -cameraInput.getZoomRatioRange((err, range) => { - if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); - return; - } - console.log('Callback returned with zoom ratio range: ' + range.length); - zoomRatioRange = range -}) +let zoomRatioRange = await captureSession.getZoomRatioRange() +if (!zoomRatioRange) { + console.error('Failed to get the zoom ratio range.'); + return; +} // Set a zoom ratio. -cameraInput.setZoomRatio(zoomRatioRange[0], (err) => { +captureSession.setZoomRatio(zoomRatioRange[0], async (err) => { if (err) { console.error('Failed to set the zoom ratio value ${err.message}'); return; @@ -219,139 +367,15 @@ cameraInput.setZoomRatio(zoomRatioRange[0], (err) => { }) ``` -#### Managing Sessions - -##### Creating a Session - -```js -// Create a Context object. -let context = featureAbility.getContext() - -// Create a session. -let captureSession -await camera.createCaptureSession((context), (err, session) => { - if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); - return; - } - console.log('Callback returned with the CaptureSession instance.' + session); - captureSession = session -}); - -// Start configuration for the session. -await captureSession.beginConfig((err) => { - if (err) { - console.error('Failed to start the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the begin config success.'); -}); - -// Add the camera input stream to the session. -await captureSession.addInput(cameraInput, (err) => { - if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); -}); - -// Add the preview input stream to the session. -await captureSession.addOutput(previewOutput, (err) => { - if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); -}); - -// Add the photographing output stream to the session. -await captureSession.addOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); -}); - -// Commit the session configuration. -await captureSession.commitConfig((err) => { - if (err) { - console.error('Failed to commit the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the commit config success.'); -}); - -// Start the session. -await captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); -}) -``` - -##### Switching a Session - -```js -// Stop the session. -await captureSession.stop((err) => { - if (err) { - console.error('Failed to stop the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session stop success.'); -}); - -// Start configuration for the session. -await captureSession.beginConfig((err) => { - if (err) { - console.error('Failed to start the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the begin config success.'); -}); - -// Remove the photographing output stream from the session. -await captureSession.removeOutput(photoOutput, (err) => { - if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); -}); - -// Add a video recording output stream to the session. -await captureSession.addOutput(videoOutput, (err) => { - if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); -}); - -// Commit the session configuration. -await captureSession.commitConfig((err) => { - if (err) { - console.error('Failed to commit the configuration. ${err.message}'); - return; - } - console.log('Callback invoked to indicate the commit config success.'); -}); - -// Start the session. -await captureSession.start().then(() => { - console.log('Promise returned to indicate the session start success.'); -}) -``` - #### Taking Photos -```js +```typescript let settings = { quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // Set the image quality to high. rotation: camera.ImageRotation.ROTATION_0 // Set the image rotation angle to 0. } // Use the current photographing settings to take photos. -photoOutput.capture(settings, (err) => { +photoOutput.capture(settings, async (err) => { if (err) { console.error('Failed to capture the photo ${err.message}'); return; @@ -362,9 +386,9 @@ photoOutput.capture(settings, (err) => { #### Recording Videos -```js +```typescript // Start the video recording output stream. -videoOutput.start((err) => { +videoOutput.start(async (err) => { if (err) { console.error('Failed to start the video output ${err.message}'); return; @@ -373,17 +397,17 @@ videoOutput.start((err) => { }); // Start video recording. -await videoRecorder.start().then(() => { +videoRecorder.start().then(() => { console.info('videoRecorder start success'); } // Stop video recording. -await videoRecorder.stop().then(() => { +videoRecorder.stop().then(() => { console.info('stop success'); } // Stop the video recording output stream. -await videoOutput.stop((err) => { +videoOutput.stop((err) => { if (err) { console.error('Failed to stop the video output ${err.message}'); return; @@ -392,81 +416,34 @@ await videoOutput.stop((err) => { }); ``` +For details about the APIs used for saving photos, see [Image Processing](image.md#using-imagereceiver). + #### Releasing Resources -```js +```typescript // Stop the session. -await captureSession.stop((err) => { - if (err) { - console.error('Failed to stop the session ${err.message}'); - return; - } - console.log('Callback invoked to indicate the session stop success.'); -}); +captureSession.stop() + // Release the camera input stream. -await cameraInput.release((err) => { - if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); +cameraInput.release() + // Release the preview output stream. -await previewOutput.release((err) => { - if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); -}); +previewOutput.release() + // Release the photographing output stream. -await photoOutput.release((err) => { - if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); -}); +photoOutput.release() + // Release the video recording output stream. -await videoOutput.release((err) => { - if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); +videoOutput.release() + // Release the session. -await captureSession.release((err) => { - if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); - return; - } - console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); -}); -``` +captureSession.release() -#### XComponent Creation -The surface ID must be obtained for image preview. +// Set the session to null. +captureSession = null +``` -```js -mXComponentController: XComponentController = new XComponentController // Create an XComponentController. +## Process Flowchart -build() { - Flex() { - XComponent({ // Create an XComponent. - id: '', - type: 'surface', - libraryname: '', - controller: this.mXComponentController - }) - .onload(() => { // Set the onload callback. - // Set the width and height of the surface to 1920 and 1080, respectively. - this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}) - // Obtain the surface ID. - globalThis.surfaceId = mXComponentController.getXComponentSurfaceId() - }) - .width('1920px') // Set the width of the XComponent. - .height('1080px') // Set the height of the XComponent. - } -} -``` +The following figure shows the process of using the camera. +![camera_framework process](figures/camera_framework_process.jpg) diff --git a/en/application-dev/media/figures/camera_framework_process.jpg b/en/application-dev/media/figures/camera_framework_process.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1207a9a4adb5d5886f9427b07f0ec7d717fc5bf8 Binary files /dev/null and b/en/application-dev/media/figures/camera_framework_process.jpg differ diff --git a/en/application-dev/media/opensles-capture.md b/en/application-dev/media/opensles-capture.md index 0d0946ca87256f6409a62b81958a2ad784af8161..4e1775e178db20e01f15ee7a9b8f685a5c47b07b 100644 --- a/en/application-dev/media/opensles-capture.md +++ b/en/application-dev/media/opensles-capture.md @@ -1,6 +1,6 @@ # OpenSL ES Audio Recording Development -## When to Use +## Introduction You can use OpenSL ES to develop the audio recording function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned. diff --git a/en/application-dev/media/opensles-playback.md b/en/application-dev/media/opensles-playback.md index 661bf70ca1551964b05b086d7ec0ab25f46c984d..fe89bc9553da3163e1e18ca43922ff99e13c1307 100644 --- a/en/application-dev/media/opensles-playback.md +++ b/en/application-dev/media/opensles-playback.md @@ -1,6 +1,6 @@ # OpenSL ES Audio Playback Development -## When to Use +## Introduction You can use OpenSL ES to develop the audio playback function in OpenHarmony. Currently, only some [OpenSL ES APIs](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h) are implemented. If an API that has not been implemented is called, **SL_RESULT_FEATURE_UNSUPPORTED** will be returned. @@ -58,7 +58,7 @@ To use OpenSL ES to develop the audio playback function in OpenHarmony, perform 5. Obtain the **bufferQueueItf** instance of the **SL_IID_OH_BUFFERQUEUE** interface. - ``` + ```c++ SLOHBufferQueueItf bufferQueueItf; (*pcmPlayerObject)->GetInterface(pcmPlayerObject, SL_IID_OH_BUFFERQUEUE, &bufferQueueItf); ``` diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md index 6ee5cf660069294f717c5cac614ed707db9f1a8c..b324f19b3cf0f3621bd74809c4f1a2d0b57d0abd 100644 --- a/en/application-dev/media/video-playback.md +++ b/en/application-dev/media/video-playback.md @@ -1,17 +1,23 @@ # Video Playback Development -## When to Use +## Introduction -You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback. +You can use video playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, set the playback speed, and obtain track information. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback. + +## Working Principles + +The following figures show the video playback state transition and the interaction with external modules for video playback. **Figure 1** Video playback state transition ![en-us_image_video_state_machine](figures/en-us_image_video_state_machine.png) -**Figure 2** Layer 0 diagram of video playback +**Figure 2** Interaction with external modules for video playback ![en-us_image_video_player](figures/en-us_image_video_player.png) +**NOTE**: When a third-party application calls a JS interface provided by the JS interface layer, the framework layer invokes the audio component through the media service of the native framework to output the audio data decoded by the software to the audio HDI. The graphics subsystem outputs the image data decoded by the codec HDI at the hardware interface layer to the display HDI. In this way, video playback is implemented. + *Note: Video playback requires hardware capabilities such as display, audio, and codec.* 1. A third-party application obtains a surface ID from the XComponent. diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md index 62e81cf05c384a7cd1a780c562697be046153d05..bef55899bcb51359a6b6d68ef6d7894d70e435ae 100644 --- a/en/application-dev/media/video-recorder.md +++ b/en/application-dev/media/video-recorder.md @@ -1,17 +1,27 @@ # Video Recording Development -## When to Use +## Introduction -During video recording, audio and video signals are captured, encoded, and saved to files. You can specify parameters such as the encoding format, encapsulation format, and file path for video recording. +You can use video recording APIs to capture audio and video signals, encode them, and save them to files. You can start, suspend, resume, and stop recording, and release resources. You can also specify parameters such as the encoding format, encapsulation format, and file path for video recording. + +## Working Principles + +The following figures show the video recording state transition and the interaction with external modules for video recording. **Figure 1** Video recording state transition ![en-us_image_video_recorder_state_machine](figures/en-us_image_video_recorder_state_machine.png) -**Figure 2** Layer 0 diagram of video recording +**Figure 2** Interaction with external modules for video recording ![en-us_image_video_recorder_zero](figures/en-us_image_video_recorder_zero.png) +**NOTE**: When a third-party camera application or system camera calls a JS interface provided by the JS interface layer, the framework layer uses the media service of the native framework to invoke the audio component. Through the audio HDI, the audio component captures audio data, encodes the audio data through software, and saves the encoded audio data to a file. The graphics subsystem captures image data through the video HDI, encodes the image data through the video codec HDI, and saves the encoded image data to a file. In this way, video recording is implemented. + +## Constraints + +Before developing video recording, configure the permissions **ohos.permission.MICROPHONE** and **ohos.permission.CAMERA** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md). + ## How to Develop For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md#videorecorder9). @@ -147,3 +157,4 @@ export class VideoRecorderDemo { } } ``` + diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md index bf16d91435bf68ebd6f93a1a52b5f6da35e67169..0030d1d3cceb059a7f0d4d8308b3ae223e8de990 100644 --- a/en/application-dev/napi/Readme-EN.md +++ b/en/application-dev/napi/Readme-EN.md @@ -4,6 +4,4 @@ - [Drawing Development](drawing-guidelines.md) - [Raw File Development](rawfile-guidelines.md) - [Native Window Development](native-window-guidelines.md) -- [Using MindSpore Lite for Model Inference](native-window-guidelines.md) - - +- [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md) diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 754d30b06c7dda42dbe16203be2342bf6f70fc2a..a9d34533736558a48cb9415f19e6175b458aee94 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -125,6 +125,8 @@ - Security - [@ohos.abilityAccessCtrl](js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager](js-apis-privacyManager.md) + - [@ohos.security.cert](js-apis-cert.md) + - [@ohos.security.cryptoFramework]js-apis-cryptoFramework.md) - [@ohos.security.huks ](js-apis-huks.md) - [@ohos.userIAM.faceAuth](js-apis-useriam-faceauth.md) - [@ohos.userIAM.userAuth ](js-apis-useriam-userauth.md) @@ -146,6 +148,8 @@ - [@ohos.document](js-apis-document.md) - [@ohos.environment](js-apis-environment.md) + - [@ohos.data.fileAccess](js-apis-fileAccess.md) + - [@ohos.fileExtensionInfo](js-apis-fileExtensionInfo.md) - [@ohos.fileio](js-apis-fileio.md) - [@ohos.filemanagement.userfile_manager](js-apis-userfilemanager.md) - [@ohos.multimedia.medialibrary](js-apis-medialibrary.md) @@ -215,6 +219,7 @@ - [@ohos.geolocation](js-apis-geolocation.md) - [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md) + - [@ohos.multimodalInput.inputDeviceCooperate](js-apis-cooperate.md) - [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md) diff --git a/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md index f321aca70ed972845f73ca702501e574aeafe5e0..8701a6b80d7d54dc8bf6a30850c3551a741e77ed 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @@ -24,7 +24,9 @@ SystemCapability.BundleManager.DistributedBundleFramework For details, see [Permission Levels](../../security/accesstoken-overview.md#permission-levels). -## distributedBundle.getRemoteAbilityInfo +## distributedBundle.getRemoteAbilityInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead. getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback<RemoteAbilityInfo>): void; @@ -51,7 +53,9 @@ This is a system API and cannot be called by third-party applications. -## distributedBundle.getRemoteAbilityInfo +## distributedBundle.getRemoteAbilityInfodeprecated + +> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead. getRemoteAbilityInfo(elementName: ElementName): Promise<RemoteAbilityInfo> @@ -81,7 +85,9 @@ This is a system API and cannot be called by third-party applications. | ------------------------------------------------------------ | --------------------------------- | | Promise\<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)> | Promise used to return the remote ability information.| -## distributedBundle.getRemoteAbilityInfos +## distributedBundle.getRemoteAbilityInfosdeprecated + +> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead. getRemoteAbilityInfos(elementNames: Array<ElementName>, callback: AsyncCallback<Array<RemoteAbilityInfo>>): void; @@ -104,11 +110,13 @@ This is a system API and cannot be called by third-party applications. | Name | Type | Mandatory| Description | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | -| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.| +| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return the remote ability information.| + +## distributedBundle.getRemoteAbilityInfosdeprecated -## distributedBundle.getRemoteAbilityInfos +> This API is deprecated since API version 9. You are advised to use [getRemoteAbilityInfo](js-apis-distributedBundle.md) instead. getRemoteAbilityInfos(elementNames: Array<ElementName>): Promise<Array<RemoteAbilityInfo>> diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index acd9ef20950cd35f4f25d0b63b5e33b4e4021e89..8296185a2866ab0148e68ee56e52eea68e708892 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -21,13 +21,11 @@ import audio from '@ohos.multimedia.audio'; ## Constants -**System API**: This is a system API. - -**System capability**: SystemCapability.Multimedia.Audio.Device - -| Name | Type | Readable| Writable| Description | -| ----- | -------------------------- | ---- | ---- | ------------------ | -| LOCAL_NETWORK_ID9+ | string | Yes | No | Network ID of the local device.| +| Name | Type | Readable | Writable| Description | +| --------------------------------------- | ----------| ---- | ---- | ------------------ | +| LOCAL_NETWORK_ID9+ | string | Yes | No | Network ID of the local device.
This is a system API.
**System capability**: SystemCapability.Multimedia.Audio.Device | +| DEFAULT_VOLUME_GROUP_ID9+ | number | Yes | No | Default volume group ID.
**System capability**: SystemCapability.Multimedia.Audio.Volume | +| DEFAULT_INTERRUPT_GROUP_ID9+ | number | Yes | No | Default audio interruption group ID.
**System capability**: SystemCapability.Multimedia.Audio.Interrupt | **Example** @@ -35,6 +33,8 @@ import audio from '@ohos.multimedia.audio'; import audio from '@ohos.multimedia.audio'; const localNetworkId = audio.LOCAL_NETWORK_ID; +const defaultVolumeGroupId = audio.DEFAULT_VOLUME_GROUP_ID; +const defaultInterruptGroupId = audio.DEFAULT_INTERRUPT_GROUP_ID; ``` ## audio.getAudioManager @@ -53,7 +53,7 @@ Obtains an **AudioManager** instance. **Example** ```js -var audioManager = audio.getAudioManager(); +let audioManager = audio.getAudioManager(); ``` ## audio.createAudioRenderer8+ @@ -75,20 +75,20 @@ Creates an **AudioRenderer** instance. This API uses an asynchronous callback to ```js import audio from '@ohos.multimedia.audio'; -var audioStreamInfo = { +let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var audioRendererInfo = { +let audioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_SPEECH, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, rendererFlags: 0 } -var audioRendererOptions = { +let audioRendererOptions = { streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } @@ -128,25 +128,25 @@ Creates an **AudioRenderer** instance. This API uses a promise to return the res ```js import audio from '@ohos.multimedia.audio'; -var audioStreamInfo = { +let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var audioRendererInfo = { +let audioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_SPEECH, usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, rendererFlags: 0 } -var audioRendererOptions = { +let audioRendererOptions = { streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } -var audioRenderer; +let audioRenderer; audio.createAudioRenderer(audioRendererOptions).then((data) => { audioRenderer = data; console.info('AudioFrameworkRenderLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); @@ -176,19 +176,19 @@ Creates an **AudioCapturer** instance. This API uses an asynchronous callback to ```js import audio from '@ohos.multimedia.audio'; -var audioStreamInfo = { +let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_2, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var audioCapturerInfo = { +let audioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, capturerFlags: 0 } -var audioCapturerOptions = { +let audioCapturerOptions = { streamInfo: audioStreamInfo, capturerInfo: audioCapturerInfo } @@ -230,24 +230,24 @@ Creates an **AudioCapturer** instance. This API uses a promise to return the res ```js import audio from '@ohos.multimedia.audio'; -var audioStreamInfo = { +let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_2, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } -var audioCapturerInfo = { +let audioCapturerInfo = { source: audio.SourceType.SOURCE_TYPE_MIC, capturerFlags: 0 } -var audioCapturerOptions = { +let audioCapturerOptions = { streamInfo: audioStreamInfo, capturerInfo: audioCapturerInfo } -var audioCapturer; +let audioCapturer; audio.createAudioCapturer(audioCapturerOptions).then((data) => { audioCapturer = data; console.info('AudioCapturer Created : Success : Stream Type: SUCCESS'); @@ -264,6 +264,8 @@ Creates a **TonePlayer** instance. This API uses an asynchronous callback to ret **System capability**: SystemCapability.Multimedia.Audio.Tone +**System API**: This is a system API. + **Parameters** | Name | Type | Mandatory| Description | @@ -276,12 +278,12 @@ Creates a **TonePlayer** instance. This API uses an asynchronous callback to ret ```js import audio from '@ohos.multimedia.audio'; -var audioRendererInfo = { +let audioRendererInfo = { "contentType": audio.ContentType.CONTENT_TYPE_MUSIC, "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, "rendererFlags": 0 } -var tonePlayer; +let tonePlayer; audio.createTonePlayer(audioRendererInfo, (err, data) => { console.info(`callback call createTonePlayer: audioRendererInfo: ${audioRendererInfo}`); @@ -302,6 +304,8 @@ Creates a **TonePlayer** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Tone +**System API**: This is a system API. + **Parameters** | Name | Type | Mandatory| Description | @@ -319,12 +323,12 @@ Creates a **TonePlayer** instance. This API uses a promise to return the result. ```js import audio from '@ohos.multimedia.audio'; async function createTonePlayer(){ - var audioRendererInfo = { + let audioRendererInfo = { "contentType": audio.ContentType.CONTENT_TYPE_MUSIC, "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, "rendererFlags": 0 } - let tonePlayer = await audio.createTonePlayer(this.audioRendererInfo); + let tonePlayer = await audio.createTonePlayer(audioRendererInfo); } ``` @@ -340,18 +344,31 @@ Enumerates the audio stream types. | RINGTONE | 2 | Audio stream for ringtones. | | MEDIA | 3 | Audio stream for media purpose. | | VOICE_ASSISTANT8+ | 9 | Audio stream for voice assistant.| -| ALL9+ | 100 | All public audio streams.
This is a system API and cannot be called by third-party applications.| +| ALL9+ | 100 | All public audio streams.
This is a system API.| + +## InterruptRequestResultType9+ + +Enumerates the result types of audio interruption requests. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**System API**: This is a system API. + +| Name | Default Value| Description | +| ---------------------------- | ------ | ---------- | +| INTERRUPT_REQUEST_GRANT | 0 | The audio interruption request is accepted.| +| INTERRUPT_REQUEST_REJECT | 1 | The audio interruption request is denied. There may be a stream with a higher priority.| ## InterruptMode9+ Enumerates the audio interruption modes. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Interrupt | Name | Default Value| Description | | ---------------------------- | ------ | ---------- | -| SHARE_MODE | 0 | Shared mode.| -| INDEPENDENT_MODE| 1 | Independent mode. | +| SHARE_MODE | 0 | Shared mode.| +| INDEPENDENT_MODE | 1 | Independent mode.| ## DeviceFlag @@ -361,14 +378,13 @@ Enumerates the audio device flags. | Name | Default Value | Description | | ------------------------------- | ------ | ------------------------------------------------- | -| NONE_DEVICES_FLAG9+ | 0 | No device.
This is a system API and cannot be called by third-party applications. | +| NONE_DEVICES_FLAG9+ | 0 | No device.
This is a system API. | | OUTPUT_DEVICES_FLAG | 1 | Output device.| | INPUT_DEVICES_FLAG | 2 | Input device.| | ALL_DEVICES_FLAG | 3 | All devices.| -| DISTRIBUTED_OUTPUT_DEVICES_FLAG9+ | 4 | Distributed output device.
This is a system API and cannot be called by third-party applications. | -| DISTRIBUTED_INPUT_DEVICES_FLAG9+ | 8 | Distributed input device.
This is a system API and cannot be called by third-party applications. | -| ALL_DISTRIBUTED_DEVICES_FLAG9+ | 12 | Distributed input and output device.
This is a system API and cannot be called by third-party applications. | - +| DISTRIBUTED_OUTPUT_DEVICES_FLAG9+ | 4 | Distributed output device.
This is a system API. | +| DISTRIBUTED_INPUT_DEVICES_FLAG9+ | 8 | Distributed input device.
This is a system API. | +| ALL_DISTRIBUTED_DEVICES_FLAG9+ | 12 | Distributed input and output device.
This is a system API. | ## DeviceRole @@ -381,7 +397,6 @@ Enumerates the audio device roles. | INPUT_DEVICE | 1 | Input role.| | OUTPUT_DEVICE | 2 | Output role.| - ## DeviceType Enumerates the audio device types. @@ -401,16 +416,15 @@ Enumerates the audio device types. | USB_HEADSET | 22 | USB Type-C headset. | | DEFAULT9+ | 1000 | Default device type. | -## ActiveDeviceType +## CommunicationDeviceType9+ -Enumerates the active device types. +Enumerates the device types used for communication. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Communication -| Name | Default Value| Description | -| ------------- | ------ | ---------------------------------------------------- | -| SPEAKER | 2 | Speaker. | -| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO links.| +| Name | Default Value| Description | +| ------------- | ------ | -------------| +| SPEAKER | 2 | Speaker. | ## AudioRingMode @@ -426,7 +440,7 @@ Enumerates the ringer modes. ## AudioSampleFormat8+ -Enumerate the audio sample formats. +Enumerates the audio sample formats. **System capability**: SystemCapability.Multimedia.Audio.Core @@ -439,6 +453,22 @@ Enumerate the audio sample formats. | SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.| | SAMPLE_FORMAT_F32LE9+ | 4 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.| +## AudioErrors9+ + +Enumerates the audio error codes. + +**System capability**: SystemCapability.Multimedia.Audio.Core + +| Error Message | Error Code | Error Description | +| ---------------------| --------| ----------------- | +| ERROR_INVALID_PARAM | 6800101 | Invalid parameter. | +| ERROR_NO_MEMORY | 6800102 | Memory allocation failure. | +| ERROR_ILLEGAL_STATE | 6800103 | Unsupported state. | +| ERROR_UNSUPPORTED | 6800104 | Unsupported parameter value. | +| ERROR_TIMEOUT | 6800105 | Processing timeout. | +| ERROR_STREAM_LIMIT | 6800201 | Too many audio streams.| +| ERROR_SYSTEM | 6800301 | System error. | + ## AudioChannel8+ Enumerates the audio channels. @@ -510,18 +540,17 @@ Enumerates the audio stream usage. | STREAM_USAGE_VOICE_ASSISTANT9+ | 3 | Used for voice assistant.| | STREAM_USAGE_NOTIFICATION_RINGTONE | 6 | Used for notification.| -## FocusType9+ +## InterruptRequestType9+ -Enumerates the focus types. +Enumerates the audio interruption request types. **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Core - -| Name | Default Value | Description | -| ---------------------------------- | ------ | ------------------------------- | -| FOCUS_TYPE_RECORDING | 0 | Other audios will be interrupted in recording scenarios. | +**System capability**: SystemCapability.Multimedia.Audio.Interrupt +| Name | Default Value | Description | +| ---------------------------------- | ------ | ------------------------- | +| INTERRUPT_REQUEST_TYPE_DEFAULT | 0 | Default type, which can be used to interrupt audio requests. | ## AudioState8+ @@ -588,29 +617,18 @@ Enumerates the hints provided along with audio interruption. | INTERRUPT_HINT_DUCK | 4 | Ducked the playback. (In ducking, the audio volume is reduced, but not silenced.)| | INTERRUPT_HINT_UNDUCK8+ | 5 | Unducked the playback. | -## InterruptActionType - -Enumerates the returned event types for audio interruption events. - -**System capability**: SystemCapability.Multimedia.Audio.Renderer - -| Name | Default Value| Description | -| -------------- | ------ | ------------------ | -| TYPE_ACTIVATED | 0 | Focus gain event.| -| TYPE_INTERRUPT | 1 | Audio interruption event.| - ## AudioStreamInfo8+ Describes audio stream information. **System capability**: SystemCapability.Multimedia.Audio.Core -| Name | Type | Mandatory| Description | -| ------------ | ---------------------------------------- | ---- | ------------------ | -| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | Yes | Audio sampling rate.| -| channels | [AudioChannel](#audiochannel8) | Yes | Number of audio channels.| -| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | Yes | Audio sample format. | -| encodingType | [AudioEncodingType](#audioencodingtype8) | Yes | Audio encoding type. | +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------- | ---- | ------------------ | +| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | Yes | Audio sampling rate.| +| channels | [AudioChannel](#audiochannel8) | Yes | Number of audio channels.| +| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | Yes | Audio sample format. | +| encodingType | [AudioEncodingType](#audioencodingtype8) | Yes | Audio encoding type. | ## AudioRendererInfo8+ @@ -624,6 +642,19 @@ Describes audio renderer information. | usage | [StreamUsage](#streamusage) | Yes | Audio stream usage.| | rendererFlags | number | Yes | Audio renderer flags.| +## InterruptResult9+ + +Describes the audio interruption result. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**System API**: This is a system API. + +| Name | Type | Mandatory| Description | +| --------------| -------------------------------------------------------------- | ---- | ---------------- | +| requestResult | [InterruptRequestResultType](#interruptrequestresulttype9) | Yes | Audio interruption request type.| +| interruptNode | number | Yes | Node to interrupt.| + ## AudioRendererOptions8+ Describes audio renderer configurations. @@ -647,31 +678,6 @@ Describes the interruption event received by the application when playback is in | forceType | [InterruptForceType](#interruptforcetype9) | Yes | Whether the interruption is taken by the system or to be taken by the application.| | hintType | [InterruptHint](#interrupthint) | Yes | Hint provided along the interruption. | -## AudioInterrupt - -Describes input parameters of audio interruption events. - -**System capability**: SystemCapability.Multimedia.Audio.Renderer - -| Name | Type | Mandatory| Description | -| --------------- | --------------------------- | ---- | ------------------------------------------------------------ | -| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage. | -| contentType | [ContentType](#contenttype) | Yes | Audio content type. | -| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite.| - -## InterruptAction - -Describes the callback invoked for audio interruption or focus gain events. - -**System capability**: SystemCapability.Multimedia.Audio.Renderer - -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | -| actionType | [InterruptActionType](#interruptactiontype) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event.| -| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. | -| hint | [InterruptHint](#interrupthint) | No | Hint provided along with the audio interruption event. | -| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released.| - ## VolumeEvent8+ Describes the event received by the application when the volume is changed. @@ -683,24 +689,42 @@ Describes the event received by the application when the volume is changed. | Name | Type | Mandatory| Description | | ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | | volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| volume | number | Yes | Volume level. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| +| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| | updateUi | boolean | Yes | Whether to show the volume change in UI. | | volumeGroupId9+ | number | Yes | Volume group ID. It can be used as an input parameter of **getGroupManager**. | | networkId9+ | string | Yes | Network ID. | +## MicStateChangeEvent9+ + +Describes the event received by the application when the microphone mute status changes. + +**System capability**: SystemCapability.Multimedia.Audio.Device + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| mute | boolean | Yes | Mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite. | + ## ConnectType9+ Enumerates the types of connected devices. **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume | Name | Default Value| Description | | :------------------------------ | :----- | :--------------------- | | CONNECT_TYPE_LOCAL | 1 | Local device. | | CONNECT_TYPE_DISTRIBUTED | 2 | Distributed device. | +## VolumeGroupInfos9+ + +Describes the volume group information. The value is an array of [VolumeGroupInfo](#volumegroupinfo9) and is read-only. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + ## VolumeGroupInfo9+ Describes the volume group information. @@ -717,26 +741,6 @@ Describes the volume group information. | groupName9+ | number | Yes | No | Group name.| | type9+ | [ConnectType](#connecttype9)| Yes | No | Type of the connected device.| -## VolumeGroupInfos9+ - -Describes the volume group information. The value is an array of [VolumeGroupInfo](#volumegroupinfo9) and is read-only. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Multimedia.Audio.Volume - -**Example** - -```js -import audio from '@ohos.multimedia.audio'; - -async function getVolumeGroupInfos(){ - let volumegroupinfos = await audio.getAudioManager().getVolumeGroups(audio.LOCAL_NETWORK_ID); - console.info('Promise returned to indicate that the volumeGroup list is obtained.'+JSON.stringify(volumegroupinfos)) -} -getVolumeGroupInfos(); -``` - ## DeviceChangeAction Describes the device connection status and device information. @@ -803,889 +807,968 @@ Enumerates the audio scenes. | Name | Default Value| Description | | :--------------------- | :----- | :-------------------------------------------- | | AUDIO_SCENE_DEFAULT | 0 | Default audio scene. | -| AUDIO_SCENE_RINGING | 1 | Ringing audio scene.
This is a system API and cannot be called by third-party applications.| -| AUDIO_SCENE_PHONE_CALL | 2 | Phone call audio scene.
This is a system API and cannot be called by third-party applications.| +| AUDIO_SCENE_RINGING | 1 | Ringing audio scene.
This is a system API.| +| AUDIO_SCENE_PHONE_CALL | 2 | Phone call audio scene.
This is a system API.| | AUDIO_SCENE_VOICE_CHAT | 3 | Voice chat audio scene. | ## AudioManager Implements audio volume and audio device management. Before calling any API in **AudioManager**, you must use [getAudioManager](#audiogetaudiomanager) to create an **AudioManager** instance. -### getRoutingManager9+ +### setAudioParameter + +setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void -getRoutingManager(callback: AsyncCallback<AudioRoutingManager>): void +Sets an audio parameter. This API uses an asynchronous callback to return the result. -Obtains an **AudioRoutingManager** instance. This API uses an asynchronous callback to return the result. +This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. -**System capability**: SystemCapability.Multimedia.Audio.Device +**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS + +**System capability**: SystemCapability.Multimedia.Audio.Core **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ---------------------------------------------------------------- | ---- | --------------------------------- | -| callback | AsyncCallback<[AudioRoutingManager](#audioroutingmanager9)> | Yes | Callback used to return the **AudioRoutingManager** instance.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | ------------------------ | +| key | string | Yes | Key of the audio parameter to set. | +| value | string | Yes | Value of the audio parameter to set. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** + ```js -audioManager.getRoutingManager((err, callback) => { +audioManager.setAudioParameter('key_example', 'value_example', (err) => { if (err) { - console.error(`Result ERROR: ${err}`); + console.error(`Failed to set the audio parameter. ${err}`); + return; } - console.info('getRoutingManager Callback SUCCESS.'); - var audioRoutingManager; - audioRoutingManager = callback; + console.info('Callback invoked to indicate a successful setting of the audio parameter.'); }); ``` -### getRoutingManager9+ +### setAudioParameter -getRoutingManager(): Promise<AudioRoutingManager> +setAudioParameter(key: string, value: string): Promise<void> -Obtains an **AudioRoutingManager** instance. This API uses a promise to return the result. +Sets an audio parameter. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. + +**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS + +**System capability**: SystemCapability.Multimedia.Audio.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| key | string | Yes | Key of the audio parameter to set.| +| value | string | Yes | Value of the audio parameter to set.| **Return value** -| Type | Description | -| ----------------------------------------------------------- | --------------------------------------- | -| Promise<[AudioRoutingManager](#audioroutingmanager9)> | Promise used to return the **AudioRoutingManager** instance.| +| Type | Description | +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result.| **Example** + ```js -var audioManager = audio.getAudioManager(); -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - var routingManager = value; - console.info('getRoutingManager Promise SUCCESS.'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); - }); -} +audioManager.setAudioParameter('key_example', 'value_example').then(() => { + console.info('Promise returned to indicate a successful setting of the audio parameter.'); +}); ``` -### setVolume - -setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void +### getAudioParameter -Sets the volume for a stream. This API uses an asynchronous callback to return the result. +getAudioParameter(key: string, callback: AsyncCallback<string>): void -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +Obtains the value of an audio parameter. This API uses an asynchronous callback to return the result. -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Core **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------- | ---- | ---------------------------- | +| key | string | Yes | Key of the audio parameter whose value is to be obtained. | +| callback | AsyncCallback<string> | Yes | Callback used to return the value of the audio parameter.| **Example** ```js -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { +audioManager.getAudioParameter('key_example', (err, value) => { if (err) { - console.error(`Failed to set the volume. ${err}`); + console.error(`Failed to obtain the value of the audio parameter. ${err}`); return; } - console.info('Callback invoked to indicate a successful volume setting.'); + console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`); }); ``` -### setVolume - -setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> +### getAudioParameter -Sets the volume for a stream. This API uses a promise to return the result. +getAudioParameter(key: string): Promise<string> -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +Obtains the value of an audio parameter. This API uses a promise to return the result. -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Core **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| key | string | Yes | Key of the audio parameter whose value is to be obtained.| **Return value** -| Type | Description | -| ------------------- | ----------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| --------------------- | ----------------------------------- | +| Promise<string> | Promise used to return the value of the audio parameter.| **Example** ```js -audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { - console.info('Promise returned to indicate a successful volume setting.'); +audioManager.getAudioParameter('key_example').then((value) => { + console.info(`Promise returned to indicate that the value of the audio parameter is obtained ${value}.`); }); ``` -### getVolume +### setAudioScene8+ -getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void -Obtains the volume of a stream. This API uses an asynchronous callback to return the result. +Sets an audio scene. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the volume.| +| Name | Type | Mandatory| Description | +| :------- | :----------------------------------- | :--- | :------------------- | +| scene | AudioScene | Yes | Audio scene to set. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { +let audioManager = audio.getAudioManager(); +audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { if (err) { - console.error(`Failed to obtain the volume. ${err}`); + console.error(`Failed to set the audio scene mode.​ ${err}`); return; } - console.info('Callback invoked to indicate that the volume is obtained.'); + console.info('Callback invoked to indicate a successful setting of the audio scene mode.'); }); ``` -### getVolume +### setAudioScene8+ -getVolume(volumeType: AudioVolumeType): Promise<number> +setAudioScene\(scene: AudioScene\): Promise -Obtains the volume of a stream. This API uses a promise to return the result. +Sets an audio scene. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +| Name| Type | Mandatory| Description | +| :----- | :----------------------------------- | :--- | :------------- | +| scene | AudioScene | Yes | Audio scene to set.| **Return value** -| Type | Description | -| --------------------- | ------------------------- | -| Promise<number> | Promise used to return the volume.| +| Type | Description | +| :------------- | :------------------- | +| Promise | Promise used to return the result.| **Example** ```js -audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promise returned to indicate that the volume is obtained ${value} .`); +let audioManager = audio.getAudioManager(); +audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { + console.info('Promise returned to indicate a successful setting of the audio scene mode.'); +}).catch ((err) => { + console.error(`Failed to set the audio scene mode ${err}`); }); ``` -### getMinVolume +### getAudioScene8+ -getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +getAudioScene\(callback: AsyncCallback\): void -Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result. +Obtains the audio scene. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the minimum volume.| - -**Example** +| Name | Type | Mandatory| Description | +| :------- | :-------------------------------------------------- | :--- | :--------------------------- | +| callback | AsyncCallback<AudioScene> | Yes | Callback used to return the audio scene.| + +**Example** ```js -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { +let audioManager = audio.getAudioManager(); +audioManager.getAudioScene((err, value) => { if (err) { - console.error(`Failed to obtain the minimum volume. ${err}`); + console.error(`Failed to obtain the audio scene mode.​ ${err}`); return; } - console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`); + console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`); }); ``` -### getMinVolume - -getMinVolume(volumeType: AudioVolumeType): Promise<number> - -Obtains the minimum volume allowed for a stream. This API uses a promise to return the result. +### getAudioScene8+ -**System capability**: SystemCapability.Multimedia.Audio.Volume +getAudioScene\(\): Promise -**Parameters** +Obtains the audio scene. This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +**System capability**: SystemCapability.Multimedia.Audio.Communication **Return value** -| Type | Description | -| --------------------- | ------------------------- | -| Promise<number> | Promise used to return the minimum volume.| +| Type | Description | +| :-------------------------------------------- | :--------------------------- | +| Promise<AudioScene> | Promise used to return the audio scene.| **Example** ```js -audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promised returned to indicate that the minimum volume is obtained. ${value}`); +let audioManager = audio.getAudioManager(); +audioManager.getAudioScene().then((value) => { + console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`); +}).catch ((err) => { + console.error(`Failed to obtain the audio scene mode ${err}`); }); ``` -### getMaxVolume +### getVolumeManager9+ -getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +getVolumeManager(): AudioVolumeManager -Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result. +Obtains an **AudioVolumeManager** instance. **System capability**: SystemCapability.Multimedia.Audio.Volume -**Parameters** - -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ---------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the maximum volume.| - **Example** ```js -audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`Failed to obtain the maximum volume. ${err}`); - return; - } - console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`); -}); +let audioVolumeManager = audioManager.getVolumeManager(); ``` -### getMaxVolume +### getStreamManager9+ -getMaxVolume(volumeType: AudioVolumeType): Promise<number> +getStreamManager(): AudioStreamManager -Obtains the maximum volume allowed for a stream. This API uses a promise to return the result. +Obtains an **AudioStreamManager** instance. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Core -**Parameters** +**Example** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +```js +let audioStreamManager = audioManager.getStreamManager(); +``` -**Return value** +### getRoutingManager9+ -| Type | Description | -| --------------------- | ----------------------------- | -| Promise<number> | Promise used to return the maximum volume.| +getRoutingManager(): AudioRoutingManager + +Obtains an **AudioRoutingManager** instance. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Example** ```js -audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { - console.info('Promised returned to indicate that the maximum volume is obtained.'); -}); +let audioRoutingManager = audioManager.getRoutingManager(); ``` -### mute +## AudioVolumeManager9+ -mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void +Implements audio volume management. Before calling an API in **AudioVolumeManager**, you must use [getVolumeManager](#getvolumemanager9) to obtain an **AudioVolumeManager** instance. -Mutes or unmutes a stream. This API uses an asynchronous callback to return the result. +### getVolumeGroupInfos9+ -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +getVolumeGroupInfos(networkId: string, callback: AsyncCallback\): void -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +Obtains the volume groups. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. **System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | -------------------- | +| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. | +| callback | AsyncCallback<[VolumeGroupInfos](#volumegroupinfos9)> | Yes | Callback used to return the volume group information array.| **Example** - ```js -audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { +audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID, (err, value) => { if (err) { - console.error(`Failed to mute the stream. ${err}`); + console.error(`Failed to obtain the volume group infos list. ${err}`); return; } - console.info('Callback invoked to indicate that the stream is muted.'); + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); }); ``` -### mute - -mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> +### getVolumeGroupInfos9+ -Mutes or unmutes a stream. This API uses a promise to return the result. +getVolumeGroupInfos(networkId: string\): Promise -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +Obtains the volume groups. This API uses a promise to return the result. -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +**System API**: This is a system API. **System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| +| Name | Type | Mandatory| Description | +| ---------- | ------------------| ---- | -------------------- | +| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. | **Return value** | Type | Description | | ------------------- | ----------------------------- | -| Promise<void> | Promise used to return the result.| +| Promise<[VolumeGroupInfos](#volumegroupinfos9)> | Volume group information array.| **Example** - ```js -audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { - console.info('Promise returned to indicate that the stream is muted.'); -}); +async function getVolumeGroupInfos(){ + let volumegroupinfos = await audio.getAudioManager().getVolumeManager().getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + console.info('Promise returned to indicate that the volumeGroup list is obtained.'+JSON.stringify(volumegroupinfos)) +} ``` +### getVolumeGroupManager9+ -### isMute - -isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void +getVolumeGroupManager(groupId: number, callback: AsyncCallback\): void -Checks whether a stream is muted. This API uses an asynchronous callback to return the result. +Obtains the audio group manager. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ----------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------------------------------ | ---- | -------------------- | +| groupId | number | Yes | Volume group ID. | +| callback | AsyncCallback< [AudioVolumeGroupManager](#audiovolumegroupmanager9) > | Yes | Callback used to return the audio group manager.| **Example** ```js -audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { +let groupid = audio.DEFAULT_VOLUME_GROUP_ID; +audioVolumeManager.getVolumeGroupManager(groupid, (err, value) => { if (err) { - console.error(`Failed to obtain the mute status. ${err}`); + console.error(`Failed to obtain the volume group infos list. ${err}`); return; } - console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`); + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); }); -``` +``` -### isMute +### getVolumeGroupManager9+ -isMute(volumeType: AudioVolumeType): Promise<boolean> +getVolumeGroupManager(groupId: number\): Promise -Checks whether a stream is muted. This method uses a promise to return the result. +Obtains the audio group manager. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------- | ---- | ---------------- | +| groupId | number | Yes | Volume group ID. | **Return value** -| Type | Description | -| ---------------------- | ------------------------------------------------------ | -| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| +| Type | Description | +| ------------------- | ----------------------------- | +| Promise< [AudioVolumeGroupManager](#audiovolumegroupmanager9) > | Promise used to return the audio group manager.| **Example** ```js -audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); -}); +let groupid = audio.DEFAULT_VOLUME_GROUP_ID; +let audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid); +console.info('Callback invoked to indicate that the volume group infos list is obtained.'); ``` -### isActive +### on('volumeChange')9+ -isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void +on(type: 'volumeChange', callback: Callback\): void -Checks whether a stream is active. This API uses an asynchronous callback to return the result. +Subscribes to system volume change events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when the system volume changes.| +| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | **Example** ```js -audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`Failed to obtain the active status of the stream. ${err}`); - return; - } - console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`); +audioVolumeManager.on('volumeChange', (volumeEvent) => { + console.info(`VolumeType of stream: ${volumeEvent.volumeType} `); + console.info(`Volume level: ${volumeEvent.volume} `); + console.info(`Whether to updateUI: ${volumeEvent.updateUi} `); }); ``` -### isActive +## AudioVolumeGroupManager9+ -isActive(volumeType: AudioVolumeType): Promise<boolean> +Manages the volume of an audio group. Before calling any API in **AudioVolumeGroupManager**, you must use [getVolumeGroupManager](#getvolumegroupmanager9) to obtain an **AudioVolumeGroupManager** instance. -Checks whether a stream is active. This method uses a promise to return the result. +**System API**: This is a system API. **System capability**: SystemCapability.Multimedia.Audio.Volume -**Parameters** - -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| - -**Return value** - -| Type | Description | -| ---------------------- | -------------------------------------------------------- | -| Promise<boolean> | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.| - -**Example** - -```js -audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`); -}); -``` - -### setRingerMode +### setVolume9+ -setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void +setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void -Sets the ringer mode. This API uses an asynchronous callback to return the result. +Sets the volume for a stream. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY -This permission is required only for muting or unmuting the ringer. +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. -**System capability**: SystemCapability.Multimedia.Audio.Communication +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | ------------------------ | -| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { +audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { if (err) { - console.error(`Failed to set the ringer mode.​ ${err}`); + console.error(`Failed to set the volume. ${err}`); return; } - console.info('Callback invoked to indicate a successful setting of the ringer mode.'); + console.info('Callback invoked to indicate a successful volume setting.'); }); ``` -### setRingerMode +### setVolume9+ -setRingerMode(mode: AudioRingMode): Promise<void> +setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> -Sets the ringer mode. This API uses a promise to return the result. +Sets the volume for a stream. This API uses a promise to return the result. **Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY -This permission is required only for muting or unmuting the ringer. +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. -**System capability**: SystemCapability.Multimedia.Audio.Communication +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------------------- | ---- | -------------- | -| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| **Return value** -| Type | Description | -| ------------------- | ------------------------------- | +| Type | Description | +| ------------------- | ----------------------------- | | Promise<void> | Promise used to return the result.| **Example** ```js -audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => { - console.info('Promise returned to indicate a successful setting of the ringer mode.'); +audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { + console.info('Promise returned to indicate a successful volume setting.'); }); ``` +### getVolume9+ -### getRingerMode - -getRingerMode(callback: AsyncCallback<AudioRingMode>): void +getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -Obtains the ringer mode. This API uses an asynchronous callback to return the result. +Obtains the volume of a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Communication +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the ringer mode.| - -**Example** +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the volume.| + +**Example** ```js -audioManager.getRingerMode((err, value) => { +audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`Failed to obtain the ringer mode.​ ${err}`); + console.error(`Failed to obtain the volume. ${err}`); return; } - console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`); + console.info('Callback invoked to indicate that the volume is obtained.'); }); ``` +### getVolume9+ -### getRingerMode +getVolume(volumeType: AudioVolumeType): Promise<number> -getRingerMode(): Promise<AudioRingMode> +Obtains the volume of a stream. This API uses a promise to return the result. -Obtains the ringer mode. This API uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Audio.Volume -**System capability**: SystemCapability.Multimedia.Audio.Communication +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| **Return value** -| Type | Description | -| ---------------------------------------------- | ------------------------------- | -| Promise<[AudioRingMode](#audioringmode)> | Promise used to return the ringer mode.| +| Type | Description | +| --------------------- | ------------------------- | +| Promise<number> | Promise used to return the volume.| **Example** ```js -audioManager.getRingerMode().then((value) => { - console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`); +audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the volume is obtained ${value}.`); }); ``` -### setAudioParameter - -setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void - -Sets an audio parameter. This API uses an asynchronous callback to return the result. +### getMinVolume9+ -This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. +getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS +Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ------------------------ | -| key | string | Yes | Key of the audio parameter to set. | -| value | string | Yes | Value of the audio parameter to set. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the minimum volume.| **Example** ```js -audioManager.setAudioParameter('key_example', 'value_example', (err) => { +audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`Failed to set the audio parameter. ${err}`); + console.error(`Failed to obtain the minimum volume. ${err}`); return; } - console.info('Callback invoked to indicate a successful setting of the audio parameter.'); + console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`); }); ``` -### setAudioParameter - -setAudioParameter(key: string, value: string): Promise<void> - -Sets an audio parameter. This API uses a promise to return the result. +### getMinVolume9+ -This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. +getMinVolume(volumeType: AudioVolumeType): Promise<number> -**Required permissions**: ohos.permission.MODIFY_AUDIO_SETTINGS +Obtains the minimum volume allowed for a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| key | string | Yes | Key of the audio parameter to set.| -| value | string | Yes | Value of the audio parameter to set.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| **Return value** -| Type | Description | -| ------------------- | ------------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| --------------------- | ------------------------- | +| Promise<number> | Promise used to return the minimum volume.| **Example** ```js -audioManager.setAudioParameter('key_example', 'value_example').then(() => { - console.info('Promise returned to indicate a successful setting of the audio parameter.'); +audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`); }); ``` -### getAudioParameter - -getAudioParameter(key: string, callback: AsyncCallback<string>): void +### getMaxVolume9+ -Obtains the value of an audio parameter. This API uses an asynchronous callback to return the result. +getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. +Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------- | ---- | ---------------------------- | -| key | string | Yes | Key of the audio parameter whose value is to be obtained. | -| callback | AsyncCallback<string> | Yes | Callback used to return the value of the audio parameter.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ---------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the maximum volume.| **Example** ```js -audioManager.getAudioParameter('key_example', (err, value) => { +audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`Failed to obtain the value of the audio parameter. ${err}`); + console.error(`Failed to obtain the maximum volume. ${err}`); return; } - console.info(`Callback invoked to indicate that the value of the audio parameter is obtained ${value}.`); + console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`); }); ``` -### getAudioParameter - -getAudioParameter(key: string): Promise<string> +### getMaxVolume9+ -Obtains the value of an audio parameter. This API uses a promise to return the result. +getMaxVolume(volumeType: AudioVolumeType): Promise<number> -This API is used to extend the audio configuration based on the hardware capability. The supported audio parameters vary according to the device and can be obtained from the device manual. The example below is for reference only. +Obtains the maximum volume allowed for a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| key | string | Yes | Key of the audio parameter whose value is to be obtained.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| **Return value** -| Type | Description | -| --------------------- | ----------------------------------- | -| Promise<string> | Promise used to return the value of the audio parameter.| +| Type | Description | +| --------------------- | ----------------------------- | +| Promise<number> | Promise used to return the maximum volume.| **Example** ```js -audioManager.getAudioParameter('key_example').then((value) => { - console.info(`Promise returned to indicate that the value of the audio parameter is obtained ${value}.`); +audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { + console.info('Promised returned to indicate that the maximum volume is obtained.'); }); ``` -### getDevices +### mute9+ -getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void +mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void -Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result. +Mutes or unmutes a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | -| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** + ```js -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { +audioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { if (err) { - console.error(`Failed to obtain the device list. ${err}`); + console.error(`Failed to mute the stream. ${err}`); return; } - console.info('Callback invoked to indicate that the device list is obtained.'); + console.info('Callback invoked to indicate that the stream is muted.'); }); ``` -### getDevices +### mute9+ -getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> +mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> -Obtains the audio devices with a specific flag. This API uses a promise to return the result. +Mutes or unmutes a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------- | ---- | ---------------- | -| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| **Return value** -| Type | Description | -| ------------------------------------------------------------ | ------------------------- | -| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list.| +| Type | Description | +| ------------------- | ----------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { - console.info('Promise returned to indicate that the device list is obtained.'); +audioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { + console.info('Promise returned to indicate that the stream is muted.'); }); ``` -### setDeviceActive +### isMute9+ -setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void +isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -Sets a device to the active state. This API uses an asynchronous callback to return the result. +Checks whether a stream is muted. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------- | ---- | ------------------------ | -| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | -| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ----------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| **Example** ```js -audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { +audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`Failed to set the active status of the device. ${err}`); + console.error(`Failed to obtain the mute status. ${err}`); return; } - console.info('Callback invoked to indicate that the device is set to the active status.'); + console.info(`Callback invoked to indicate that the mute status of the stream is obtained ${value}.`); }); ``` -### setDeviceActive +### isMute9+ -setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void> +isMute(volumeType: AudioVolumeType): Promise<boolean> -Sets a device to the active state. This API uses a promise to return the result. +Checks whether a stream is muted. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------- | ---- | ------------------ | -| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type.| -| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| **Return value** -| Type | Description | -| ------------------- | ------------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ---------------------- | ------------------------------------------------------ | +| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| **Example** - ```js -audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { - console.info('Promise returned to indicate that the device is set to the active status.'); +audioVolumeGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); }); ``` -### isDeviceActive +### setRingerMode9+ -isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void +setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void -Checks whether a device is active. This API uses an asynchronous callback to return the result. +Sets the ringer mode. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------- | ---- | ------------------------ | -| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------ | +| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```js -audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { +audioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { if (err) { - console.error(`Failed to obtain the active status of the device. ${err}`); + console.error(`Failed to set the ringer mode.​ ${err}`); return; } - console.info('Callback invoked to indicate that the active status of the device is obtained.'); + console.info('Callback invoked to indicate a successful setting of the ringer mode.'); }); ``` +### setRingerMode9+ -### isDeviceActive +setRingerMode(mode: AudioRingMode): Promise<void> -isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean> +Sets the ringer mode. This API uses a promise to return the result. -Checks whether a device is active. This API uses a promise to return the result. +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY -**System capability**: SystemCapability.Multimedia.Audio.Device +This permission is required only for muting or unmuting the ringer. + +**System API**: This is a system API. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------- | ---- | ------------------ | -| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type.| +| Name| Type | Mandatory| Description | +| ------ | ------------------------------- | ---- | -------------- | +| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode.| **Return value** -| Type | Description | -| ---------------------- | ------------------------------- | -| Promise<boolean> | Promise used to return the active state of the device.| +| Type | Description | +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => { - console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`); +audioVolumeGroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => { + console.info('Promise returned to indicate a successful setting of the ringer mode.'); +}); +``` + +### getRingerMode9+ + +getRingerMode(callback: AsyncCallback<AudioRingMode>): void + +Obtains the ringer mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the ringer mode.| + +**Example** + +```js +audioVolumeGroupManager.getRingerMode((err, value) => { + if (err) { + console.error(`Failed to obtain the ringer mode.​ ${err}`); + return; + } + console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`); +}); +``` + +### getRingerMode9+ + +getRingerMode(): Promise<AudioRingMode> + +Obtains the ringer mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Return value** + +| Type | Description | +| ---------------------------------------------- | ------------------------------- | +| Promise<[AudioRingMode](#audioringmode)> | Promise used to return the ringer mode.| + +**Example** + +```js +audioVolumeGroupManager.getRingerMode().then((value) => { + console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`); }); ``` -### setMicrophoneMute +### on('ringerModeChange')9+ + +on(type: 'ringerModeChange', callback: Callback\): void + +Subscribes to ringer mode change events. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'ringerModeChange'** means the ringer mode change event, which is triggered when a ringer mode change is detected.| +| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the system volume change event. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | + +**Example** + +```js +audioVolumeGroupManager.on('ringerModeChange', (ringerMode) => { + console.info(`Updated ringermode: ${ringerMode}`); +}); +``` +### setMicrophoneMute9+ setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.MICROPHONE +**Required permissions**: ohos.permission.MANAGE_AUDIO_CONFIG -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** @@ -1697,7 +1780,7 @@ Mutes or unmutes the microphone. This API uses an asynchronous callback to retur **Example** ```js -audioManager.setMicrophoneMute(true, (err) => { +audioVolumeGroupManager.setMicrophoneMute(true, (err) => { if (err) { console.error(`Failed to mute the microphone. ${err}`); return; @@ -1706,15 +1789,15 @@ audioManager.setMicrophoneMute(true, (err) => { }); ``` -### setMicrophoneMute +### setMicrophoneMute9+ setMicrophoneMute(mute: boolean): Promise<void> Mutes or unmutes the microphone. This API uses a promise to return the result. -**Required permissions:** ohos.permission.MICROPHONE +**Required permissions**: ohos.permission.MANAGE_AUDIO_CONFIG -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** @@ -1731,20 +1814,18 @@ Mutes or unmutes the microphone. This API uses a promise to return the result. **Example** ```js -audioManager.setMicrophoneMute(true).then(() => { +audioVolumeGroupManager.setMicrophoneMute(true).then(() => { console.info('Promise returned to indicate that the microphone is muted.'); }); ``` -### isMicrophoneMute +### isMicrophoneMute9+ isMicrophoneMute(callback: AsyncCallback<boolean>): void Checks whether the microphone is muted. This API uses an asynchronous callback to return the result. -**Required permissions**: ohos.permission.MICROPHONE - -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** @@ -1755,7 +1836,7 @@ Checks whether the microphone is muted. This API uses an asynchronous callback t **Example** ```js -audioManager.isMicrophoneMute((err, value) => { +audioVolumeGroupManager.isMicrophoneMute((err, value) => { if (err) { console.error(`Failed to obtain the mute status of the microphone. ${err}`); return; @@ -1764,15 +1845,13 @@ audioManager.isMicrophoneMute((err, value) => { }); ``` -### isMicrophoneMute +### isMicrophoneMute9+ isMicrophoneMute(): Promise<boolean> Checks whether the microphone is muted. This API uses a promise to return the result. -**Required permissions**: ohos.permission.MICROPHONE - -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Volume **Return value** @@ -1782,20 +1861,17 @@ Checks whether the microphone is muted. This API uses a promise to return the re **Example** - ```js -audioManager.isMicrophoneMute().then((value) => { +audioVolumeGroupManager.isMicrophoneMute().then((value) => { console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`); }); ``` -### on('volumeChange')8+ +### on('micStateChange')9+ -on(type: 'volumeChange', callback: Callback\): void - -Subscribes to system volume change events. +on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void -**System API**: This is a system API. +Subscribes to system mic state change events. Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance. @@ -1805,3709 +1881,4263 @@ Currently, when multiple **AudioManager** instances are used in a single process | Name | Type | Mandatory| Description | | -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value **volumeChange** means the system volume change event, which is triggered when a system volume change is detected.| -| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the system volume change event. | +| type | string | Yes | Event type. The value **'micStateChange'** means the system mic state change event, which is triggered when the system mic state changes.| +| callback | Callback<[MicStateChangeEvent](#micstatechangeevent9)> | Yes | Callback used to return the changed micr state. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | **Example** ```js -audioManager.on('volumeChange', (volumeEvent) => { - console.info(`VolumeType of stream: ${volumeEvent.volumeType} `); - console.info(`Volume level: ${volumeEvent.volume} `); - console.info(`Whether to updateUI: ${volumeEvent.updateUi} `); +audioVolumeGroupManager.on('micStateChange', (micStateChange) => { + console.info(`Current microphone status is: ${micStateChange.mute} `); }); ``` -### on('ringerModeChange')8+ +## AudioStreamManager9+ -on(type: 'ringerModeChange', callback: Callback\): void +Implements audio stream management. Before calling any API in **AudioStreamManager**, you must use [getStreamManager](#getstreammanager9) to obtain an **AudioStreamManager** instance. -Subscribes to ringer mode change events. +### getCurrentAudioRendererInfoArray9+ -**System API**: This is a system API. +getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void -**System capability**: SystemCapability.Multimedia.Audio.Communication +Obtains the information about the current audio renderer. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value **ringerModeChange** means the ringer mode change event, which is triggered when a ringer mode change is detected.| -| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the system volume change event. | +| Name | Type | Mandatory | Description | +| -------- | ----------------------------------- | -------- | --------------------------- | +| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the audio renderer information.| **Example** ```js -audioManager.on('ringerModeChange', (ringerMode) => { - console.info(`Updated ringermode: ${ringerMode}`); +audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); + if (err) { + console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`); + } else { + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); + console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); + console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); + console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); + console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); + console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); + for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); + } + } + } + } }); ``` -### on('deviceChange') +### getCurrentAudioRendererInfoArray9+ -on(type: 'deviceChange', callback: Callback): void +getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray> -Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback. +Obtains the information about the current audio renderer. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** +**Return value** -| Name | Type | Mandatory| Description | -| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | -| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.| -| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes | Callback used to return the device update details. | +| Type | Description | +| ---------------------------------------------------------------------------------| --------------------------------------- | +| Promise<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Promise used to return the audio renderer information. | **Example** ```js -audioManager.on('deviceChange', (deviceChanged) => { - console.info(`device change type : ${deviceChanged.type} `); - console.info(`device descriptor size : ${deviceChanged.deviceDescriptors.length} `); - console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole} `); - console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceType} `); -}); +async function getCurrentAudioRendererInfoArray(){ + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info(`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`); + if (AudioRendererChangeInfoArray != null) { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); + console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); + console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); + console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); + console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); + console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); + for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); + } + } + } + }).catch((err) => { + console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`); + }); +} ``` -### off('deviceChange') +### getCurrentAudioCapturerInfoArray9+ -off(type: 'deviceChange', callback?: Callback): void +getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void -Unsubscribes from device change events. +Obtains the information about the current audio capturer. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------ | -| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.| -| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to return the device update details. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | -------------------------------------------------------- | +| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the audio capturer information.| **Example** ```js -audioManager.off('deviceChange', (deviceChanged) => { - console.info('Should be no callback.'); +audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); + if (err) { + console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`); + } else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); + console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); + console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); + console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); + console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } + } + } + } }); ``` -### on('interrupt') +### getCurrentAudioCapturerInfoArray9+ -on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\): void +getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray> -Subscribes to audio interruption events. When the application's audio is interrupted by another playback event, the application will receive the callback. +Obtains the information about the current audio capturer. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.| -| interrupt | AudioInterrupt | Yes | Audio interruption event type. | -| callback | Callback<[InterruptAction](#interruptaction)> | Yes | Callback invoked for the audio interruption event. | +**Return value** -**Example** +| Type | Description | +| -----------------------------------------------------------------------------| ----------------------------------- | +| Promise<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Promise used to return the audio capturer information. | + +**Example** ```js -var interAudioInterrupt = { - streamUsage:2, - contentType:0, - pauseWhenDucked:true -}; -audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => { - if (InterruptAction.actionType === 0) { - console.info('An event to gain the audio focus starts.'); - console.info(`Focus gain event: ${InterruptAction} `); - } - if (InterruptAction.actionType === 1) { - console.info('An audio interruption event starts.'); - console.info(`Audio interruption event: ${InterruptAction} `); - } -}); +async function getCurrentAudioCapturerInfoArray(){ + await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); + console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); + console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); + console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); + console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } + } + } + }).catch((err) => { + console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`); + }); +} ``` -### off('interrupt') +### on('audioRendererChange')9+ -off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\): void +on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArray>): void -Unsubscribes from audio interruption events. +Subscribes to audio renderer change events. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| --------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application.| -| interrupt | AudioInterrupt | Yes | Audio interruption event type. | -| callback | Callback<[InterruptAction](#interruptaction)> | No | Callback invoked for the audio interruption event. | +| Name | Type | Mandatory | Description | +| -------- | ---------- | --------- | ------------------------------------------------------------------------ | +| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes. | +| callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the result. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | **Example** ```js -var interAudioInterrupt = { - streamUsage:2, - contentType:0, - pauseWhenDucked:true -}; -audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => { - if (InterruptAction.actionType === 0) { - console.info('An event to release the audio focus starts.'); - console.info(`Focus release event: ${InterruptAction} `); +audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; + console.info(`## RendererChange on is called for ${i} ##`); + console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); + console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); + console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); + console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); + console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); + console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); + for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); + } } }); ``` -### setAudioScene8+ +### off('audioRendererChange')9+ -setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void +off(type: "audioRendererChange"): void -Sets an audio scene. This API uses an asynchronous callback to return the result. +Unsubscribes from audio renderer change events. -**System API**: This is a system API. +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**System capability**: SystemCapability.Multimedia.Audio.Communication +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------- | ---- | ---------------- | +| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.| + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | + +**Example** + +```js +audioStreamManager.off('audioRendererChange'); +console.info('######### RendererChange Off is called #########'); +``` + +### on('audioCapturerChange')9+ + +on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArray>): void + +Subscribes to audio capturer change events. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :----------------------------------- | :--- | :------------------- | -| scene | AudioScene | Yes | Audio scene to set. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ------- | --------- | ----------------------------------------------------------------------- | +| type | string | Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes. | +| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { - if (err) { - console.error(`Failed to set the audio scene mode.​ ${err}`); - return; +audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`## CapChange on is called for element ${i} ##`); + console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); + console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); + console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); + console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); + console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } } - console.info('Callback invoked to indicate a successful setting of the audio scene mode.'); }); ``` -### setAudioScene8+ - -setAudioScene\(scene: AudioScene\): Promise +### off('audioCapturerChange')9+ -Sets an audio scene. This API uses a promise to return the result. +off(type: "audioCapturerChange"): void; -**System API**: This is a system API. +Unsubscribes from audio capturer change events. -**System capability**: SystemCapability.Multimedia.Audio.Communication +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name| Type | Mandatory| Description | -| :----- | :----------------------------------- | :--- | :------------- | -| scene | AudioScene | Yes | Audio scene to set.| - -**Return value** - -| Type | Description | -| :------------- | :------------------- | -| Promise | Promise used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | -------- | --- | ------------------------------------------------------------- | +| type | string |Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes.| **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { - console.info('Promise returned to indicate a successful setting of the audio scene mode.'); -}).catch ((err) => { - console.error(`Failed to set the audio scene mode ${err}`); -}); +audioStreamManager.off('audioCapturerChange'); +console.info('######### CapturerChange Off is called #########'); + ``` -### getAudioScene8+ +### isActive9+ -getAudioScene\(callback: AsyncCallback\): void +isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -Obtains the audio scene. This API uses an asynchronous callback to return the result. +Checks whether a stream is active. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Communication +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :-------------------------------------------------- | :--- | :--------------------------- | -| callback | AsyncCallback<AudioScene> | Yes | Callback used to return the audio scene.| +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.| **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getAudioScene((err, value) => { +audioStreamManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error(`Failed to obtain the audio scene mode.​ ${err}`); + console.error(`Failed to obtain the active status of the stream. ${err}`); return; } - console.info(`Callback invoked to indicate that the audio scene mode is obtained ${value}.`); + console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`); }); ``` +### isActive9+ -### getAudioScene8+ +isActive(volumeType: AudioVolumeType): Promise<boolean> -getAudioScene\(\): Promise +Checks whether a stream is active. This API uses a promise to return the result. -Obtains the audio scene. This API uses a promise to return the result. +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**System capability**: SystemCapability.Multimedia.Audio.Communication +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| **Return value** -| Type | Description | -| :-------------------------------------------- | :--------------------------- | -| Promise<AudioScene> | Promise used to return the audio scene.| +| Type | Description | +| ---------------------- | -------------------------------------------------------- | +| Promise<boolean> | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite.| **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getAudioScene().then((value) => { - console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`); -}).catch ((err) => { - console.error(`Failed to obtain the audio scene mode ${err}`); +audioStreamManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`); }); ``` -### getVolumeGroups9+ +## AudioRoutingManager9+ -getVolumeGroups(networkId: string, callback: AsyncCallback\): void +Implements audio routing management. Before calling any API in **AudioRoutingManager**, you must use [getRoutingManager](#getroutingmanager9) to obtain an **AudioRoutingManager** instance. -Obtains the volume groups. This API uses an asynchronous callback to return the result. +### getDevices9+ -**System API**: This is a system API. +getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void -**System capability**: SystemCapability.Multimedia.Audio.Volume +Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. You can call **getRoutingManager().getDevices()** to obtain all network IDs. | -| callback | AsyncCallback<[VolumeGroupInfos](#volumegroupinfos9)> | Yes | Callback used to return the volume group information array.| +| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list.| **Example** + ```js -var audioManager = audio.getAudioManager(); -audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID, (err, value) => { +audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { if (err) { - console.error(`Failed to obtain the volume group infos list. ${err}`); + console.error(`Failed to obtain the device list. ${err}`); return; } - console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + console.info('Callback invoked to indicate that the device list is obtained.'); }); ``` -### getVolumeGroups9+ - -getVolumeGroups(networkId: string\): Promise +### getDevices9+ -Obtains the volume groups. This API uses a promise to return the result. +getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> -**System API**: This is a system API. +Obtains the audio devices with a specific flag. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| networkId | string | Yes | Network ID of the device. The network ID of the local device is **audio.LOCAL_NETWORK_ID**. You can call **getRoutingManager().getDevices()** to obtain all network IDs. | +| Name | Type | Mandatory| Description | +| ---------- | ------------------------- | ---- | ---------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag.| **Return value** -| Type | Description | -| ------------------- | ----------------------------- | -| Promise<[VolumeGroupInfos](#volumegroupinfos9)> | Volume group information array.| +| Type | Description | +| ------------------------------------------------------------ | ------------------------- | +| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list.| **Example** ```js -async function getVolumeGroupInfos(){ - let volumegroupinfos = await audio.getAudioManager().getVolumeGroups(audio.LOCAL_NETWORK_ID); - console.info('Promise returned to indicate that the volumeGroup list is obtained.'+JSON.stringify(volumegroupinfos)) -} +audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { + console.info('Promise returned to indicate that the device list is obtained.'); +}); ``` -### getGroupManager9+ - -getGroupManager(groupId: number, callback: AsyncCallback\): void +### on9+ -Obtains the audio group manager. This API uses an asynchronous callback to return the result. +on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void -**System API**: This is a system API. +Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| groupId | number | Yes | Volume group ID. | -| callback | AsyncCallback< [AudioGroupManager](#audiogroupmanager9) > | Yes | Callback used to return the audio group manager.| - -**Example** - -```js -var audioManager = audio.getAudioManager(); -var audioGroupManager; -async function getGroupManager(){ - let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); - if (value.length > 0) { - let groupid = value[0].groupId; - audioManager.getGroupManager(groupid, (err, value) => { - if (err) { - console.error(`Failed to obtain the volume group infos list. ${err}`); - return; - } - audioGroupManager = value - console.info('Callback invoked to indicate that the volume group infos list is obtained.'); - }); - } -} -``` - -### getGroupManager9+ - -getGroupManager(groupId: number\): Promise - -Obtains the audio group manager. This API uses a promise to return the result. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Multimedia.Audio.Volume - -**Parameters** +| Name | Type | Mandatory| Description | +| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | +| type | string | Yes | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.| +| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | +| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes | Callback used to return the device update details. | -| Name | Type | Mandatory| Description | -| ---------- | ---------------------------------------- | ---- | ---------------- | -| groupId | number | Yes | Volume group ID. | +**Error codes** -**Return value** +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). -| Type | Description | -| ------------------- | ----------------------------- | -| Promise< [AudioGroupManager](#audiogroupmanager9) > | Promise used to return the audio group manager.| +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | **Example** ```js -var audioManager = audio.getAudioManager(); -async function getGroupManager(){ - let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); - if (value.length > 0) { - let groupid = value[0].groupId; - let audioGroupManager = await audioManager.getGroupManager(groupid) - console.info('Callback invoked to indicate that the volume group infos list is obtained.'); - } -} +audioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => { + console.info('device change type : ' + deviceChanged.type); + console.info('device descriptor size : ' + deviceChanged.deviceDescriptors.length); + console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceRole); + console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceType); +}); ``` -### getStreamManager9+ +### off9+ -getStreamManager(callback: AsyncCallback\): void +off(type: 'deviceChange', callback?: Callback): void -Obtains an **AudioStreamManager** instance. This API uses an asynchronous callback to return the result. +Unsubscribes from device change events. -**System capability**: SystemCapability.Multimedia.Audio.Core +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------------------- | ---- | ---------------- | -| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | Yes | **AudioStreamManager** instance.| - -**Example** - -```js -var audioManager = audio.getAudioManager(); -let audioStreamManager; -audioManager.getStreamManager((err, data) => { - if (err) { - console.error(`getStreamManager : Error: ${err}`); - } else { - console.info('getStreamManager : Success : SUCCESS'); - audioStreamManager = data; - } -}); -``` - -### getStreamManager9+ - -getStreamManager(): Promise - -Obtains an **AudioStreamManager** instance. This API uses a promise to return the result. +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------ | +| type | string | Yes | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected.| +| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to return the device update details. | -**System capability**: SystemCapability.Multimedia.Audio.Core +**Error codes** -**Return value** +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). -| Type | Description | -| ---------------------------------------------------- | ---------------- | -| Promise<[AudioStreamManager](#audiostreammanager9)> | **AudioStreamManager** instance.| +| ID| Error Message| +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error. | **Example** ```js -var audioManager = audio.getAudioManager(); -var audioStreamManager; -audioManager.getStreamManager().then((data) => { - audioStreamManager = data; - console.info('getStreamManager: Success!'); -}).catch((err) => { - console.error(`getStreamManager: ERROR : ${err}`); +audioRoutingManager.off('deviceChange', (deviceChanged) => { + console.info('Should be no callback.'); }); - ``` -### requestIndependentInterrupt9+ +### selectInputDevice9+ -requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback\): void +selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void -Requests independent interruption and obtains an interruption session ID. This API uses an asynchronous callback to return the result. +Selects an audio input device. Currently, only one input device can be selected. This API uses an asynchronous callback to return the result. **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ----------------- | -| focusType | [FocusType](#focustype) | Yes | Focus type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Input device. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js -async function requestIndependentInterrupt(){ - let value = await audioManager.requestIndependentInterrupt(audio.FocusType.FOCUS_TYPE_RECORDING); - if (value) { - console.info('requestIndependentInterrupt interface for result callback: SUCCESS'); - } else { - console.error('Result ERROR'); - } +let inputAudioDeviceDescriptor = [{ + "deviceRole":audio.DeviceRole.INPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; + +async function selectInputDevice(){ + audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select input devices result callback: SUCCESS'); } + }); } ``` -### requestIndependentInterrupt9+ -requestIndependentInterrupt(focusType: FocusType): Promise +### selectInputDevice9+ -Requests independent interruption and obtains an interruption session ID. This API uses a promise to return the result. +selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void> **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +Selects an audio input device. Currently, only one input device can be selected. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name| Type| Mandatory| Description| -| ------ | ---- | ---- | ---- | -| focusType | [FocusType](#focustype) | Yes | Focus type. | +| Name | Type | Mandatory| Description | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Input device. | **Return value** -| Type | Description | -| --------------------------------------------------------- | ------------ | -| Promise<boolean> | Promise used to return the result.| +| Type | Description | +| --------------------- | --------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -async function requestIndependentInterrupt(){ - audioManager.requestIndependentInterrupt(audio.FocusType.FOCUS_TYPE_RECORDING).then((value) => { - console.info('Promise returned to succeed '); - }).catch ((err) => { - console.error('Failed to requestIndependentInterrupt'); - }); +let inputAudioDeviceDescriptor =[{ + "deviceRole":audio.DeviceRole.INPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; + +async function getRoutingManager(){ + audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => { + console.info('Select input devices result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }); } ``` -### abandonIndependentInterrupt9+ -abandonIndependentInterrupt(focusType: FocusType, callback: AsyncCallback\): void +### setCommunicationDevice9+ -Abandons independent interruption. This API uses an asynchronous callback to return the result. +setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean, callback: AsyncCallback<void>): void -**System API**: This is a system API. +Sets a communication device to the active state. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------- | ---- | ----------------- | -| focusType | [FocusType](#focustype) | Yes | Focus type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| ---------- | ------------------------------------- | ---- | ------------------------ | +| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes | Communication device type. | +| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```js -async function abandonIndependentInterrupt(){ - let value = await audioManager.abandonIndependentInterrupt(audio.FocusType.FOCUS_TYPE_RECORDING); - if (value) { - console.info('abandonIndependentInterrupt interface for result callback: SUCCESS'); - } else { - console.error('Result ERROR'); +audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true, (err) => { + if (err) { + console.error(`Failed to set the active status of the device. ${err}`); + return; } -} + console.info('Callback invoked to indicate that the device is set to the active status.'); +}); ``` -### abandonIndependentInterrupt9+ -abandonIndependentInterrupt(focusType: FocusType): Promise +### setCommunicationDevice9+ -Abandons independent interruption. This API uses a promise to return the result. +setCommunicationDevice(deviceType: CommunicationDeviceType, active: boolean): Promise<void> -**System API**: This is a system API. +Sets a communication device to the active state. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name| Type| Mandatory| Description| -| ------ | ---- | ---- | ---- | -| focusType | [FocusType](#focustype) | Yes | Focus type. | +| Name | Type | Mandatory| Description | +| ---------- | ----------------------------------------------------- | ---- | ------------------ | +| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes | Communication device type.| +| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | **Return value** -| Type | Description | -| --------------------------------------------------------- | ------------ | -| Promise<boolean> | Promise used to return the result.| +| Type | Description | +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -async function abandonIndependentInterrupt(){ - audioManager.abandonIndependentInterrupt(audio.FocusType.FOCUS_TYPE_RECORDING).then((value) => { - console.info('Promise returned to succeed'); - }).catch ((err) => { - console.error('Failed to abandonIndependentInterrupt'); - }); -} +audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true).then(() => { + console.info('Promise returned to indicate that the device is set to the active status.'); +}); ``` -## AudioGroupManager9+ -Manages the volume of an audio group. Before calling any API in **AudioGroupManager**, you must use [getGroupManager](#getgroupmanager9) to create an **AudioGroupManager** instance. - -**System API**: This is a system API. - -**System capability**: SystemCapability.Multimedia.Audio.Volume - -### setVolume9+ -setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void - -Sets the volume for a stream. This API uses an asynchronous callback to return the result. - -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +### isCommunicationDeviceActive9+ -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +isCommunicationDeviceActive(deviceType: CommunicationDeviceType, callback: AsyncCallback<boolean>): void -**System API**: This is a system API. +Checks whether a communication device is active. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ------------------------ | +| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes | Communication device type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.| **Example** ```js -audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { +audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER, (err, value) => { if (err) { - console.error(`Failed to set the volume. ${err}`); + console.error(`Failed to obtain the active status of the device. ${err}`); return; } - console.info('Callback invoked to indicate a successful volume setting.'); + console.info('Callback invoked to indicate that the active status of the device is obtained.'); }); ``` -### setVolume9+ - -setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> - -Sets the volume for a stream. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +### isCommunicationDeviceActive9+ -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise<boolean> -**System API**: This is a system API. +Checks whether a communication device is active. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**.| +| Name | Type | Mandatory| Description | +| ---------- | ---------------------------------------------------- | ---- | ------------------ | +| deviceType | [CommunicationDeviceType](#communicationdevicetype9) | Yes | Communication device type.| **Return value** -| Type | Description | -| ------------------- | ----------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ---------------------- | ------------------------------- | +| Promise<boolean> | Promise used to return the active state of the device.| **Example** ```js -audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { - console.info('Promise returned to indicate a successful volume setting.'); +audioRoutingManager.isCommunicationDeviceActive(audio.CommunicationDeviceType.SPEAKER).then((value) => { + console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`); }); ``` -### getVolume9+ +### selectOutputDevice9+ -getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void -Obtains the volume of a stream. This API uses an asynchronous callback to return the result. +Selects an audio output device. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result. **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the volume.| +| Name | Type | Mandatory| Description | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js -audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`Failed to obtain the volume. ${err}`); - return; - } - console.info('Callback invoked to indicate that the volume is obtained.'); -}); +let outputAudioDeviceDescriptor = [{ + "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; +async function selectOutputDevice(){ + audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select output devices result callback: SUCCESS'); } + }); +} ``` -### getVolume9+ - -getVolume(volumeType: AudioVolumeType): Promise<number> +### selectOutputDevice9+ -Obtains the volume of a stream. This API uses a promise to return the result. +selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void> **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Volume +Selects an audio output device. Currently, only one output device can be selected. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +| Name | Type | Mandatory| Description | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | **Return value** -| Type | Description | -| --------------------- | ------------------------- | -| Promise<number> | Promise used to return the volume.| +| Type | Description | +| --------------------- | --------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promise returned to indicate that the volume is obtained ${value}.`); -}); -``` - -### getMinVolume9+ +let outputAudioDeviceDescriptor =[{ + "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; -getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +async function selectOutputDevice(){ + audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { + console.info('Select output devices result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }); +} +``` -Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result. +### selectOutputDeviceByFilter9+ + +selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Volume +Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the minimum volume.| +| Name | Type | Mandatory| Description | +| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | +| filter | [AudioRendererFilter](#audiorendererfilter9) | Yes | Filter criteria. | +| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** - ```js -audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`Failed to obtain the minimum volume. ${err}`); - return; - } - console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`); -}); -``` +let outputAudioRendererFilter = { + "uid":20010041, + "rendererInfo": { + "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, + "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags":0 }, + "rendererId":0 }; +let outputAudioDeviceDescriptor = [{ + "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; -### getMinVolume9+ +async function selectOutputDeviceByFilter(){ + audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select output devices by filter result callback: SUCCESS'); } + }); +} +``` -getMinVolume(volumeType: AudioVolumeType): Promise<number> +### selectOutputDeviceByFilter9+ -Obtains the minimum volume allowed for a stream. This API uses a promise to return the result. +selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise<void> **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Volume +Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +| Name | Type | Mandatory| Description | +| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- | +| filter | [AudioRendererFilter](#audiorendererfilter9) | Yes | Filter criteria. | +| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | **Return value** -| Type | Description | -| --------------------- | ------------------------- | -| Promise<number> | Promise used to return the minimum volume.| +| Type | Description | +| --------------------- | --------------------------- | +| Promise<void> | Promise used to return the result.| **Example** ```js -audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`); -}); +let outputAudioRendererFilter = { + "uid":20010041, + "rendererInfo": { + "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, + "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags":0 }, + "rendererId":0 }; +let outputAudioDeviceDescriptor = [{ + "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, + "networkId":audio.LOCAL_NETWORK_ID, + "interruptGroupId":1, + "volumeGroupId":1 }]; + +async function selectOutputDeviceByFilter(){ + audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { + console.info('Select output devices by filter result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }) +} ``` -### getMaxVolume9+ +## AudioRendererChangeInfoArray9+ -getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void +Defines an **AudioRenderChangeInfo** array, which is read-only. -Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result. +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**System API**: This is a system API. +## AudioRendererChangeInfo9+ -**System capability**: SystemCapability.Multimedia.Audio.Volume +Describes the audio renderer change event. -**Parameters** +**System capability**: SystemCapability.Multimedia.Audio.Renderer -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ---------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<number> | Yes | Callback used to return the maximum volume.| +| Name | Type | Readable | Writable | Description | +| ------------- | ---------------------------------------- | -------- | -------- | ---------------------------------------------------------- | +| streamId | number | Yes | No | Unique ID of an audio stream. | +| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API. | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. | +| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. | **Example** ```js -audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { +import audio from '@ohos.multimedia.audio'; + +let audioStreamManager; +let resultFlag = false; +let audioManager = audio.getAudioManager(); + +audioManager.getStreamManager((err, data) => { if (err) { - console.error(`Failed to obtain the maximum volume. ${err}`); - return; + console.error(`Get AudioStream Manager : ERROR : ${err}`); + } else { + audioStreamManager = data; + console.info('Get AudioStream Manager : Success'); } - console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`); }); -``` -### getMaxVolume9+ +audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { + console.info(`## RendererChange on is called for ${i} ##`); + console.info(`StreamId for ${i} is: ${AudioRendererChangeInfoArray[i].streamId}`); + console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfoArray[i].clientUid}`); + console.info(`Content for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.content}`); + console.info(`Stream for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.usage}`); + console.info(`Flag ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags}`); + console.info(`State for ${i} is: ${AudioRendererChangeInfoArray[i].rendererState}`); + let devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`Addr: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`SR: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`C ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`CM: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } + if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) { + resultFlag = true; + console.info(`ResultFlag for ${i} is: ${resultFlag}`); + } + } +}); +``` -getMaxVolume(volumeType: AudioVolumeType): Promise<number> -Obtains the maximum volume allowed for a stream. This API uses a promise to return the result. +## AudioCapturerChangeInfoArray9+ -**System API**: This is a system API. +Defines an **AudioCapturerChangeInfo** array, which is read-only. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Capturer -**Parameters** +## AudioCapturerChangeInfo9+ -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +Describes the audio capturer change event. -**Return value** +**System capability**: SystemCapability.Multimedia.Audio.Capturer -| Type | Description | -| --------------------- | ----------------------------- | -| Promise<number> | Promise used to return the maximum volume.| +| Name | Type | Readable | Writable | Description | +| ------------- | ---------------------------------------- | -------- | -------- | ---------------------------------------------------------- | +| streamId | number | Yes | No | Unique ID of an audio stream. | +| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API. | +| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. | +| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API. | **Example** ```js -audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { - console.info('Promised returned to indicate that the maximum volume is obtained.'); -}); -``` - -### mute9+ +import audio from '@ohos.multimedia.audio'; -mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void +const audioManager = audio.getAudioManager(); +let audioStreamManager; +audioManager.getStreamManager((err, data) => { + if (err) { + console.error(`getStreamManager : Error: ${err}`); + } else { + console.info('getStreamManager : Success : SUCCESS'); + audioStreamManager = data; + } +}); -Mutes or unmutes a stream. This API uses an asynchronous callback to return the result. +let resultFlag = false; +audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`## CapChange on is called for element ${i} ##`); + console.info(`StrId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); + console.info(`CUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); + console.info(`Src for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); + console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); + console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`Addr: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`SR: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`C ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`CM ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } + if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { + resultFlag = true; + console.info(`ResultFlag for element ${i} is: ${resultFlag}`); + } + } +}); +``` -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +## AudioDeviceDescriptors -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +Defines an [AudioDeviceDescriptor](#audiodevicedescriptor) array, which is read-only. -**System API**: This is a system API. +## AudioDeviceDescriptor -**System capability**: SystemCapability.Multimedia.Audio.Volume +Describes an audio device. -**Parameters** +**System capability**: SystemCapability.Multimedia.Audio.Device -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| -| callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Readable | Writable | Description | +| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ | +| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role. | +| deviceType | [DeviceType](#devicetype) | Yes | No | Device type. | +| id9+ | number | Yes | No | Device ID. | +| name9+ | string | Yes | No | Device name. | +| address9+ | string | Yes | No | Device address. | +| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. | +| channelCounts9+ | Array<number> | Yes | No | Number of channels supported. | +| channelMasks9+ | Array<number> | Yes | No | Supported channel masks. | +| networkId9+ | string | Yes | No | ID of the device network.
This is a system API. | +| interruptGroupId9+ | number | Yes | No | ID of the interruption group to which the device belongs.
This is a system API. | +| volumeGroupId9+ | number | Yes | No | ID of the volume group to which the device belongs.
This is a system API. | **Example** ```js -audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { - if (err) { - console.error(`Failed to mute the stream. ${err}`); - return; +import audio from '@ohos.multimedia.audio'; + +function displayDeviceProp(value) { + deviceRoleValue = value.deviceRole; + deviceTypeValue = value.deviceType; +} + +let deviceRoleValue = null; +let deviceTypeValue = null; +const promise = audio.getAudioManager().getDevices(1); +promise.then(function (value) { + console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG'); + value.forEach(displayDeviceProp); + if (deviceTypeValue != null && deviceRoleValue != null){ + console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS'); + } else { + console.error('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL'); } - console.info('Callback invoked to indicate that the stream is muted.'); }); ``` -### mute9+ - -mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> - -Mutes or unmutes a stream. This API uses a promise to return the result. - -**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY +## AudioRendererFilter9+ -This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. +Implements filter criteria. Before calling **selectOutputDeviceByFilter**, you must obtain an **AudioRendererFilter** instance. **System API**: This is a system API. -**System capability**: SystemCapability.Multimedia.Audio.Volume +| Name | Type | Mandatory | Description | +| ------------ | ---------------------------------------- | --------- | ------------------------------------------------------------ | +| uid | number | Yes | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer | +| rendererId | number | No | Unique ID of an audio stream.
**System capability**: SystemCapability.Multimedia.Audio.Renderer | -**Parameters** +**Example** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite.| +```js +let outputAudioRendererFilter = { + "uid":20010041, + "rendererInfo": { + "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, + "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, + "rendererFlags":0 }, + "rendererId":0 }; +``` -**Return value** +## AudioRenderer8+ -| Type | Description | -| ------------------- | ----------------------------- | -| Promise<void> | Promise used to return the result.| +Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance. + +### Attributes + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +| Name | Type | Readable | Writable | Description | +| ------------------ | -------------------------- | -------- | -------- | --------------------- | +| state8+ | [AudioState](#audiostate8) | Yes | No | Audio renderer state. | **Example** ```js -audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { - console.info('Promise returned to indicate that the stream is muted.'); -}); +let state = audioRenderer.state; ``` -### isMute9+ - -isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void +### getRendererInfo8+ -Checks whether a stream is muted. This API uses an asynchronous callback to return the result. +getRendererInfo(callback: AsyncCallback): void -**System API**: This is a system API. +Obtains the renderer information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Volume +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ----------------------------------------------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| +| Name | Type | Mandatory | Description | +| :------- | :------------------------------------------------------- | :-------- | :------------------------------------------------ | +| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes | Callback used to return the renderer information. | **Example** ```js -audioGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { - if (err) { - console.error(`Failed to obtain the mute status. ${err}`); - return; - } - console.info(`Callback invoked to indicate that the mute status of the stream is obtained ${value}.`); +audioRenderer.getRendererInfo((err, rendererInfo) => { + console.info('Renderer GetRendererInfo:'); + console.info(`Renderer content: ${rendererInfo.content}`); + console.info(`Renderer usage: ${rendererInfo.usage}`); + console.info(`Renderer flags: ${rendererInfo.rendererFlags}`); }); ``` -### isMute9+ - -isMute(volumeType: AudioVolumeType): Promise<boolean> - -Checks whether a stream is muted. This method uses a promise to return the result. - -**System API**: This is a system API. +### getRendererInfo8+ -**System capability**: SystemCapability.Multimedia.Audio.Volume +getRendererInfo(): Promise -**Parameters** +Obtains the renderer information of this **AudioRenderer** instance. This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| ---------- | ----------------------------------- | ---- | ------------ | -| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type.| +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| ---------------------- | ------------------------------------------------------ | -| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite.| +| Type | Description | +| -------------------------------------------------- | ------------------------------------------------ | +| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information. | **Example** ```js -audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { - console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); +audioRenderer.getRendererInfo().then((rendererInfo) => { + console.info('Renderer GetRendererInfo:'); + console.info(`Renderer content: ${rendererInfo.content}`); + console.info(`Renderer usage: ${rendererInfo.usage}`); + console.info(`Renderer flags: ${rendererInfo.rendererFlags}`) +}).catch((err) => { + console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err}`); }); ``` -## AudioStreamManager9+ - -Implements audio stream management. Before calling any API in **AudioStreamManager**, you must use [getStreamManager](#getstreammanager9) to obtain an **AudioStreamManager** instance. - -### getCurrentAudioRendererInfoArray9+ +### getStreamInfo8+ -getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeInfoArray>): void +getStreamInfo(callback: AsyncCallback): void -Obtains the information about the current audio renderers. This API uses an asynchronous callback to return the result. +Obtains the stream information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ----------------------------------- | -------- | --------------------------- | -| callback | AsyncCallback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the audio renderer information.| +| Name | Type | Mandatory | Description | +| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- | +| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. | **Example** ```js -audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { - console.info('getCurrentAudioRendererInfoArray **** Get Callback Called ****'); - if (err) { - console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`); - } else { - if (AudioRendererChangeInfoArray != null) { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; - console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); - console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); - console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); - console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); - console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); - console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); - for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); - } - } - } - } +audioRenderer.getStreamInfo((err, streamInfo) => { + console.info('Renderer GetStreamInfo:'); + console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`); + console.info(`Renderer channel: ${streamInfo.channels}`); + console.info(`Renderer format: ${streamInfo.sampleFormat}`); + console.info(`Renderer encoding type: ${streamInfo.encodingType}`); }); ``` -### getCurrentAudioRendererInfoArray9+ +### getStreamInfo8+ -getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray> +getStreamInfo(): Promise -Obtains the information about the current audio renderers. This API uses a promise to return the result. +Obtains the stream information of this **AudioRenderer** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| ---------------------------------------------------------------------------------| --------------------------------------- | -| Promise<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Promise used to return the audio renderer information. | +| Type | Description | +| :--------------------------------------------- | :--------------------------------------------- | +| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. | **Example** ```js -async function getCurrentAudioRendererInfoArray(){ - await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { - console.info(`getCurrentAudioRendererInfoArray ######### Get Promise is called ##########`); - if (AudioRendererChangeInfoArray != null) { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; - console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); - console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); - console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); - console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); - console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); - console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); - for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); - } - } - } - }).catch((err) => { - console.error(`getCurrentAudioRendererInfoArray :ERROR: ${err}`); - }); -} +audioRenderer.getStreamInfo().then((streamInfo) => { + console.info('Renderer GetStreamInfo:'); + console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`); + console.info(`Renderer channel: ${streamInfo.channels}`); + console.info(`Renderer format: ${streamInfo.sampleFormat}`); + console.info(`Renderer encoding type: ${streamInfo.encodingType}`); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); + ``` -### getCurrentAudioCapturerInfoArray9+ +### getAudioStreamId9+ -getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeInfoArray>): void +getAudioStreamId(callback: AsyncCallback): void -Obtains the information about the current audio capturers. This API uses an asynchronous callback to return the result. +Obtains the stream ID of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory | Description | -| ---------- | ----------------------------------- | --------- | -------------------------------------------------------- | -| callback | AsyncCallback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the audio capturer information.| +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the stream ID. | **Example** ```js -audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info('getCurrentAudioCapturerInfoArray **** Get Callback Called ****'); - if (err) { - console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`); - } else { - if (AudioCapturerChangeInfoArray != null) { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); - console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); - console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); - console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); - console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } - } - } - } +audioRenderer.getAudioStreamId((err, streamid) => { + console.info(`Renderer GetStreamId: ${streamid}`); }); + ``` -### getCurrentAudioCapturerInfoArray9+ +### getAudioStreamId9+ -getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray> +getAudioStreamId(): Promise -Obtains the information about the current audio capturers. This API uses a promise to return the result. +Obtains the stream ID of this **AudioRenderer** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| -----------------------------------------------------------------------------| ----------------------------------- | -| Promise<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Promise used to return the audio capturer information. | +| Type | Description | +| :--------------- | :------------------------------------ | +| Promise | Promise used to return the stream ID. | **Example** ```js -async function getCurrentAudioCapturerInfoArray(){ - await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { - console.info('getCurrentAudioCapturerInfoArray **** Get Promise Called ****'); - if (AudioCapturerChangeInfoArray != null) { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); - console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); - console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); - console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); - console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } - } - } - }).catch((err) => { - console.error(`getCurrentAudioCapturerInfoArray :ERROR: ${err}`); - }); -} -``` - -### on('audioRendererChange')9+ +audioRenderer.getAudioStreamId().then((streamid) => { + console.info(`Renderer getAudioStreamId: ${streamid}`); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); -on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArray>): void +``` -Subscribes to audio renderer change events. +### start8+ + +start(callback: AsyncCallback): void + +Starts the renderer. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------- | --------- | ------------------------------------------------------------------------ | -| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes. | -| callback | Callback<[AudioRendererChangeInfoArray](#audiorendererchangeinfoarray9)> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js -audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - let AudioRendererChangeInfo = AudioRendererChangeInfoArray[i]; - console.info(`## RendererChange on is called for ${i} ##`); - console.info(`StreamId for ${i} is: ${AudioRendererChangeInfo.streamId}`); - console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfo.clientUid}`); - console.info(`Content ${i} is: ${AudioRendererChangeInfo.rendererInfo.content}`); - console.info(`Stream ${i} is: ${AudioRendererChangeInfo.rendererInfo.usage}`); - console.info(`Flag ${i} is: ${AudioRendererChangeInfo.rendererInfo.rendererFlags}`); - console.info(`State for ${i} is: ${AudioRendererChangeInfo.rendererState}`); - for (let j = 0;j < AudioRendererChangeInfo.deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCount ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioRendererChangeInfo.deviceDescriptors[j].channelMasks}`); - } +audioRenderer.start((err) => { + if (err) { + console.error('Renderer start failed.'); + } else { + console.info('Renderer start success.'); } }); + ``` -### off('audioRendererChange')9+ +### start8+ -off(type: "audioRendererChange"); +start(): Promise -Unsubscribes from audio renderer change events. +Starts the renderer. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** +**Return value** -| Name | Type | Mandatory| Description | -| -------- | ------- | ---- | ---------------- | -| type | string | Yes | Event type. The event `'audioRendererChange'` is triggered when the audio renderer changes.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js -audioStreamManager.off('audioRendererChange'); -console.info('######### RendererChange Off is called #########'); +audioRenderer.start().then(() => { + console.info('Renderer started'); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); + ``` -### on('audioCapturerChange')9+ +### pause8+ -on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArray>): void +pause(callback: AsyncCallback\): void -Subscribes to audio capturer change events. +Pauses rendering. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------- | --------- | ----------------------------------------------------------------------- | -| type | string | Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes. | -| callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js -audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`## CapChange on is called for element ${i} ##`); - console.info(`StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); - console.info(`ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); - console.info(`Source for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); - console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); - console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); - var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`Address: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`SampleRates: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`ChannelCounts ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`ChannelMask: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } +audioRenderer.pause((err) => { + if (err) { + console.error('Renderer pause failed'); + } else { + console.info('Renderer paused.'); } }); + ``` -### off('audioCapturerChange')9+ +### pause8+ -off(type: "audioCapturerChange"); +pause(): Promise\ -Unsubscribes from audio capturer change events. +Pauses rendering. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** +**Return value** -| Name | Type | Mandatory| Description | -| -------- | -------- | --- | ------------------------------------------------------------- | -| type | string |Yes | Event type. The event `'audioCapturerChange'` is triggered when the audio capturer changes.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js -audioStreamManager.off('audioCapturerChange'); -console.info('######### CapturerChange Off is called #########'); +audioRenderer.pause().then(() => { + console.info('Renderer paused'); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); ``` -## AudioRoutingManager9+ -Implements audio routing management. Before calling any API in **AudioRoutingManager**, you must use [getRoutingManager](#getroutingmanager9) to obtain an **AudioRoutingManager** instance. - -### getDevices9+ +### drain8+ -getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void +drain(callback: AsyncCallback\): void -Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result. +Drains the playback buffer. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | -| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getRoutingManager((err,AudioRoutingManager)=>{ +audioRenderer.drain((err) => { if (err) { - console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); + console.error('Renderer drain failed'); } else { - AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { - if (err) { - console.error(`Failed to obtain the device list. ${err}`); - return; - } - console.info('Callback invoked to indicate that the device list is obtained.'); - }); + console.info('Renderer drained.'); } -}) -``` - -### getDevices9+ +}); -getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> +``` -Obtains the audio devices with a specific flag. This API uses a promise to return the result. +### drain8+ -**System capability**: SystemCapability.Multimedia.Audio.Device +drain(): Promise\ -**Parameters** +Drains the playback buffer. This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| ---------- | ------------------------- | ---- | ---------------- | -| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag.| +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| ------------------------------------------------------------ | ------------------------- | -| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getRoutingManager((err,AudioRoutingManager)=>{ - if (err) { - console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); - } - else { - AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { - console.info('Promise returned to indicate that the device list is obtained.'); - }); - } +audioRenderer.drain().then(() => { + console.info('Renderer drained successfully'); +}).catch((err) => { + console.error(`ERROR: ${err}`); }); + ``` -### on9+ +### stop8+ -on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void +stop(callback: AsyncCallback\): void -Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback. +Stops rendering. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :--------------------------------------------------- | :--- | :----------------------------------------- | -| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.| -| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | -| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes | Callback used to return the device update details. | +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getRoutingManager((err,AudioRoutingManager)=>{ +audioRenderer.stop((err) => { if (err) { - console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); - } - else { - AudioRoutingManager.on('deviceChange', audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (deviceChanged) => { - console.info('device change type : ' + deviceChanged.type); - console.info('device descriptor size : ' + deviceChanged.deviceDescriptors.length); - console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceRole); - console.info('device change descriptor : ' + deviceChanged.deviceDescriptors[0].deviceType); - }); + console.error('Renderer stop failed'); + } else { + console.info('Renderer stopped.'); } }); + ``` -### off9+ +### stop8+ -off(type: 'deviceChange', callback?: Callback): void +stop(): Promise\ -Unsubscribes from device change events. +Stops rendering. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** +**Return value** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------ | -| type | string | Yes | Event type. The value **deviceChange** means the device change event, which is triggered when a device connection status change is detected.| -| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to return the device update details. | +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -audioManager.getRoutingManager((err,AudioRoutingManager)=>{ - if (err) { - console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); - } else { - AudioRoutingManager.off('deviceChange', (deviceChanged) => { - console.info('Should be no callback.'); - }); - } +audioRenderer.stop().then(() => { + console.info('Renderer stopped successfully'); +}).catch((err) => { + console.error(`ERROR: ${err}`); }); -``` -### selectInputDevice9+ +``` -selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void +### release8+ -Selects an audio input device. Currently, only one input device can be selected. This API uses an asynchronous callback to return the result. +release(callback: AsyncCallback\): void -**System API**: This is a system API. +Releases the renderer. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | -| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Input device. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** -```js -var audioManager = audio.getAudioManager(); -let inputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.INPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => { - if (err) { - console.error(`Result ERROR: ${err}`); - } else { - console.info('Select input devices result callback: SUCCESS'); } - }); - }); -} -``` - -### selectInputDevice9+ - -selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void> +```js +audioRenderer.release((err) => { + if (err) { + console.error('Renderer release failed'); + } else { + console.info('Renderer released.'); + } +}); -**System API**: This is a system API. +``` -Selects an audio input device. Currently, only one input device can be selected. This API uses a promise to return the result. +### release8+ -**System capability**: SystemCapability.Multimedia.Audio.Device +release(): Promise\ -**Parameters** +Releases the renderer. This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | -| inputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Input device. | +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| --------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | **Example** ```js -var audioManager = audio.getAudioManager(); -let inputAudioDeviceDescriptor =[{ - "deviceRole":audio.DeviceRole.INPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; +audioRenderer.release().then(() => { + console.info('Renderer released successfully'); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => { - console.info('Select input devices result promise: SUCCESS'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); - }); - }); -} ``` -### selectOutputDevice9+ - -selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void +### write8+ -Selects an audio output device. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result. +write(buffer: ArrayBuffer, callback: AsyncCallback\): void -**System API**: This is a system API. +Writes the buffer. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | -| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | ------------------------------------------------------------ | +| buffer | ArrayBuffer | Yes | Buffer to be written. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. | **Example** -```js -var audioManager = audio.getAudioManager(); -let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { - if (err) { - console.error(`Result ERROR: ${err}`); - } else { - console.info('Select output devices result callback: SUCCESS'); } - }); +```js +let bufferSize; +audioRenderer.getBufferSize().then((data)=> { + console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); + bufferSize = data; + }).catch((err) => { + console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); }); +console.info(`Buffer size: ${bufferSize}`); +let context = featureAbility.getContext(); +let path; +async function getCacheDir(){ + path = await context.getCacheDir(); } -``` - -### selectOutputDevice9+ - -selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void> +let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +audioRenderer.write(buf, (err, writtenbytes) => { + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.info(`Actual written bytes: ${writtenbytes}`); + } +}); -**System API**: This is a system API. +``` -Selects an audio output device. Currently, only one output device can be selected. This API uses a promise to return the result. +### write8+ -**System capability**: SystemCapability.Multimedia.Audio.Device +write(buffer: ArrayBuffer): Promise\ -**Parameters** +Writes the buffer. This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | -| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| --------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. | **Example** ```js -var audioManager = audio.getAudioManager(); -let outputAudioDeviceDescriptor =[{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; - -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { - console.info('Select output devices result promise: SUCCESS'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); - }); +let bufferSize; +audioRenderer.getBufferSize().then((data) => { + console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); + bufferSize = data; + }).catch((err) => { + console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); }); +console.info(`BufferSize: ${bufferSize}`); +let context = featureAbility.getContext(); +let path; +async function getCacheDir(){ + path = await context.getCacheDir(); } -``` +let filePath = path + '/StarWars10s-2C-48000-4SW.wav'; +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +audioRenderer.write(buf).then((writtenbytes) => { + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.info(`Actual written bytes: ${writtenbytes}`); + } +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); -### selectOutputDeviceByFilter9+ +``` -selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCallback<void>): void +### getAudioTime8+ -**System API**: This is a system API. +getAudioTime(callback: AsyncCallback\): void -Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses an asynchronous callback to return the result. +Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Device +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory| Description | -| --------------------------- | ------------------------------------------------------------ | ---- | ------------------------- | -| filter | [AudioRendererFilter](#audiorendererfilter9) | Yes | Filter criteria. | -| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | -| callback | AsyncCallback<void> | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | -------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the timestamp. | **Example** + ```js -var audioManager = audio.getAudioManager(); -let outputAudioRendererFilter = { - "uid":20010041, - "rendererInfo": { - "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags":0 }, - "rendererId":0 }; -let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; +audioRenderer.getAudioTime((err, timestamp) => { + console.info(`Current timestamp: ${timestamp}`); +}); -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { - if (err) { - console.error(`Result ERROR: ${err}`); - } else { - console.info('Select output devices by filter result callback: SUCCESS'); } - }); - }); -} ``` -### selectOutputDeviceByFilter9+ - -selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise<void> - -**System API**: This is a system API. - -Selects an audio output device based on the filter criteria. Currently, only one output device can be selected. This API uses a promise to return the result. +### getAudioTime8+ -**System capability**: SystemCapability.Multimedia.Audio.Device +getAudioTime(): Promise\ -**Parameters** +Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result. -| Name | Type | Mandatory| Description | -| ----------------------| ------------------------------------------------------------ | ---- | ------------------------- | -| filter | [AudioRendererFilter](#audiorendererfilter9) | Yes | Filter criteria. | -| outputAudioDevices | [AudioDeviceDescriptors](#audiodevicedescriptors) | Yes | Output device. | +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Return value** -| Type | Description | -| --------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| +| Type | Description | +| ---------------- | ------------------------------------- | +| Promise\ | Promise used to return the timestamp. | **Example** ```js -var audioManager = audio.getAudioManager(); -let outputAudioRendererFilter = { - "uid":20010041, - "rendererInfo": { - "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags":0 }, - "rendererId":0 }; -let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; -var audioRoutingManager; +audioRenderer.getAudioTime().then((timestamp) => { + console.info(`Current timestamp: ${timestamp}`); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); -async function getRoutingManager(){ - await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { - console.info('Select output devices by filter result promise: SUCCESS'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); - }) - }); -} ``` -## AudioRendererChangeInfo9+ - -Describes the audio renderer change event. +### getBufferSize8+ -**System capability**: SystemCapability.Multimedia.Audio.Renderer +getBufferSize(callback: AsyncCallback\): void -| Name | Type | Readable | Writable | Description | -| ------------- | ---------------------------------------- | -------- | -------- | ------------------------------------------------------------ | -| streamId | number | Yes | No | Unique ID of an audio stream. | -| clientUid | number | Yes | No | UID of the audio renderer client.
This is a system API and cannot be called by third-party applications. | -| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | Yes | No | Audio renderer information. | -| rendererState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API and cannot be called by third-party applications. | +Obtains a reasonable minimum buffer size in bytes for rendering. This API uses an asynchronous callback to return the result. -## AudioRendererChangeInfoArray9+ +**System capability**: SystemCapability.Multimedia.Audio.Renderer -Describes the **AudioRenderChangeInfo** array, which is read-only. +**Parameters** -**System capability**: SystemCapability.Multimedia.Audio.Renderer +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the buffer size. | **Example** ```js -import audio from '@ohos.multimedia.audio'; - -var audioStreamManager; -var resultFlag = false; -var audioManager = audio.getAudioManager(); - -audioManager.getStreamManager((err, data) => { +let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { if (err) { - console.error(`Get AudioStream Manager : ERROR : ${err}`); - } else { - audioStreamManager = data; - console.info('Get AudioStream Manager : Success'); + console.error('getBufferSize error'); } }); -audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { - for (let i = 0; i < AudioRendererChangeInfoArray.length; i++) { - console.info(`## RendererChange on is called for ${i} ##`); - console.info(`StreamId for ${i} is: ${AudioRendererChangeInfoArray[i].streamId}`); - console.info(`ClientUid for ${i} is: ${AudioRendererChangeInfoArray[i].clientUid}`); - console.info(`Content for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.content}`); - console.info(`Stream for ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.usage}`); - console.info(`Flag ${i} is: ${AudioRendererChangeInfoArray[i].rendererInfo.rendererFlags}`); - console.info(`State for ${i} is: ${AudioRendererChangeInfoArray[i].rendererState}`); - var devDescriptor = AudioRendererChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioRendererChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`Addr: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`SR: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`C ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`CM: ${i} : ${AudioRendererChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } - if (AudioRendererChangeInfoArray[i].rendererState == 1 && devDescriptor != null) { - resultFlag = true; - console.info(`ResultFlag for ${i} is: ${resultFlag}`); +``` + +### getBufferSize8+ + +getBufferSize(): Promise\ + +Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Return value** + +| Type | Description | +| ---------------- | --------------------------------------- | +| Promise\ | Promise used to return the buffer size. | + +**Example** + +```js +let bufferSize; +audioRenderer.getBufferSize().then((data) => { + console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); + bufferSize = data; +}).catch((err) => { + console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); +}); + +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\): void + +Sets the render rate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | --------- | ----------------------------------- | +| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Example** + +```js +audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => { + if (err) { + console.error('Failed to set params'); + } else { + console.info('Callback invoked to indicate a successful render rate setting.'); + } +}); + +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate): Promise\ + +Sets the render rate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---- | ---------------------------------------- | --------- | ------------------ | +| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. | + +**Return value** + +| Type | Description | +| -------------- | ---------------------------------- | +| Promise\ | Promise used to return the result. | + +**Example** + +```js +audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { + console.info('setRenderRate SUCCESS'); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); + +``` + +### getRenderRate8+ + +getRenderRate(callback: AsyncCallback\): void + +Obtains the current render rate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------------------------------------------------------- | --------- | ---------------------------------------------- | +| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | Yes | Callback used to return the audio render rate. | + +**Example** + +```js +audioRenderer.getRenderRate((err, renderrate) => { + console.info(`getRenderRate: ${renderrate}`); +}); + +``` + +### getRenderRate8+ + +getRenderRate(): Promise\ + +Obtains the current render rate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Return value** + +| Type | Description | +| ------------------------------------------------- | --------------------------------------------- | +| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise used to return the audio render rate. | + +**Example** + +```js +audioRenderer.getRenderRate().then((renderRate) => { + console.info(`getRenderRate: ${renderRate}`); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); + +``` + +### setInterruptMode9+ + +setInterruptMode(mode: InterruptMode): Promise<void> + +Sets the audio interruption mode for the application. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---- | -------------------------------- | --------- | ------------------------ | +| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. | + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. | + +**Example** + +```js +let mode = 0; +audioRenderer.setInterruptMode(mode).then(data=>{ + console.info('setInterruptMode Success!'); +}).catch((err) => { + console.error(`setInterruptMode Fail: ${err}`); +}); + +``` + +### setInterruptMode9+ + +setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void + +Sets the audio interruption mode for the application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------------------- | --------- | ----------------------------------- | +| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Example** + +```js +let mode = 1; +audioRenderer.setInterruptMode(mode, (err, data)=>{ + if(err){ + console.error(`setInterruptMode Fail: ${err}`); + } + console.info('setInterruptMode Success!'); +}); + +``` + +### setVolume9+ + +setVolume(volume: number): Promise<void> + +Sets the volume for the application. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------ | ------ | --------- | -------------- | +| volume | number | Yes | Volume to set. | + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. | + +**Example** + +```js +audioRenderer.setVolume(10).then(data=>{ + console.info('setVolume Success!'); +}).catch((err) => { + console.error(`setVolume Fail: ${err}`); +}); + +``` + +### setVolume9+ + +setVolume(volume: number, callback: AsyncCallback\): void + +Sets the volume for the application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | --------- | ----------------------------------- | +| volume | number | Yes | Volume to set. | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + +**Example** + +```js +audioRenderer.setVolume(10, (err, data)=>{ + if(err){ + console.error(`setVolume Fail: ${err}`); + } + console.info('setVolume Success!'); +}); + +``` + +### on('audioInterrupt')9+ + +on(type: 'audioInterrupt', callback: Callback\): void + +Subscribes to audio interruption events. This API uses a callback to get interrupt events. + +Same as [on('interrupt')](#oninterruptdeprecated), this API has obtained the focus before **start**, **pause**, or **stop** of **AudioRenderer** is called. Therefore, you do not need to request the focus. + +**System capability**: SystemCapability.Multimedia.Audio.Interrupt + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'audioInterrupt'** means the audio interruption event, which is triggered when audio playback is interrupted. | +| callback | Callback<[InterruptEvent](#interruptevent9)> | Yes | Callback used to return the audio interruption event. | + +**Error codes** + +For details about the error codes, see [Audio Error Codes](../errorcodes/errorcode-audio.md). + +| ID | Error Message | +| ------- | ------------------------------- | +| 6800101 | if input parameter value error. | + +**Example** + +```js +let isPlay; +let started; +audioRenderer.on('audioInterrupt', async(interruptEvent) => { + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('Force paused. Stop writing'); + isPlay = false; + break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.info('Force stopped. Stop writing'); + isPlay = false; + break; } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + console.info('Resume force paused renderer or ignore'); + await audioRenderer.start().then(async function () { + console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); + started = true; + }).catch((err) => { + console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`); + started = false; + }); + if (started) { + isPlay = true; + console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`); + } else { + console.error('AudioInterruptMusic Renderer start failed'); + } + break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('Choose to pause or ignore'); + if (isPlay == true) { + isPlay == false; + console.info('AudioInterruptMusic: Media PAUSE : TRUE'); + } else { + isPlay = true; + console.info('AudioInterruptMusic: Media PLAY : TRUE'); + } + break; + } + } +}); + +``` + +### on('markReach')8+ + +on(type: "markReach", frame: number, callback: Callback<number>): void + +Subscribes to mark reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is invoked. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'markReach'**. | +| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | +| callback | Callback\ | Yes | Callback invoked when the event is triggered. | + +**Example** + +```js +audioRenderer.on('markReach', 1000, (position) => { + if (position == 1000) { + console.info('ON Triggered successfully'); + } +}); + +``` + + +### off('markReach') 8+ + +off(type: 'markReach'): void + +Unsubscribes from mark reached events. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :--- | :----- | :-------- | :------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'markReach'**. | + +**Example** + +```js +audioRenderer.off('markReach'); + +``` + +### on('periodReach') 8+ + +on(type: "periodReach", frame: number, callback: Callback<number>): void + +Subscribes to period reached events. When the number of frames rendered reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'periodReach'**. | +| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | +| callback | Callback\ | Yes | Callback invoked when the event is triggered. | + +**Example** + +```js +audioRenderer.on('periodReach', 1000, (position) => { + if (position == 1000) { + console.info('ON Triggered successfully'); + } +}); + +``` + +### off('periodReach') 8+ + +off(type: 'periodReach'): void + +Unsubscribes from period reached events. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :--- | :----- | :-------- | :--------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'periodReach'**. | + +**Example** + +```js +audioRenderer.off('periodReach') + +``` + +### on('stateChange')8+ + +on(type: 'stateChange', callback: Callback): void + +Subscribes to state change events. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :------------------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value **stateChange** means the state change event. | +| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. | + +**Example** + +```js +audioRenderer.on('stateChange', (state) => { + if (state == 1) { + console.info('audio renderer state is: STATE_PREPARED'); + } + if (state == 2) { + console.info('audio renderer state is: STATE_RUNNING'); } }); + ``` -## AudioCapturerChangeInfo9+ +## AudioCapturer8+ -Describes the audio capturer change event. +Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance. + +### Attributes **System capability**: SystemCapability.Multimedia.Audio.Capturer -| Name | Type | Readable | Writable | Description | -| ------------- | ---------------------------------------- | -------- | -------- | ------------------------------------------------------------ | -| streamId | number | Yes | No | Unique ID of an audio stream. | -| clientUid | number | Yes | No | UID of the audio capturer client.
This is a system API and cannot be called by third-party applications. | -| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | Yes | No | Audio capturer information. | -| capturerState | [AudioState](#audiostate) | Yes | No | Audio state.
This is a system API and cannot be called by third-party applications. | +| Name | Type | Readable | Writable | Description | +| :----------------- | :------------------------- | :------- | :------- | :-------------------- | +| state8+ | [AudioState](#audiostate8) | Yes | No | Audio capturer state. | + +**Example** + +```js +let state = audioCapturer.state; -## AudioCapturerChangeInfoArray9+ +``` -Describes the **AudioCapturerChangeInfo** array, which is read-only. +### getCapturerInfo8+ + +getCapturerInfo(callback: AsyncCallback): void + +Obtains the capturer information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Audio.Capturer +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :-------------------------------- | :-------- | :------------------------------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the capturer information. | + **Example** ```js -import audio from '@ohos.multimedia.audio'; - -const audioManager = audio.getAudioManager(); -let audioStreamManager; -audioManager.getStreamManager((err, data) => { +audioCapturer.getCapturerInfo((err, capturerInfo) => { if (err) { - console.error(`getStreamManager : Error: ${err}`); + console.error('Failed to get capture info'); } else { - console.info('getStreamManager : Success : SUCCESS'); - audioStreamManager = data; + console.info('Capturer getCapturerInfo:'); + console.info(`Capturer source: ${capturerInfo.source}`); + console.info(`Capturer flags: ${capturerInfo.capturerFlags}`); } }); -var resultFlag = false; -audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`## CapChange on is called for element ${i} ##`); - console.info(`StrId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); - console.info(`CUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); - console.info(`Src for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); - console.info(`Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); - console.info(`State for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`); - var devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`Id: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`Type: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`Role: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`Name: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`Addr: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`SR: ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`C ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`CM ${i} : ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } - if (AudioCapturerChangeInfoArray[i].capturerState == 1 && devDescriptor != null) { - resultFlag = true; - console.info(`ResultFlag for element ${i} is: ${resultFlag}`); - } - } -}); ``` -## AudioDeviceDescriptor -Describes an audio device. +### getCapturerInfo8+ -**System capability**: SystemCapability.Multimedia.Audio.Device +getCapturerInfo(): Promise -| Name | Type | Readable | Writable | Description | -| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ | -| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role. | -| deviceType | [DeviceType](#devicetype) | Yes | No | Device type. | -| id9+ | number | Yes | No | Device ID. | -| name9+ | string | Yes | No | Device name. | -| address9+ | string | Yes | No | Device address. | -| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. | -| channelCounts9+ | Array<number> | Yes | No | Number of channels supported. | -| channelMasks9+ | Array<number> | Yes | No | Supported channel masks. | -| networkId9+ | string | Yes | No | ID of the device network.
This is a system API and cannot be called by third-party applications. | -| interruptGroupId9+ | number | Yes | No | ID of the interruption group to which the device belongs.
This is a system API and cannot be called by third-party applications. | -| volumeGroupId9+ | number | Yes | No | ID of the volume group to which the device belongs.
This is a system API and cannot be called by third-party applications. | +Obtains the capturer information of this **AudioCapturer** instance. This API uses a promise to return the result. -## AudioDeviceDescriptors +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Return value** -Array of [AudioDeviceDescriptor](#audiodevicedescriptor), which is read-only. +| Type | Description | +| :------------------------------------------------ | :----------------------------------------------- | +| Promise<[AudioCapturerInfo](#audiocapturerinfo)\> | Promise used to return the capturer information. | **Example** ```js -import audio from '@ohos.multimedia.audio'; +audioCapturer.getCapturerInfo().then((audioParamsGet) => { + if (audioParamsGet != undefined) { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info(`AudioFrameworkRecLog: Capturer SourceType: ${audioParamsGet.source}`); + console.info(`AudioFrameworkRecLog: Capturer capturerFlags: ${audioParamsGet.capturerFlags}`); + } else { + console.info(`AudioFrameworkRecLog: audioParamsGet is : ${audioParamsGet}`); + console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect'); + } +}).catch((err) => { + console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`); +}); -function displayDeviceProp(value) { - deviceRoleValue = value.deviceRole; - deviceTypeValue = value.deviceType; -} +``` -var deviceRoleValue = null; -var deviceTypeValue = null; -const promise = audio.getAudioManager().getDevices(1); -promise.then(function (value) { - console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG'); - value.forEach(displayDeviceProp); - if (deviceTypeValue != null && deviceRoleValue != null){ - console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS'); +### getStreamInfo8+ + +getStreamInfo(callback: AsyncCallback): void + +Obtains the stream information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- | +| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. | + +**Example** + +```js +audioCapturer.getStreamInfo((err, streamInfo) => { + if (err) { + console.error('Failed to get stream info'); } else { - console.error('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL'); + console.info('Capturer GetStreamInfo:'); + console.info(`Capturer sampling rate: ${streamInfo.samplingRate}`); + console.info(`Capturer channel: ${streamInfo.channels}`); + console.info(`Capturer format: ${streamInfo.sampleFormat}`); + console.info(`Capturer encoding type: ${streamInfo.encodingType}`); } }); + ``` -## AudioRendererFilter9+ +### getStreamInfo8+ -Implements filter criteria. Before calling **selectOutputDeviceByFilter**, you must obtain an **AudioRendererFilter** instance. +getStreamInfo(): Promise -**System API**: This is a system API. +Obtains the stream information of this **AudioCapturer** instance. This API uses a promise to return the result. -| Name | Type | Mandatory | Description | -| ------------ | ---------------------------------------- | --------- | ------------------------------------------------------------ | -| uid | number | Yes | Application ID.
**System capability**: SystemCapability.Multimedia.Audio.Core | -| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | No | Audio renderer information.
**System capability**: SystemCapability.Multimedia.Audio.Renderer | -| rendererId | number | No | Unique ID of an audio stream.
**System capability**: SystemCapability.Multimedia.Audio.Renderer | +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Return value** + +| Type | Description | +| :--------------------------------------------- | :--------------------------------------------- | +| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. | **Example** ```js -let outputAudioRendererFilter = { - "uid":20010041, - "rendererInfo": { - "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags":0 }, - "rendererId":0 }; +audioCapturer.getStreamInfo().then((audioParamsGet) => { + console.info('getStreamInfo:'); + console.info(`sampleFormat: ${audioParamsGet.sampleFormat}`); + console.info(`samplingRate: ${audioParamsGet.samplingRate}`); + console.info(`channels: ${audioParamsGet.channels}`); + console.info(`encodingType: ${audioParamsGet.encodingType}`); +}).catch((err) => { + console.error(`getStreamInfo :ERROR: ${err}`); +}); + +``` + +### getAudioStreamId9+ + +getAudioStreamId(callback: AsyncCallback): void + +Obtains the stream ID of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the stream ID. | + +**Example** + +```js +audioCapturer.getAudioStreamId((err, streamid) => { + console.info(`audioCapturer GetStreamId: ${streamid}`); +}); + +``` + +### getAudioStreamId9+ + +getAudioStreamId(): Promise + +Obtains the stream ID of this **AudioCapturer** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Return value** + +| Type | Description | +| :--------------- | :------------------------------------ | +| Promise | Promise used to return the stream ID. | + +**Example** + +```js +audioCapturer.getAudioStreamId().then((streamid) => { + console.info(`audioCapturer getAudioStreamId: ${streamid}`); +}).catch((err) => { + console.error(`ERROR: ${err}`); +}); + +``` + +### start8+ + +start(callback: AsyncCallback): void + +Starts capturing. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | + +**Example** + +```js +audioCapturer.start((err) => { + if (err) { + console.error('Capturer start failed.'); + } else { + console.info('Capturer start success.'); + } +}); + ``` -## AudioRenderer8+ -Provides APIs for audio rendering. Before calling any API in **AudioRenderer**, you must use [createAudioRenderer](#audiocreateaudiorenderer8) to create an **AudioRenderer** instance. +### start8+ -### Attributes +start(): Promise -**System capability**: SystemCapability.Multimedia.Audio.Renderer +Starts capturing. This API uses a promise to return the result. -| Name | Type | Readable | Writable | Description | -| ------------------ | -------------------------- | -------- | -------- | --------------------- | -| state8+ | [AudioState](#audiostate8) | Yes | No | Audio renderer state. | +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Return value** + +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -var state = audioRenderer.state; +audioCapturer.start().then(() => { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); + console.info(`AudioFrameworkRecLog: AudioCapturer: STATE: ${audioCapturer.state}`); + console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); + if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { + console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); + } +}).catch((err) => { + console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`); +}); + ``` -### getRendererInfo8+ +### stop8+ -getRendererInfo(callback: AsyncCallback): void +stop(callback: AsyncCallback): void -Obtains the renderer information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result. +Stops capturing. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------------------------------------------- | :-------- | :------------------------------------------------ | -| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | Yes | Callback used to return the renderer information. | +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.getRendererInfo((err, rendererInfo) => { - console.info('Renderer GetRendererInfo:'); - console.info(`Renderer content: ${rendererInfo.content}`); - console.info(`Renderer usage: ${rendererInfo.usage}`); - console.info(`Renderer flags: ${rendererInfo.rendererFlags}`); +audioCapturer.stop((err) => { + if (err) { + console.error('Capturer stop failed'); + } else { + console.info('Capturer stopped.'); + } }); + ``` -### getRendererInfo8+ -getRendererInfo(): Promise +### stop8+ -Obtains the renderer information of this **AudioRenderer** instance. This API uses a promise to return the result. +stop(): Promise -**System capability**: SystemCapability.Multimedia.Audio.Renderer +Stops capturing. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Return value** -| Type | Description | -| -------------------------------------------------- | ------------------------------------------------ | -| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise used to return the renderer information. | +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -audioRenderer.getRendererInfo().then((rendererInfo) => { - console.info('Renderer GetRendererInfo:'); - console.info(`Renderer content: ${rendererInfo.content}`); - console.info(`Renderer usage: ${rendererInfo.usage}`); - console.info(`Renderer flags: ${rendererInfo.rendererFlags}`) +audioCapturer.stop().then(() => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS'); + if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ + console.info('AudioFrameworkRecLog: State is Stopped:'); + } }).catch((err) => { - console.error(`AudioFrameworkRenderLog: RendererInfo :ERROR: ${err}`); + console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); }); + ``` -### getStreamInfo8+ +### release8+ -getStreamInfo(callback: AsyncCallback): void +release(callback: AsyncCallback): void -Obtains the stream information of this **AudioRenderer** instance. This API uses an asynchronous callback to return the result. +Releases this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- | -| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. | +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.getStreamInfo((err, streamInfo) => { - console.info('Renderer GetStreamInfo:'); - console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`); - console.info(`Renderer channel: ${streamInfo.channels}`); - console.info(`Renderer format: ${streamInfo.sampleFormat}`); - console.info(`Renderer encoding type: ${streamInfo.encodingType}`); +audioCapturer.release((err) => { + if (err) { + console.error('capturer release failed'); + } else { + console.info('capturer released.'); + } }); + ``` -### getStreamInfo8+ -getStreamInfo(): Promise +### release8+ -Obtains the stream information of this **AudioRenderer** instance. This API uses a promise to return the result. +release(): Promise -**System capability**: SystemCapability.Multimedia.Audio.Renderer +Releases this **AudioCapturer** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Return value** -| Type | Description | -| :--------------------------------------------- | :--------------------------------------------- | -| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. | +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -audioRenderer.getStreamInfo().then((streamInfo) => { - console.info('Renderer GetStreamInfo:'); - console.info(`Renderer sampling rate: ${streamInfo.samplingRate}`); - console.info(`Renderer channel: ${streamInfo.channels}`); - console.info(`Renderer format: ${streamInfo.sampleFormat}`); - console.info(`Renderer encoding type: ${streamInfo.encodingType}`); +let stateFlag; +audioCapturer.release().then(() => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`); + console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`); }).catch((err) => { - console.error(`ERROR: ${err}`); + console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); }); ``` -### start8+ +### read8+ -start(callback: AsyncCallback): void +read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void -Starts the renderer. This API uses an asynchronous callback to return the result. +Reads the buffer. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | --------- | ----------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------------- | :-------------------------- | :-------- | :----------------------------------- | +| size | number | Yes | Number of bytes to read. | +| isBlockingRead | boolean | Yes | Whether to block the read operation. | +| callback | AsyncCallback | Yes | Callback used to return the buffer. | **Example** ```js -audioRenderer.start((err) => { - if (err) { - console.error('Renderer start failed.'); - } else { - console.info('Renderer start success.'); +let bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); + bufferSize = data; + }).catch((err) => { + console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`); + }); +audioCapturer.read(bufferSize, true, async(err, buffer) => { + if (!err) { + console.info('Success in reading the buffer data'); } }); ``` -### start8+ +### read8+ -start(): Promise +read(size: number, isBlockingRead: boolean): Promise -Starts the renderer. This API uses a promise to return the result. +Reads the buffer. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer + +**Parameters** + +| Name | Type | Mandatory | Description | +| :------------- | :------ | :-------- | :----------------------------------- | +| size | number | Yes | Number of bytes to read. | +| isBlockingRead | boolean | Yes | Whether to block the read operation. | **Return value** -| Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| Type | Description | +| :-------------------- | :----------------------------------------------------------- | +| Promise | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned. | **Example** ```js -audioRenderer.start().then(() => { - console.info('Renderer started'); +let bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); + bufferSize = data; + }).catch((err) => { + console.info(`AudioFrameworkRecLog: getBufferSize: ERROR ${err}`); + }); +console.info(`Buffer size: ${bufferSize}`); +audioCapturer.read(bufferSize, true).then((buffer) => { + console.info('buffer read successfully'); }).catch((err) => { - console.error(`ERROR: ${err}`); + console.info(`ERROR : ${err}`); }); ``` -### pause8+ +### getAudioTime8+ -pause(callback: AsyncCallback\): void +getAudioTime(callback: AsyncCallback): void -Pauses rendering. This API uses an asynchronous callback to return the result. +Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | --------- | ----------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.pause((err) => { - if (err) { - console.error('Renderer pause failed'); - } else { - console.info('Renderer paused.'); - } +audioCapturer.getAudioTime((err, timestamp) => { + console.info(`Current timestamp: ${timestamp}`); }); ``` -### pause8+ +### getAudioTime8+ -pause(): Promise\ +getAudioTime(): Promise -Pauses rendering. This API uses a promise to return the result. +Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Return value** -| Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| Type | Description | +| :--------------- | :------------------------------------ | +| Promise | Promise used to return the timestamp. | **Example** ```js -audioRenderer.pause().then(() => { - console.info('Renderer paused'); +audioCapturer.getAudioTime().then((audioTime) => { + console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`); }).catch((err) => { - console.error(`ERROR: ${err}`); + console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`); }); ``` -### drain8+ +### getBufferSize8+ -drain(callback: AsyncCallback\): void +getBufferSize(callback: AsyncCallback): void -Drains the playback buffer. This API uses an asynchronous callback to return the result. +Obtains a reasonable minimum buffer size in bytes for capturing. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | --------- | ----------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :--------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the buffer size. | **Example** ```js -audioRenderer.drain((err) => { - if (err) { - console.error('Renderer drain failed'); - } else { - console.info('Renderer drained.'); +audioCapturer.getBufferSize((err, bufferSize) => { + if (!err) { + console.info(`BufferSize : ${bufferSize}`); + audioCapturer.read(bufferSize, true).then((buffer) => { + console.info(`Buffer read is ${buffer}`); + }).catch((err) => { + console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`); + }); } }); ``` -### drain8+ +### getBufferSize8+ -drain(): Promise\ +getBufferSize(): Promise -Drains the playback buffer. This API uses a promise to return the result. +Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Return value** -| Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| Type | Description | +| :--------------- | :-------------------------------------- | +| Promise | Promise used to return the buffer size. | **Example** ```js -audioRenderer.drain().then(() => { - console.info('Renderer drained successfully'); +let bufferSize; +audioCapturer.getBufferSize().then((data) => { + console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`); + bufferSize = data; }).catch((err) => { - console.error(`ERROR: ${err}`); + console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`); }); ``` -### stop8+ +### on('markReach')8+ -stop(callback: AsyncCallback\): void +on(type: "markReach", frame: number, callback: Callback<number>): void -Stops rendering. This API uses an asynchronous callback to return the result. +Subscribes to mark reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is invoked. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | --------- | ----------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'markReach'**. | +| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | +| callback | Callback\ | Yes | Callback invoked when the event is triggered. | **Example** ```js -audioRenderer.stop((err) => { - if (err) { - console.error('Renderer stop failed'); - } else { - console.info('Renderer stopped.'); +audioCapturer.on('markReach', 1000, (position) => { + if (position == 1000) { + console.info('ON Triggered successfully'); } }); ``` -### stop8+ +### off('markReach')8+ -stop(): Promise\ +off(type: 'markReach'): void -Stops rendering. This API uses a promise to return the result. +Unsubscribes from mark reached events. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer -**Return value** +**Parameters** -| Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| Name | Type | Mandatory | Description | +| :--- | :----- | :-------- | :------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'markReach'**. | **Example** ```js -audioRenderer.stop().then(() => { - console.info('Renderer stopped successfully'); -}).catch((err) => { - console.error(`ERROR: ${err}`); -}); +audioCapturer.off('markReach'); ``` -### release8+ +### on('periodReach')8+ -release(callback: AsyncCallback\): void +on(type: "periodReach", frame: number, callback: Callback<number>): void -Releases the renderer. This API uses an asynchronous callback to return the result. +Subscribes to period reached events. When the number of frames captured reaches the value of the **frame** parameter, a callback is triggered and the specified value is returned. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | --------- | ----------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :---------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'periodReach'**. | +| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | +| callback | Callback\ | Yes | Callback invoked when the event is triggered. | **Example** ```js -audioRenderer.release((err) => { - if (err) { - console.error('Renderer release failed'); - } else { - console.info('Renderer released.'); +audioCapturer.on('periodReach', 1000, (position) => { + if (position == 1000) { + console.info('ON Triggered successfully'); } }); ``` -### release8+ +### off('periodReach')8+ -release(): Promise\ +off(type: 'periodReach'): void -Releases the renderer. This API uses a promise to return the result. +Unsubscribes from period reached events. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer -**Return value** +**Parameters** -| Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| Name | Type | Mandatory | Description | +| :--- | :----- | :-------- | :--------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'periodReach'**. | **Example** ```js -audioRenderer.release().then(() => { - console.info('Renderer released successfully'); -}).catch((err) => { - console.error(`ERROR: ${err}`); -}); +audioCapturer.off('periodReach') ``` -### write8+ +### on('stateChange')8+ -write(buffer: ArrayBuffer, callback: AsyncCallback\): void +on(type: 'stateChange', callback: Callback): void -Writes the buffer. This API uses an asynchronous callback to return the result. +Subscribes to state change events. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Capturer **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------- | --------- | ------------------------------------------------------------ | -| buffer | ArrayBuffer | Yes | Buffer to be written. | -| callback | AsyncCallback\ | Yes | Callback used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. | +| Name | Type | Mandatory | Description | +| :------- | :------------------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value **stateChange** means the state change event. | +| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. | **Example** ```js -var bufferSize; -audioRenderer.getBufferSize().then((data)=> { - console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); - bufferSize = data; - }).catch((err) => { - console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); - }); -console.info(`Buffer size: ${bufferSize}`); -var context = featureAbility.getContext(); -var path; -async function getCacheDir(){ - path = await context.getCacheDir(); -} -var filePath = path + '/StarWars10s-2C-48000-4SW.wav'; -let ss = fileio.createStreamSync(filePath, 'r'); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -audioRenderer.write(buf, (err, writtenbytes) => { - if (writtenbytes < 0) { - console.error('write failed.'); - } else { - console.info(`Actual written bytes: ${writtenbytes}`); +audioCapturer.on('stateChange', (state) => { + if (state == 1) { + console.info('audio capturer state is: STATE_PREPARED'); + } + if (state == 2) { + console.info('audio capturer state is: STATE_RUNNING'); } }); ``` -### write8+ - -write(buffer: ArrayBuffer): Promise\ +## ToneType9+ -Writes the buffer. This API uses a promise to return the result. +Enumerates the tone types of the player. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System API**: This is a system API. -**Return value** +**System capability**: SystemCapability.Multimedia.Audio.Tone -| Type | Description | -| ---------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the result. If the operation is successful, the number of bytes written is returned; otherwise, an error code is returned. | +| Name | Default Value | Description | +| :----------------------------------------------- | :------------ | :-------------------------------------------- | +| TONE_TYPE_DIAL_0 | 0 | DTMF tone of key 0. | +| TONE_TYPE_DIAL_1 | 1 | DTMF tone of key 1. | +| TONE_TYPE_DIAL_2 | 2 | DTMF tone of key 2. | +| TONE_TYPE_DIAL_3 | 3 | DTMF tone of key 3. | +| TONE_TYPE_DIAL_4 | 4 | DTMF tone of key 4. | +| TONE_TYPE_DIAL_5 | 5 | DTMF tone of key 5. | +| TONE_TYPE_DIAL_6 | 6 | DTMF tone of key 6. | +| TONE_TYPE_DIAL_7 | 7 | DTMF tone of key 7. | +| TONE_TYPE_DIAL_8 | 8 | DTMF tone of key 8. | +| TONE_TYPE_DIAL_9 | 9 | DTMF tone of key 9. | +| TONE_TYPE_DIAL_S | 10 | DTMF tone of the star key (*). | +| TONE_TYPE_DIAL_P | 11 | DTMF tone of the pound key (#). | +| TONE_TYPE_DIAL_A | 12 | DTMF tone of key A. | +| TONE_TYPE_DIAL_B | 13 | DTMF tone of key B. | +| TONE_TYPE_DIAL_C | 14 | DTMF tone of key C. | +| TONE_TYPE_DIAL_D | 15 | DTMF tone of key D. | +| TONE_TYPE_COMMON_SUPERVISORY_DIAL | 100 | Supervisory tone - dial tone. | +| TONE_TYPE_COMMON_SUPERVISORY_BUSY | 101 | Supervisory tone - busy. | +| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION | 102 | Supervisory tone - congestion. | +| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK | 103 | Supervisory tone - radio path acknowledgment. | +| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104 | Supervisory tone - radio path not available. | +| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING | 106 | Supervisory tone - call waiting tone. | +| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE | 107 | Supervisory tone - ringing tone. | +| TONE_TYPE_COMMON_PROPRIETARY_BEEP | 200 | Proprietary tone - beep tone. | +| TONE_TYPE_COMMON_PROPRIETARY_ACK | 201 | Proprietary tone - ACK. | +| TONE_TYPE_COMMON_PROPRIETARY_PROMPT | 203 | Proprietary tone - PROMPT. | +| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP | 204 | Proprietary tone - double beep tone. | -**Example** +## TonePlayer9+ -```js -var bufferSize; -audioRenderer.getBufferSize().then((data) => { - console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); - bufferSize = data; - }).catch((err) => { - console.info(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); - }); -console.info(`BufferSize: ${bufferSize}`); -var context = featureAbility.getContext(); -var path; -async function getCacheDir(){ - path = await context.getCacheDir(); -} -var filePath = path + '/StarWars10s-2C-48000-4SW.wav'; -let ss = fileio.createStreamSync(filePath, 'r'); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); -audioRenderer.write(buf).then((writtenbytes) => { - if (writtenbytes < 0) { - console.error('write failed.'); - } else { - console.info(`Actual written bytes: ${writtenbytes}`); - } -}).catch((err) => { - console.error(`ERROR: ${err}`); -}); +Provides APIs for playing and managing DTMF tones, such as dial tones, ringback tones, supervisory tones, and proprietary tones. -``` +**System API**: This is a system API. -### getAudioTime8+ +### load9+ -getAudioTime(callback: AsyncCallback\): void +load(type: ToneType, callback: AsyncCallback<void>): void -Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result. +Loads the DTMF tone configuration. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------- | --------- | -------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the timestamp. | +| Name | Type | Mandatory | Description | +| :------- | :--------------------- | :-------- | :---------------------------------- | +| type | [ToneType](#tonetype9) | Yes | Tone type. | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.getAudioTime((err, timestamp) => { - console.info(`Current timestamp: ${timestamp}`); +tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => { + if (err) { + console.error(`callback call load failed error: ${err.message}`); + return; + } else { + console.info('callback call load success'); + } }); ``` -### getAudioTime8+ +### load9+ -getAudioTime(): Promise\ +load(type: ToneType): Promise<void> -Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result. +Loads the DTMF tone configuration. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone + +**Parameters** + +| Name | Type | Mandatory | Description | +| :--- | :--------------------- | :-------- | ----------- | +| type | [ToneType](#tonetype9) | Yes | Tone type. | **Return value** -| Type | Description | -| ---------------- | ------------------------------------- | -| Promise\ | Promise used to return the timestamp. | +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -audioRenderer.getAudioTime().then((timestamp) => { - console.info(`Current timestamp: ${timestamp}`); -}).catch((err) => { - console.error(`ERROR: ${err}`); +tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => { + console.info('promise call load '); +}).catch(() => { + console.error('promise call load fail'); }); ``` -### getBufferSize8+ +### start9+ -getBufferSize(callback: AsyncCallback\): void +start(callback: AsyncCallback<void>): void -Obtains a reasonable minimum buffer size in bytes for rendering. This API uses an asynchronous callback to return the result. +Starts DTMF tone playing. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------- | --------- | ---------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the buffer size. | +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { +tonePlayer.start((err) => { if (err) { - console.error('getBufferSize error'); + console.error(`callback call start failed error: ${err.message}`); + return; + } else { + console.info('callback call start success'); } }); ``` -### getBufferSize8+ +### start9+ -getBufferSize(): Promise\ +start(): Promise<void> -Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a promise to return the result. +Starts DTMF tone playing. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Return value** -| Type | Description | -| ---------------- | --------------------------------------- | -| Promise\ | Promise used to return the buffer size. | +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -var bufferSize; -audioRenderer.getBufferSize().then((data) => { - console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`); - bufferSize = data; -}).catch((err) => { - console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`); +tonePlayer.start().then(() => { + console.info('promise call start'); +}).catch(() => { + console.error('promise call start fail'); }); ``` -### setRenderRate8+ +### stop9+ -setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\): void +stop(callback: AsyncCallback<void>): void -Sets the render rate. This API uses an asynchronous callback to return the result. +Stops the tone that is being played. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | --------- | ----------------------------------- | -| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => { +tonePlayer.stop((err) => { if (err) { - console.error('Failed to set params'); + console.error(`callback call stop error: ${err.message}`); + return; } else { - console.info('Callback invoked to indicate a successful render rate setting.'); + console.error('callback call stop success '); } }); ``` -### setRenderRate8+ - -setRenderRate(rate: AudioRendererRate): Promise\ - -Sets the render rate. This API uses a promise to return the result. +### stop9+ -**System capability**: SystemCapability.Multimedia.Audio.Renderer +stop(): Promise<void> -**Parameters** +Stops the tone that is being played. This API uses a promise to return the result. -| Name | Type | Mandatory | Description | -| ---- | ---------------------------------------- | --------- | ------------------ | -| rate | [AudioRendererRate](#audiorendererrate8) | Yes | Audio render rate. | +**System capability**: SystemCapability.Multimedia.Audio.Tone **Return value** | Type | Description | -| -------------- | ---------------------------------- | -| Promise\ | Promise used to return the result. | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { - console.info('setRenderRate SUCCESS'); -}).catch((err) => { - console.error(`ERROR: ${err}`); +tonePlayer.stop().then(() => { + console.info('promise call stop finish'); +}).catch(() => { + console.error('promise call stop fail'); }); ``` -### getRenderRate8+ +### release9+ -getRenderRate(callback: AsyncCallback\): void +release(callback: AsyncCallback<void>): void -Obtains the current render rate. This API uses an asynchronous callback to return the result. +Releases the resources associated with the **TonePlayer** instance. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------------------------- | --------- | ---------------------------------------------- | -| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | Yes | Callback used to return the audio render rate. | +| Name | Type | Mandatory | Description | +| :------- | :------------------- | :-------- | :---------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.getRenderRate((err, renderrate) => { - console.info(`getRenderRate: ${renderrate}`); +tonePlayer.release((err) => { + if (err) { + console.error(`callback call release failed error: ${err.message}`); + return; + } else { + console.info('callback call release success '); + } }); ``` -### getRenderRate8+ +### release9+ -getRenderRate(): Promise\ +release(): Promise<void> -Obtains the current render rate. This API uses a promise to return the result. +Releases the resources associated with the **TonePlayer** instance. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Tone **Return value** -| Type | Description | -| ------------------------------------------------- | --------------------------------------------- | -| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise used to return the audio render rate. | +| Type | Description | +| :------------- | :--------------------------------- | +| Promise | Promise used to return the result. | **Example** ```js -audioRenderer.getRenderRate().then((renderRate) => { - console.info(`getRenderRate: ${renderRate}`); -}).catch((err) => { - console.error(`ERROR: ${err}`); +tonePlayer.release().then(() => { + console.info('promise call release'); +}).catch(() => { + console.error('promise call release fail'); }); ``` -### setInterruptMode9+ - -setInterruptMode(mode: InterruptMode): Promise<void> +## ActiveDeviceType(deprecated) -Sets the audio interruption mode for the application. This API uses a promise to return the result. +Enumerates the active device types. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +> **NOTE** +> +> This API is deprecated since API version 9. You are advised to use [CommunicationDeviceType](#communicationdevicetype9) instead. -**Parameters** +**System capability**: SystemCapability.Multimedia.Audio.Device -| Name | Type | Mandatory | Description | -| ---- | -------------------------------- | --------- | ------------------------ | -| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. | +| Name | Default Value | Description | +| ------------- | ------------- | ------------------------------------------------------------ | +| SPEAKER | 2 | Speaker. | +| BLUETOOTH_SCO | 7 | Bluetooth device using Synchronous Connection Oriented (SCO) links. | -**Return value** +## InterruptActionType(deprecated) -| Type | Description | -| ------------------- | ------------------------------------------------------------ | -| Promise<void> | Promise used to return the result. If the operation is successful, **undefined** is returned. Otherwise, **error** is returned. | +Enumerates the returned event types for audio interruption events. -**Example** +> **NOTE** +> This API is supported since API version 7 and deprecated since API version 9. -```js -let mode = 0; -audioRenderer.setInterruptMode(mode).then(data=>{ - console.info('setInterruptMode Success!'); -}).catch((err) => { - console.error(`setInterruptMode Fail: ${err}`); -}); +**System capability**: SystemCapability.Multimedia.Audio.Renderer -``` +| Name | Default Value | Description | +| -------------- | ------------- | ------------------------- | +| TYPE_ACTIVATED | 0 | Focus gain event. | +| TYPE_INTERRUPT | 1 | Audio interruption event. | -### setInterruptMode9+ +## AudioInterrupt(deprecated) -setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. -Sets the audio interruption mode for the application. This API uses a callback to return the result. +Describes input parameters of audio interruption events. **System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | -------------------------------- | --------- | ----------------------------------- | -| mode | [InterruptMode](#interruptmode9) | Yes | Audio interruption mode. | -| callback | AsyncCallback\ | Yes | Callback used to return the result. | - -**Example** - -```js -let mode = 1; -audioRenderer.setInterruptMode(mode, (err, data)=>{ - if(err){ - console.error(`setInterruptMode Fail: ${err}`); - } - console.info('setInterruptMode Success!'); -}); - -``` +| Name | Type | Mandatory | Description | +| --------------- | --------------------------- | --------- | ------------------------------------------------------------ | +| streamUsage | [StreamUsage](#streamusage) | Yes | Audio stream usage. | +| contentType | [ContentType](#contenttype) | Yes | Audio content type. | +| pauseWhenDucked | boolean | Yes | Whether audio playback can be paused during audio interruption. The value **true** means that audio playback can be paused during audio interruption, and **false** means the opposite. | -### on('interrupt')9+ +## InterruptAction(deprecated) -on(type: 'interrupt', callback: Callback\): void +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. -Subscribes to audio interruption events. This API uses a callback to get interrupt events. +Describes the callback invoked for audio interruption or focus gain events. **System capability**: SystemCapability.Multimedia.Audio.Renderer -**Parameters** - -| Name | Type | Mandatory | Description | -| -------- | -------------------------------------------- | --------- | ------------------------------------------------------------ | -| type | string | Yes | Event type. The value **interrupt** means the audio interruption event, which is triggered when audio playback is interrupted. | -| callback | Callback<[InterruptEvent](#interruptevent9)> | Yes | Callback used to return the audio interruption event. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------------- | --------- | ------------------------------------------------------------ | +| actionType | [InterruptActionType](#interruptactiontype) | Yes | Returned event type. The value **TYPE_ACTIVATED** means the focus gain event, and **TYPE_INTERRUPT** means the audio interruption event. | +| type | [InterruptType](#interrupttype) | No | Type of the audio interruption event. | +| hint | [InterruptHint](#interrupthint) | No | Hint provided along with the audio interruption event. | +| activated | boolean | No | Whether the focus is gained or released. The value **true** means that the focus is gained or released, and **false** means that the focus fails to be gained or released. | -**Example** +### setVolume(deprecated) -```js -var isPlay; -var started; -audioRenderer.on('interrupt', async(interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.info('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.info('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.info('Resume force paused renderer or ignore'); - await audioRenderer.start().then(async function () { - console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); - started = true; - }).catch((err) => { - console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`); - started = false; - }); - if (started) { - isPlay = true; - console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`); - } else { - console.error('AudioInterruptMusic Renderer start failed'); - } - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.info('Choose to pause or ignore'); - if (isPlay == true) { - isPlay == false; - console.info('AudioInterruptMusic: Media PAUSE : TRUE'); - } else { - isPlay = true; - console.info('AudioInterruptMusic: Media PLAY : TRUE'); - } - break; - } - } -}); +setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void -``` +Sets the volume for a stream. This API uses an asynchronous callback to return the result. -### on('markReach')8+ +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. -on(type: "markReach", frame: number, callback: Callback<number>): void +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY -Subscribes to mark reached events. When the number of frames rendered reaches the value of the **frame** parameter, the callback is invoked. +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. | -| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | -| callback | Callback | Yes | Callback invoked when the event is triggered. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioRenderer.on('markReach', 1000, (position) => { - if (position == 1000) { - console.info('ON Triggered successfully'); +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { + if (err) { + console.error(`Failed to set the volume. ${err}`); + return; } + console.info('Callback invoked to indicate a successful volume setting.'); }); ``` +### setVolume(deprecated) -### off('markReach') 8+ +setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> -off(type: 'markReach'): void +Sets the volume for a stream. This API uses a promise to return the result. -Unsubscribes from mark reached events. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setVolume](#setvolume9) in **AudioVolumeGroupManager**. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| volume | number | Yes | Volume to set. The value range can be obtained by calling **getMinVolume** and **getMaxVolume**. | -**Parameters** +**Return value** -| Name | Type | Mandatory | Description | -| :--- | :----- | :-------- | :----------------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **markReach**. | +| Type | Description | +| ------------------- | ---------------------------------- | +| Promise<void> | Promise used to return the result. | **Example** ```js -audioRenderer.off('markReach'); +audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { + console.info('Promise returned to indicate a successful volume setting.'); +}); ``` -### on('periodReach') 8+ +### getVolume(deprecated) -on(type: "periodReach", frame: number, callback: Callback<number>): void +getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -Subscribes to period reached events. When the period of frame rendering reaches the value of the **frame** parameter, the callback is invoked. +Obtains the volume of a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getVolume](#getvolume9) in **AudioVolumeGroupManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter. | -| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | -| callback | Callback | Yes | Callback invoked when the event is triggered. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ----------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the volume. | **Example** ```js -audioRenderer.on('periodReach', 1000, (position) => { - if (position == 1000) { - console.info('ON Triggered successfully'); +audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume. ${err}`); + return; } + console.info('Callback invoked to indicate that the volume is obtained.'); }); ``` -### off('periodReach') 8+ +### getVolume(deprecated) -off(type: 'periodReach'): void +getVolume(volumeType: AudioVolumeType): Promise<number> -Unsubscribes from period reached events. +Obtains the volume of a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getVolume](#getvolume9) in **AudioVolumeGroupManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :--- | :----- | :-------- | :------------------------------------------------- | -| type | string | Yes | Event type. The value is fixed at **periodReach**. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------- | +| Promise<number> | Promise used to return the volume. | **Example** ```js -audioRenderer.off('periodReach') +audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the volume is obtained ${value} .`); +}); ``` -### on('stateChange')8+ +### getMinVolume(deprecated) -on(type: 'stateChange', callback: Callback): void +getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -Subscribes to state change events. +Obtains the minimum volume allowed for a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Renderer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMinVolume](#getminvolume9) in **AudioVolumeGroupManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **stateChange** means the state change event. | -| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the minimum volume. | **Example** ```js -audioRenderer.on('stateChange', (state) => { - if (state == 1) { - console.info('audio renderer state is: STATE_PREPARED'); - } - if (state == 2) { - console.info('audio renderer state is: STATE_RUNNING'); +audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { + if (err) { + console.error(`Failed to obtain the minimum volume. ${err}`); + return; } + console.info(`Callback invoked to indicate that the minimum volume is obtained. ${value}`); }); ``` -## AudioCapturer8+ +### getMinVolume(deprecated) -Provides APIs for audio capture. Before calling any API in **AudioCapturer**, you must use [createAudioCapturer](#audiocreateaudiocapturer8) to create an **AudioCapturer** instance. +getMinVolume(volumeType: AudioVolumeType): Promise<number> -### Attributes +Obtains the minimum volume allowed for a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMinVolume](#getminvolume9) in **AudioVolumeGroupManager**. -| Name | Type | Readable | Writable | Description | -| :----------------- | :------------------------- | :------- | :------- | :-------------------- | -| state8+ | [AudioState](#audiostate8) | Yes | No | Audio capturer state. | +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------------------ | +| Promise<number> | Promise used to return the minimum volume. | **Example** ```js -var state = audioCapturer.state; +audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promised returned to indicate that the minimum volume is obtained. ${value}`); +}); ``` -### getCapturerInfo8+ +### getMaxVolume(deprecated) -getCapturerInfo(callback: AsyncCallback): void +getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -Obtains the capturer information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. +Obtains the maximum volume allowed for a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMaxVolume](#getmaxvolume9) in **AudioVolumeGroupManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :-------------------------------- | :-------- | :------------------------------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the capturer information. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<number> | Yes | Callback used to return the maximum volume. | **Example** ```js -audioCapturer.getCapturerInfo((err, capturerInfo) => { +audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error('Failed to get capture info'); - } else { - console.info('Capturer getCapturerInfo:'); - console.info(`Capturer source: ${capturerInfo.source}`); - console.info(`Capturer flags: ${capturerInfo.capturerFlags}`); + console.error(`Failed to obtain the maximum volume. ${err}`); + return; } + console.info(`Callback invoked to indicate that the maximum volume is obtained. ${value}`); }); ``` +### getMaxVolume(deprecated) -### getCapturerInfo8+ +getMaxVolume(volumeType: AudioVolumeType): Promise<number> -getCapturerInfo(): Promise +Obtains the maximum volume allowed for a stream. This API uses a promise to return the result. -Obtains the capturer information of this **AudioCapturer** instance. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getMaxVolume](#getmaxvolume9) in **AudioVolumeGroupManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | **Return value** -| Type | Description | -| :------------------------------------------------ | :----------------------------------------------- | -| Promise<[AudioCapturerInfo](#audiocapturerinfo)\> | Promise used to return the capturer information. | +| Type | Description | +| --------------------- | ------------------------------------------ | +| Promise<number> | Promise used to return the maximum volume. | **Example** ```js -audioCapturer.getCapturerInfo().then((audioParamsGet) => { - if (audioParamsGet != undefined) { - console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); - console.info(`AudioFrameworkRecLog: Capturer SourceType: ${audioParamsGet.source}`); - console.info(`AudioFrameworkRecLog: Capturer capturerFlags: ${audioParamsGet.capturerFlags}`); - } else { - console.info(`AudioFrameworkRecLog: audioParamsGet is : ${audioParamsGet}`); - console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect'); - } -}).catch((err) => { - console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`); +audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { + console.info('Promised returned to indicate that the maximum volume is obtained.'); }); ``` -### getStreamInfo8+ +### mute(deprecated) -getStreamInfo(callback: AsyncCallback): void +mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void -Obtains the stream information of this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. +Mutes or unmutes a stream. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------------------------------------- | :-------- | :---------------------------------------------- | -| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | Yes | Callback used to return the stream information. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioCapturer.getStreamInfo((err, streamInfo) => { +audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { if (err) { - console.error('Failed to get stream info'); - } else { - console.info('Capturer GetStreamInfo:'); - console.info(`Capturer sampling rate: ${streamInfo.samplingRate}`); - console.info(`Capturer channel: ${streamInfo.channels}`); - console.info(`Capturer format: ${streamInfo.sampleFormat}`); - console.info(`Capturer encoding type: ${streamInfo.encodingType}`); + console.error(`Failed to mute the stream. ${err}`); + return; } + console.info('Callback invoked to indicate that the stream is muted.'); }); ``` -### getStreamInfo8+ +### mute(deprecated) -getStreamInfo(): Promise +mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> -Obtains the stream information of this **AudioCapturer** instance. This API uses a promise to return the result. +Mutes or unmutes a stream. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [mute](#mute9) in **AudioVolumeGroupManager**. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer when **volumeType** is set to **AudioVolumeType.RINGTONE**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the stream, and **false** means the opposite. | **Return value** -| Type | Description | -| :--------------------------------------------- | :--------------------------------------------- | -| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise used to return the stream information. | +| Type | Description | +| ------------------- | ---------------------------------- | +| Promise<void> | Promise used to return the result. | **Example** + ```js -audioCapturer.getStreamInfo().then((audioParamsGet) => { - console.info('getStreamInfo:'); - console.info(`sampleFormat: ${audioParamsGet.sampleFormat}`); - console.info(`samplingRate: ${audioParamsGet.samplingRate}`); - console.info(`channels: ${audioParamsGet.channels}`); - console.info(`encodingType: ${audioParamsGet.encodingType}`); -}).catch((err) => { - console.error(`getStreamInfo :ERROR: ${err}`); +audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { + console.info('Promise returned to indicate that the stream is muted.'); }); ``` -### start8+ +### isMute(deprecated) -start(callback: AsyncCallback): void +isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -Starts capturing. This API uses an asynchronous callback to return the result. +Checks whether a stream is muted. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMute](#ismute9) in **AudioVolumeGroupManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite. | **Example** ```js -audioCapturer.start((err) => { +audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error('Capturer start failed.'); - } else { - console.info('Capturer start success.'); + console.error(`Failed to obtain the mute status. ${err}`); + return; } + console.info(`Callback invoked to indicate that the mute status of the stream is obtained. ${value}`); }); ``` +### isMute(deprecated) -### start8+ +isMute(volumeType: AudioVolumeType): Promise<boolean> -start(): Promise +Checks whether a stream is muted. This API uses a promise to return the result. -Starts capturing. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMute](#ismute9) in **AudioVolumeGroupManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | **Return value** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return the mute status of the stream. The value **true** means that the stream is muted, and **false** means the opposite. | **Example** ```js -audioCapturer.start().then(() => { - console.info('AudioFrameworkRecLog: ---------START---------'); - console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); - console.info(`AudioFrameworkRecLog: AudioCapturer: STATE: ${audioCapturer.state}`); - console.info('AudioFrameworkRecLog: Capturer started: SUCCESS'); - if ((audioCapturer.state == audio.AudioState.STATE_RUNNING)) { - console.info('AudioFrameworkRecLog: AudioCapturer is in Running State'); - } -}).catch((err) => { - console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`); +audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); }); ``` -### stop8+ +### isActive(deprecated) -stop(callback: AsyncCallback): void +isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -Stops capturing. This API uses an asynchronous callback to return the result. +Checks whether a stream is active. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isActive](#isactive9) in **AudioStreamManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------------------------------------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite. | **Example** ```js -audioCapturer.stop((err) => { +audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { - console.error('Capturer stop failed'); - } else { - console.info('Capturer stopped.'); + console.error(`Failed to obtain the active status of the stream. ${err}`); + return; } + console.info(`Callback invoked to indicate that the active status of the stream is obtained ${value}.`); }); ``` +### isActive(deprecated) -### stop8+ +isActive(volumeType: AudioVolumeType): Promise<boolean> -stop(): Promise +Checks whether a stream is active. This API uses a promise to return the result. -Stops capturing. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isActive](#isactive9) in **AudioStreamManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Volume + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ----------------------------------- | --------- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | Yes | Audio stream type. | **Return value** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return the active status of the stream. The value **true** means that the stream is active, and **false** means the opposite. | **Example** ```js -audioCapturer.stop().then(() => { - console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); - console.info('AudioFrameworkRecLog: Capturer stopped: SUCCESS'); - if ((audioCapturer.state == audio.AudioState.STATE_STOPPED)){ - console.info('AudioFrameworkRecLog: State is Stopped:'); - } -}).catch((err) => { - console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); +audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => { + console.info(`Promise returned to indicate that the active status of the stream is obtained ${value}.`); }); ``` -### release8+ +### setRingerMode(deprecated) -release(callback: AsyncCallback): void +setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void -Releases this **AudioCapturer** instance. This API uses an asynchronous callback to return the result. +Sets the ringer mode. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. + +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer. + +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------------- | --------- | ----------------------------------- | +| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioCapturer.release((err) => { +audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { if (err) { - console.error('capturer release failed'); - } else { - console.info('capturer released.'); + console.error(`Failed to set the ringer mode.​ ${err}`); + return; } + console.info('Callback invoked to indicate a successful setting of the ringer mode.'); }); ``` +### setRingerMode(deprecated) -### release8+ +setRingerMode(mode: AudioRingMode): Promise<void> -release(): Promise +Sets the ringer mode. This API uses a promise to return the result. -Releases this **AudioCapturer** instance. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setRingerMode](#setringermode9) in **AudioVolumeGroupManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**Required permissions**: ohos.permission.ACCESS_NOTIFICATION_POLICY + +This permission is required only for muting or unmuting the ringer. + +**System capability**: SystemCapability.Multimedia.Audio.Communication + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---- | ------------------------------- | --------- | ------------ | +| mode | [AudioRingMode](#audioringmode) | Yes | Ringer mode. | **Return value** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| Type | Description | +| ------------------- | ---------------------------------- | +| Promise<void> | Promise used to return the result. | **Example** ```js -var stateFlag; -audioCapturer.release().then(() => { - console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); - console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); - console.info(`AudioFrameworkRecLog: AudioCapturer : STATE : ${audioCapturer.state}`); - console.info(`AudioFrameworkRecLog: stateFlag : ${stateFlag}`); -}).catch((err) => { - console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`); +audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => { + console.info('Promise returned to indicate a successful setting of the ringer mode.'); }); ``` +### getRingerMode(deprecated) -### read8+ +getRingerMode(callback: AsyncCallback<AudioRingMode>): void -read(size: number, isBlockingRead: boolean, callback: AsyncCallback): void +Obtains the ringer mode. This API uses an asynchronous callback to return the result. -Reads the buffer. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getRingerMode](#getringermode9) in **AudioVolumeGroupManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Communication **Parameters** -| Name | Type | Mandatory | Description | -| :------------- | :-------------------------- | :-------- | :----------------------------------- | -| size | number | Yes | Number of bytes to read. | -| isBlockingRead | boolean | Yes | Whether to block the read operation. | -| callback | AsyncCallback | Yes | Callback used to return the buffer. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------------------- | --------- | ---------------------------------------- | +| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the ringer mode. | **Example** ```js -var bufferSize; -audioCapturer.getBufferSize().then((data) => { - console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); - bufferSize = data; - }).catch((err) => { - console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`); - }); -audioCapturer.read(bufferSize, true, async(err, buffer) => { - if (!err) { - console.info('Success in reading the buffer data'); +audioManager.getRingerMode((err, value) => { + if (err) { + console.error(`Failed to obtain the ringer mode.​ ${err}`); + return; } + console.info(`Callback invoked to indicate that the ringer mode is obtained ${value}.`); }); ``` +### getRingerMode(deprecated) -### read8+ - -read(size: number, isBlockingRead: boolean): Promise - -Reads the buffer. This API uses a promise to return the result. +getRingerMode(): Promise<AudioRingMode> -**System capability**: SystemCapability.Multimedia.Audio.Capturer +Obtains the ringer mode. This API uses a promise to return the result. -**Parameters** +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getRingerMode](#getringermode9) in **AudioVolumeGroupManager**. -| Name | Type | Mandatory | Description | -| :------------- | :------ | :-------- | :----------------------------------- | -| size | number | Yes | Number of bytes to read. | -| isBlockingRead | boolean | Yes | Whether to block the read operation. | +**System capability**: SystemCapability.Multimedia.Audio.Communication **Return value** -| Type | Description | -| :-------------------- | :----------------------------------------------------------- | -| Promise | Promise used to return the result. If the operation is successful, the buffer data read is returned; otherwise, an error code is returned. | +| Type | Description | +| ---------------------------------------------- | --------------------------------------- | +| Promise<[AudioRingMode](#audioringmode)> | Promise used to return the ringer mode. | **Example** ```js -var bufferSize; -audioCapturer.getBufferSize().then((data) => { - console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); - bufferSize = data; - }).catch((err) => { - console.info(`AudioFrameworkRecLog: getBufferSize: ERROR ${err}`); - }); -console.info(`Buffer size: ${bufferSize}`); -audioCapturer.read(bufferSize, true).then((buffer) => { - console.info('buffer read successfully'); -}).catch((err) => { - console.info(`ERROR : ${err}`); +audioManager.getRingerMode().then((value) => { + console.info(`Promise returned to indicate that the ringer mode is obtained ${value}.`); }); ``` +### getDevices(deprecated) -### getAudioTime8+ +getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void -getAudioTime(callback: AsyncCallback): void +Obtains the audio devices with a specific flag. This API uses an asynchronous callback to return the result. -Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDevices](#getdevices9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------------------------------ | --------- | ---------------------------------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Yes | Callback used to return the device list. | **Example** ```js -audioCapturer.getAudioTime((err, timestamp) => { - console.info(`Current timestamp: ${timestamp}`); +audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { + if (err) { + console.error(`Failed to obtain the device list. ${err}`); + return; + } + console.info('Callback invoked to indicate that the device list is obtained.'); }); ``` +### getDevices(deprecated) -### getAudioTime8+ +getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> -getAudioTime(): Promise +Obtains the audio devices with a specific flag. This API uses a promise to return the result. -Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970). This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getDevices](#getdevices9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ------------------------- | --------- | ------------------ | +| deviceFlag | [DeviceFlag](#deviceflag) | Yes | Audio device flag. | **Return value** -| Type | Description | -| :--------------- | :------------------------------------ | -| Promise | Promise used to return the timestamp. | +| Type | Description | +| ------------------------------------------------------------ | --------------------------------------- | +| Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise used to return the device list. | **Example** ```js -audioCapturer.getAudioTime().then((audioTime) => { - console.info(`AudioFrameworkRecLog: AudioCapturer getAudioTime : Success ${audioTime}`); -}).catch((err) => { - console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`); +audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => { + console.info('Promise returned to indicate that the device list is obtained.'); }); ``` +### setDeviceActive(deprecated) -### getBufferSize8+ +setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback<void>): void -getBufferSize(callback: AsyncCallback): void +Sets a device to the active state. This API uses an asynchronous callback to return the result. -Obtains a reasonable minimum buffer size in bytes for capturing. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setCommunicationDevice](#setcommunicationdevice9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------------- | :-------- | :--------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the buffer size. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------- | --------- | ------------------------------------------------------------ | +| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | +| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioCapturer.getBufferSize((err, bufferSize) => { - if (!err) { - console.info(`BufferSize : ${bufferSize}`); - audioCapturer.read(bufferSize, true).then((buffer) => { - console.info(`Buffer read is ${buffer}`); - }).catch((err) => { - console.error(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`); - }); +audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { + if (err) { + console.error(`Failed to set the active status of the device. ${err}`); + return; } + console.info('Callback invoked to indicate that the device is set to the active status.'); }); ``` +### setDeviceActive(deprecated) -### getBufferSize8+ +setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise<void> -getBufferSize(): Promise +Sets a device to the active state. This API uses a promise to return the result. -Obtains a reasonable minimum buffer size in bytes for capturing. This API uses a promise to return the result. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setCommunicationDevice](#setcommunicationdevice9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device + +**Parameters** + +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------- | --------- | ------------------------------------------------------------ | +| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | +| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. | **Return value** -| Type | Description | -| :--------------- | :-------------------------------------- | -| Promise | Promise used to return the buffer size. | +| Type | Description | +| ------------------- | ---------------------------------- | +| Promise<void> | Promise used to return the result. | **Example** + ```js -var bufferSize; -audioCapturer.getBufferSize().then((data) => { - console.info(`AudioFrameworkRecLog: getBufferSize :SUCCESS ${data}`); - bufferSize = data; -}).catch((err) => { - console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`); +audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { + console.info('Promise returned to indicate that the device is set to the active status.'); }); ``` +### isDeviceActive(deprecated) -### on('markReach')8+ +isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback<boolean>): void -on(type: "markReach", frame: number, callback: Callback<number>): void +Checks whether a device is active. This API uses an asynchronous callback to return the result. -Subscribes to mark reached events. When the number of frames captured reaches the value of the **frame** parameter, the callback is invoked. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isCommunicationDeviceActive](#iscommunicationdeviceactive9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. | -| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | -| callback | Callback | Yes | Callback invoked when the event is triggered. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------- | --------- | ------------------------------------------------------- | +| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device. | **Example** ```js -audioCapturer.on('markReach', 1000, (position) => { - if (position == 1000) { - console.info('ON Triggered successfully'); +audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { + if (err) { + console.error(`Failed to obtain the active status of the device. ${err}`); + return; } + console.info('Callback invoked to indicate that the active status of the device is obtained.'); }); ``` -### off('markReach')8+ - -off(type: 'markReach'): void - -Unsubscribes from mark reached events. - -**System capability**: SystemCapability.Multimedia.Audio.Capturer - -**Parameters** - -| Name | Type | Mandatory | Description | -| :--- | :----- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **markReach** means the mark reached event, which is triggered when the number of frames captured reaches the value of the **frame** parameter. | - -**Example** - -```js -audioCapturer.off('markReach'); - -``` +### isDeviceActive(deprecated) -### on('periodReach')8+ +isDeviceActive(deviceType: ActiveDeviceType): Promise<boolean> -on(type: "periodReach", frame: number, callback: Callback<number>): void +Checks whether a device is active. This API uses a promise to return the result. -Subscribes to mark reached events. When the period of frame capturing reaches the value of the **frame** parameter, the callback is invoked. +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isCommunicationDeviceActive](#iscommunicationdeviceactive9) in **AudioRoutingManager**. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :--------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame rendering reaches the value of the **frame** parameter. | -| frame | number | Yes | Number of frames to trigger the event. The value must be greater than **0**. | -| callback | Callback | Yes | Callback invoked when the event is triggered. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------------------- | --------- | ------------------ | +| deviceType | [ActiveDeviceType](#activedevicetype) | Yes | Audio device type. | + +**Return value** + +| Type | Description | +| ---------------------- | ------------------------------------------------------ | +| Promise<boolean> | Promise used to return the active state of the device. | **Example** ```js -audioCapturer.on('periodReach', 1000, (position) => { - if (position == 1000) { - console.info('ON Triggered successfully'); - } +audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => { + console.info(`Promise returned to indicate that the active status of the device is obtained ${value}.`); }); ``` -### off('periodReach')8+ +### setMicrophoneMute(deprecated) -off(type: 'periodReach'): void +setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void -Unsubscribes from period reached events. +Mutes or unmutes the microphone. This API uses an asynchronous callback to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setMicrophoneMute](#setmicrophonemute9) in **AudioVolumeGroupManager**. + +**Required permissions**: ohos.permission.MICROPHONE + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :--- | :----- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **periodReach** means the period reached event, which is triggered when the period of frame capturing reaches the value of the **frame** parameter. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | --------- | ------------------------------------------------------------ | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js -audioCapturer.off('periodReach') +audioManager.setMicrophoneMute(true, (err) => { + if (err) { + console.error(`Failed to mute the microphone. ${err}`); + return; + } + console.info('Callback invoked to indicate that the microphone is muted.'); +}); ``` -### on('stateChange')8+ +### setMicrophoneMute(deprecated) -on(type: 'stateChange', callback: Callback): void +setMicrophoneMute(mute: boolean): Promise<void> -Subscribes to state change events. +Mutes or unmutes the microphone. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Capturer +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setMicrophoneMute](#setmicrophonemute9) in **AudioVolumeGroupManager**. + +**Required permissions**: ohos.permission.MICROPHONE + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------------- | :-------- | :----------------------------------------------------------- | -| type | string | Yes | Event type. The value **stateChange** means the state change event. | -| callback | [AudioState](#audiostate8) | Yes | Callback used to return the state change. | +| Name | Type | Mandatory | Description | +| ---- | ------- | --------- | ------------------------------------------------------------ | +| mute | boolean | Yes | Mute status to set. The value **true** means to mute the microphone, and **false** means the opposite. | + +**Return value** + +| Type | Description | +| ------------------- | ---------------------------------- | +| Promise<void> | Promise used to return the result. | **Example** ```js -audioCapturer.on('stateChange', (state) => { - if (state == 1) { - console.info('audio capturer state is: STATE_PREPARED'); - } - if (state == 2) { - console.info('audio capturer state is: STATE_RUNNING'); - } +audioManager.setMicrophoneMute(true).then(() => { + console.info('Promise returned to indicate that the microphone is muted.'); }); ``` -## ToneType 9+ - -Enumerates the tone types of the player. - -**System capability**: SystemCapability.Multimedia.Audio.Tone - -| Name | Default Value | Description | -| :----------------------------------------------- | :------------ | :------------------------------------------- | -| TONE_TYPE_DIAL_0 | 0 | DTMF tone of key 0. | -| TONE_TYPE_DIAL_1 | 1 | DTMF tone of key 1. | -| TONE_TYPE_DIAL_2 | 2 | DTMF tone of key 2. | -| TONE_TYPE_DIAL_3 | 3 | DTMF tone of key 3. | -| TONE_TYPE_DIAL_4 | 4 | DTMF tone of key 4. | -| TONE_TYPE_DIAL_5 | 5 | DTMF tone of key 5. | -| TONE_TYPE_DIAL_6 | 6 | DTMF tone of key 6. | -| TONE_TYPE_DIAL_7 | 7 | DTMF tone of key 7. | -| TONE_TYPE_DIAL_8 | 8 | DTMF tone of key 8. | -| TONE_TYPE_DIAL_9 | 9 | DTMF tone of key 9. | -| TONE_TYPE_DIAL_S | 10 | DTMF tone of the star key (*). | -| TONE_TYPE_DIAL_P | 11 | DTMF tone of the pound key (#). | -| TONE_TYPE_DIAL_A | 12 | DTMF tone of key A. | -| TONE_TYPE_DIAL_B | 13 | DTMF tone of key B. | -| TONE_TYPE_DIAL_C | 14 | DTMF tone of key C. | -| TONE_TYPE_DIAL_D | 15 | DTMF tone of key D. | -| TONE_TYPE_COMMON_SUPERVISORY_DIAL | 100 | Supervisory tone - dial tone. | -| TONE_TYPE_COMMON_SUPERVISORY_BUSY | 101 | Supervisory tone - busy. | -| TONE_TYPE_COMMON_SUPERVISORY_CONGESTION | 102 | Supervisory tone - congestion. | -| TONE_TYPE_COMMON_SUPERVISORY_RADIO_ACK | 103 | Supervisory tone - radio path acknowledgment | -| TONE_TYPE_COMMON_SUPERVISORY_RADIO_NOT_AVAILABLE | 104 | Supervisory tone - radio path not available | -| TONE_TYPE_COMMON_SUPERVISORY_CALL_WAITING | 106 | Supervisory tone - call waiting tone | -| TONE_TYPE_COMMON_SUPERVISORY_RINGTONE | 107 | Supervisory tone - ringing tone | -| TONE_TYPE_COMMON_PROPRIETARY_BEEP | 200 | Proprietary tone - beep tone. | -| TONE_TYPE_COMMON_PROPRIETARY_ACK | 201 | Proprietary tone - ACK. | -| TONE_TYPE_COMMON_PROPRIETARY_PROMPT | 203 | Proprietary tone - PROMPT. | -| TONE_TYPE_COMMON_PROPRIETARY_DOUBLE_BEEP | 204 | Proprietary tone - double beep tone. | - -## TonePlayer9+ +### isMicrophoneMute(deprecated) -Provides APIs for playing and managing DTMF tones, such as dial tones, ringback tones, supervisory tones, and proprietary tones. +isMicrophoneMute(callback: AsyncCallback<boolean>): void -### load9+ +Checks whether the microphone is muted. This API uses an asynchronous callback to return the result. -load(type: ToneType, callback: AsyncCallback<void>): void +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMicrophoneMute](#ismicrophonemute9) in **AudioVolumeGroupManager**. -Loads the DTMF tone configuration. This API uses an asynchronous callback to return the result. +**Required permissions**: ohos.permission.MICROPHONE -**System capability**: SystemCapability.Multimedia.Audio.Tone +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| type | ToneType(#tonetype9) | Yes | Tone type. | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | --------- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite. | **Example** ```js -tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => { +audioManager.isMicrophoneMute((err, value) => { if (err) { - console.error(`callback call load failed error: ${err.message}`); + console.error(`Failed to obtain the mute status of the microphone. ${err}`); return; - } else { - console.info('callback call load success'); } + console.info(`Callback invoked to indicate that the mute status of the microphone is obtained ${value}.`); }); ``` -### load9+ +### isMicrophoneMute(deprecated) -load(type: ToneType): Promise<void> +isMicrophoneMute(): Promise<boolean> -Loads the DTMF tone configuration. This API uses a promise to return the result. +Checks whether the microphone is muted. This API uses a promise to return the result. -**System capability**: SystemCapability.Multimedia.Audio.Tone +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [isMicrophoneMute](#ismicrophonemute9) in **AudioVolumeGroupManager**. -**Parameters** +**Required permissions**: ohos.permission.MICROPHONE -| Name | Type | Mandatory | Description | -| :--- | :------------------- | :-------- | ----------- | -| type | ToneType(#tonetype9) | Yes | Tone type. | +**System capability**: SystemCapability.Multimedia.Audio.Device **Return value** -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +| Type | Description | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise used to return the mute status of the microphone. The value **true** means that the microphone is muted, and **false** means the opposite. | **Example** ```js -tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => { - console.info('promise call load '); -}).catch(() => { - console.error('promise call load fail'); +audioManager.isMicrophoneMute().then((value) => { + console.info(`Promise returned to indicate that the mute status of the microphone is obtained ${value}.`); }); ``` -### start9+ +### on('volumeChange')(deprecated) -start(callback: AsyncCallback<void>): void +on(type: 'volumeChange', callback: Callback\): void -Starts DTMF tone playing. This API uses an asynchronous callback to return the result. +> **NOTE** +> +> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [on](#on9) in **AudioVolumeManager**. -**System capability**: SystemCapability.Multimedia.Audio.Tone +Subscribes to system volume change events. + +**System API**: This is a system API. + +Currently, when multiple **AudioManager** instances are used in a single process, only the subscription of the last instance takes effect, and the subscription of other instances is overwritten (even if the last instance does not initiate a subscription). Therefore, you are advised to use a single **AudioManager** instance. + +**System capability**: SystemCapability.Multimedia.Audio.Volume **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'volumeChange'** means the system volume change event, which is triggered when a system volume change is detected. | +| callback | Callback<[VolumeEvent](#volumeevent8)> | Yes | Callback used to return the result. | **Example** ```js -tonePlayer.start((err) => { - if (err) { - console.error(`callback call start failed error: ${err.message}`); - return; - } else { - console.info('callback call start success'); - } +audioManager.on('volumeChange', (volumeEvent) => { + console.info(`VolumeType of stream: ${volumeEvent.volumeType} `); + console.info(`Volume level: ${volumeEvent.volume} `); + console.info(`Whether to updateUI: ${volumeEvent.updateUi} `); }); ``` -### start9+ +### on('ringerModeChange')(deprecated) -start(): Promise<void> +on(type: 'ringerModeChange', callback: Callback\): void -Starts DTMF tone playing. This API uses a promise to return the result. +Subscribes to ringer mode change events. -**System capability**: SystemCapability.Multimedia.Audio.Tone +> **NOTE** +> +> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [on('ringerModeChange')](#onringermodechange9) in **AudioVolumeGroupManager**. -**Return value** +**System API**: This is a system API. -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +**System capability**: SystemCapability.Multimedia.Audio.Communication + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ----------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'ringerModeChange'** means the ringer mode change event, which is triggered when a ringer mode change is detected. | +| callback | Callback<[AudioRingMode](#audioringmode)> | Yes | Callback used to return the result. | **Example** ```js -tonePlayer.start().then(() => { - console.info('promise call start'); -}).catch(() => { - console.error('promise call start fail'); +audioManager.on('ringerModeChange', (ringerMode) => { + console.info(`Updated ringermode: ${ringerMode}`); }); ``` -### stop9+ +### on('deviceChange')(deprecated) -stop(callback: AsyncCallback<void>): void +on(type: 'deviceChange', callback: Callback): void -Stops the tone that is being played. This API uses an asynchronous callback to return the result. +Subscribes to device change events. When a device is connected or disconnected, registered clients will receive the callback. -**System capability**: SystemCapability.Multimedia.Audio.Tone +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [on](#on9) in **AudioRoutingManager**. + +**System capability**: SystemCapability.Multimedia.Audio.Device **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| :------- | :--------------------------------------------------- | :-------- | :----------------------------------------------------------- | +| type | string | Yes | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected. | +| callback | Callback<[DeviceChangeAction](#devicechangeaction)\> | Yes | Callback used to return the device update details. | **Example** ```js -tonePlayer.stop((err) => { - if (err) { - console.error(`callback call stop error: ${err.message}`); - return; - } else { - console.error('callback call stop success '); - } +audioManager.on('deviceChange', (deviceChanged) => { + console.info(`device change type : ${deviceChanged.type} `); + console.info(`device descriptor size : ${deviceChanged.deviceDescriptors.length} `); + console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceRole} `); + console.info(`device change descriptor : ${deviceChanged.deviceDescriptors[0].deviceType} `); }); ``` -### stop9+ +### off('deviceChange')(deprecated) -stop(): Promise<void> +off(type: 'deviceChange', callback?: Callback): void -Stops the tone that is being played. This API uses a promise to return the result. +Unsubscribes from device change events. -**System capability**: SystemCapability.Multimedia.Audio.Tone +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [off](#off9) in **AudioRoutingManager**. -**Return value** +**System capability**: SystemCapability.Multimedia.Audio.Device -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | --------------------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'deviceChange'** means the device change event, which is triggered when a device connection status change is detected. | +| callback | Callback<[DeviceChangeAction](#devicechangeaction)> | No | Callback used to return the device update details. | **Example** ```js -tonePlayer.stop().then(() => { - console.info('promise call stop finish'); -}).catch(() => { - console.error('promise call stop fail'); +audioManager.off('deviceChange', (deviceChanged) => { + console.info('Should be no callback.'); }); - ``` -### release9+ +### on('interrupt')(deprecated) -release(callback: AsyncCallback<void>): void +on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback\): void -Releases the resources associated with the **TonePlay** instance. This API uses an asynchronous callback to return the result. +Subscribes to audio interruption events. When the application's audio is interrupted by another playback event, the application will receive the callback. -**System capability**: SystemCapability.Multimedia.Audio.Tone +Same as [on('audioInterrupt')](#onaudiointerrupt9), this API is used to listen for focus changes. However, this API is used in scenarios without audio streams (no **AudioRenderer** instance is created), such as frequency modulation (FM) and voice wakeup. + +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. + +**System capability**: SystemCapability.Multimedia.Audio.Renderer **Parameters** -| Name | Type | Mandatory | Description | -| :------- | :------------------- | :-------- | :---------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'interrupt'** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application. | +| interrupt | AudioInterrupt | Yes | Audio interruption event type. | +| callback | Callback<[InterruptAction](#interruptaction)> | Yes | Callback invoked for the audio interruption event. | **Example** ```js -tonePlayer.release((err) => { - if (err) { - console.error(`callback call release failed error: ${err.message}`); - return; - } else { - console.info('callback call release success '); +let interAudioInterrupt = { + streamUsage:2, + contentType:0, + pauseWhenDucked:true +}; +audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => { + if (InterruptAction.actionType === 0) { + console.info('An event to gain the audio focus starts.'); + console.info(`Focus gain event: ${InterruptAction} `); + } + if (InterruptAction.actionType === 1) { + console.info('An audio interruption event starts.'); + console.info(`Audio interruption event: ${InterruptAction} `); } }); + ``` -### release9+ +### off('interrupt')(deprecated) -release(): Promise<void> +off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback\): void -Releases the resources associated with the **TonePlay** instance. This API uses a promise to return the result. +Unsubscribes from audio interruption events. -**System capability**: SystemCapability.Multimedia.Audio.Tone +> **NOTE** +> +> This API is supported since API version 7 and deprecated since API version 9. -**Return value** +**System capability**: SystemCapability.Multimedia.Audio.Renderer -| Type | Description | -| :------------- | :--------------------------------- | -| Promise | Promise used to return the result. | +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------------- | --------- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value **'interrupt'** means the audio interruption event, which is triggered when the audio playback of the current application is interrupted by another application. | +| interrupt | AudioInterrupt | Yes | Audio interruption event type. | +| callback | Callback<[InterruptAction](#interruptaction)> | No | Callback invoked for the audio interruption event. | **Example** ```js -tonePlayer.release().then(() => { - console.info('promise call release'); -}).catch(() => { - console.error('promise call release fail'); +let interAudioInterrupt = { + streamUsage:2, + contentType:0, + pauseWhenDucked:true +}; +audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => { + if (InterruptAction.actionType === 0) { + console.info('An event to release the audio focus starts.'); + console.info(`Focus release event: ${InterruptAction} `); + } }); ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md index 9e70a90e4fc19197ebd37021ad3326ab64c3ccfc..adf30d8b7442dd67e822f200a0114f93957bd892 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-ShortcutInfo.md @@ -1,30 +1,32 @@ -# ShortcutInfo +# ShortcutInfo(deprecated) The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute). > **NOTE** > +> This module is deprecated since API version 9. You are advised to use [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) instead. +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## ShortcutWant +## ShortcutWant(deprecated) -Describes the information about the target to which the shortcut points. +> This API is deprecated since API version 9. You are advised to use [ShortcutWant](js-apis-bundleManager-shortcutInfo.md) instead. -**System capability**: SystemCapability.BundleManager.BundleFramework + **System capability**: SystemCapability.BundleManager.BundleFramework -**System API**: This is a system API and cannot be called by third-party applications. + **System API**: This is a system API and cannot be called by third-party applications. | Name | Type | Readable| Writable| Description | | ------------------------- | ------ | ---- | ---- | -------------------- | | targetBundle | string | Yes | No | Target bundle of the shortcut.| -| targetModule9+ | string | Yes | No | Target module of the shortcut. | | targetClass | string | Yes | No | Target class required by the shortcut.| -## ShortcutInfo +## ShortcutInfo(deprecated) + +> This API is deprecated since API version 9. You are advised to use [ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) instead. -Describes the shortcut attribute information. -**System capability**: SystemCapability.BundleManager.BundleFramework + **System capability**: SystemCapability.BundleManager.BundleFramework | Name | Type | Readable| Writable| Description | | ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- | @@ -40,4 +42,3 @@ Describes the shortcut attribute information. | isStatic | boolean | Yes | No | Whether the shortcut is static. | | isHomeShortcut | boolean | Yes | No | Whether the shortcut is a home shortcut.| | isEnabled | boolean | Yes | No | Whether the shortcut is enabled. | -| moduleName9+ | string | Yes | No | Module name of the shortcut. | diff --git a/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md index f44ea5c33a652e87193e1a976c0031dccd049e07..ffde8d4356caee1dde9f47bdbb424d2dbdda57bb 100644 --- a/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md +++ b/en/application-dev/reference/apis/js-apis-bundle-remoteAbilityInfo.md @@ -6,7 +6,9 @@ The **RemoteAbilityInfo** module provides information about a remote ability. > > 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. -## RemoteAbilityInfo +## RemoteAbilityInfo(deprecated) + +> This API is deprecated since API version 9. You are advised to use [RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md) instead. **System capability**: SystemCapability.BundleManager.DistributedBundleFramework diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md b/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md new file mode 100644 index 0000000000000000000000000000000000000000..93b932d3c40ee9bf838f5d2caed848b2916b81cf --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-elementName.md @@ -0,0 +1,22 @@ +# ElementName + +The **ElementName** module provides the element name information, which can be obtained through [Context.getElementName](js-apis-Context.md). + + +> **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. + +## ElementName + +**System capability**: SystemCapability.BundleManager.BundleFramework.Core + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ---------| ---- | ---- | ------------------------- | +| deviceId | string | Yes | Yes | Device ID. | +| bundleName | string | Yes | Yes | Bundle name of the application. | +| abilityName | string | Yes | Yes | Name of the ability. | +| uri | string | Yes | Yes | Resource ID. | +| shortName | string | Yes | Yes | Short name of the ability. | +| moduleName | string | Yes | Yes | Module name of the HAP file to which the ability belongs. | + diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-remoteAbilityInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-remoteAbilityInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..0281e4fc7785bd815c1b988a9f67fb74b5a514de --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-remoteAbilityInfo.md @@ -0,0 +1,19 @@ +# RemoteAbilityInfo + +The **RemoteAbilityInfo** module provides information about a remote ability, which can be obtained through [distributedBundle.getRemoteAbilityInfo](js-apis-distributedBundle.md). + +> **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. + +## RemoteAbilityInfo + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**System API**: This is a system API. + +| Name | Type | Readable| Writable| Description | +| ----------- | -------------------------------------------- | ---- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | No | Element name information of the remote ability. | +| label | string | Yes | No | Label of the remote ability. | +| icon | string | Yes | No | Icon of the remote ability.| diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..0f1d6b7e992484875d65479a3734b00484141d21 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md @@ -0,0 +1,37 @@ +# ShortcutInfo + +The **ShortcutInfo** module provides shortcut information defined in the configuration file. For details about the configuration in the FA model, see [config.json](../../quick-start/package-structure.md). For details about the configuration in the stage model, see [Internal Structure of the shortcuts Attribute](../../quick-start/stage-structure.md#internal-structure-of-the-shortcuts-attribute). + +> **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. + +## ShortcutWant + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**System API**: This is a system API. + +| Name | Type | Readable| Writable| Description | +| ------------------------- | ------ | ---- | ---- | -------------------- | +| targetBundle | string | Yes | No | Target bundle name of the shortcut.| +| targetModule | string | Yes | No | Target module name of the shortcut. | +| targetAbility | string | Yes | No | Target ability name of the shortcut.| + +## ShortcutInfo + +**System capability**: SystemCapability.BundleManager.BundleFramework.Launcher + +**System API**: This is a system API. + +| Name | Type | Readable| Writable| Description | +| ----------------------- | ------------------------------------------ | ---- | ---- | ---------------------------- | +| id | string | Yes | No | ID of the application to which the shortcut belongs. | +| bundleName | string | Yes | No | Name of the bundle that contains the shortcut. | +| moduleName | string | Yes | No | Module name of the shortcut. | +| hostAbility | string | Yes | No | Local ability name of the shortcut. | +| icon | string | Yes | No | Icon of the shortcut. | +| iconId | number | Yes | No | Icon ID of the shortcut. | +| label | string | Yes | No | Label of the shortcut. | +| labelId | number | Yes | No | Label ID of the shortcut. | +| wants | Array\<[ShortcutWant](#shortcutwant)> | Yes | No | Want information required for the shortcut. | diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 34fe47f45abe436abf986da809e343fd638540d7..a04f49f6d46bd886af5b23c01e65ce7d0b689e85 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -796,7 +796,7 @@ call.reject(rejectMessageOptions, (err, data) => { ## call.reject7+ -reject(callId: number, callback: AsyncCallback): +reject(callId: number, callback: AsyncCallback\): void Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result. @@ -811,16 +811,11 @@ This is a system API. | callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | -**Return value** - -| Type | Description | -| ------------------- | --------------------------- | -| Promise<void> | Promise used to return the result.| **Example** ```js -call.reject(1, (error, data) => { +call.reject(1, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1621,8 +1616,8 @@ This is a system API. **Example** ```js -call.on('callDetailsChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callDetailsChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1646,8 +1641,8 @@ This is a system API. **Example** ```js -call.on('callEventChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callEventChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1671,8 +1666,8 @@ This is a system API. **Example** ```js -call.on('callDisconnectedCause', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('callDisconnectedCause', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1696,8 +1691,8 @@ This is a system API. **Example** ```js -call.on('mmiCodeResult', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.on('mmiCodeResult', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1721,8 +1716,8 @@ This is a system API. **Example** ```js -call.off('callDetailsChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callDetailsChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1746,8 +1741,8 @@ This is a system API. **Example** ```js -call.off('callEventChange', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callEventChange', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1771,8 +1766,8 @@ This is a system API. **Example** ```js -call.off('callDisconnectedCause', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('callDisconnectedCause', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -1796,8 +1791,8 @@ This is a system API. **Example** ```js -call.off('mmiCodeResult', (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +call.off('mmiCodeResult', data => { + console.log(`callback: data->${JSON.stringify(data)}`); }); ``` @@ -2386,7 +2381,7 @@ This is a system API. let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err, value) => { +call.setAudioDevice(1, audioDeviceOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-cert.md b/en/application-dev/reference/apis/js-apis-cert.md new file mode 100644 index 0000000000000000000000000000000000000000..f6da43b47b7ea93738ba62832c7672307f2e9c9b --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-cert.md @@ -0,0 +1,2419 @@ +# Certificate + +The **certificate** module provides APIs for performing certificate operations. The APIs of this module depend on the basic algorithm capabilities provided by the cryptography framework. For details about the cryptography framework APIs, see [Cryptography Framework](./js-apis-cryptoFramework.md). + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. + +## Modules to Import + +```javascript +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" +``` + +## CertResult + + Enumerates the error codes. + + **System capability**: SystemCapability.Security.Cert + +| Name | Default Value | Description | +| --------------------------------------| -------- | -----------------------------| +| INVALID_PARAMS | 401 | Invalid parameters. | +| NOT_SUPPORT | 801 | This operation is not supported. | +| ERR_OUT_OF_MEMORY | 19020001 | Memory error. | +| ERR_RUNTIME_ERROR | 19020002 | Runtime error. | +| ERR_CRYPTO_OPERATION | 19030001 | Crypto operation error. | +| ERR_CERT_SIGNATURE_FAILURE | 19030002 | The certificate signature verification failed. | +| ERR_CERT_NOT_YET_VALID | 19030003 | The certificate has not taken effect. | +| ERR_CERT_HAS_EXPIRED | 19030004 | The certificate has expired. | +| ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY | 19030005 | Failed to obtain the certificate issuer. | +| ERR_KEYUSAGE_NO_CERTSIGN | 19030006 | The key cannot be used for signing a certificate. | +| ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE | 19030007 | The key cannot be used for digital signature. | + +## DataBlob +Defines a binary data array. + **System capability**: SystemCapability.Security.Cert +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ----------------| +| data | Uint8Array | Yes | Yes | Data. | + +## DataArray +Defines a list of data arrays. + **System capability**: SystemCapability.Security.Cert +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ----------------| +| data | Uint8Array | Yes | Yes | Data list. | + +## EncodingFormat + + Enumerates the certificate encoding formats. + + **System capability**: SystemCapability.Security.Cert + +| Name | Default Value | Description | +| ------------| ---------| -----------| +| FORMAT_DER | 0 | Distinguished Encoding Rules (DER) format. | +| FORMAT_PEM | 1 | Privacy-Enhanced Mail (PEM) format. | + + +## EncodingBlob + +Defines a certificate binary array in encoding format. + +### Attributes + +**System capability**: SystemCapability.Security.Cert + +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ----------------------------------| +| data | Uint8Array | Yes | Yes | Certificate data. | +| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format.| + + +## CertChainData + +Defines the certificate chain data, which is passed in as input parameters during certificate chain verification. + +### Attributes + +**System capability**: SystemCapability.Security.Cert + +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | +| data | Uint8Array | Yes | Yes | Certificate data, in the *length* (2 bytes) + *data* format. For example, **08ABCDEFGH07ABCDEFG**. The first two bytes indicate the length of the first certificate is eight bytes, and the following eight bytes indicate the certificate data. Then, the next two bytes indicates the length of another certificate is seven bytes, and the seven bytes followed indicate the certificate data. | +| count | number | Yes | Yes | Number of certificates contained in the input data. | +| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format.| + + +## cryptoCert.createX509Cert + +createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\) : void + +Creates an **X509Cert** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------ | +| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data.| +| callback | AsyncCallback\ | No | Callback invoked to return the **X509Cert** instance created. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + } +}); +``` + +## cryptoCert.createX509Cert + +createX509Cert(inStream : EncodingBlob) : Promise\ + +Creates an **X509Cert** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------ | ---- | ------------------ | +| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data.| + +**Return value** + +| Type | Description | +| :------- | ---------------- | +| Promise\ |Promise used to return the **X509Cer** instance created.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { + Console.log("createX509Cert success"); +}, error => { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +## X509Cert + +Provides APIs for X.509 certificate operations. + +### verify + +verify(key : cryptoFramework.PubKey, callback : AsyncCallback\) : void + +Verifies the certificate signature. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------------ | +| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| +| callback | AsyncCallback\) | No | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + // Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance. + let pubKey = null; + x509Cert.verify(pubKey, function (error, data) { + if (error != null) { + Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("verify success"); + } + }); + } +}); +``` + +### verify + +verify(key : cryptoFramework.PubKey) : Promise\ + +Verifies the certificate signature. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { + Console.log("createX509Cert success"); + // Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance. + let pubKey = null; + x509Cert.verify(pubKey).then(result => { + Console.log("verify success"); + }, error => { + Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getEncoded + +getEncoded(callback : AsyncCallback\) : void + +Obtains the serialized X.509 certificate data. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | No | Callback invoked to return the serialized X.509 certificate data obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + x509Cert.getEncoded(function (error, data) { + if (error != null) { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getEncoded success"); + } + }); + } +}); +``` + +### getEncoded + +getEncoded() : Promise\ + +Obtains the serialized X.509 certificate data. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------------ | ---------------------- | +| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized X.509 certificate data obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { + Console.log("createX509Cert success"); + x509Cert.getEncoded().then(result => { + Console.log("getEncoded success"); + }, error => { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getPublicKey + +getPublicKey(callback : AsyncCallback\) : void + +Obtains the public key of this X.509 certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback | No | Callback invoked to return the public key obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + x509Cert.getPublicKey(function (error, pubKey) { + if (error != null) { + Console.log("getPublicKey failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getPublicKey success"); + } + }); + } +}); +``` + +### getPublicKey + +getPublicKey() : Promise\ + +Obtains the public key of this X.509 certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ---------------- | +| cryptoFramework.PubKey | X.509 certificate public key obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { + Console.log("createX509Cert success"); + x509Cert.getPublicKey().then(pubKey => { + Console.log("getPublicKey success"); + }, error => { + Console.log("getPublicKey failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### checkValidityWithDate + +checkValidityWithDate(date: string, callback : AsyncCallback\) : void + +Checks the validity period of this X.509 certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| date | string | Yes | Date of the certificate to check. | +| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the certificate is valid. If **error** is not **null**, the certificate has expired.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let date = "150527000001Z"; + x509Cert.checkValidityWithDate(date, function (error, data) { + if (error != null) { + Console.log("checkValidityWithDate failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("checkValidityWithDate success"); + } + }); + } +}); +``` + +### checkValidityWithDate + +checkValidityWithDate(date: string) : Promise\ + +Checks the validity period of this X.509 certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name| Type | Mandatory| Description| +| ------ | ------ | ---- | ---- | +| date | string | Yes | Date of the certificate to check.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob).then(x509Cert => { + Console.log("createX509Cert success"); + let date = "150527000001Z"; + x509Cert.checkValidityWithDate(date).then(result => { + Console.log("checkValidityWithDate success"); + }, error => { + Console.log("checkValidityWithDate failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getVersion + +getVersion() : number + +Obtains the X.509 certificate version. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ---------------- | +| number | X.509 certificate version obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let version = x509Cert.getVersion(); + } +}); +``` + +### getSerialNumber + +getSerialNumber() : number + +Obtains the X.509 certificate serial number. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ------------------ | +| number | X.509 certificate serial number obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let serialNumber = x509Cert.getSerialNumber(); + } +}); +``` + +### getIssuerName + +getIssuerName() : DataBlob + +Obtains the X.509 certificate issuer. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | ---------------------- | +| [DataBlob](#datablob) | X.509 certificate issuer obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let issuerName = x509Cert.getIssuerName(); + } +}); +``` + +### getSubjectName + +getSubjectName() : DataBlob + +Obtains the subject of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | -------------------- | +| [DataBlob](#datablob) | Subject name obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let subjectName = x509Cert.getSubjectName(); + } +}); +``` + +### getNotBeforeTime + +getNotBeforeTime() : string + +Obtains the start time of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| string | Start time of the X.509 certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let notBefore = x509Cert.getNotBeforeTime(); + } +}); +``` + +### getNotAfterTime + +getNotAfterTime() : string + +Obtains the expiration time of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------------- | +| string | Expiration time of the X.509 certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let notAfter = x509Cert.getNotAfterTime(); + } +}); +``` + +### getSignature + +getSignature() : DataBlob + +Obtains the signature data of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | -------------------- | +| [DataBlob](#datablob) | Signature data obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let signature = x509Cert.getSignature(); + } +}); +``` + +### getSignatureAlgName + +getSignatureAlgName() : string + +Obtains the signing algorithm of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ------------------------ | +| string | X.509 certificate signing algorithm obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let sigAlgName = x509Cert.getSignatureAlgName(); + } +}); +``` + +### getSignatureAlgOid + +getSignatureAlgOid() : string + +Obtains the object identifier (OID) of the X.509 certificate signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO). + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | --------------------------------- | +| string | OID obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let sigAlgOid = x509Cert.getSignatureAlgOid(); + } +}); +``` + +### getSignatureAlgParams + +getSignatureAlgParams() : DataBlob + +Obtains the signing algorithm parameters of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | ------------------------ | +| [DataBlob](#datablob) | X.509 certificate signing algorithm parameters obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let sigAlgParams = x509Cert.getSignatureAlgParams(); + } +}); +``` + +### getKeyUsage + +getKeyUsage() : DataBlob + +Obtains the key usage of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | -------------------- | +| [DataBlob](#datablob) | Key usage of the X.509 certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let keyUsage = x509Cert.getKeyUsage(); + } +}); +``` + +### getExtKeyUsage + +getExtKeyUsage() : DataArray + +Obtains the usage of the extended key of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| --------- | ------------------------ | +| [DataArray](#dataarray) | Usage of the extended key obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let extKeyUsage = x509Cert.getExtKeyUsage(); + } +}); +``` + +### getBasicConstraints + +getBasicConstraints() : number + +Obtains the basic constraints for obtaining this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| number | Basic constraints obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let basicConstraints = x509Cert.getBasicConstraints(); + } +}); +``` + +### getSubjectAltNames + +getSubjectAltNames() : DataArray + +Obtains the Subject Alternative Names (SANs) of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| --------- | ------------------------ | +| [DataArray](#dataarray) | SANs obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let subjectAltNames = x509Cert.getSubjectAltNames(); + } +}); +``` + +### getIssuerAltNames + +getIssuerAltNames() : DataArray + +Obtains the Issuer Alternative Names (IANs) of this X.509 certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| --------- | -------------------------- | +| [DataArray](#dataarray) | IANs obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Certificate binary data, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) { + if (error != null) { + Console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Cert success"); + let issuerAltNames = x509Cert.getIssuerAltNames(); + } +}); +``` + +## cryptoCert.createX509Crl + +createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\) : void + +Creates an **X509Crl** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------------------------- | +| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized certificate revocation list (CRL) data.| +| callback | AsyncCallback\ | No | Callback invoked to return the **X509Crl** instance created. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + } +}); +``` + +## cryptoCert.createX509Crl + +createX509Crl(inStream : EncodingBlob) : Promise\ + +Creates an **X509Crl** instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------ | ---- | -------------------------- | +| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized CRL data.| + +**Return value** + +| Type | Description | +| ------- | -------------------- | +| Promise\ | Promise used to return the **X509Crl** instance created.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +## X509Crl + +Provides APIs for X.509 certificate CRL operations. + +### isRevoked + +isRevoked(cert : X509Cert, callback : AsyncCallback\) : void + +Checks whether an X.509 certificate is revoked. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------------------- | +| cert | [X509Cert](#x509cert) | Yes | X.509 certificate to check.| +| callback | AsyncCallback\ | No | Callback invoked to return the result. The value **true** indicates that the certificate is revoked, and **false** indicates the opposite. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + // Create an X509Cert instance. + let x509Cert = null; + x509Crl.isRevoked(x509Cert, function (error, isRevoked) { + if (error != null) { + Console.log("call isRevoked failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("call isRevoked success"); + } + }); + } +}); +``` + +### isRevoked + +isRevoked(cert : X509Cert) : Promise\ + +Checks whether an X.509 certificate is revoked. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | -------------------- | +| cert | X509Cert | Yes | X.509 certificate to check.| + +**Return value** + +| Type | Description | +| ------- | ------------------------------------------------- | +| Promise\ | Promise used to return the result. The value **true** indicates the certificate is revoked; the value **false** indicates the opposite.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + // Create an X509Cert instance. + let x509Cert = null; + x509Crl.isRevoked(x509Cert).then(isRevoked => { + Console.log("call isRevoked success"); + }, error => { + Console.log("call isRevoked failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getType + +getType() : string + +Obtains the CRL type. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| string | CRL type obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let type = x509Crl.getType(); + } +}); +``` + +### getEncoded + +getEncoded(callback : AsyncCallback\) : void + +Obtains the serialized X.509 CRL data. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\ | No | Callback invoked to return the serialized X.509 CRL data obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + x509Crl.getEncoded(function (error, data) { + if (error != null) { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getEncoded success"); + } + }); + } +}); +``` + +### getEncoded + +getEncoded() : Promise\ + +Obtains the serialized X.509 CRL data. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------------ | -------------------------------- | +| Promise\ | Promise used to return the serialized X.509 CRL data obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + x509Crl.getEncoded().then(result => { + Console.log("getEncoded success"); + }, error => { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### verify + +verify(key : cryptoFramework.PubKey, callback : AsyncCallback\) : void + +Verifies the signature of the X.509 CRL. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ---------------------- | +| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| +| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + // Generate the public key by AsyKeyGenerator. + let pubKey = null; + x509Crl.verify(pubKey, function (error, data) { + if (error != null) { + Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("verify success"); + } + }); + } +}); +``` + +### verify + +verify(key : cryptoFramework.PubKey) : Promise\ + +Verifies the signature of the X.509 CRL. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------------------- | +| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + // Generate the public key by AsyKeyGenerator. + let pubKey = null; + x509Crl.verify(pubKey).then(result => { + Console.log("verify success"); + }, error => { + Console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getVersion + +getVersion() : number + +Obtains the version of the X.509 CRL. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------------------- | +| number | Version of the X.509 CRL obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let version = x509Crl.getVersion(); + } +}); +``` + +### getIssuerName + +getIssuerName() : DataBlob + +Obtains the issuer of the X.509 CRL. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | ------------------------------ | +| [DataBlob](#datablob) | Issuer of the X.509 CRL obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let issuerName = x509Crl.getIssuerName(); + } +}); +``` + +### getLastUpdate + +getLastUpdate() : string + +Obtains the date when the X.509 CRL was last updated. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ------------------------------------ | +| string | Last update date of the X.509 CRL.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let lastUpdate = x509Crl.getLastUpdate(); + } +}); +``` + +### getNextUpdate + +getNextUpdate() : string + +Obtains the date when the CRL will be updated the next time. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ------------------------------------ | +| string | Next update date obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let nextUpdate = x509Crl.getNextUpdate(); + } +}); +``` + +### getRevokedCert + +getRevokedCert(serialNumber : number, callback : AsyncCallback\) : void + +Obtains the revoked X.509 certificate based on the specified serial number of the certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------- | ---- | -------------- | +| serialNumber | number | Yes | Serial number of the certificate.| +| callback | AsyncCallback\ | No | Callback invoked to return the revoked X.509 certificate. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + // Set the serial number of the corresponding certificate. + let serialNumber = 1000; + x509Crl.getRevokedCert(serialNumber, function (error, entry) { + if (error != null) { + Console.log("getRevokedCert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getRevokedCert success"); + } + }); + } +}); +``` + +### getRevokedCert + +getRevokedCert(serialNumber : number) : Promise\ + +Obtains the revoked X.509 certificate based on the specified serial number of the certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | -------------- | +| serialNumber | number | Yes | Serial number of the certificate.| + +**Return value** + +| Type | Description | +| ------------ | ---------------------- | +| Promise\ | Promise used to return the revoked X.509 certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + // Set the serial number of the corresponding certificate. + let serialNumber = 1000; + x509Crl.getRevokedCert(serialNumber).then(entry => { + Console.log("getRevokedCert success"); + }, error => { + Console.log("getRevokedCert failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getRevokedCertWithCert + +getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback\) : void + +Obtains the revoked X.509 certificate based on the specified certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | ------------ | +| cert | X509Cert | Yes | Certificate based on which the revoked certificate is obtained.| +| callback | AsyncCallback\ | No | Callback invoked to return the revoked X.509 certificate obtained. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + // Create an X509Cert instance. + let x509Cert = null; + x509Crl.getRevokedCertWithCert(x509Cert, function (error, entry) { + if (error != null) { + Console.log("getRevokedCertWithCert failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getRevokedCertWithCert success"); + } + }); + } +}); +``` + +### getRevokedCertWithCert + +getRevokedCertWithCert(cert : X509Cert) : Promise\ + +Obtains the revoked X.509 certificate based on the specified certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ------------ | +| cert | X509Cert | Yes | Certificate based on which the revoked certificate is obtained.| + +**Return value** + +| Type | Description | +| ------------ | ---------------------- | +| Promise\ | Promise used to return the revoked X.509 certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + // Create an X509Cert instance. + let x509Cert = null; + x509Crl.getRevokedCertWithCert(x509Cert).then(entry => { + Console.log("getRevokedCertWithCert success"); + }, error => { + Console.log("getRevokedCertWithCert failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getRevokedCerts + +getRevokedCerts(callback : AsyncCallback>) : void + +Obtains all the revoked X.509 certificates. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback> | No | Callback invoked to return the revoked X.509 certificates obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + x509Crl.getRevokedCerts(function (error, array) { + if (error != null) { + Console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getRevokedCerts success"); + } + }); + } +}); +``` + +### getRevokedCerts + +getRevokedCerts() : Promise> + +Obtains all the revoked X.509 certificates. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------------------- | ---------------------- | +|Promise> | Promise used to return a list of revoked X.509 certificates.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + x509Crl.getRevokedCerts().then(array => { + Console.log("getRevokedCerts success"); + }, error => { + Console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getTbsInfo + +getTbsInfo(callback : AsyncCallback\) : void + +Obtains the DER-encoded CRL information, the **tbsCertList** from this CRL. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\<[DataBlob](#datablob)> | No | Callback invoked to return the tbsCertList information obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + x509Crl.getTbsInfo(function (error, tbsInfo) { + if (error != null) { + Console.log("getTbsInfo failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getTbsInfo success"); + } + }); + } +}); +``` + +### getTbsInfo + +getTbsInfo() : Promise\ + +Obtains the DER-encoded CRL information, the **tbsCertList** from this CRL. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | --------------------------------- | +| Promise\<[DataBlob](#datablob)> | Promise used to return the **tbsCertList** information obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob).then(x509Crl => { + Console.log("createX509Crl success"); + x509Crl.getTbsInfo().then(tbsInfo => { + Console.log("getTbsInfo success"); + }, error => { + Console.log("getTbsInfo failed, errCode: " + error.code + ", errMsg: " + error.message); + }); +}, error => { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getSignature + +getSignature() : DataBlob + +Obtains the signature data of the X.509 CRL. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | ------------------------------ | +| [DataBlob](#datablob) | Signature data of the X.509 CRL obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let signature = x509Crl.getSignature(); + } +}); +``` + +### getSignatureAlgName + +getSignatureAlgName() : string + +Obtains the signing algorithm of the X.509 CRL. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------------------- | +| string | Signing algorithm obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let sigAlgName = x509Crl.getSignatureAlgName(); + } +}); +``` + +### getSignatureAlgOid + +getSignatureAlgOid() : string + +Obtains the OID of the X.509 CRL signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO). + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | --------------------------------------------- | +| string | OID of the X.509 CRL signing algorithm obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let sigAlgOid = x509Crl.getSignatureAlgOid(); + } +}); +``` + +### getSignatureAlgParams + +getSignatureAlgParams() : DataBlob + +Obtains the parameters of the X.509 CRL signing algorithm. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | ---------------------------------- | +| [DataBlob](#datablob) | Algorithm parameters obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Binary data of the CRL, which must be set based on the service. +let encodingData = null; +let encodingBlob = { + data: encodingData, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) { + if (error != null) { + Console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("createX509Crl success"); + let sigAlgParams = x509Crl.getSignatureAlgParams(); + } +}); +``` + +## cryptoCert.createCertChainValidator + +createCertChainValidator(algorithm :string) : CertChainValidator + +Creates a **CertChainValidator** object. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------------------------------------ | +| algorithm | string | Yes | Certificate chain validator algorithm. Currently, only **PKIX** is supported.| + +**Return value** + +| Type | Description | +| ------------------ | -------------------- | +| CertChainValidator | **CertChainValidator** object created.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +let validator = cryptoCert.createCertChainValidator("PKIX"); +``` + +## CertChainValidator + +Provides APIs for certificate chain validator operations. + +### validate + +validate(certChain : CertChainData, callback : AsyncCallback\) : void + +Validates the X.509 certificate chain. This API uses an asynchronous callback to return the result. +The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------- | ---- | ------------------------ | +| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data.| +| callback | AsyncCallback\ | No | Callback invoked to return the result. If **error** is **null**, the X.509 certificate chain is valid. If **error** is not **null**, the X.509 certificate chain is not valid. | + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +let validator = cryptoCert.createCertChainValidator("PKIX"); +// Certificate chain binary data, which must be set based on the service. +let encodingData = null; +// Number of certificates in the certificate chain. It must be set based on the service. +let certCount = 2; +let certChainData = { + data: encodingData, + count: certCount, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +validator.validate(certChainData, function (error, data) { + if (error != null) { + Console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("validate success"); + } +}); +``` + +### validate + +validate(certChain : CertChainData) : Promise\ + +Validates the X.509 certificate chain. This API uses a promise to return the result. +The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](./../security/cert-overview.md#certificate-specifications). + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------- | ---- | ------------------------ | +| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +let validator = cryptoCert.createCertChainValidator("PKIX"); +// Certificate chain binary data, which must be set based on the service. +let encodingData = null; +// Number of certificates in the certificate chain. It must be set based on the service. +let certCount = 2; +let certChainData = { + data: encodingData, + count: certCount, + // Set the encoding format, which can be FORMAT_PEM or FORMAT_DER. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM +}; +validator.validate(certChainData).then(result => { + Console.log("validate success"); +}, error => { + Console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### algorithm + +algorithm : string + +Obtains the algorithm of the X.509 certificate chain validator. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ------------------------ | +| string | Algorithm of the X.509 certificate chain validator obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +let validator = cryptoCert.createCertChainValidator("PKIX"); +let algorithm = validator.algorithm; +``` + +## X509CrlEntry + +Provides APIs for operating the revoked certificates. + +### getEncoded + +getEncoded(callback : AsyncCallback\) : void + +Obtains the serialized data of this revoked certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | No | Callback invoked to return the serialized data of the revoked certificate.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getEncoded(function (error, data) { + if (error != null) { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getEncoded success"); + } +}); +``` + +### getEncoded + +getEncoded() : Promise\ + +Obtains the serialized data of this revoked certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------------ | -------------------------- | +| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized data of the revoked certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getEncoded().then(result => { + Console.log("getEncoded success"); +}, error => { + Console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getSerialNumber + +getSerialNumber() : number + +Obtains the serial number of this revoked certificate. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | ---------------------- | +| number | Serial number of the revoked certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +let serialNumber = x509CrlEntry.getSerialNumber(); +``` + +### getCertIssuer + +getCertIssuer(callback : AsyncCallback\) : void + +Obtains the issuer of this revoked certificate. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\<[DataBlob](#datablob)> | No | Callback invoked to return the issuer of the revoked certificate obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getCertIssuer(function (error, issuer) { + if (error != null) { + Console.log("getCertIssuer failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getCertIssuer success"); + } +}); +``` + +### getCertIssuer + +getCertIssuer() : Promise\ + +Obtains the issuer of this revoked certificate. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| -------- | -------------------------- | +| Promise\<[DataBlob](#datablob)> | Promise used to return the issuer of the revoked certificate obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getCertIssuer().then(issuer => { + Console.log("getCertIssuer success"); +}, error => { + Console.log("getCertIssuer failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` + +### getRevocationDate + +getRevocationDate(callback : AsyncCallback\) : void + +Obtains the date when the certificate was revoked. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------- | ---- | -------- | +| callback | AsyncCallback\ | No | Callback invoked to return the certificate revocation date obtained.| + + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getRevocationDate(function (error, date) { + if (error != null) { + Console.log("getRevocationDate failed, errCode: " + error.code + ", errMsg: " + error.message); + } else { + Console.log("getRevocationDate success"); + } +}); +``` + +### getRevocationDate + +getRevocationDate() : Promise\ + +Obtains the date when the certificate was revoked. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.Cert + +**Return value** + +| Type | Description | +| ------ | -------------------- | +| Promise\ | Promise used to return the certificate revocation date obtained.| + +**Example** + +```js +import cryptoCert from '@ohos.security.cert'; + +// Obtain X509CrlEntry by using getRevokedCert() of X509Crl. +let x509CrlEntry = null; +x509CrlEntry.getRevocationDate().then(date => { + Console.log("getRevocationDate success"); +}, error => { + Console.log("getRevocationDate failed, errCode: " + error.code + ", errMsg: " + error.message); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-config-policy.md b/en/application-dev/reference/apis/js-apis-config-policy.md index 3c8f4d0050107f7e0b50e0d8f6c2a44d0a87e664..4e541cbfe0022219d9ebf57b0502e82984c84384 100644 --- a/en/application-dev/reference/apis/js-apis-config-policy.md +++ b/en/application-dev/reference/apis/js-apis-config-policy.md @@ -1,12 +1,12 @@ # Configuration Policy -The configuration policy provides the capability of obtaining the custom configuration directory and file path based on the predefined custom configuration level. +The **configPolicy** module provides APIs for obtaining the custom configuration directory and file path based on the predefined custom configuration level. > **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > -> The APIs of this module are system APIs and cannot be called by third-party applications. +> The APIs provided by this module are system APIs. ## Modules to Import @@ -32,7 +32,7 @@ For example, if the **config.xml** file is stored in **/system/etc/config.xml** **Example** ```js configPolicy.getOneCfgFile('etc/config.xml', (error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); @@ -73,7 +73,8 @@ Obtains the path of a configuration file with the specified name and highest pri getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>) -Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses an asynchronous callback to return the result. For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys_pod/etc/config.xml**, then **/system/etc/config.xml, /sys_pod/etc/config.xml** is returned. +Obtains a list of configuration files with the specified name, sorted in ascending order of priority. This API uses an asynchronous callback to return the result. +For example, if the **config.xml** file is stored in **/system/etc/config.xml** and **/sys_pod/etc/config.xml** (in ascending order of priority), then **/system/etc/config.xml, /sys_pod/etc/config.xml** is returned. **System capability**: SystemCapability.Customization.ConfigPolicy @@ -86,7 +87,7 @@ Obtains all configuration files with the specified name and lists them in ascend **Example** ```js configPolicy.getCfgFiles('etc/config.xml', (error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); @@ -99,7 +100,7 @@ Obtains all configuration files with the specified name and lists them in ascend getCfgFiles(relPath: string): Promise<Array<string>> -Obtains all configuration files with the specified name and lists them in ascending order of priority. This API uses a promise to return the result. +Obtains a list of configuration files with the specified name, sorted in ascending order of priority. This API uses a promise to return the result. **System capability**: SystemCapability.Customization.ConfigPolicy @@ -127,7 +128,7 @@ Obtains all configuration files with the specified name and lists them in ascend getCfgDirList(callback: AsyncCallback<Array<string>>) -Obtains the configuration level directory list. This API uses an asynchronous callback to return the result. +Obtains the list of configuration level directories. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Customization.ConfigPolicy @@ -139,7 +140,7 @@ Obtains the configuration level directory list. This API uses an asynchronous ca **Example** ```js configPolicy.getCfgDirList((error, value) => { - if (error == undefined) { + if (error == null) { console.log("value is " + value); } else { console.log("error occurs "+ error); @@ -152,7 +153,7 @@ Obtains the configuration level directory list. This API uses an asynchronous ca getCfgDirList(): Promise<Array<string>> -Obtains the configuration level directory list. This API uses a promise to return the result. +Obtains the list of configuration level directories. This API uses a promise to return the result. **System capability**: SystemCapability.Customization.ConfigPolicy diff --git a/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md index 4c04dd7a835c647889d70dff754d6baf14730efb..3b3a18170e3cdfb1c301174c940ff9e14b6fa7f0 100644 --- a/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md +++ b/en/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -10,16 +10,18 @@ Currently, this module provides incomplete functions, and its APIs are mainly us ## Modules to Import -```js +```ts import continuationManager from '@ohos.continuation.continuationManager' ``` -## continuationManager.register +## continuationManager.register(deprecated) register(callback: AsyncCallback\): void; Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -28,9 +30,19 @@ Registers the continuation management service and obtains a token. This API does | -------- | -------- | -------- | -------- | | callback | AsyncCallback\ | Yes| Callback used to return the token generated after the continuation management service is connected.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360207 | The maximum number of registrations exceeded. | + **Example** - ```js + ```ts let token = -1; continuationManager.register((err, data) => { if (err.code != 0) { @@ -42,12 +54,14 @@ Registers the continuation management service and obtains a token. This API does }); ``` -## continuationManager.register +## continuationManager.register(deprecated) register(options: ContinuationExtraParams, callback: AsyncCallback\): void; Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -57,9 +71,20 @@ Registers the continuation management service and obtains a token. This API uses | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| | callback | AsyncCallback\ | Yes| Callback used to return the token generated after the continuation management service is connected.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360207 | The maximum number of registrations exceeded. | +| 29360216 | Invalid continuation mode. | + **Example** - ```js + ```ts let token = -1; let continuationExtraParams = { deviceType: ["00E"] @@ -74,12 +99,14 @@ Registers the continuation management service and obtains a token. This API uses }); ``` -## continuationManager.register +## continuationManager.register(deprecated) register(options?: ContinuationExtraParams): Promise\; Registers the continuation management service and obtains a token. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -94,9 +121,20 @@ Registers the continuation management service and obtains a token. This API uses | ------------------------- | ------------------ | | Promise\ | Promise used to return the token generated after the continuation management service is connected.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object | +| 7 | The object is null. | +| 29360207 | The maximum number of registrations exceeded. | +| 29360216 | Invalid continuation mode. | + **Example** - ```js + ```ts let token = -1; let continuationExtraParams = { deviceType: ["00E"] @@ -111,13 +149,159 @@ Registers the continuation management service and obtains a token. This API uses }); ``` +## continuationManager.registerContinuation9+ + +registerContinuation(callback: AsyncCallback\): void; + +Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback\ | Yes| Callback used to return the token generated after the continuation management service is connected.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600003 | The number of token registration times has reached the upper limit. | + +**Example** + + ```ts + let token = -1; + try { + continuationManager.registerContinuation((err, data) => { + if (err.code != 0) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.registerContinuation9+ + +registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\): void; + +Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| + | callback | AsyncCallback\ | Yes| Callback used to return the token generated after the continuation management service is connected.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600003 | The number of token registration times has reached the upper limit. | + +**Example** + + ```ts + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.registerContinuation(continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.registerContinuation9+ + +registerContinuation(options?: ContinuationExtraParams): Promise\; + +Registers the continuation management service and obtains a token. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the token generated after the continuation management service is connected.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600003 | The number of token registration times has reached the upper limit. | + +**Example** + + ```ts + let token = -1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.register(continuationExtraParams) + .then((data) => { + console.info('registerContinuation finished, ' + JSON.stringify(data)); + token = data; + }) + .catch((err) => { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('registerContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + + ## continuationManager.on("deviceConnect")(deprecated) on(type: "deviceConnect", callback: Callback\): void; Subscribes to device connection events. This API uses an asynchronous callback to return the result. -> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect9) instead. +> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceselected9) instead. **System capability**: SystemCapability.Ability.DistributedAbilityManager @@ -128,9 +312,21 @@ Subscribes to device connection events. This API uses an asynchronous callback t | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object | +| 7 | The object is null | 7 | +| 29360208 | The token has not registered. | +| 29360209 | Callback has been registered. | +| 29360214 | The type of callback is not supported. | + **Example** - ```js + ```ts continuationManager.on("deviceConnect", (data) => { console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); @@ -144,7 +340,7 @@ on(type: "deviceDisconnect", callback: Callback\): void; Subscribes to device disconnection events. This API uses an asynchronous callback to return the result. -> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect9) instead. +> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceunselected9) instead. **System capability**: SystemCapability.Ability.DistributedAbilityManager @@ -153,11 +349,23 @@ Subscribes to device disconnection events. This API uses an asynchronous callbac | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| - | callback | Callback\ | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + | callback | Callback\ | Yes| Callback invoked when a device is unselected from the device list provided by the device selection module. This callback returns the device ID.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360209 | Callback has been registered. | +| 29360214 | The type of callback is not supported. | **Example** - ```js + ```ts continuationManager.on("deviceDisconnect", (data) => { console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); }); @@ -169,7 +377,7 @@ off(type: "deviceConnect", callback?: Callback\): void; Unsubscribes from device connection events. This API uses an asynchronous callback to return the result. -> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect9) instead. +> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceselected9) instead. **System capability**: SystemCapability.Ability.DistributedAbilityManager @@ -180,9 +388,21 @@ Unsubscribes from device connection events. This API uses an asynchronous callba | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | No| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360214 | The type of callback is not supported. | + **Example** - ```js + ```ts continuationManager.off("deviceConnect", (data) => { console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id)); console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type)); @@ -196,7 +416,7 @@ off(type: "deviceDisconnect", callback?: Callback\): void; Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result. -> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect9) instead. +> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceunselected9) instead. **System capability**: SystemCapability.Ability.DistributedAbilityManager @@ -205,125 +425,209 @@ Unsubscribes from device disconnection events. This API uses an asynchronous cal | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| - | callback | Callback\ | No| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + | callback | Callback\ | No| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360214 | The type of callback is not supported. | **Example** - ```js + ```ts continuationManager.off("deviceDisconnect", (data) => { console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data)); }); ``` -## continuationManager.on("deviceConnect")9+ +## continuationManager.on("deviceSelected")9+ -on(type: "deviceConnect", token: number, callback: Callback\>): void; +on(type: "deviceSelected", token: number, callback: Callback\>): void; Subscribes to device connection events. This API uses an asynchronous callback to return the result. +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | type | string | Yes| Event type. The value is fixed at **deviceSelected**.| | token | number | Yes| Token obtained after the registration of the continuation management service.| | callback | Callback\> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | +| 16600004 | The specified callback has been registered. | + **Example** - ```js + ```ts let token = 1; - continuationManager.on("deviceConnect", token, (data) => { - console.info('onDeviceConnect len: ' + data.length); - for (let i = 0; i < data.length; i++) { - console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id)); - console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type)); - console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name)); - } - }); + try { + continuationManager.on("deviceSelected", token, (data) => { + console.info('onDeviceSelected len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceSelected deviceId: ' + JSON.stringify(data[i].id)); + console.info('onDeviceSelected deviceType: ' + JSON.stringify(data[i].type)); + console.info('onDeviceSelected deviceName: ' + JSON.stringify(data[i].name)); + } + }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` -## continuationManager.on("deviceDisconnect")9+ +## continuationManager.on("deviceUnselected")9+ -on(type: "deviceDisconnect", token: number, callback: Callback\>): void; +on(type: "deviceUnselected", token: number, callback: Callback\>): void; Subscribes to device disconnection events. This API uses an asynchronous callback to return the result. +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | type | string | Yes| Event type. The value is fixed at **deviceUnselected**.| | token | number | Yes| Token obtained after the registration of the continuation management service.| - | callback | Callback\> | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.| + | callback | Callback\> | Yes| Callback invoked when a device is unselected from the device list provided by the device selection module. This callback returns the device ID, type, and name.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | +| 16600004 | The specified callback has been registered. | **Example** - ```js + ```ts let token = 1; - continuationManager.on("deviceDisconnect", token, (data) => { - console.info('onDeviceDisconnect len: ' + data.length); - for (let i = 0; i < data.length; i++) { - console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i])); - } - console.info('onDeviceDisconnect finished.'); - }); + try { + continuationManager.on("deviceUnselected", token, (data) => { + console.info('onDeviceUnselected len: ' + data.length); + for (let i = 0; i < data.length; i++) { + console.info('onDeviceUnselected deviceId: ' + JSON.stringify(data[i].id)); + console.info('onDeviceUnselected deviceType: ' + JSON.stringify(data[i].type)); + console.info('onDeviceUnselected deviceName: ' + JSON.stringify(data[i].name)); + } + console.info('onDeviceUnselected finished.'); + }); + } catch (err) { + console.error('on failed, cause: ' + JSON.stringify(err)); + } ``` -## continuationManager.off("deviceConnect")9+ +## continuationManager.off("deviceSelected")9+ -off(type: "deviceConnect", token: number): void; +off(type: "deviceSelected", token: number): void; Unsubscribes from device connection events. +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is fixed at **deviceConnect**.| + | type | string | Yes| Event type. The value is fixed at **deviceSelected**.| | token | number | Yes| Token obtained after the registration of the continuation management service.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | +| 16600004 | The specified callback has been registered. | + **Example** - ```js + ```ts let token = 1; - continuationManager.off("deviceConnect", token); + try { + continuationManager.off("deviceSelected", token); + } catch (err) { + console.error('off failed, cause: ' + JSON.stringify(err)); + } ``` -## continuationManager.off("deviceDisconnect")9+ +## continuationManager.off("deviceUnselected")9+ -off(type: "deviceDisconnect", token: number): void; +off(type: "deviceUnselected", token: number): void; Unsubscribes from device disconnection events. +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.| + | type | string | Yes| Event type. The value is fixed at **deviceUnselected**.| | token | number | Yes| Token obtained after the registration of the continuation management service.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | +| 16600004 | The specified callback has been registered. | + **Example** - ```js + ```ts let token = 1; - continuationManager.off("deviceDisconnect", token); + try { + continuationManager.off("deviceUnselected", token); + } catch (err) { + console.error('off failed, cause: ' + JSON.stringify(err)); + } ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, callback: AsyncCallback\): void; Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -333,9 +637,22 @@ Starts the device selection module to show the list of available devices on the | token | number | Yes| Token obtained after the registration of the continuation management service.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360211 | Failed to connect ability. | +| 29360216 | Invalid continuation mode. | + **Example** - ```js + ```ts let token = 1; continuationManager.startDeviceManager(token, (err, data) => { if (err.code != 0) { @@ -346,12 +663,14 @@ Starts the device selection module to show the list of available devices on the }); ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void; Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -362,9 +681,22 @@ Starts the device selection module to show the list of available devices on the | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object | +| 7 | The object is null | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360211 | Failed to connect ability. | +| 29360216 | Invalid continuation mode. | + **Example** - ```js + ```ts let token = 1; let continuationExtraParams = { deviceType: ["00E"] @@ -378,12 +710,14 @@ Starts the device selection module to show the list of available devices on the }); ``` -## continuationManager.startDeviceManager +## continuationManager.startDeviceManager(deprecated) startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\; Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -399,9 +733,22 @@ Starts the device selection module to show the list of available devices on the | ------------------------- | ------------------ | | Promise\ | Promise used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object | +| 7 | The object is null | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360211 | Failed to connect ability. | +| 29360216 | Invalid continuation mode. | + **Example** - ```js + ```ts let token = 1; let continuationExtraParams = { deviceType: ["00E"] @@ -415,12 +762,159 @@ Starts the device selection module to show the list of available devices on the }); ``` -## continuationManager.updateConnectStatus +## continuationManager.startContinuationDeviceManager9+ + +startContinuationDeviceManager(token: number, callback: AsyncCallback\): void; + +Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + try { + continuationManager.startContinuationDeviceManager(token, (err, data) => { + if (err.code != 0) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.startContinuationDeviceManager9+ + +startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\): void; + +Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.| + | callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.startContinuationDeviceManager(token, continuationExtraParams, (err, data) => { + if (err.code != 0) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.startContinuationDeviceManager9+ + +startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\; + +Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + let continuationExtraParams = { + deviceType: ["00E"] + }; + try { + continuationManager.startContinuationDeviceManager(token, continuationExtraParams) + .then((data) => { + console.info('startContinuationDeviceManager finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.updateConnectStatus(deprecated) updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void; Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [updateContinuationState](#continuationmanagerupdatecontinuationstate9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -432,9 +926,22 @@ Instructs the device selection module to update the device connection state. Thi | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360211 | Failed to connect ability. | +| 29360215 | Invalid connect state. | + **Example** - ```js + ```ts let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { @@ -446,12 +953,14 @@ Instructs the device selection module to update the device connection state. Thi }); ``` -## continuationManager.updateConnectStatus +## continuationManager.updateConnectStatus(deprecated) updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\; Instructs the device selection module to update the device connection state. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [updateContinuationState](#continuationmanagerupdatecontinuationstate9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -468,9 +977,22 @@ Instructs the device selection module to update the device connection state. Thi | ------------------------- | ------------------ | | Promise\ | Promise used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | +| 29360210 | Callback has not registered. | +| 29360211 | Failed to connect ability. | +| 29360215 | Invalid connect state. | + **Example** - ```js + ```ts let token = 1; let deviceId: string = "test deviceId"; continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) @@ -482,12 +1004,114 @@ Instructs the device selection module to update the device connection state. Thi }); ``` -## continuationManager.unregister +## continuationManager.updateContinuationState9+ + +updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\): void; + +Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | deviceId | string | Yes| Device ID.| + | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.| + | callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + let deviceId: string = "test deviceId"; + try { + continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => { + if (err.code != 0) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.updateContinuationState9+ + +updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\; + +Instructs the device selection module to update the device connection state. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | deviceId | string | Yes| Device ID.| + | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + let deviceId: string = "test deviceId"; + try { + continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED) + .then((data) => { + console.info('updateContinuationState finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('updateContinuationState failed, cause: ' + JSON.stringify(err)); + } + ``` + + +## continuationManager.unregister(deprecated) unregister(token: number, callback: AsyncCallback\): void; Deregisters the continuation management service. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [unregisterContinuation](#continuationmanagerunregistercontinuation9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -497,9 +1121,19 @@ Deregisters the continuation management service. This API uses an asynchronous c | token | number | Yes| Token obtained after the registration of the continuation management service.| | callback | AsyncCallback\ | Yes| Callback used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | + **Example** - ```js + ```ts let token = 1; continuationManager.unregister(token, (err, data) => { if (err.code != 0) { @@ -510,12 +1144,14 @@ Deregisters the continuation management service. This API uses an asynchronous c }); ``` -## continuationManager.unregister +## continuationManager.unregister(deprecated) unregister(token: number): Promise\; Deregisters the continuation management service. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [unregisterContinuation](#continuationmanagerunregistercontinuation9) instead. + **System capability**: SystemCapability.Ability.DistributedAbilityManager **Parameters** @@ -530,9 +1166,19 @@ Deregisters the continuation management service. This API uses a promise to retu | ------------------------- | ------------------ | | Promise\ | Promise used to return the result.| +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 3 | Failed to flatten the object. | +| 7 | The object is null. | +| 29360208 | The token has not registered. | + **Example** - ```js + ```ts let token = 1; continuationManager.unregister(token) .then((data) => { @@ -543,6 +1189,100 @@ Deregisters the continuation management service. This API uses a promise to retu }); ``` +## continuationManager.unregisterContinuation9+ + +unregisterContinuation(token: number, callback: AsyncCallback\): void; + +Deregisters the continuation management service. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + | callback | AsyncCallback\ | Yes| Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + try { + continuationManager.unregisterContinuation(token, (err, data) => { + if (err.code != 0) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + return; + } + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + +## continuationManager.unregisterContinuation9+ + +unregisterContinuation(token: number): Promise\; + +Deregisters the continuation management service. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.DistributedAbilityManager + +**Parameters** + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | token | number | Yes| Token obtained after the registration of the continuation management service.| + +**Return value** + +| Type | Description | +| ------------------------- | ------------------ | +| Promise\ | Promise used to return the result.| + +**Error codes** + +For details about the error codes, see [Distributed Scheduler Error Codes](../errorcodes/errcode-DistributedSchedule.md). + +| ID| Error Message| +| ------- | -------------------------------------------- | +| 401 | The parameter check failed. | +| 16600001 | The system ability work abnormally. | +| 16600002 | The specified token or callback has not registered. | + +**Example** + + ```ts + let token = 1; + try { + continuationManager.unregisterContinuation(token) + .then((data) => { + console.info('unregisterContinuation finished, ' + JSON.stringify(data)); + }) + .catch((err) => { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + }); + } catch (err) { + console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err)); + } + ``` + + ## DeviceConnectState Enumerates the device connection states. diff --git a/en/application-dev/reference/apis/js-apis-cooperate.md b/en/application-dev/reference/apis/js-apis-cooperate.md new file mode 100644 index 0000000000000000000000000000000000000000..96fa3ebc9ff8fadf13097fd6042339ad202f186c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-cooperate.md @@ -0,0 +1,390 @@ +# Screen Hopping + +The Screen Hopping module enables two or more networked devices to share the keyboard and mouse for collaborative operations. + +> **Description** +> +> 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 inputDeviceCooperate from '@ohos.multimodalInput.inputDeviceCooperate' +``` + +## inputDeviceCooperate.enable + +enable(enable: boolean, callback: AsyncCallback<void>): void + +Specifies whether to enable screen hopping. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | --------------------------- | +| enable | boolean | Yes | Whether to enable screen hopping.| +| callback | AsyncCallback<void> | Yes |Callback used to return the result. | + + + +**Example** + +```js +try { + inputDeviceCooperate.enable(true, (error) => { + if (error) { + console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Keyboard mouse crossing enable success.`); + }); +} catch (error) { + console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.enable + +enable(enable: boolean): Promise<void> + +Specifies whether to enable screen hopping. This API uses a promise to return the result. + + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ------- | ---- | ------------------------------------------------------------------- | +| enable | boolean | Yes | Whether to enable screen hopping. | + + + +**Return value** + +| Name | Description | +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result. | + + + +**Example** + +```js +try { + inputDeviceCooperate.enable(true).then(() => { + console.log(`Keyboard mouse crossing enable success.`); + }, (error) => { + console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + }); +} catch (error) { + console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.start + +start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback\): void + +Starts screen hopping. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| sinkDeviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. | +| srcInputDeviceId | number | Yes | ID of the target device for screen hopping. | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| + +**Error codes** + +For details about the error codes, see [Screen Hopping Error Codes](../errorcodes/errorcodes-multimodalinput.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. | +| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. | + +**Example** + +```js +try { + inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => { + if (error) { + console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Start Keyboard mouse crossing success.`); + }); +} catch (error) { + console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.start + +start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ + +Starts screen hopping. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| sinkDeviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. | +| srcInputDeviceId | number | Yes | ID of the target device for screen hopping. | + + + +**Return value** + +| Name | Description | +| ---------------------- | ------------------------------- | +| Promise\ | Promise used to return the result. | + +**Error codes** + +For details about the error codes, see [Screen Hopping Error Codes](../errorcodes/errorcodes-multimodalinput.md). + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. | +| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. | + +**Example** + +```js +try { + inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => { + console.log(`Start Keyboard mouse crossing success.`); + }, (error) => { + console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + }); +} catch (error) { + console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.stop + +stop(callback: AsyncCallback\): void + +Stops screen hopping. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback\ | Yes | Callback used to return the result. | + + + +**Example** + +```js +try { + inputDeviceCooperate.stop((error) => { + if (error) { + console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Stop Keyboard mouse crossing success.`); + }); +} catch (error) { + console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.stop + +stop(): Promise\ + +Stops screen hopping. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Description | +| -------- | ---------------------------- | +| Promise\ | Promise used to return the result. | + +**Example** + +```js +try { + inputDeviceCooperate.stop().then(() => { + console.log(`Stop Keyboard mouse crossing success.`); + }, (error) => { + console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + }); +} catch (error) { + console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.getState + +getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void + +Checks whether screen hopping is enabled. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | --------- | ---- | ---------------------------- | +| deviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. | +| callback | AsyncCallback<{ state: boolean }> | Yes | Callback used to return the result. | + +**Example** + +```js +try { + inputDeviceCooperate.getState(deviceDescriptor, (error, data) => { + if (error) { + console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Get the status success, data: ${JSON.stringify(data)}`); + }); +} catch (error) { + console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## inputDeviceCooperate.getState + +getState(deviceDescriptor: string): Promise<{ state: boolean }> + +Checks whether screen hopping is enabled. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | --------- | ---- | ---------------------------- | +| deviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. | + + + +**Return value** + +| Name | Description | +| ------------------- | ------------------------------- | +| Promise<{ state: boolean }>| Promise used to return the result. | + + + +**Example** + +```js +try { + inputDeviceCooperate.getState(deviceDescriptor).then((data) => { + console.log(`Get the status success, data: ${JSON.stringify(data)}`); + }, (error) => { + console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + }); +} catch (error) { + console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## on('cooperation') + +on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void + +Enables listening for screen hopping events. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | Yes | Event type. The value is **cooperation**. | +| callback | AsyncCallback<{ deviceDescriptor: string, eventMsg: [EventMsg](#eventmsg) }> | Yes | Callback used to return the result. | + + + +**Example** + +```js +try { + inputDeviceCooperate.on('cooperation', (data) => { + console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`); + }); +} catch (err) { + console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## off('cooperation') + +off(type: 'cooperation', callback?: AsyncCallback\): void + +Disables listening for screen hopping events. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------------- | +| type | string | Yes | Event type. The value is **cooperation**. | +| callback | AsyncCallback | No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.| + + + +**Example** + +```js +// Unregister a single callback. +callback: function(event) { + console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); + return false; +}, +try { + inputDeviceCooperate.on('cooperation', this.callback); + inputDeviceCooperate.off("cooperation", this.callback); +} catch (error) { + console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` +```js +// Unregister all callbacks. +callback: function(event) { + console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); + return false; +}, +try { + inputDeviceCooperate.on('cooperation', this.callback); + inputDeviceCooperate.off("cooperation"); +} catch (error) { + console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## EventMsg + +Enumerates screen hopping event. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate + +| Name | Value | Description | +| -------- | --------- | ----------------- | +| MSG_COOPERATE_INFO_START | 200 | Screen hopping starts. | +| MSG_COOPERATE_INFO_SUCCESS | 201 | Screen hopping succeeds. | +| MSG_COOPERATE_INFO_FAIL | 202 | Screen hopping fails. | +| MSG_COOPERATE_STATE_ON | 500 | Screen hopping is enabled. | +| MSG_COOPERATE_STATE_OFF | 501 | Screen hopping is disabled. | diff --git a/en/application-dev/reference/apis/js-apis-cryptoFramework.md b/en/application-dev/reference/apis/js-apis-cryptoFramework.md new file mode 100644 index 0000000000000000000000000000000000000000..30d79a672420f70d0ab3067857e8726ab8a7ba32 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-cryptoFramework.md @@ -0,0 +1,2145 @@ +# Crypto Framework + +The **cryptoFramework** module shields underlying hardware and algorithm libraries and provides unified APIs for crytographic operations. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 9. + +## Modules to Import + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" +``` + +## Result + + Enumerates the error codes. + + **System capability**: SystemCapability.Security.CryptoFramework + +| Name | Default Value | Description | +| --------------------------------------| -------- | -------------------------| +| INVALID_PARAMS | 401 | Invalid parameters. | +| NOT_SUPPORT | 801 | This operation is not supported. | +| ERR_OUT_OF_MEMORY | 17620001 | Memory error. | +| ERR_RUNTIME_ERROR | 17620002 | Runtime error. | +| ERR_CRYPTO_OPERATION | 17630001 | Crypto operation error. | + +## DataBlob +Defines a binary data array. + **System capability**: SystemCapability.Security.CryptoFramework +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ----------------| +| data | Uint8Array | Yes | Yes | Data. | + +## cryptoFramework.createMac + +createMac(algName : string) : Mac + +Creates a **Mac** instance for message authentication code (MAC) operations. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| algName | string | Yes | Digest algorithm to use, which can be SHA-1, SHA-224, SHA-256, SHA-384, or SHA-512.| + +**Return value** + +| Type| Description | +| ---- | --------------------------------------- | +| Mac | [Mac](#mac) instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +``` + +## Mac + +Provides APIs for MAC operations. Before using any API of the **Mac** class, you must create a **Mac** instance by using [createMac](#cryptoframeworkcreatemac). + +### **Attributes** + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | -------------------- | +| algName | string | Yes | No | Digest algorithm to use.| + +### init + +init(key : SymKey, callback : AsyncCallback\) : void; + +Initializes the MAC computation using a symmetric key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| key | SymKey | Yes | Shared symmetric key. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +var KeyBlob; +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +symKeyGenerator.convertKey(KeyBlob, (err, symKey) => { + if (err) { + console.error("[Callback] err: " + err.code); + } + mac.init(symKey, (err1, ) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } + }); +}); +``` + + + +### init + +init(key : SymKey) : Promise\; + +Initializes the MAC computation using a symmetric key. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------ | +| key | SymKey | Yes | Shared symmetric key.| + +**Return value** + +| Type | Description | +| --------------- | ------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + AlertDialog.show({message: "[Promise]: error code: " + error.code + ", message is: " + error.message}); + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); + +} +console.error("Mac algName is: " + mac.algName); + +var KeyBlob; +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); +promiseConvertKey.then(symKey => { + var promiseMacInit = mac.init(symKey); + return promiseMacInit; +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); + +``` + +### update + +update(input : DataBlob, callback : AsyncCallback\) : void; + +Updates the MAC computation data. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ---------- | +| input | DataBlob | Yes | Message to pass in. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var KeyBlob; +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + AlertDialog.show({message: "[Callback]: error code: " + error.code + ", message is: " + error.message}); + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +symKeyGenerator.convertKey(KeyBlob, (err, symKey) => { + if (err) { + console.error("[Callback] err: " + err.code); + } + mac.init(symKey, (err1, ) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } + let blob; + mac.update(blob, (err2, data) => { + if (err2) { + console.error("[Callback] err: " + err2.code); + } + }); + }); +}); +``` + +### update + +update(input : DataBlob) : Promise\; + +Updates the MAC computation data. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| input | DataBlob | Yes | Message to pass in.| + +**Return value** + +| Type | Description | +| --------------- | ----------- | +| Promise\ | Promise used to return the result.| + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + AlertDialog.show({message: "[Promise]: error code: " + error.code + ", message is: " + error.message}); + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Mac algName is: " + mac.algName); +AlertDialog.show({message: "Mac algName is: " + mac.algName}); + +var KeyBlob; + +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); +promiseConvertKey.then(symKey => { + var promiseMacInit = mac.init(symKey); + return promiseMacInit; +}).then(() => { + let blob; + var promiseMacUpdate = mac.update(blob); + return promiseMacUpdate; +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); + +``` + + + +### doFinal + +doFinal(callback : AsyncCallback\) : void; + +Finalizes the MAC computation. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var KeyBlob; +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + AlertDialog.show({message: "[Callback]: error code: " + error.code + ", message is: " + error.message}); + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +symKeyGenerator.convertKey(KeyBlob, (err, symKey) => { + if (err) { + console.error("[Callback] err: " + err.code); + } + mac.init(symKey, (err1, ) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } + let blob; + mac.update(blob, (err2, ) => { + if (err2) { + console.error("[Callback] err: " + err2.code); + } + mac.doFinal((err3, macOutput) => { + if (err3) { + console.error("[Callback] err: " + err3.code); + } else { + console.error("[Promise]: HMAC result: " + macOutput); + } + }); + }); + }); +}); +``` + +### doFinal + +doFinal() : Promise\ + +Finalizes the MAC computation. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| ------------------- | ----------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Mac algName is: " + mac.algName); +AlertDialog.show({message: "Mac algName is: " + mac.algName}); + +var KeyBlob; +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); +promiseConvertKey.then(symKey => { + var promiseMacInit = mac.init(symKey); + return promiseMacInit; +}).then(() => { + let blob; + var promiseMacUpdate = mac.update(blob); + return promiseMacUpdate; +}).then(() => { + var PromiseMacDoFinal = mac.doFinal(); + return PromiseMacDoFinal; +}).then(macOutput => { + console.error("[Promise]: HMAC result: " + macOutput.data); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +### getMacLength + +getMacLength() : number + +Obtains the MAC length, in bytes. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| ------ | ------------------------- | +| number | MAC length obtained.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var mac; +try { + mac = cryptoFramework.createMac("SHA256"); +} catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Mac algName is: " + mac.algName); +AlertDialog.show({message: "Mac algName is: " + mac.algName}); + +var KeyBlob; +var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); +var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); +promiseConvertKey.then(symKey => { + var promiseMacInit = mac.init(symKey); + return promiseMacInit; +}).then(() => { + let blob; + var promiseMacUpdate = mac.update(blob); + return promiseMacUpdate; +}).then(() => { + var PromiseMacDoFinal = mac.doFinal(); + return PromiseMacDoFinal; +}).then(macOutput => { + console.error("[Promise]: HMAC result: " + macOutput.data); + let macLen = mac.getMacLength(); + AlertDialog.show({message: "MAC len: " + macLen}); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +## cryptoFramework.createMd + +createMd(algName : string) : Md + +Creates an **Md** instance for message digest operations. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| algName | string | Yes | Digest algorithm to use, which can be SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, or MD5.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------------- | +| Md | [Md](#md) instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); +} +``` + +## Md + +Provides APIs for message digest operations. Before using any API of the **Md** class, you must create an **Md** instance by using [createMd](#cryptoframeworkcreatemd). + +### **Attributes** + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | -------------------- | +| algName | string | Yes | No | Digest algorithm to use.| + +### update + +update(input : DataBlob, callback : AsyncCallback\) : void; + +Updates the message digest data with the message passed in. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------ | +| input | DataBlob | Yes | Message to pass in. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Md algName is: " + md.algName); + +let blob; +md.update(blob, (err,) => { + if (err) { + console.error("[Callback] err: " + err.code); + } +}); +``` + +### update + +update(input : DataBlob) : Promise\; + +Updates the message digest data with the message passed in. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| input | DataBlob | Yes | Message to pass in.| + +**Return value** + +| Type | Description | +| --------------- | ------------ | +| Promise\ | Promise used to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Md algName is: " + md.algName); + +let blob; +var promiseMdUpdate = md.update(blob); +promiseMdUpdate.then(() => { + // do something +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +### digest + +digest(callback : AsyncCallback\) : void + +Generates a message digest. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Md algName is: " + md.algName); + +let blob; +md.update(blob, (err,) => { + if (err) { + console.error("[Callback] err: " + err.code); + } + md.digest((err1, mdOutput) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } else { + console.error("[Callback]: MD result: " + mdOutput); + } + }); +}); +``` + +### digest + +digest() : Promise\ + +Generates a message digest. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| ------------------- | ----------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Md algName is: " + md.algName); + +let blob; +var promiseMdUpdate = md.update(blob); +promiseMdUpdate.then(() => { + var PromiseMdDigest = md.digest(); + return PromiseMdDigest; +}).then(mdOutput => { + console.error("[Promise]: MD result: " + mdOutput.data); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +### getMdLength + +getMdLength() : number + +Obtains the message digest length, in bytes. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| ------ | ------------------------ | +| number | Message digest length obtained. | + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var md; +try { + md = cryptoFramework.createMd("SHA256"); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +console.error("Md algName is: " + md.algName); + +let blob; +var promiseMdUpdate = md.update(blob); +promiseMdUpdate.then(() => { + var PromiseMdDigest = md.digest(); + return PromiseMdDigest; +}).then(mdOutput => { + console.error("[Promise]: MD result: " + mdOutput.data); + let mdLen = md.getMdLength(); + AlertDialog.show({message: "MD len: " + mdLen}); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +## cryptoFramework.createRandom + +createRandom() : Random + +Creates a **Random** instance for generating random numbers and setting seeds. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| ------ | --------------------------------------------- | +| Random | [Random](#random) instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +try { + var rand = cryptoFramework.createRandom(); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +``` + +## Random + +Provides APIs for computing random numbers. Before using any API of the **Random** class, you must create a **Random** instance by using [createRandom](#cryptoframeworkcreaterandom). + +### generateRandom + +generateRandom(len : number, callback: AsyncCallback\) : void; + +Generates a random number of the given length. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | ------------------------- | ---- | -------------------- | +| len | number | Yes | Length of the random number to generate.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var rand; +try { + rand = cryptoFramework.createRandom(); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} +rand.generateRandom(12, (err, randData) => { + if (err) { + console.error("[Callback] err: " + err.code); + } else { + console.error("[Callback]: generate random result: " + randData.data); + } +}); +``` + +### generateRandom + +generateRandom(len : number) : Promise\; + +Generates a random number of the given length. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------- | +| len | number | Yes | Length of the random number to generate.| + +**Return value** + +| Type | Description | +| ------------------- | ----------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var rand; +try { + rand = cryptoFramework.createRandom(); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} + +var promiseGenerateRand = rand.generateRandom(12); +promiseGenerateRand.then(randData => { + console.error("[Promise]: rand result: " + randData.data); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +### setSeed + +setSeed(seed : DataBlob, callback : AsyncCallback\) : void; + +Sets a seed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------ | +| seed | DataBlob | Yes | Seed to set. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var rand; +try { + rand = cryptoFramework.createRandom(); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} + +rand.generateRandom(12, (err, randData) => { + if (err) { + console.error("[Callback] err: " + err.code); + } else { + console.error("[Callback]: generate random result: " + randData.data); + rand.setSeed(randData, (err1, data) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } else { + console.error("[Callback]: setSeed success"); + } + }); + } +}); +``` + +### setSeed + +setSeed(seed : DataBlob) : Promise\; + +Sets a seed. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| seed | DataBlob | Yes | Seed to set.| + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +var rand; +try { + rand = cryptoFramework.createRandom(); +} catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); +} + +var promiseGenerateRand = rand.generateRandom(12); +promiseGenerateRand.then(randData => { + console.error("[Promise]: rand result: " + randData.data); + var promiseSetSeed = rand.setSeed(randData); + return promiseSetSeed; +}).then(() => { + console.error("[Promise]: setSeed success"); +}).catch(error => { + console.error("[Promise]: error: " + error.message); +}); +``` + +## ParamsSpec + +Defines the parameters for encryption and decryption. For the symmetric encryption and decryption modes that require parameters such as the initialization vector (IV), you need to construct a child class object and pass it to [init()](#init-2). You do not need to construct the child class object if the IV is not required. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| algoName | string | Yes | Yes | Symmetric encryption and decryption parameters.
Options:
- **IvParamsSpec**: applicable to the CBC, CTR, OFB, and CFB modes.
- **GcmParamsSpec**: applicable to the GCM mode.
- **CcmParamsSpec**: applicable to the CCM mode. | + +## IvParamsSpec + +Defines the parameters for the CBC, CTR, OFB, and CFB modes, which require only an IV for each encryption operation. For the symmetric encryption and decryption that use the CBC, CTR, OFB, or CFB mode, you need to construct **IvParamsSpec** and pass it to [init()](#init-2). + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| iv | [DataBlob](#datablob) | Yes | Yes | IV for encryption and decryption.
Options:
- AES CBC, CTR, OFB, or CFB mode: 16-byte IV
- 3DES CBC, OFB or CFB mode: 8-byte IV | + +## GcmParamsSpec + +Defines the parameters for the GCM mode. For the symmetric encryption and decryption that use the GCM mode, you need to construct **GcmParamsSpec** and pass it to [init()](#init-2). + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| iv | [DataBlob](#datablob) | Yes | Yes | IV, which is of 12 bytes.| +| aad | [DataBlob](#datablob) | Yes | Yes | Additional authenticated data (AAD), which is of 8 bytes.| +| authTag | [DataBlob](#datablob) | Yes | Yes | AuthTag, which is of 16 bytes.
When the GCM mode is used for encryption, the last 16 bytes of the [DataBlob](#datablob) returned by [doFinal()](#dofinal-2) are used as the **authTag** in [GcmParamsSpec](#gcmparamsspec) for decryption.| + +## CcmParamsSpec + +Defines the parameters for the CCM mode. For the symmetric encryption and decryption that use the CCM mode, you need to construct **CcmParamsSpec** and pass it to [init()](#init-2). + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | -------- | ---- | ---- | -------------------------------| +| iv | [DataBlob](#datablob) | Yes | Yes | IV, which is of 7 bytes. | +| aad | [DataBlob](#datablob) | Yes | Yes | AAD, which is of 8 bytes. | +| authTag | [DataBlob](#datablob) | Yes | Yes | AuthTag, which is of 12 bytes.
When the CCM mode is used for encryption, the last 12 bytes of the [DataBlob](#datablob) returned by [doFinal()](#dofinal-2) are used as the **authTag** in [CcmParamsSpec](#ccmparamsspec) for decryption.| + +## CryptoMode + +Enumerates the cryptographic operations. + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Value | Description | +| ------------ | -------- | -------------------------------- | +| ENCRYPT_MODE | 0 | Encryption. | +| DECRYPT_MODE | 1 | Decryption. | + +## Key + +Provides APIs for key operations. Before performing cryptographic operations (such as encryption and decryption), you need to construct a child class object of **Key** and pass it to [init()](#init-2) of the [Cipher](#cipher) instance. Keys can be generated by a key generator. + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| format | string | Yes | No | Format of the key.| +| algName | string | Yes | No | Algorithm name (including the key length).| + +### getEncoded + +getEncoded() : DataBlob + +Obtains the key in hexadecimal format. This API returns the result synchronously. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type |Description | +| ------- | ----------- | +| [DataBlob](#datablob) | Key obtained.| + +**Example** + +```js +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +let key; // The key is generated by a symKeyGenerator. The generation process is omitted here. +let encodedKey = key.getEncoded(); +console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); +``` + +## SymKey + +Provides APIs for symmetric key operations. It is a child class of [Key](#key). Its objects need to be passed to [init()](#init-2) of the [Cipher](#cipher) instance in symmetric encryption and decryption. Symmetric keys can be generated by a [SymKeyGenerator](#symkeygenerator). + +### clearMem + +clearMem() : void + +Clears the keys from the memory. This API returns the result synchronously. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Example** + +```js +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +let key; // The key is generated by a symKeyGenerator. The generation process is omitted here. +let encodedKey = key.getEncoded(); +console.info("key hex: "+ uint8ArrayToShowStr(encodedKey.data)); // Display key content. +key.clearMem(); +encodedKey = key.getEncoded(); +console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); // Display all 0s. +``` + +## PubKey + +Provides APIs for public key operations. It is a child class of [Key](#key). Its objects need to be passed in during asymmetric encryption and decryption, signature verification, and key agreement. Public keys can be generated by an **AsyKeyGenerator**. + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| format | string | Yes | No | Format of the key.| +| algName | string | Yes | No | Algorithm name (including the key length).| + + +### getEncoded + +getEncoded() : DataBlob + +Obtains the key in binary format. This API returns the result synchronously. The public key format must comply with the ASN.1 syntax, X.509 specifications, and DER encoding format. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type |Description | +| ------- | ----------- | +| [DataBlob](#datablob) | Key obtained.| + +**Example** + +```js +console.info("key format:" + key.format); +console.info("key algName:" + key.algName); +var encodedKey = key.getEncoded(); +console.info("key encoded:" + Uint8ArrayToShowStr(encodedKey.data)); +``` + +## PriKey + +Provides APIs for private key operations. It is a child class of [Key](#key). Its objects need to be passed in during asymmetric encryption and decryption, signature verification, and key agreement. Private keys can be generated by an **AsyKeyGenerator**. + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------- | +| format | string | Yes | No | Format of the key.| +| algName | string | Yes | No | Algorithm name (including the key length).| + +### getEncoded + +getEncoded() : DataBlob + +Obtains the key in binary format. This API returns the result synchronously. The private key format must comply with the ASN.1 syntax, PKCS #8 specifications, and DER encoding mode. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type |Description | +| ------- | ----------- | +| [DataBlob](#datablob) | Key obtained.| + +**Example** + +```js +console.info("key format:" + key.format); +console.info("key algName:" + key.algName); +var encodedKey = key.getEncoded(); +console.info("key encoded:" + Uint8ArrayToShowStr(encodedKey.data)); +``` + +### clearMem + +clearMem() : void + +Clears the keys from the memory. This API returns the result synchronously. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Example** + +```js +key.clearMem(); +``` + +## cryptoFramework.createSymKeyGenerator + +createSymKeyGenerator(algName : string) : SymKeyGenerator + +Creates a **SymKeyGenerator** instance based on the specified algorithm. For details about the supported symmetric key parameters, see "String for Generating a Key" in [Key Generation Specifications](../../security/cryptoFramework-overview.md#key-generation-specifications). + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ----------------------------- | +| algName | string | Yes | Algorithm used by the **symkeyGenerator**.| + +**Return value** + +| Type | Description | +| ----------------------------------- | -------------------------- | +| [SymKeyGenerator](#symkeygenerator) | **SymKeyGenerator** instance created.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); +``` + +## SymKeyGenerator + +Provides APIs for using the **symKeyGenerator**. Before using any API of the **SymKeyGenerator** class, you must create a **symKeyGenerator** instance by using [createSymKeyGenerator](#cryptoframeworkcreatesymkeygenerator). + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| ------- | ------ | ---- | ---- | ---------------------------- | +| algName | string | Yes | No | Algorithm used by the **symKeyGenerator**.| + +### generateSymKey + +generateSymKey(callback : AsyncCallback\) : void + +Generates a key randomly. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------- | ---- | ------------------- | +| callback | AsyncCallback\<[SymKey](#symkey)> | Yes | Callback invoked to return the symmetric key generated.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symAlgoName = '3DES192'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); +symKeyGenerator.generateSymKey((err, symKey) => { + if (err) { + console.error('Failed to generate symKey'); + return; + } + console.log('Generate symKey success, algName: ' + symKey.algName); +}) +``` + +### generateSymKey + +generateSymKey() : Promise\ + +Generates a key randomly. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------- | +| Promise\<[SymKey](#symkey)> | Promise used to return the symmetric key generated.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symAlgoName = 'AES128'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); +symKeyGenerator.generateSymKey().then((symKey) => { + console.log('Generate symKey success, algName:' + symKey.algName); +}) +``` + +### convertKey + +convertKey(key : DataBlob, callback : AsyncCallback\) : void + +Converts a key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------- | ---- | ---------------------- | +| key | [DataBlob](#datablob) | Yes | Key to convert. | +| callback | AsyncCallback\<[SymKey](#symkey)> | Yes | Callback invoked to return the symmetric key generated.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + +let symAlgoName = '3DES192'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); +let keyMaterialBlob = genKeyMaterialBlob(); +symKeyGenerator.convertKey(keyMaterial, (err, symKey) => { + if (err) { + console.error('Failed to convert symKey'); + return; + } + console.log('Convert symKey success, algName:' + symKey.algName); +}) +``` + +### convertKey + +convertKey(key : DataBlob) : Promise\ + +Converts a key. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | -------- | ---- | -------------------- | +| key | [DataBlob](#datablob) | Yes | Key to convert.| + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------- | +| Promise\<[SymKey](#symkey)> | Promise used to return the symmetric key generated.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + +let symAlgoName = '3DES192'; +let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); +let keyMaterialBlob = genKeyMaterialBlob(); +symKeyGenerator.convertKey(keyMaterial).then((symKey) => { + console.log('Convert symKey success, algName:' + symKey.algName); +}) +``` + +## cryptoFramework.createAsyKeyGenerator + +createAsyKeyGenerator(algName : string) : AsyKeyGenerator +Creates an **AsyKeyGenerator** instance based on the specified algorithm. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | -------------------------------- | +| algName | string | Yes | Algorithm used by the **symkeyGenerator**.| + +**Return value** + +| Type | Description | +| --------------- | -------------------------- | +| asyKeyGenerator | **AsyKeyGenerator** instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); +``` + +## AsyKeyGenerator + +Provides APIs for using the **AsKeyGenerator**. Before using any API of the **AsKeyGenerator** class, you must create an **AsyKeyGenerator** instance by using **createAsyKeyGenerator()**. + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + +| Name | Type | Readable| Writable| Description | +| -------------- | -------------- | ---- | ---- | ----------------------------------| +| algName | string | Yes | No | Algorithm used by the **AsKeyGenerator**. | + + + +### generateKeyPair + +generateKeyPair(callback : AsyncCallback\) : void; +Generates a key pair randomly. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback\ | Yes | Callback invoked to return the key pair obtained.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); +asyKeyGenerator.generateKeyPair((err, keyPair) => { + if (err) { + console.error("generateKeyPair: error."); + return; + } + console.info("generateKeyPair: success."); +}) +``` + + +### generateKeyPair + +generateKeyPair() : Promise\ +Generates a key pair randomly. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------- | +| Promise\ | Promise used to return the key pair generated.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); +let keyGenPromise = asyKeyGenerator.generateKeyPair(); +keyGenPromise.then( keyPair => { + console.info("generateKeyPair success."); +}).catch(error => { + console.error("generateKeyPair error."); +}); +``` + +### convertKey + +convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\) : void +Converts an asymmetric key. This API uses an asynchronous callback to return the result. For details, see **Key Conversion**. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------- | ---- | ---------------------------- | +| pubKey | DataBlob | No | Public key material to convert. | +| priKey | DataBlob | No | Private key material to convert. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the key pair obtained.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); +asyKeyGenerator.convertKey(pubKey, priKey, (err, keyPair) => { + if (err) { + console.error("convertKey: error."); + return; + } + console.info("convertKey: success."); +}) +``` + +### convertKey + +convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\ +Converts an asymmetric key. This API uses a promise to return the result. For details, see **Key Conversion**. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | -------- | ---- | -------------------- | +| pubKey | DataBlob | No | Public key material to convert. | +| priKey | DataBlob | No | Private key material to convert. | + +**Return value** + +| Type | Description | +| --------------------- | ------------------------------- | +| Promise\ | Promise used to return the key pair generated.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let asyKeyGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); +let keyGenPromise = asyKeyGenerator.convertKey(pubKey, priKey); +keyGenPromise.then( keyPair => { + console.info("convertKey success."); +}).catch(error => { + console.error("convertKey error."); +}); +``` + +**Key Conversion** + +- After **getEncoded()** is called for the asymmetric public and private keys (RSA and ECC), binary data in X.509 and PKCS #8 formats is returned, respectively. The data can be used for cross-application transfer or persistent storage. +- The public key returned by **convertKey()** must comply with the ASN.1 syntax, X.509 specifications, and DER encoding format, and the private key must comply with the ASN.1 syntax, PKCS #8 specifications, and DER encoding format. +- In **convertKey()**, **pubKey** and **priKey** are optional. Either **pubKey** or **priKey** can be passed in. As a result, the returned **KeyPair** instance contains only the key converted from the data you passed in. + +## cryptoFramework.createCipher + +createCipher(transformation : string) : Cipher +Creates a [Cipher](#cipher) instance based on the specified algorithm. +For details about the supported algorithms, see "Algorithm String" in [Encryption and Decryption Specifications](../../security/cryptoFramework-overview.md#encryption-and-decryption-specifications). + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------------- | ------ | -------- | ------------------------------------------------------------ | +| transformation | string | Yes | Combination of the algorithm name, encryption mode, and padding algorithm of the **Cipher** instance to create. For example, **RSA1024\|PKCS1** or **RSA1024\|PKCS1_OAEP\|SHA256\|SHA256**.| + +**Return value** + +| Type | Description | +| ------ | ------------------------ | +| [Cipher](#cipher) | [Cipher](#cipher) instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let cipherAlgoName = '3DES192|ECB|PKCS7'; +var cipher; +try { + cipher = cryptoFramework.createCipher(cipherAlgoName); + console.info(`cipher algName: ${cipher.algName}`); +} catch (error) { + console.error(`createCipher failed, ${error.code}, ${error.message}`); + return; +} +``` + +## Cipher + +Provides APIs for cipher operations. The [init()](#init-2), [update()](#update-4), and [doFinal()](#dofinal-2) APIs in this class are called in sequence to implement symmetric encryption or decryption and asymmetric encryption or decryption. For details about the complete encryption and decryption process, see [Encryption and Decryption Operations](../../security/cryptoFramework-guidelines.md#encryption-and-decryption-operations). + +### Attributes + +**System capability**: SystemCapability.Security.CryptoFramework + + +| Name | Type | Readable | Writable | Description | +| ------- | ------ | -------- | ----------- | ---------------------------- | +| algName | string | Yes | No | Algorithm to use.| + +### init + +init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallback\) : void + +Initializes a [cipher](#cipher) instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------------------------ | ------- | ------------------------ | +| opMode | [CryptoMode](#cryptomode) | Yes | Operation (encryption or decryption) to perform. | +| key | [Key](#key) | Yes | Key for encryption or decryption. | +| params | [ParamsSpec](#paramsspec) | Yes | Parameters for encryption or decryption. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symKey; // The process of generating the symmetric key is omitted here. +let cipher; // The process of creating a Cipher instance is omitted here. +cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null, (err, ) => { + if (err) { + console.error('Failed to init cipher'); + return; + } + console.log('Init cipher success'); + // Perform subsequent operations such as update. +}) +``` + +### init + +init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\ + +Initializes a [cipher](#cipher) instance. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ---------- | ---- | ---------------------- | +| opMode | [CryptoMode](#cryptomode) | Yes | Operation (encryption or decryption) to perform. | +| key | [Key](#key) | Yes | Key for encryption or decryption.| +| params | [ParamsSpec](#paramsspec) | Yes | Parameters for encryption or decryption. For algorithm modes without parameters (such as ECB), **null** can be passed in. | + +**Return value** + +| Type | Description | +| ------------------- | --------------------------- | +| Promise\ | Promise used to return the result.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; +let symKey; // The process of generating the symmetric key is omitted here. +let cipher; // The process of creating a Cipher instance is omitted here. +cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, symKey, null).then(() => { + console.log('Init cipher success'); + // Perform subsequent operations such as update. +}) +``` + +### update + +update(data : DataBlob, callback : AsyncCallback\) : void + +Updates the data to encrypt or decrypt by segment. This API uses an asynchronous callback to return the encrypted or decrypted data. The number of times that **update()** is called varies depending on the data volume. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------ | +| data | [DataBlob](#datablob) | Yes | Data to encrypt or decrypt. | +| callback | AsyncCallback\<[DataBlob](#datablob)> | Yes | Callback invoked to return the encrypted or decrypted data.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function stringToUint8Array(str) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +let cipher; // The process of creating a Cipher instance is omitted here. +// The init() process is omitted here. +let plainText = {data : stringToUint8Array('this is test!')}; +cipher.update(plainText, (err, output) => { // Example of the encryption process. + if (err) { + console.error('Failed to update cipher'); + return; + } + console.log('Update cipher success'); + // Perform subsequent operations such as doFinal. +}) +``` + +### update + +update(data : DataBlob) : Promise\ + +Updates the data to encrypt or decrypt by segment. This API uses a promise to return the result. The number of times that **update()** is called varies depending on the data volume. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | -------- | ---- | -------------------- | +| data | [DataBlob](#datablob) | Yes | Data to encrypt or decrypt.| + +**Return value** + +| Type | Description | +| ----------------------- | --------------------------- | +| Promise\<[DataBlob](#datablob)> | Promise used to return the result.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function stringToUint8Array(str) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +let cipher; // The process of creating a Cipher instance is omitted here. +// The init() process is omitted here. +let plainText = {data : stringToUint8Array('this is test!')}; +cipher.update(data).then((output) => { + console.log('Update cipher success'); + // Perform subsequent operations such as doFinal. +}) +``` + +### doFinal + +doFinal(data : DataBlob, callback : AsyncCallback\) : void + +Finalizes the data encryption or decryption operation. This API uses an asynchronous callback to return the result. + +The output of **doFinal** varies depending on the symmetric encryption and decryption mode. + +- For symmetric encryption in GCM or CCM mode, **doFinal** returns the combination of the remaining ciphertext and **authTag**. **authTag** is the last 16 bytes for the GCM mode or the last 12 bytes for the CCM mode. If **data** of **doFinal** is **null**, **doFinal** returns **authTag**. After **doFinal** is complete, **authTag** needs to be temporarily stored and filled in [**GcmParamsSpec**](#gcmparamsspec) or [**CcmParamsSpec**](#ccmparamsspec) during decryption. +- For symmetric encryption and decryption in other modes, the output can be either of the following: + (1) **Update()** returns part of the encryption and decryption result, and **doFinal()** returns the remaining encryption and decryption result. + (2) **Update()** returns all the encryption and decryption result, and **doFinal()** returns no value. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ------------------------------------------ | +| data | [DataBlob](#datablob) | Yes | Data to encrypt or decrypt.
If data is already passed in by [update()](#update-4), **data** can be **null**. | +| callback | AsyncCallback\<[DataBlob](#datablob)> | Yes | Callback invoked to return the encrypted or decrypted data.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +let cipher; // The process of creating a Cipher instance is omitted here. +let data; // The process of preparing the data to encrypt or decrypt is omitted here. +// The init() and update() processes are omitted here. +cipher.doFinal(data, (err, output) => { + if (err) { + console.error('Failed to final cipher'); + return; + } + console.log('Final cipher success'); +}) +``` + +### doFinal + +doFinal(data : DataBlob) : Promise\ + +Finalizes the data encryption or decryption operation. This API uses a promise to return the result. + +The output of **doFinal** varies depending on the symmetric encryption and decryption mode. + +- For symmetric encryption in GCM or CCM mode, **doFinal** returns the combination of the remaining ciphertext and **authTag**. **authTag** is the last 16 bytes for the GCM mode or the last 12 bytes for the CCM mode. If **data** of **doFinal** is **null**, **doFinal** returns **authTag**. After **doFinal** is complete, **authTag** needs to be temporarily stored and filled in [**GcmParamsSpec**](#gcmparamsspec) or [**CcmParamsSpec**](#ccmparamsspec) during decryption. + +- For symmetric encryption and decryption in other modes, the output includes the following: + + (1) **Update()** returns part of the encryption and decryption results, and **doFinal()** returns the remaining encryption and decryption results. + + (2) **Update()** returns all the encryption and decryption result, and **doFinal()** returns no value. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | -------- | ---- | -------------------- | +| data | [DataBlob](#datablob) | Yes | Data to encrypt or decrypt. If data is already passed in by [update()](#update-4), **data** can be **null**. | + +**Return value** + +| Type | Description | +| ----------------------- | --------------------------- | +| Promise\<[DataBlob](#datablob)> | Promise used to return the result.| + +**Example** + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +let cipher; // The process of creating a Cipher instance is omitted here. +let data; // The process of preparing the data to encrypt or decrypt is omitted here. +// The init() and update() processes are omitted here. +cipher.doFinal(data).then((output) => { + console.log('Final cipher success'); +}) +``` + +**Callback example**: + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); +let cipher = cryptoFramework.createCipher("RSA1024|PKCS1"); +rsaGenerator.generateKeyPair(function (err, keyPair) { + let pubKey = keyPair.pubKey; + cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null, function (err, data) { + let input = {data : stringToUint8Array(plan) }; + cipher.doFinal(input, function (err, data) { + AlertDialog.show({ message : "EncryptOutPut is " + data.data} ); + }); + }); +}); +``` + +**Promise example**: + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); +let cipher = cryptoFramework.createCipher("RSA1024|PKCS1"); +let keyGenPromise = rsaGenerator.generateKeyPair(); +keyGenPromise.then(rsaKeyPair => { + let pubKey = rsaKeyPair.pubKey; + return cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); // Pass in the private key and DECRYPT_MODE to initialize the decryption mode. +}).then(() => { + let input = { data : stringToUint8Array(plan) }; + return cipher.doFinal(input); +}).then(dataBlob => { + console.info("EncryptOutPut is " + dataBlob.data); +}); +``` + + +## cryptoFramework.createSign + +createSign(algName : string) : Sign + +Creates a **Sign** instance. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| algName | string | Yes | Signing algorithm to use, which can be RSA or ECC. If RSA PKCS #1 is used, the digest must be set. If RSA PSS is used, the digest and mask digest must be set.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------ | +| Sign | **Sign** instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let signer1 = cryptoFramework.createSign("RSA1024|PKCS1|SHA256"); + +let singer2 = cryptoFramework.createSign("RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA256") +``` + +## Sign + +Provides APIs for signing. Before using any API of the **Sign** class, you must create a **Sign** instance by using **createSign()**. + +### init + +init(priKey : PriKey, callback : AsyncCallback\) : void + +Initializes a **Sign** instance using a private key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| priKey | Key |Yes| Private key used for the initialization.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### init + +init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\ + +Initializes a **Sign** instance using a private key. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| priKey | Key |Yes| Private key used for the initialization.| + +**Return value** + +| Type | Description | +| ------------- | ----------- | +| Promise\ | Promise used to return the result.| + +### update + +update(data : DataBlob, callback : AsyncCallback\) : void + +Updates the data to be signed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| data | DataBlob | Yes | Message to pass in. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### update + +update(data : DataBlob) : Promise\; + +Updates the data to be signed. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| data | DataBlob | Yes | Message to pass in. | + +**Return value** + +| Type | Description | +| ------------- | ----------- | +| Promise\ | Promise used to return the result.| + +### sign + +sign(data : DataBlob, callback : AsyncCallback\) : void + +Signs the data. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| data | DataBlob | Yes | Message to pass in. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### sign + +sign(data : DataBlob) : Promise\ + +Signs the data. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| data | DataBlob | Yes | Message to pass in. | + +**Return value** + +| Type | Description | +| ------------- | ----------- | +| Promise\ | Promise used to return the result.| + +**Callback example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); +let signer = cryptoFramework.createSign("RSA1024|PKCS1|SHA256"); +rsaGenerator.generateKeyPair(function (err, keyPair) { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + signer.init(priKey, function (err, data) { + signer.update(input1, function (err, data) { + signer.sign(input2, function (err, data) { + SignMessageBlob = data; + console.info("sign output is " + SignMessageBlob.data); + }); + }); + }); +}); +``` + +**Promise example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); +let signer = cryptoFramework.createSign("RSA1024|PKCS1|SHA256"); +let keyGenPromise = rsaGenerator.generateKeyPair(); +keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + return signer.init(priKey); +}).then(() => { + return signer.update(input1); +}).then(() => { + return signer.sign(input2); +}).then(dataBlob => { + SignMessageBlob = dataBlob; + console.info("sign output is " + SignMessageBlob.data); +}); +``` + +## cryptoFramework.createVerify + +createVerify(algName : string) : Verify + +Creates a **Verify** instance. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| algName | string | Yes | Signing algorithm to use, which can be RSA or ECC. If RSA PKCS #1 is used, the digest must be set. If RSA PSS is used, the digest and mask digest must be set.| + +**Return value** + +| Type| Description | +| ---- | ------------------------------ | +| Verify | **Verify** instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let verifyer1 = cryptoFramework.createVerify("RSA1024|PKCS1|SHA256"); + +let verifyer2 = cryptoFramework.createVerify("RSA1024|PKCS1_OAEP|SHA256|MGF1_SHA256") +``` +## Verify + +Provides APIs for signature verification. Before using any API of the **Verify** class, you must create a **Verify** instance by using **createVerify()**. + +### init + +init(pubKey : PubKey, callback : AsyncCallback\) : void + +Initializes the **Verify** instance using a public key. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| pubKey | Key |Yes| Public key used for the initialization.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### init +init(pubKey : PubKey) : Promise\ + +Initializes the **Verify** instance using a public key. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| pubKey | Key |Yes|Public key used for the initialization.| + +**Return value** + +| Type | Description | +| --------------- | ------------ | +| Promise\ | Promise used to return the result.| + +### update + +update(data : DataBlob, callback : AsyncCallback\) : void + +Updates the data for signature verification. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| data | DataBlob | Yes | Message to pass in. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### update + +update(data : DataBlob) : Promise\; + +Updates the data for signature verification. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| data | DataBlob | Yes | Message to pass in. | + +**Return value** + +| Type | Description | +| ------------- | ----------- | +| Promise\ | Promise used to return the result.| + +### verify + +verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback\) : void + +Verifies the signature. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| data | DataBlob | Yes | Message to pass in. | +| signatureData | DataBlob | Yes | Signature data. | +| callback | AsyncCallback\ | Yes | Callback invoked to return the result.| + +### verify + +verify(data : DataBlob, signatureData : DataBlob) : Promise\ + +Verifies the signature. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | -------- | ---- | ---------- | +| data | DataBlob | Yes | Message to pass in.| +| signatureData | DataBlob| Yes| Signature data.| + +**Return value** + +| Type | Description | +| --------------- | ------------ | +| Promise\ | Promise used to return the result.| + +**Callback example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let verifyer = cryptoFramework.createVerify("RSA1024|PKCS1|SHA25"); +verifyer.init(globalKeyPair.pubKey, function (err, data) { + verifyer.update(input1, function(err, data) { + verifyer.verify(input2, SignMessageBlob, function(err, data) { + console.info("verify result is " + data); + }) + }); +}) +``` + +**Promise example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let verifyer = cryptoFramework.createVerify("RSA1024|PKCS1|SHA256"); +let verifyInitPromise = verifyer.init(globalKeyPair.pubKey); +verifyInitPromise.then(() => { + return verifyer.update(input1); +}).then(() => { + return verifyer.verify(input2, SignMessageBlob); +}).then(res => { + console.log("Verify result is " + res); +}); +``` +## cryptoFramework.createKeyAgreement + +createKeyAgreement(algName : string) : KeyAgreement + +Creates a **KeyAgreement** instance. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| algName | string | Yes | Key agreement algorithm to use. Only ECC is supported. | + +**Return value** + +| Type| Description | +| ---- | ------------------------------ | +| KeyAgreement | **KeyAgreement** instance created.| + +**Example** + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let keyAgreement = cryptoFramework.createKeyAgreement("ECC256"); + +``` + +## KeyAgreement + +Provides APIs for key agreement operations. Before using any API of the **keyAgreement** class, you must create a **KeyAgreement** instance by using **createKeyAgreement()**. + +### generateSecret + +generateSecret(priKey : PriKey, pubKey : PubKey, callback : AsyncCallback\) : void + +Generates a shared secret. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| priKey | PriKey |Yes| Private key used for key agreement.| +| pubKey | PubKey |Yes| Public key used for key agreement.| +| callback | AsyncCallback\ | Yes | Callback invoked to return the shared secret generated. | + +### generateSecret +generateSecret(priKey : PriKey, pubKey : PubKey) : Promise\ + +Generates a shared secret. This API uses a promise to return the result. + +**System capability**: SystemCapability.Security.CryptoFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------- | ---- | ------------------ | +| priKey | PriKey |Yes| Private key used for key agreement.| +| pubKey | PubKey |Yes| Public key used for key agreement.| + +**Return value** + +| Type | Description | +| --------------- | ------------ | +| Promise\ | Promise used to return the shared secret generated. | + +**Callback example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let keyAgreement = cryptoFramework.createKeyAgreement("ECC256"); +keyAgreement.generateSecret(globalKeyPair.priKey, globalKeyPair.pubKey, function (err, secret) { + if (err) { + console.error("keyAgreement error."); + return; + } + console.info("keyAgreement output is " + secret.data); +}); +``` + +**Promise example**: +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let keyAgreement = cryptoFramework.createKeyAgreement("ECC256"); +let keyAgreementPromise = keyAgreement.generateSecret(globalKeyPair.priKey, globalKeyPair.pubKey); +keyAgreementPromise.then((secret) => { + console.info("keyAgreement output is " + secret.data); +}).catch((error) => { + console.error("keyAgreement error."); +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-distributedBundle.md b/en/application-dev/reference/apis/js-apis-distributedBundle.md new file mode 100644 index 0000000000000000000000000000000000000000..4df752e4c6b97ba160a40f9c14c6a729f629a1b0 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-distributedBundle.md @@ -0,0 +1,503 @@ +# distributedBundle + +The **distributedBundle** module provides APIs for managing distributed bundles. + +> **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 provided by this module are system APIs. + +## Modules to Import + +``` +import distributedBundle from '@ohos.bundle.distributedBundle'; +``` + +## System Capability + +SystemCapability.BundleManager.DistributedBundleFramework + +## Required Permissions + +| Permission | Permission Level | Description | +| ------------------------------------------ | ------------ | ------------------ | +| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | Permission to query information about all applications.| + +For details, see "Permission Levels" in [Access Control Overview](../../security/accesstoken-overview.md). + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback\): void; + +Obtains information about the remote ability that matches the given element name. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. | +| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **RemoteAbilityInfo** object obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }, (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName): Promise\; + +Obtains information about the remote ability that matches the given element name. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | -------------------------------------------- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Promise used to return the **RemoteAbilityInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }).then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementNames: Array\, callback: AsyncCallback\>): void; + +Obtains information about remote abilities that match the given element names. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | +| callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **RemoteAbilityInfo** objects obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + [ + { + deviceId: '1', + bundleName: 'com.example.application1', + abilityName: 'MainAbility1' + }, + { + deviceId: '1', + bundleName: 'com.example.application2', + abilityName: 'MainAbility' + } + ], (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementNames: Array\): Promise\>; + +Obtains information about remote abilities that match the given element names. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------------------------- | ---- | ----------------------- | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\> | Promise used to return the array of **RemoteAbilityInfo** objects obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + [ + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }, + { + deviceId: '1', + bundleName: 'com.example.application2', + abilityName: 'MainAbility' + } + ]).then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCallback\): void; + +Obtains information about the remote ability that matches the given element name and locale. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name. | +| locale | string |Yes| Target locale.| +| callback | AsyncCallback<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **RemoteAbilityInfo** object obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }, 'zh-Hans-CN', (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise\; + +Obtains information about the remote ability that matches the given element name and locale. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | -------------------------------------------- | ---- | ----------------------- | +| elementName | [ElementName](js-apis-bundleManager-elementName.md) | Yes | Target element name.| +| locale | string |Yes| Target locale.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\<[RemoteAbilityInfo](js-apis-bundleManager-remoteAbilityInfo.md)> | Promise used to return the **RemoteAbilityInfo** object obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }, 'zh-Hans-CN').then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementNames: Array\, locale: string, callback: AsyncCallback\>): void; + +Obtains information about remote abilities that match the given element names and locales. This API uses an asynchronous callback to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | +| locale | string |Yes| Target locale.| +| callback | AsyncCallback\> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the array of **RemoteAbilityInfo** objects obtained. Otherwise, **err** is an error object.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + [ + { + deviceId: '1', + bundleName: 'com.example.application1', + abilityName: 'MainAbility1' + }, + { + deviceId: '1', + bundleName: 'com.example.application2', + abilityName: 'MainAbility' + } + ], 'zh-Hans-CN', (err, data) => { + if (err) { + console.error('Operation failed:' + JSON.stringify(err)); + } else { + console.info('Operation succeed:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` + +## distributedBundle.getRemoteAbilityInfo + +getRemoteAbilityInfo(elementNames: Array\, locale: string): Promise\>; + +Obtains information about remote abilities that match the given element names and locales. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**System capability**: SystemCapability.BundleManager.DistributedBundleFramework + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------------------------- | ---- | ----------------------- | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | **ElementName** array, whose maximum length is 10.| +| locale | string |Yes| Target locale.| + +**Return value** + +| Type | Description | +| ------------------------------------------------------------ | --------------------------------- | +| Promise\> | Promise used to return the array of **RemoteAbilityInfo** objects obtained.| + +**Error codes** + +For details about the error codes, see [Bundle Error Codes](../errorcodes/errcode-bundle.md). + +| ID | Error Message | +|---------------|-------------------------| +| 201 | Permission denied.| +| 401 | The parameter check failed. | +| 801 | Capability not supported. | +| 17700001 | The specified bundle name is not found | +| 17700003 | The specified ability name is not found. | +| 17700007 | The specified device id is not found. | +| 17700027 | The distributed service is not running. | + +**Example** + +```js +try { + distributedBundle.getRemoteAbilityInfo( + [ + { + deviceId: '1', + bundleName: 'com.example.application', + abilityName: 'MainAbility' + }, + { + deviceId: '1', + bundleName: 'com.example.application2', + abilityName: 'MainAbility' + } + ], 'zh-Hans-CN').then(data => { + console.info('Operation succeed:' + JSON.stringify(data)); + }).catch(err => { + console.error('Operation failed:' + JSON.stringify(err)); + }); +} catch (err) { + console.error('Operation failed:' + JSON.stringify(err)); +} +``` diff --git a/en/application-dev/reference/apis/js-apis-distributedMissionManager.md b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md index 3d5a11c39a470fd730ae359619d7ee0c29dc9eb6..aa49db0f38c911850ec73e2fdb00fa98399ff1fc 100644 --- a/en/application-dev/reference/apis/js-apis-distributedMissionManager.md +++ b/en/application-dev/reference/apis/js-apis-distributedMissionManager.md @@ -1,6 +1,6 @@ # Distributed Mission Management -The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, and start or stop synchronizing the remote mission list. +The **distributedMissionManager** module implements system mission management across devices. You can use the APIs provided by this module to register or deregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device. > **NOTE** > @@ -48,16 +48,23 @@ Registers a mission status listener. This API uses an asynchronous callback to r console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); } var parameter = { - deviceId: remoteDeviceId + deviceId: "" }; var options = { notifyMissionsChanged: NotifyMissionsChanged, notifySnapshot: NotifySnapshot, notifyNetDisconnect: NotifyNetDisconnect } - distributedMissionManager.registerMissionListener(parameter, options, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.registerMissionListener(parameter, options, (error) => { + if (error.code != 0) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } + console.info('registerMissionListener finished') + }) + } catch (error) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.registerMissionListener @@ -97,19 +104,23 @@ Registers a mission status listener. This API uses a promise to return the resul console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); } var parameter = { - deviceId: remoteDeviceId + deviceId: "" }; var options = { notifyMissionsChanged: NotifyMissionsChanged, notifySnapshot: NotifySnapshot, notifyNetDisconnect: NotifyNetDisconnect } - distributedMissionManager.registerMissionListener(parameter, options) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.registerMissionListener(parameter, options) + .then(data => { + console.info('registerMissionListener finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` @@ -134,11 +145,18 @@ Deregisters a mission status listener. This API uses an asynchronous callback to ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: "" }; - distributedMissionManager.unRegisterMissionListener(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.unRegisterMissionListener(parameter, (error) => { + if (error.code != 0) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } + console.info('unRegisterMissionListener finished') + }) + } catch (error) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` @@ -168,14 +186,18 @@ Deregisters a mission status listener. This API uses a promise to return the res ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: "" }; - distributedMissionManager.unRegisterMissionListener(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.unRegisterMissionListener(parameter) + .then(data => { + console.info('unRegisterMissionListener finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.startSyncRemoteMissions @@ -199,13 +221,20 @@ Starts to synchronize the remote mission list. This API uses an asynchronous cal ```ts var parameter = { - deviceId: remoteDeviceId, + deviceId: "", fixConflict: false, tag: 0 }; - distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.startSyncRemoteMissions(parameter, (error) => { + if (error.code != 0) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + console.info('startSyncRemoteMissions finished') + }) + } catch (error) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.startSyncRemoteMissions @@ -234,16 +263,20 @@ Starts to synchronize the remote mission list. This API uses a promise to return ```ts var parameter = { - deviceId: remoteDeviceId, + deviceId: "", fixConflict: false, tag: 0 }; - distributedMissionManager.startSyncRemoteMissions(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.startSyncRemoteMissions(parameter) + .then(data => { + console.info('startSyncRemoteMissions finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.stopSyncRemoteMissions @@ -267,11 +300,18 @@ Stops synchronizing the remote mission list. This API uses an asynchronous callb ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: "" }; - distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { - console.log("error.code = " + error.code) - }) + try { + distributedMissionManager.stopSyncRemoteMissions(parameter, (error) => { + if (error.code != 0) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + console.info('stopSyncRemoteMissions finished') + }) + } catch (error) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } ``` ## distributedMissionManager.stopSyncRemoteMissions @@ -300,14 +340,113 @@ Stops synchronizing the remote mission list. This API uses a promise to return t ```ts var parameter = { - deviceId: remoteDeviceId + deviceId: "" + }; + try { + distributedMissionManager.stopSyncRemoteMissions(parameter) + .then(data => { + console.info('stopSyncRemoteMissions finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)) + } + ``` + +## distributedMissionManager.continueMission + +continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback<void>): void; + +Continues a mission on a remote device. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.| +| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| + +**Example** + + ```ts + var parameter = { + srcDeviceId: "", + dstDeviceId: "", + missionId: 1, + wantParam: {"key": "value"} + }; + function OnContinueDone(resultCode) { + console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode)); + }; + var options = { + OnContinueDone: OnContinueDone + }; + try { + distributedMissionManager.continueMission(parameter, options, (error) => { + if (error.code != 0) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } + console.info('continueMission finished') + }) + } catch (error) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } + ``` + +## distributedMissionManager.continueMission + +continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise<void> + +Continues a mission on a remote device. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | --------------------------------------- | ---- | ----- | +| parameter | [ContinueDeviceInfo](#continuedeviceinfo) | Yes | Parameters required for mission continuation.| +| options | [ContinueCallback](#continuecallback) | Yes | Callback invoked when the mission continuation is complete.| + +**Return value** + +| Type | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```ts + var parameter = { + srcDeviceId: "", + dstDeviceId: "", + missionId: 1, + wantParam: {"key": "value"} + }; + function OnContinueDone(resultCode) { + console.log('OnContinueDone resultCode: ' + JSON.stringify(resultCode)); + }; + var options = { + OnContinueDone: OnContinueDone }; - distributedMissionManager.stopSyncRemoteMissions(parameter) - .then(data => { - console.info('success data is ' + data); - }).catch(error => { - console.info('error error is ' + error); - }) + try { + distributedMissionManager.continueMission(parameter, options) + .then(data => { + console.info('continueMission finished, ' + JSON.stringify(data)); + }).catch(error => { + console.error('continueMission failed, cause: ' + JSON.stringify(error)); + }) + } catch (error) { + console.error('continueMission failed, cause: ' + JSON.stringify(error)) + } ``` ## MissionCallback @@ -349,3 +488,30 @@ Defines the parameters required for registering a listener. | Name | Type | Readable | Writable | Description | | -------- | ------ | ---- | ---- | ------- | | deviceId | string | Yes | Yes | Device ID.| + +## ContinueDeviceInfo + +Defines the parameters required for mission continuation. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +| Name | Type | Readable | Writable | Description | +| -------- | ------ | ---- | ---- | ------- | +| srcDeviceId | string | Yes | Yes | ID of the source device.| +| dstDeviceId | string | Yes | Yes | ID of the target device.| +| missionId | number | Yes | Yes | Mission ID.| +| wantParam | {[key: string]: any} | Yes | Yes | Extended parameters.| + +## ContinueCallback + +Defines the callback invoked when the mission continuation is complete. + +**Required permissions**: ohos.permission.MANAGE_MISSIONS + +**System capability**: SystemCapability.Ability.AbilityRuntime.Mission + +| Name | Type | Readable | Writable | Description | +| --------------------- | -------- | ---- | ---- | ------------------ | +| onContinueDone | function | Yes | No | Callback used to notify the user that the mission continuation is complete and return the continuation result. | diff --git a/en/application-dev/reference/apis/js-apis-faultLogger.md b/en/application-dev/reference/apis/js-apis-faultLogger.md index 9cfb16523cf8c3333f8193d803be03c61e45a139..5b84cfa1c1e778e0de657aeaea41e98c2146417c 100644 --- a/en/application-dev/reference/apis/js-apis-faultLogger.md +++ b/en/application-dev/reference/apis/js-apis-faultLogger.md @@ -39,10 +39,12 @@ Defines the data structure of the fault log information. | summary | string | Summary of the fault.| | fullLog | string | Full log text.| -## faultLogger.querySelfFaultLog +## faultLogger.querySelfFaultLog(deprecated) querySelfFaultLog(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void +> **NOTE**
This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9) instead. + Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger @@ -52,7 +54,8 @@ Obtains the fault information about the current process. This API uses an asynch | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | faultType | [FaultType](#faulttype) | Yes| Fault type.| -| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes | Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. | +| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. + **Example** ```js @@ -78,10 +81,12 @@ function queryFaultLogCallback(error, value) { faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); ``` -## faultLogger.querySelfFaultLog +## faultLogger.querySelfFaultLog(deprecated) querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>> +> **NOTE**
This API is deprecated since API version 9. You are advised to use [faultLogger.query](#faultloggerquery9-1) instead. + Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. **System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger @@ -105,18 +110,125 @@ async function getLog() { let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); if (value) { console.info("value length is " + value.length); - let len = value.length; - for (let i = 0; i < len; i++) { - console.info("log: " + i); - console.info("Log pid: " + value[i].pid); - console.info("Log uid: " + value[i].uid); - console.info("Log type: " + value[i].type); - console.info("Log timestamp: " + value[i].timestamp); - console.info("Log reason: " + value[i].reason); - console.info("Log module: " + value[i].module); - console.info("Log summary: " + value[i].summary); - console.info("Log text: " + value[i].fullLog); - } + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log timestamp: " + value[i].timestamp); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } + } +} +``` + +## faultLogger.query9+ + +query(faultType: FaultType, callback: AsyncCallback<Array<FaultLogInfo>>) : void + +Obtains the fault information about the current process. This API uses an asynchronous callback to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. + +**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| faultType | [FaultType](#faulttype) | Yes| Fault type.| +| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. + +**Error codes** + +For details about the error codes, see [faultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). + +| ID| Error Message| +| --- | --- | +| 10600001 | The service is not running or broken | + +**Example** + +```js +function queryFaultLogCallback(error, value) { + if (error) { + console.info('error is ' + error); + } else { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log timestamp: " + value[i].timestamp); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } + } +} +try { + faultLogger.query(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); +} catch (err) { + console.error(`code: ${err.code}, message: ${err.message}`); +} +``` + +## faultLogger.query9+ + +query(faultType: FaultType) : Promise<Array<FaultLogInfo>> + +Obtains the fault information about the current process. This API uses a promise to return the fault information array obtained, which contains a maximum of 10 pieces of fault information. + +**System capability**: SystemCapability.HiviewDFX.Hiview.FaultLogger + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| faultType | [FaultType](#faulttype) | Yes| Fault type.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**.
The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| + +**Error codes** + +For details about the error codes, see [faultLogger Error Codes](../errorcodes/errorcode-faultlogger.md). + +| ID| Error Message| +| --- | --- | +| 10600001 | The service is not running or broken | + +**Example** + +```js +async function getLog() { + try { + let value = await faultLogger.query(faultLogger.FaultType.JS_CRASH); + if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log timestamp: " + value[i].timestamp); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } + } + } catch (err) { + console.error(`code: ${err.code}, message: ${err.message}`); } } ``` diff --git a/en/application-dev/reference/apis/js-apis-fileAccess.md b/en/application-dev/reference/apis/js-apis-fileAccess.md new file mode 100644 index 0000000000000000000000000000000000000000..743e17c77f8dd2c4baa48f90de3ff9ac47fedfc0 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-fileAccess.md @@ -0,0 +1,735 @@ +# User File Access and Management + +The **fileAccess** module is a framework for accessing and operating user files based on the extension mechanism. This module interacts with diverse file management services, such as the media library and external storage management service, and provides a set of unified file access and management APIs for system applications. The media library service allows access to user files on local devices and distributed devices. The external storage management service allows access to the user files stored on devices such as shared disks, USB flash drives, and SD cards. + +>**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 provided by this module are system APIs and cannot be called by third-party applications. Currently, the APIs can be called only by FilePicker and the file manager app. + +## Modules to Import + +```js +import fileAccess from '@ohos.data.fileAccess'; +``` + +## fileAccess.getFileAccessAbilityInfo + +getFileAccessAbilityInfo( ) : Promise<Array<Want>> + +Obtains information about all wants with **extension** set to **fileAcesss** in the system. A want is a basic communication component used to start services. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +None + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<Array<Want>> | Promise used to return the want information obtained.| + +**Example** + + ```js + async getFileAccessAbilityInfo() { + let wantInfos = []; + try { + wantInfos = await fileAccess.getFileAccessAbilityInfo(); + console.log("getFileAccessAbilityInfo data " + JSON.stringify(wantInfos)); + } catch (error) { + console.error("getFileAccessAbilityInfo failed, error " + error); + } + } + ``` + +## fileAccess.createFileAccessHelper + +createFileAccessHelper(context: Context, wants: Array<Want>) : FileAccessHelper + +Synchronously creates a **Helper** object to connect to the specified wants. The **Helper** object provides file access and management capabilities. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| context | Context | Yes| Context of the ability.| +| wants | Array<Want> | Yes| Wants to connect.| + +**Return value** + +| Type| Description| +| --- | -- | +| FileAccessHelper | **Helper** object created.| + +**Example** + + ```js + createFileAccessHelper() { + let fileAccesssHelper = null; + // Obtain want information by using getFileAccessAbilityInfo(). + // Create a Helper object to interact with the media library service only. + let wantInfos = [ + { + "bundleName": "com.ohos.medialibrary.medialibrarydata", + "abilityName": "FileExtensionAbility", + }, + ] + try { + fileAccesssHelper = fileAccess.createFileAccessHelper(this.context, wantInfos); + if (!fileAccesssHelper) + console.error("createFileAccessHelper interface returns an undefined object"); + } catch (error) { + console.error("createFileAccessHelper failed, error " + error); + } + } + ``` + +## fileAccess.createFileAccessHelper + +createFileAccessHelper(context: Context) : FileAccessHelper + +Synchronously creates a **Helper** object that connects to all file management services in the current system. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| context | Context | Yes| Context of the ability.| + +**Return value** + +| Type| Description| +| --- | -- | +| FileAccessHelper | **Helper** object created.| + +**Example** + + ```js + createFileAccessHelper() { + let fileAccesssHelperAllServer = null; + // Create a Helper object to interact with all file management services configured with fileAccess in the system. + try { + fileAccesssHelperAllServer = fileAccess.createFileAccessHelper(this.context); + if (!fileAccesssHelperAllServer) + console.error("createFileAccessHelper interface returns an undefined object"); + } catch (error) { + console.error("createFileAccessHelper failed, error " + error); + } + } + ``` + +## FileAccessHelper.getRoots + +getRoots( ) : Promise<RootIterator> + +Obtains information about the root nodes for the devices of the file management service type connected to the **Helper** object. This API uses a promise to return a **RootIterator** object, which +returns [RootInfo](#rootinfo) by using [next()](#rootiteratornext). + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +None + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<RootIterator> | **RootIterator** object obtained.| + +**Example** + + ```js + async getRoots() { + let rootIterator = null; + let rootinfos = []; + let isDone = false; + try { + rootIterator = await fileAccesssHelper.getRoots(); + if (!rootIterator) { + console.error("getRoots interface returns an undefined object"); + return; + } + while (!isDone) { + let result = rootIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + rootinfos.push(result.value); + } + } catch (error) { + console.error("getRoots failed, error " + error); + } + } + ``` + +## RootInfo.listfile + +listFile(filter?: Filter) : FileIterator + +Synchronously obtains the **FileIterator** object of the first-level files (file folder) matching the conditions of the filter from the root node of a device. The **FileIterator** object then returns [FileInfo](#fileinfo) by using [next()](#fileiteratornext). + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | -- | -- | +| filter | Filter | No| **Filter** object. | + + +**Return value** + +| Type| Description| +| --- | -- | +| FileIterator | **FileIterator** object obtained.| + +**Example** + + ```js + / / Obtain root information by using getRoots(). + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let rootInfo = rootinfos[0]; + let fileInfos = []; + let isDone = false; + try { + let fileIterator = rootInfo.listFile(); + // ListFile that contains the filter implementation. + // let fileIterator = rootInfo.listFile(filter); + if (!fileIterator) { + console.error("listFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + fileInfos.push(result.value); + } + } catch (error) { + console.log("listFile failed, error " + error); + } + ``` + +## RootInfo.scanFile + +scanFile(filter?: Filter) : FileIterator + +Recursively obtains the **FileIterator** object of the files matching the conditions of the filter from the root node of a device synchronously. The **FileIterator** object then returns [FileInfo](#fileinfo) by using the [next()](#fileiteratornext). + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | -- | -- | +| filter | Filter | No| **Filter** object. | + +**Return value** + +| Type| Description| +| --- | -- | +| FileIterator | **FileIterator** object obtained.| + +**Example** + + ```js + / / Obtain root information by using getRoots(). + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let rootInfo = rootinfos[0]; + let fileInfos = []; + let isDone = false; + try { + let fileIterator = rootInfo.scanFile(); + // ScanFile that contains the filter implementation + // let fileIterator = rootInfo.scanFile(filter); + if (!fileIterator) { + console.error("scanFile interface returns undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + fileInfos.push(result.value); + } + } catch (error) { + console.error("scanFile failed, error " + error); + } + ``` + +## FileInfo.listfile + +listFile(filter?: Filter) : FileIterator + +Synchronously obtains the **FileIterator** object of the next-level files (file folders) matching the conditions of the filter from a directory. The **FileIterator** object then returns [FileInfo](#fileinfo) by using [next()](#fileiteratornext). + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | -- | -- | +| filter | Filter | No| **Filter** object. | + +**Return value** + +| Type| Description| +| --- | -- | +| FileIterator | **FileIterator** object obtained.| + +**Example** + + ```js + // fileInfoDir specifies the target directory. + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let fileInfoDir = fileInfos[0]; + let subfileInfos = []; + let isDone = false; + try { + let fileIterator = fileInfoDir.listFile(); + // ListFile that contains the filter implementation. + // let fileIterator = rootInfo.listFile(filter); + if (!fileIterator) { + console.error("listFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.log("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + subfileInfos.push(result.value); + } + } catch (error) { + console.error("listFile failed, error " + error); + } + ``` + +## FileInfo.scanfile + +scanFile(filter?: Filter) : FileIterator; + +Recursively obtains the **FileIterator** object of the files matching the conditions of the filter from a directory synchronously. The **FileIterator** object then returns [FileInfo](#fileinfo) by using [next()](#fileiteratornext). + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | -- | -- | +| filter | Filter | No| **Filter** object. | + + +**Return value** + +| Type| Description| +| --- | -- | +| FileIterator | **FileIterator** object obtained.| + +**Example** + + ```js + // fileInfoDir specifies the target directory. + // let filter = {suffix : [".txt", ".jpg", ".xlsx"]}; + let fileInfoDir = fileInfos[0]; + let subfileInfos = []; + let isDone = false; + try { + let fileIterator = fileInfoDir.scanFile(); + // ScanFile that contains the filter implementation + // let fileIterator = rootInfo.scanFile(filter); + if (!fileIterator) { + console.error("scanFile interface returns an undefined object"); + return; + } + while (!isDone) { + let result = fileIterator.next(); + console.error("next result = " + JSON.stringify(result)); + isDone = result.done; + if (!isDone) + subfileInfos.push(result.value); + } + } catch (error) { + console.error("scanFile-filter failed, error " + error); + } + ``` + +## FileAccessHelper.createFile + +createFile(uri: string, displayName: string) : Promise<string> + +Creates a file in a directory. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| uri | string | Yes| URI of the parent directory for the file to create.| +| displayName | string | Yes| Name of the file to create. A file name extension must be added for a local file. It is not required for a file stored in a shared disk.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<string> | URI of the file created.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let sourceUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon"; + let displayName = "file1" + let fileUri = null; + try { + fileUri = await fileAccessHelper.createFile(sourceUri, displayName) + if (!fileUri) { + console.error("createFile return undefined object"); + return; + } + console.log("File created successfully. fileUri: " + JSON.stringify(fileUri)); + } catch (error) { + console.error("createFile failed, error " + error); + }; + ``` + +## FileAccessHelper.mkDir + +mkDir(parentUri: string, displayName: string) : Promise<string> + +Creates a folder in a directory. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| parentUri | string | Yes| URI of the parent directory for the folder to create.| +| displayName | string | Yes| Name of the folder to create.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<string> | URI of the folder created.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let sourceUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon"; + let dirName = "dirTest" + let dirUri = null; + try { + dirUri = await fileAccessHelper.mkDir(sourceUri, dirName) + if (!dirUri) { + console.error("mkDir return undefined object"); + return; + } + console.log("Folder created successfully. dirUri: " + JSON.stringify(dirUri)); + } catch (error) { + console.error("mkDir failed, error " + error); + }; + ``` + +## FileAccessHelper.openFile + +openFile(uri: string, flags: [OPENFLAGS](#openflags)) : Promise<number> + +Opens a file. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| uri | string | Yes| URI of the file to open.| +| flags | OPENFLAGS | |File open mode.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<number> | Handle of the file opened.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let targetUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + try { + let fd = await fileAccessHelper.openFile(targetUri, OPENFLAGS.READ); + } cache (error) { + console.error("openFile failed, error " + error); + }; + ``` + +## FileAccessHelper.delete + +delete(uri: string) : Promise<number> + +Deletes a file or folder. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| uri | string | Yes| URI of the file or folder to delete.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<number> | Promise used to return the result.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let targetUri = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + try { + let code = await fileAccessHelper.delete(targetUri); + if (code != 0) + console.error("delete failed, code " + code); + } cache (error) { + console.error("delete failed, error " + error); + }; + ``` + +## FileAccessHelper.move + +move(sourceFile: string, destFile: string) : Promise<string> + +Moves a file or folder. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| sourceFile | string | Yes| URI of the file or folder to move.| +| destFile | string | Yes| URI of the folder to which the file or folder is moved.| + +**Return value** + +| Type| Description| +| ----- | ------ | +| Promise<string> | URI of the file or folder in the destination directory.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let sourceFile = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/file1"; + let destFile = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let fileUri = await fileAccessHelper.move(sourceFile, destFile); + console.log("Operation successful. fileUri: " + JSON.stringify(fileUri)); + } cache (error) { + console.error("move failed, error " + error); + }; + ``` + +## FileAccessHelper.rename + +rename(uri: string, displayName: string) : Promise<string> + +Renames a file or folder. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| uri | string | Yes| URI of the file or folder to rename.| +| displayName | string | Yes| New name of the file or folder, which can contain the file name extension.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<string> | URI of the renamed file or folder.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let sourceDir = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let DestDir = await fileAccessHelper.rename(sourceDir, "testDir"); + console.log("Operation successful. DestDir: " + JSON.stringify(DestDir)); + } cache (error) { + console.error("rename failed, error " + error); + }; + ``` + +## FileAccessHelper.access + +access(sourceFileUri: string) : Promise<boolean> + +Checks whether a file or folder exists. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +| Name| Type| Mandatory| Description| +| --- | --- | --- | -- | +| sourceFileUri | string | Yes| URI of the file or folder.| + +**Return value** + +| Type| Description| +| --- | -- | +| Promise<boolean> | Promise used to return the result.| + +**Example** + + ```js + // The URI of a shared disk is used as an example. + let sourceDir = "datashare:///com.ohos.UserFile.ExternalFileManager/data/storage/el1/bundle/storage_daemon/dirTest"; + try { + let existJudgment = await fileAccessHelper.access(sourceDir); + if (existJudgment) + console.log("sourceDir exists"); + else + console.log("sourceDir does not exist"); + } cache (error) { + console.error("rename failed, error " + error); + }; + ``` + +## RootIterator.next + +next( ) : { value: RootInfo, done: boolean } + +Obtains the next-level device root directory. **RootIterator** is an iterator object of the device root directory. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +None + +**Return value** + +| Type| Description| +| --- | -- | +| {value: RootInfo, done: boolean} | Root directory information obtained. This API traverses the folder until **done** returns **true**. The **value** field contains the root directory information.| + +## FileIterator.next + +next( ) : { value: FileInfo, done: boolean } + +Obtains the information about the next-level file or folder. **FileIterator** is an iterator object of a folder. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +**Parameters** + +None + +**Return value** + +| Type| Description| +| --- | -- | +| {value: FileInfo, done: boolean} | File or folder information obtained. This API traverses the specified folder until **done** returns **true**. The **value** field contains the file or folder information obtained.| + +## RootInfo + +Represents the root attribute information and interface capabilities of a device. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +### Attributes + +| Name| Type | Readable| Writable| Description | +| ------ | ------ | -------- | ------ | -------- | +| deviceType | number | Yes| No|Device type.| +| uri | string | Yes| No| Root directory URI of the device.| +| displayName | string | Yes| No| Device name.| +| deviceFlags | number | Yes| No| Capabilities supported by the device.| + +## FileInfo + +Represents the file or folder attribute information and interface capabilities. + +**System capability**: SystemCapability.FileManagement.UserFileService + +**Required permissions**: ohos.permission.FILE_ACCESS_MANAGER + +### Attributes + +| Name| Type | Readable| Writable| Description | +| ------ | ------ | -------- | ------ | -------- | +| uri | string | Yes| No| URI of the file or folder.| +| fileName | string | Yes| No| Name of a file or folder.| +| mode | number | Yes| No| Permissions on the file or folder.| +| size | number | Yes| No| Size of the file or folder.| +| mtime | number | Yes| No| Time when the file or folder was last modified.| +| mimeType | string | Yes| No| Media resource type of the file or folder.| + +## OPENFLAGS + +Enumerates the modes for opening a file. + +**System capability**: SystemCapability.FileManagement.UserFileService + +| Name| Value| Description| +| ----- | ------ | ------ | +| READ | 0o0 | Read mode.| +| WRITE | 0o1 | Write mode.| +| WRITE_READ | 0o2 | Read/Write mode.| diff --git a/en/application-dev/reference/apis/js-apis-fileExtensionInfo.md b/en/application-dev/reference/apis/js-apis-fileExtensionInfo.md new file mode 100644 index 0000000000000000000000000000000000000000..fce0a93c72553be6306910412404e2fe09bc2290 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-fileExtensionInfo.md @@ -0,0 +1,58 @@ +# User File Extension Info + +The **fileExtensionInfo** module defines attributes in **RootInfo** and **FileInfo** of the user file access and management module. + +>**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 provided by this module are system APIs. + +## Modules to Import + +```js +import fileExtensionInfo from '@ohos.fileExtensionInfo'; +``` + +## fileExtensionInfo.DeviceType + +Defines the values of **deviceType** used in **RootInfo**. + +**System capability**: SystemCapability.FileManagement.UserFileService + +| Name| Value| Description| +| ----- | ------ | ------ | +| DEVICE_LOCAL_DISK | 1 | Local disk.| +| DEVICE_SHARED_DISK | 2 | Shared disk.| +| DEVICE_SHARED_TERMINAL | 3 | Distributed network device.| +| DEVICE_NETWORK_NEIGHBORHOODS | 4 | Network neighbor device.| +| DEVICE_EXTERNAL_MTP | 5 | MTP device.| +| DEVICE_EXTERNAL_USB | 6 | USB device.| +| DEVICE_EXTERNAL_CLOUD | 7 | Cloud disk.| + +## fileExtensionInfo.DeviceFlag + +Defines the values of **deviceFlags** used in **RootInfo**. **deviceFlags** is used to determine whether a capability is available through the AND operation. + +**System capability**: SystemCapability.FileManagement.UserFileService + +### Attributes + + | Name| Type | Value| Readable| Writable| Description | + | ------ | ------ | ---- | ---- | ---- | -------- | + | SUPPORTS_READ | number | 0b1 | Yes | No | Read support.| + | SUPPORTS_WRITE | number | 0b10 | Yes | No | Write support.| + +## fileExtensionInfo.DocumentFlag + +Defines the values of **mode** used in **FileInfo**. + +**System capability**: SystemCapability.FileManagement.UserFileService + +### Attributes + + | Name| Type | Value| Readable| Writable| Description | + | ------ | ------ | ---- | ---- | ---- | -------- | + | REPRESENTS_FILE | number | 0b1 | Yes | No | File.| + | REPRESENTS_DIR | number | 0b10 | Yes | No | Directory.| + | SUPPORTS_READ | number | 0b100 | Yes | No | Read support.| + | SUPPORTS_WRITE | number | 0b1000 | Yes | No | Write support.| diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md index 8c85faa1eee7abbbc888e11cd5c12f2a308905c7..373fbf8faee9549ab17b5fbe462997f8cb3eaa30 100644 --- a/en/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -38,12 +38,16 @@ This is a system API. **Example** ``` -let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOptions) { - console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, - "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 } +let callback = function (keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +} +try { + inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback); +} catch (error) { + console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`); } -inputConsumer.on('key', keyOptions, callback); ``` @@ -68,12 +72,16 @@ This is a system API. **Example** ``` -let keyOptions = {preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0} -let callback = function(keyOptions) { - console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, - "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 } +let callback = function (keyOptions) { + console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey, + "isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration) +} +try { + inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback); +} catch (error) { + console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`); } -inputConsumer.off('key', keyOptions, callback); ``` diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index 2f4986f90f431852a7b2e76d8f58e24ba8469ed9..f5cf9b1af9502462bd906302bee23fcff28780b4 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -15,6 +15,130 @@ The Input Device module implements listening for connection, disconnection, and ```js import inputDevice from '@ohos.multimodalInput.inputDevice'; ``` +## inputDevice.getDeviceList9+ + +getDeviceList(callback: AsyncCallback<Array<number>>): void + +Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------- | +| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + inputDevice.getDeviceList((error, ids) => { + if (error) { + console.log(`Failed to get device list. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + this.data = ids; + console.log("The device ID list is: " + ids); + }); +} catch (error) { + console.info("getDeviceList " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceList9+ + +getDeviceList(): Promise<Array<number>> + +Obtains the IDs of all input devices. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Return value** + +| Name | Description | +| ---------------------------------- | ------------------------------- | +| Promise<Array<number>> | Promise used to return the result.| + +**Example** + +```js +try { + inputDevice.getDeviceList().then((ids) => { + console.log("The device ID list is: " + ids); + }); +} catch (error) { + console.info("getDeviceList " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceInfo9+ + +getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): void + +Obtains information about an input device. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------------- | ---- | --------------------------------------- | +| deviceId | number | Yes | ID of the input device. | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| + +**Example** + +```js +// Obtain the name of the device whose ID is 1. +try { + inputDevice.getDeviceInfo(1, (error, inputDevice) => { + if (error) { + console.log(`Failed to get device information. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log("The device name is: " + inputDevice.name); + }); +} catch (error) { + console.info("getDeviceInfo " + error.code + " " + error.message); +} +``` + +## inputDevice.getDeviceInfo9+ + +getDeviceInfo(deviceId: number): Promise<InputDeviceData> + +Obtains information about an input device. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ---------------------- | +| deviceId | number | Yes | ID of the input device.| + +**Return value** + +| Name | Description | +| -------------------------------------------------- | ------------------------------- | +| Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| + +**Example** + +```js +// Obtain the name of the device whose ID is 1. +try { + inputDevice.getDeviceInfo(id).then((inputDevice) => { + console.log("The device name is: " + inputDevice.name); + }); +} catch (error) { + console.info("getDeviceInfo " + error.code + " " + error.message); +} +``` + ## inputDevice.on9+ @@ -35,20 +159,24 @@ Enables listening for hot swap events of an input device. ```js let isPhysicalKeyboardExist = true; -inputDevice.on("change", (data) => { +try { + inputDevice.on("change", (data) => { console.log("type: " + data.type + ", deviceId: " + data.deviceId); inputDevice.getKeyboardType(data.deviceId, (err, ret) => { - console.log("The keyboard type of the device is: " + ret); - if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { - // The physical keyboard is connected. - isPhysicalKeyboardExist = true; - } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { - // The physical keyboard is disconnected. - isPhysicalKeyboardExist = false; - } + console.log("The keyboard type of the device is: " + ret); + if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + // The physical keyboard is connected. + isPhysicalKeyboardExist = true; + } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + // The physical keyboard is disconnected. + isPhysicalKeyboardExist = false; + } }); -}); -// Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist. + }); + // Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist. +} catch (error) { + console.info("oninputdevcie " + error.code + " " + error.message); +} ``` ## inputDevice.off9+ @@ -69,24 +197,43 @@ Disables listening for hot swap events of an input device. **Example** ```js -function listener(data) { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); +callback: function(data) { + console.log("type: " + data.type + ", deviceId: " + data.deviceId); } +try { + inputDevice.on("change", this.callback); +} catch (error) { + console.info("oninputdevcie " + error.code + " " + error.message) +} + +// Enable listening for hot swap events of an input device. +inputDevice.on("change", listener); + // Disable this listener. -inputDevice.off("change", listener); +try { + inputDevice.off("change", this.callback); +} catch (error) { + console.info("offinputdevcie " + error.code + " " + error.message) +} // Disable all listeners. -inputDevice.off("change"); +try { + inputDevice.off("change"); +} catch (error) { + console.info("offinputdevcie " + error.code + " " + error.message); +} // By default, the soft keyboard is closed when listening is disabled. ``` -## inputDevice.getDeviceIds +## inputDevice.getDeviceIds(deprecated) getDeviceIds(callback: AsyncCallback<Array<number>>): void Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result. +This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead. + **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **Parameters** @@ -103,12 +250,14 @@ inputDevice.getDeviceIds((ids)=>{ }); ``` -## inputDevice.getDeviceIds +## inputDevice.getDeviceIds(deprecated) getDeviceIds(): Promise<Array<number>> Obtains the IDs of all input devices. This API uses a promise to return the result. +This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead. + **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **Return value** @@ -125,12 +274,14 @@ inputDevice.getDeviceIds().then((ids)=>{ }); ``` -## inputDevice.getDevice +## inputDevice.getDevice(deprecated) getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void Obtains information about an input device. This API uses an asynchronous callback to return the result. +This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead. + **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **Parameters** @@ -149,12 +300,14 @@ inputDevice.getDevice(1, (inputDevice)=>{ }); ``` -## inputDevice.getDevice +## inputDevice.getDevice(deprecated) getDevice(deviceId: number): Promise<InputDeviceData> Obtains information about an input device. This API uses a promise to return the result. +This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead. + **System capability**: SystemCapability.MultimodalInput.Input.InputDevice **Parameters** @@ -198,9 +351,13 @@ Obtains the key codes supported by the input device. This API uses an asynchrono ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. -inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{ +try { + inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => { console.log("The query result is as follows: " + ret); -}); + }); +} catch (error) { + console.info("supportKeys " + error.code + " " + error.message); +} ``` ## inputDevice.supportKeys9+ @@ -228,9 +385,13 @@ Obtains the key codes supported by the input device. This API uses a promise to ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. -inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{ +try { + inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => { console.log("The query result is as follows: " + ret); -}) + }); +} catch (error) { + console.info("supportKeys " + error.code + " " + error.message); +} ``` ## inputDevice.getKeyboardType9+ @@ -252,9 +413,18 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call ```js // Query the keyboard type of the input device whose ID is 1. -inputDevice.getKeyboardType(1, (ret)=>{ - console.log("The keyboard type of the device is: " + ret); -}); +try { + inputDevice.getKeyboardType(1, (error, number) => { + if (error) { + console.log(`Failed to get keyboardtype. + error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); + return; + } + console.log("The keyboard type of the device is: " + number); + }); +} catch (error) { + console.info("getKeyboardType " + error.code + " " + error.message); +} ``` ## inputDevice.getKeyboardType9+ @@ -275,14 +445,18 @@ Obtains the keyboard type of an input device. This API uses a promise to return ```js // Query the keyboard type of the input device whose ID is 1. -inputDevice.getKeyboardType(1).then((ret)=>{ - console.log("The keyboard type of the device is: " + ret); -}) +try { + inputDevice.getKeyboardType(1).then((number) => { + console.log("The keyboard type of the device is: " + number); + }); +} catch (error) { + console.info("getKeyboardType " + error.code + " " + error.message); +} ``` ## DeviceListener9+ -Defines the information about an input device. +Defines the listener for hot swap events of an input device. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice diff --git a/en/application-dev/reference/apis/js-apis-inputeventclient.md b/en/application-dev/reference/apis/js-apis-inputeventclient.md index c38734f143bed4fd8288df7672d721caf4696025..695a7a5bf4b611270ff32acb8aab17cc6f802aa3 100644 --- a/en/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/en/application-dev/reference/apis/js-apis-inputeventclient.md @@ -36,13 +36,24 @@ This is a system API. **Example** ```js -let keyEvent = { +try { + var keyEvent = { isPressed: true, keyCode: 2, keyDownDuration: 0, isIntercepted: false + } + inputEventClient.injectKeyEvent({ KeyEvent: keyEvent }); + var keyEvent1 = { + isPressed: false, + keyCode: 2, + keyDownDuration: 0, + isIntercepted: false + }; + inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 }); +} catch (error) { + console.info("injectKeyEvent " + error.code + " " + error.message); } -let res = inputEventClient.injectEvent({KeyEvent: keyEvent}); ``` diff --git a/en/application-dev/reference/apis/js-apis-inputmonitor.md b/en/application-dev/reference/apis/js-apis-inputmonitor.md index 9fdcb88e96a336e19a87efab9c9856af746df558..315e2d81f718bff6f6f1bc9b0ce813df11850da5 100644 --- a/en/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/en/application-dev/reference/apis/js-apis-inputmonitor.md @@ -43,10 +43,14 @@ This is a system API. **Example** ```js -inputMonitor.off("touch", (event) => { - // A touch event is consumed. - return false; -}); +try { + inputMonitor.on("touch", (data)=> { + console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`); + return false; + }); +} catch (error) { + console.info("onMonitor " + error.code + " " + error.message) +} ``` on(type: "mouse", receiver: Callback<MouseEvent>): void @@ -69,13 +73,16 @@ This is a system API. **Example** ```js -inputMonitor.off("mouse", (event) => { - // A mouse event is consumed. -}); +try { + inputMonitor.on("mouse", (data)=> { + console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`); + return false; + }); +} catch (error) { + console.info("onMonitor " + error.code + " " + error.message) +} ``` - - ## inputMonitor.off off(type: "touch", receiver?: TouchEventReceiver): void @@ -98,7 +105,26 @@ This is a system API. **Example** ```js -inputMonitor.off("touch"); +// Disable listening globally. +try { + inputMonitor.off("touch"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} +// Disable listening for this receiver. +callback:function(data) { + console.info(`call success ${JSON.stringify(data)}`); +}, +try { + inputMonitor.on("touch", this.callback); +} catch (error) { + console.info("onTouchMonitor " + error.code + " " + error.message) +}, +try { + inputMonitor.off("touch",this.callback); +} catch (error) { + console.info("offTouchMonitor " + error.code + " " + error.message) +} ``` off(type: "mouse", receiver?:Callback\):void @@ -121,7 +147,26 @@ This is a system API. **Example** ```js -inputMonitor.off("mouse"); +// Disable listening globally. +try { + inputMonitor.off("mouse"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} +// Disable listening for this receiver. +callback:function(data) { + console.info(`call success ${JSON.stringify(data)}`); +}, +try { + inputMonitor.on("mouse", this.callback); +} catch (error) { + console.info("onMouseMonitor " + error.code + " " + error.message) +}, +try { + inputMonitor.off("mouse", this.callback); +} catch (error) { + console.info("offMouseMonitor " + error.code + " " + error.message) +} ``` @@ -149,9 +194,13 @@ This is a system API. **Example** ```js -inputMonitor.on("touch", (event) => { - // A touch event is consumed. - return false; -}); -inputMonitor.off("touch"); +try { + inputMonitor.on("touch", (event) => { + // If true is returned, all subsequent events of this operation will be consumed by the listener, instead of being distributed to the window. + return false; + }); + inputMonitor.off("touch"); +} catch (error) { + console.info("offMonitor " + error.code + " " + error.message) +} ``` diff --git a/en/application-dev/reference/apis/js-apis-media.md b/en/application-dev/reference/apis/js-apis-media.md index b29a380a5b1b2e8afb4d41687a659dc29db4344c..8c4dd734fbdbe5d2a3d2bbd621f04f54ed20d883 100644 --- a/en/application-dev/reference/apis/js-apis-media.md +++ b/en/application-dev/reference/apis/js-apis-media.md @@ -1,7 +1,6 @@ # Media > **NOTE** -> > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources. @@ -53,7 +52,7 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance, which can be used to manage and play video media.| +| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.| **Example** @@ -80,9 +79,9 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result **Return value** -| Type | Description | -| ------------------------------------- | ----------------------------------- | -| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance, which can be used to manage and play video media.| +| Type | Description | +| ------------------------------------- | ------------------------------------------------------------ | +| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.| **Example** @@ -112,9 +111,9 @@ Only one **AudioRecorder** instance can be created per device. **Return value** -| Type | Description | -| ------------------------------- | ----------------------------------------- | -| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise.| +| Type | Description | +| ------------------------------- | ------------------------------------------------------------ | +| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise. The instance can be used to record audio media.| **Example** @@ -135,7 +134,7 @@ Only one **AudioRecorder** instance can be created per device. | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance, which can be used to record video media.| +| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.| **Example** @@ -163,9 +162,9 @@ Only one **AudioRecorder** instance can be created per device. **Return value** -| Type | Description | -| ----------------------------------------- | ----------------------------------- | -| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance, which can be used to record video media.| +| Type | Description | +| ----------------------------------------- | ------------------------------------------------------------ | +| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.| **Example** @@ -263,7 +262,7 @@ Enumerates the buffering event types. | BUFFERING_START | 1 | Buffering starts. | | BUFFERING_END | 2 | Buffering ends. | | BUFFERING_PERCENT | 3 | Buffering progress, in percent. | -| CACHED_DURATION | 4 | Cache duration, in milliseconds.| +| CACHED_DURATION | 4 | Cache duration, in ms.| ## AudioPlayer @@ -362,9 +361,9 @@ Seeks to the specified playback position. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ------------------------------------ | -| timeMs | number | Yes | Position to seek to, in milliseconds.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ----------------------------------------------------------- | +| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].| **Example** @@ -427,9 +426,9 @@ Obtains the audio track information. This API uses an asynchronous callback to r **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------------ | ---- | -------------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the audio track information obtained.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| callback | AsyncCallback> | Yes | Callback used to return a **MediaDescription** array, which records the audio track information.| **Example** @@ -463,9 +462,9 @@ Obtains the audio track information. This API uses a promise to return the resul **Return value** -| Type | Description | -| ------------------------------------------------------ | ------------------------------- | -| Promise> | Promise used to return the audio track information obtained.| +| Type | Description | +| ------------------------------------------------------ | ----------------------------------------------- | +| Promise> | Promise used to return a **MediaDescription** array, which records the audio track information.| **Example** @@ -497,7 +496,7 @@ for (let i = 0; i < arrayDescription.length; i++) { on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferinginfotype8), value: number) => void): void -Subscribes to the audio buffering update event. +Subscribes to the audio buffering update event. Only network playback supports this subscription. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer @@ -594,7 +593,7 @@ audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' e on(type: 'timeUpdate', callback: Callback\): void -Subscribes to the **'timeUpdate'** event. +Subscribes to the **'timeUpdate'** event. This event is reported every second when the audio playback is in progress. **System capability**: SystemCapability.Multimedia.Media.AudioPlayer @@ -1014,10 +1013,10 @@ Seeks to the specified playback position. The next key frame at the specified po **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------- | ---- | ------------------------------------ | -| timeMs | number | Yes | Position to seek to, in milliseconds.| -| callback | function | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | -------- | ---- | ------------------------------------------------------------ | +| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].| +| callback | function | Yes | Callback used to return the result. | **Example** @@ -1042,11 +1041,11 @@ Seeks to the specified playback position. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------------------ | -| timeMs | number | Yes | Position to seek to, in milliseconds.| -| mode | [SeekMode](#seekmode8) | Yes | Seek mode. | -| callback | function | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].| +| mode | [SeekMode](#seekmode8) | Yes | Seek mode. | +| callback | function | Yes | Callback used to return the result. | **Example** @@ -1072,16 +1071,16 @@ Seeks to the specified playback position. If **mode** is not specified, the next **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ---------------------- | ---- | ------------------------------------ | -| timeMs | number | Yes | Position to seek to, in milliseconds.| -| mode | [SeekMode](#seekmode8) | No | Seek mode. | +| Name| Type | Mandatory| Description | +| ------ | ---------------------- | ---- | ------------------------------------------------------------ | +| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].| +| mode | [SeekMode](#seekmode8) | No | Seek mode. | **Return value** -| Type | Description | -| -------------- | ----------------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| -------------- | ------------------------------------------- | +| Promise\ | Promise used to return the playback position, in ms.| **Example** @@ -1220,9 +1219,9 @@ Obtains the video track information. This API uses an asynchronous callback to r **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------------------ | ---- | -------------------------- | -| callback | AsyncCallback> | Yes | Callback used to return the video track information obtained.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | +| callback | AsyncCallback> | Yes | Callback used to return a **MediaDescription** array, which records the video track information.| **Example** @@ -1256,9 +1255,9 @@ Obtains the video track information. This API uses a promise to return the resul **Return value** -| Type | Description | -| ------------------------------------------------------ | ------------------------------- | -| Promise> | Promise used to return the video track information obtained.| +| Type | Description | +| ------------------------------------------------------ | ----------------------------------------------- | +| Promise> | Promise used to return a **MediaDescription** array, which records the video track information.| **Example** @@ -1332,9 +1331,9 @@ Sets the video playback speed. This API uses a promise to return the result. **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return playback speed. For details, see [PlaybackSpeed](#playbackspeed8).| **Example** @@ -1389,13 +1388,13 @@ Selects a bit rate from available ones, which can be obtained by calling [availa | Name | Type | Mandatory| Description | | ------- | ------ | ---- | -------------------------------------------- | -| bitrate | number | Yes | Bit rate to select, which is used in the HLS multi-bit rate scenario. The unit is bit/s.| +| bitrate | number | Yes | Bit rate, which is used in the HLS multi-bit rate scenario. The unit is bit/s.| **Return value** -| Type | Description | -| ---------------- | ------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ---------------- | --------------------------- | +| Promise\ | Promise used to return the bit rate.| **Example** @@ -1435,7 +1434,7 @@ videoPlayer.on('playbackCompleted', () => { on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void -Subscribes to the video buffering update event. +Subscribes to the video buffering update event. Only network playback supports this subscription. **System capability**: SystemCapability.Multimedia.Media.VideoPlayer diff --git a/en/application-dev/reference/apis/js-apis-net-connection.md b/en/application-dev/reference/apis/js-apis-net-connection.md index 4502b4cd9601bf0ae050f972a674028fb271a86a..31414ab325572d7ed25a31b1b3a78a725dce39e6 100644 --- a/en/application-dev/reference/apis/js-apis-net-connection.md +++ b/en/application-dev/reference/apis/js-apis-net-connection.md @@ -309,6 +309,8 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): v Reports connection of the data network. This API uses an asynchronous callback to return the result. +If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. + **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -337,6 +339,8 @@ reportNetConnected(netHandle: NetHandle): Promise<void> Reports connection of the data network. This API uses a promise to return the result. +If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. + **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -351,7 +355,7 @@ Reports connection of the data network. This API uses a promise to return the re | Type| Description| | -------- | -------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> | Promise that returns no value.| **Example** @@ -370,6 +374,8 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>) Reports disconnection of the data network. This API uses an asynchronous callback to return the result. +If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. + **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -398,6 +404,8 @@ reportNetDisconnected(netHandle: NetHandle): Promise<void> Reports disconnection of the data network. This API uses a promise to return the result. +If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module. + **Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET **System capability**: SystemCapability.Communication.NetManager.Core @@ -412,7 +420,7 @@ Reports disconnection of the data network. This API uses a promise to return the | Type| Description| | -------- | -------- | -| Promise<void> | Promise used to return the result.| +| Promise<void> | Promise that returns no value.| **Example** @@ -521,7 +529,7 @@ This is a system API. | Type | Description | | ------------------------------------------- | ----------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Example** @@ -570,7 +578,7 @@ This is a system API. | Type | Description | | ------------------------------------------- | ----------------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Example** @@ -888,7 +896,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses | Type | Description | | -------------- | ---------------------- | -| Promise\ | Promise used to return the result.| +| Promise\ | Promise that returns no value.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-pointer.md b/en/application-dev/reference/apis/js-apis-pointer.md index 97429f0dee1df4f12487cce5d361182ba660fe87..ea2d452000bb542e55232a29456d3811fd24526c 100644 --- a/en/application-dev/reference/apis/js-apis-pointer.md +++ b/en/application-dev/reference/apis/js-apis-pointer.md @@ -12,7 +12,7 @@ The mouse pointer module provides APIs related to pointer attribute management. import pointer from '@ohos.multimodalInput.pointer'; ``` -## pointer.setPointerVisibele +## pointer.setPointerVisible9+ setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void @@ -22,24 +22,28 @@ Sets the visible status of the mouse pointer. This API uses an asynchronous call **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------- | ---- | ------------------------------------------------------------------- | -| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| -| callback | AysncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ---------------------------------------- | +| visible | boolean | Yes | Whether the mouse pointer is visible.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Example** ```js -pointer.setPointerVisible(true, (err, data) => { - if (err) { - console.log(`set pointer visible failed. err=${JSON.stringify(err)}`); - return; +try { + pointer.setPointerVisible(true, (error) => { + if (error) { + console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; } - console.log(`set pointer visible success.`); -); + console.log(`Set pointer visible success`); + }); +} catch (error) { + console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} ``` -## pointer.setPointerVisible +## pointer.setPointerVisible9+ setPointerVisible(visible: boolean): Promise<void> @@ -49,66 +53,400 @@ Sets the visible status of the mouse pointer. This API uses a promise to return **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------- | ---- | ------------------------------------------------------------------- | -| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.| +| Name | Type | Mandatory | Description | +| ------- | ------- | ---- | ---------------------------------------- | +| visible | boolean | Yes | Whether the mouse pointer is visible.| **Return value** -| Parameter | Description | -| ------------------- | ------------------------------- | +| Name | Description | +| ------------------- | ------------------- | | Promise<void> | Promise used to return the result.| **Example** ```js -pointer.setPointerVisible(false).then( data => { - console.log(`set mouse pointer visible success`); - }, data => { - console.log(`set mouse pointer visible failed err=${JSON.stringify(data)}`); -}); +try { + pointer.setPointerVisible(false).then(() => { + console.log(`Set pointer visible success`); + }); +} catch (error) { + console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} ``` -## pointer.isPointerVisible +## pointer.isPointerVisible9+ isPointerVisible(callback: AsyncCallback<boolean>): void -Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. +Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.Pointer **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------- | ---- | ---------------------------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | -------------- | +| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.| **Example** ```js -pointer.isPointerVisible((visible)=>{ - console.log("The mouse pointer visible attributes is " + visible); -}); +try { + pointer.isPointerVisible((error, visible) => { + if (error) { + console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); + }); +} catch (error) { + console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} ``` -## pointer.isPointerVisible +## pointer.isPointerVisible9+ isPointerVisible(): Promise<boolean> -Checks the visible status of the mouse pointer. This API uses a promise to return the result. +Checks the visible status of the mouse pointer. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.Pointer **Return value** -| Parameter | Description | -| ---------------------- | ------------------------------- | +| Name | Description | +| ---------------------- | ------------------- | | Promise<boolean> | Promise used to return the result.| **Example** ```js -pointer.isPointerVisible().then( data => { - console.log(`isPointerThen success data=${JSON.stringify(data)}`); +pointer.isPointerVisible().then((visible) => { + console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`); }); ``` + +## pointer.setPointerSpeed9+ + +setPointerSpeed(speed: number, callback: AsyncCallback<void>): void + +Sets the mouse movement speed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ------------------------------------- | +| speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**. | +| callback | AysncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + pointer.setPointerSpeed(5, (error) => { + if (error) { + console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Set pointer speed success`); + }); +} catch (error) { + console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## pointer.setPointerSpeed9+ + +setPointerSpeed(speed: number): Promise<void> + +Sets the mouse movement speed. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------------------------------- | +| speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**.| + +**Return value** + +| Name | Description | +| ------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + +```js +try { + pointer.setPointerSpeed(5).then(() => { + console.log(`Set pointer speed success`); + }); +} catch (error) { + console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## pointer.getPointerSpeed9+ + +getPointerSpeed(callback: AsyncCallback<number>): void + +Obtains the mouse movement speed. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | -------------- | +| callback | AsyncCallback<number> | Yes | Callback used to return the result.| + +**Example** + +```js +try { + pointer.getPointerSpeed((error, speed) => { + if (error) { + console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + return; + } + console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); + }); +} catch (error) { + console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## pointer.getPointerSpeed9+ + +getPointerSpeed(): Promise<number> + +Obtains the mouse movement speed. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Return value** + +| Name | Description | +| --------------------- | ------------------- | +| Promise<number> | Promise used to return the result.| + +**Example** + +```js +try { + pointer.getPointerSpeed().then(speed => { + console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`); + }); +} catch (error) { + console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`); +} +``` + +## pointer.getPointerStyle9+ + +getPointerStyle(windowId: number, callback: AsyncCallback<PointerStyle>): void + +Obtains the mouse pointer style. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------------- | +| windowId | number | Yes | Window ID. | +| callback | AsyncCallback<[PointerStyle](#pointerstyle9)> | Yes | Callback used to return the result.| + +**Example** + +```js +import window from '@ohos.window'; + +window.getTopWindow((error, win) => { + win.getProperties((error, properties) => { + var windowId = properties.id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId, (error, style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + }); +}); +``` + +## pointer.getPointerStyle9+ + +getPointerStyle(windowId: number): Promise<PointerStyle> + +Obtains the mouse pointer style. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | -------- | +| windowId | number | Yes | Window ID.| + +**Return value** + +| Name | Description | +| ---------------------------------------- | ------------------- | +| Promise<[PointerStyle](#pointerstyle9)> | Promise used to return the result.| + +**Example** + +```js +import window from '@ohos.window'; + +window.getTopWindow((error, win) => { + win.getProperties((error, properties) => { + var windowId = properties.id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.getPointerStyle(windowId).then((style) => { + console.log(`Get pointer style success, style: ${JSON.stringify(style)}`); + }); + } catch (error) { + console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + }); +}); +``` + +## pointer.setPointerStyle9+ + +setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback<void>): void + +Sets the mouse pointer style. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------------ | ------------------------------ | ---- | ----------------------------------- | +| windowId | number | Yes | Window ID. | +| pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. | +| callback | AysncCallback<void> | Yes | Callback used to return the result.| + +**Example** + +```js +import window from '@ohos.window'; + +window.getTopWindow((error, win) => { + win.getProperties((error, properties) => { + var windowId = properties.id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + }); +}); +``` +## pointer.setPointerStyle9+ + +setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise<void> + +Sets the mouse pointer style. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------------------- | ------------------------------ | ---- | ---------------- | +| windowId | number | Yes | Window ID. | +| pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. | +| Promise<void> | void | Yes | Promise used to return the result.| + +**Example** + +```js +import window from '@ohos.window'; + +window.getTopWindow((error, win) => { + win.getProperties((error, properties) => { + var windowId = properties.id; + if (windowId < 0) { + console.log(`Invalid windowId`); + return; + } + try { + pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { + console.log(`Set pointer style success`); + }); + } catch (error) { + console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`); + } + }); +}); +``` +## PointerStyle9+ + +Enumerates mouse pointer styles. + +**System capability**: SystemCapability.MultimodalInput.Input.Pointer + +| Name | Value | Description | +| -------------------------------- | ---- | ------ | +| DEFAULT | 0 | Default | +| EAST | 1 | East arrow | +| WEST | 2 | West arrow | +| SOUTH | 3 | South arrow | +| NORTH | 4 | North arrow | +| WEST_EAST | 5 | West-east arrow | +| NORTH_SOUTH | 6 | North-south arrow | +| NORTH_EAST | 7 | North-east arrow | +| NORTH_WEST | 8 | North-west arrow | +| SOUTH_EAST | 9 | South-east arrow | +| SOUTH_WEST | 10 | South-west arrow | +| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment| +| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment| +| CROSS | 13 | Cross (accurate selection) | +| CURSOR_COPY | 14 | Copy cursor | +| CURSOR_FORBID | 15 | Forbid cursor | +| COLOR_SUCKER | 16 | Sucker | +| HAND_GRABBING | 17 | Grabbing hand | +| HAND_OPEN | 18 | Opening hand | +| HAND_POINTING | 19 | Hand-shaped pointer | +| HELP | 20 | Help | +| MOVE | 21 | Move | +| RESIZE_LEFT_RIGHT | 22 | Left and right resizing| +| RESIZE_UP_DOWN | 23 | Up and down resizing| +| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair| +| SCREENSHOT_CURSOR | 25 | Screenshot cursor | +| TEXT_CURSOR | 26 | Text cursor | +| ZOOM_IN | 27 | Zoom in | +| ZOOM_OUT | 28 | Zoom out | +| MIDDLE_BTN_EAST | 29 | Scrolling east | +| MIDDLE_BTN_WEST | 30 | Scrolling west | +| MIDDLE_BTN_SOUTH | 31 | Scrolling south | +| MIDDLE_BTN_NORTH | 32 | Scrolling north | +| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south | +| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east | +| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west | +| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east | +| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west | +| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions| diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index 206ad668b6dbdaf8f12d74423a92c5d6ebaf2853..a5515dadfbd141dc16bfa44b2edffea5013109f4 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy **Example** ```js -let name = "China Mobile"; +let name = "ShowName"; sim.setShowName(0, name, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -744,7 +744,7 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom **Example** ```js -let name = "China Mobile"; +let name = "ShowName"; let promise = sim.setShowName(0, name); promise.then(data => { console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); diff --git a/en/application-dev/reference/apis/js-apis-uiappearance.md b/en/application-dev/reference/apis/js-apis-uiappearance.md deleted file mode 100644 index 3bac964627675b3475e273551d06b146636b410d..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-uiappearance.md +++ /dev/null @@ -1,106 +0,0 @@ -# UI Appearance - -The **uiAppearance** module provides basic capabilities for managing the system appearance. It allows for color mode configuration currently, and will introduce more features over time. - -> **NOTE** -> -> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. -> -> The APIs provided by this module are system APIs. - - -## Modules to Import - -```ts -import uiAppearance from '@ohos.uiAppearance' -``` - - -## DarkMode - -Enumerates the color modes. - - -**System capability**: SystemCapability.ArkUI.UiAppearance - -| Name| Value| Description| -| -- | -- | -- | -| ALWAYS_DARK | 0 | The system is always in dark mode. | -| ALWAYS_LIGHT | 1 | The system is always in light mode.| - - -## uiAppearance.setDarkMode - -setDarkMode(mode: DarkMode, callback: AsyncCallback\): void - -Sets the system color mode. This API uses an asynchronous callback to return the result. - -**Permission required**: ohos.permission.UPDATE_CONFIGURATION - -**System capability**: SystemCapability.ArkUI.UiAppearance - -**Parameters** -| Name| Type| Mandatory| Description| -| -- | -- | -- | -- | -| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| -| callback | AsyncCallback\| Yes| Callback used to return the result.| - -**Example** - ```ts -uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK, (err) => { - console.info(`${err}`); -}) - ``` - - -## uiAppearance.setDarkMode - -setDarkMode(mode: DarkMode): Promise\; - -Sets the system color mode. This API uses a promise to return the result. - -**Permission required**: ohos.permission.UPDATE_CONFIGURATION - -**System capability**: SystemCapability.ArkUI.UiAppearance - -**Parameters** -| Name| Type| Mandatory| Description| -| -- | -- | -- | -- | -| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| - -**Return value** - -| Type | Description | -| ------ | ------------------------------ | -| Promise\ | Promise that returns no value.| - -**Example** - ```ts -uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { - console.log('Set dark-mode successfully.'); -}).catch((err) => { - console.log(`Set dark-mode failed, ${err}`); -}); - ``` - - -## uiAppearance.getDarkMode - -getDarkMode(): DarkMode; - -Obtains the system color mode. - -**Permission required**: ohos.permission.UPDATE_CONFIGURATION - -**System capability**: SystemCapability.ArkUI.UiAppearance - -**Return value** -| Type| Description| -| -- | -- | -|[DarkMode](#darkmode) | Color mode obtained.| - -**Example** - ```ts -let darkMode = uiAppearance.getDarkMode(); -console.log(`Get dark-mode ${darkMode}`); - ``` diff --git a/en/application-dev/reference/apis/js-apis-window.md b/en/application-dev/reference/apis/js-apis-window.md index e88c24874ded38ec76625957039617147d5664b6..24176d5c9727d1905d229aca43521462d6ebdd29 100644 --- a/en/application-dev/reference/apis/js-apis-window.md +++ b/en/application-dev/reference/apis/js-apis-window.md @@ -2334,7 +2334,7 @@ Loads content from a page associated with a local storage to this window. This A | Name | Type | Mandatory| Description | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** @@ -2380,7 +2380,7 @@ Loads content from a page associated with a local storage to this window. This A | Name | Type | Mandatory| Description | | ------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| +| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application.| **Return value** @@ -6199,7 +6199,7 @@ Loads content from a page associated with a local storage to the main window in | Name | Type | Mandatory | Description | | -------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | +| storage | LocalStorage | Yes | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Error codes** @@ -6251,7 +6251,7 @@ Loads content from a page associated with a local storage to the main window in | Name | Type | Mandatory | Description | | ------- | ------------------------------------------------------------ | --------- | ------------------------------------------------------------ | | path | string | Yes | Path of the page from which the content will be loaded. | -| storage | [LocalStorage](../../quick-start/arkts-state-mgmt-application-level.md#localstorage) | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | +| storage | LocalStorage | No | A storage unit, which provides storage for variable state properties and non-variable state properties of an application. | **Return value** diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 75ac7f144e75fd9ed1068f161854fb185c0d6210..967def0ecbdfda71fe88bc55ac02e6d395046a00 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -1,31 +1,32 @@ -# Zip +# zlib + +The **zlib** module provides APIs for file compression and decompression. > **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Constraints - -None ## Modules to Import ```javascript import zlib from '@ohos.zlib'; ``` -## zlib.zipFile -zipFile(inFile:string, outFile:string, options: Options): Promise<void> +## zlib.zipFile(deprecated) +zipFile(inFile: string, outFile: string, options: Options): Promise<void> Zips a file. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [zlib.compressFile](#zlibcompressfile9) instead. + **System capability**: SystemCapability.BundleManager.Zlib **Parameters** | Name | Type | Mandatory| Description | | ------- | ------------------- | ---- | ------------------------------------------------------------ | -| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| -| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | +| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | | options | [Options](#options) | No | Optional parameters for the zip operation. | **Return value** @@ -36,59 +37,59 @@ Zips a file. This API uses a promise to return the result. **Example 1** -```javascript - +```typescript // Zip a file. -import zlib from '@ohos.zlib' -var inFile = "/xxx/filename.xxx"; -var outFile = "/xxx/xxx.zip"; -var options = { +import zlib from '@ohos.zlib'; +let inFile = '/xxx/filename.xxx'; +let outFile = '/xxx/xxx.zip'; +let options = { level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY }; zlib.zipFile(inFile, outFile, options).then((data) => { - console.log("zipFile result: " + data); -}).catch((err)=>{ - console.log("catch((err)=>" + err); + console.log('zipFile result is ' + JSON.Stringify(data)); +}).catch((err) => { + console.log('error is ' + JSON.Stringify(err)); }); - ``` **Example 2** -``` +```typescript // Zip a folder. -import zlib from '@ohos.zlib' -var inFile = "/xxx/xxx"; -var outFile = "/xxx/xxx.zip"; -var options = { +import zlib from '@ohos.zlib'; +let inFile = '/xxx/xxx'; +let outFile = '/xxx/xxx.zip'; +let options = { level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY }; zlib.zipFile(inFile , outFile, options).then((data) => { - console.log("zipFile result: " + data); + console.log('zipFile result is ' + JSON.Stringify(data)); }).catch((err)=>{ - console.log("catch((err)=>" + err); + console.log('error is ' + JSON.Stringify(err)); }); ``` -## zlib.unzipFile +## zlib.unzipFile(deprecated) unzipFile(inFile:string, outFile:string, options: Options): Promise<void> Unzips a file. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [zlib.decompressFile](#zlibdecompressfile9) instead. + **System capability**: SystemCapability.BundleManager.Zlib **Parameters** | Name | Type | Mandatory| Description | | ------- | ------------------- | ---- | ------------------------------------------------------------ | -| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| +| inFile | string | Yes | Path of the folder or file to unzip. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| | outFile | string | Yes | Path of the unzipped file. | | options | [Options](#options) | No | Optional parameters for the unzip operation. | @@ -100,11 +101,11 @@ Unzips a file. This API uses a promise to return the result. **Example** -```javascript +```typescript // Unzip a file. -import zlib from '@ohos.zlib' -var inFile = "/xx/xxx.zip"; -var outFile = "/xxx"; +import zlib from '@ohos.zlib'; +let inFile = '/xx/xxx.zip'; +let outFile = '/xxx'; let options = { level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, @@ -112,11 +113,202 @@ let options = { strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY }; zlib.unzipFile(inFile, outFile, options).then((data) => { - console.log("unzipFile result: " + data); + console.log('unzipFile result is ' + JSON.Stringify(data)); }).catch((err)=>{ - console.log("catch((err)=>" + err); + console.log('error is ' + JSON.Stringify(err)); }) - +``` + +## zlib.compressFile9+ + +compressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback\): void; + +Compresses a file. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the compressed file. | +| options | [Options](#options) | Yes | Compression parameters. | +| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | + +**Error codes** + +| ID| Error Message | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +**Example** + +```typescript +// Compress a file. +// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +import zlib from '@ohos.zlib'; +let inFile = '/xxx/filename.xxx'; +let outFile = '/xxx/xxx.zip'; +let options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.compressFile(inFile, outFile, options, (errData) => { + if (erData !== null) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + } + }) +} catch(errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} +``` + +compressFile(inFile: string, outFile: string, options: Options): Promise\; + +Compresses a file. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the compressed file. | +| options | [Options](#options) | Yes | Compression parameters. | + +**Error codes** + +| ID| Error Message | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +```typescript +// Compress a file. +// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +import zlib from '@ohos.zlib'; +let inFile = '/xxx/filename.xxx'; +let outFile = '/xxx/xxx.zip'; +let options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.compressFile(inFile, outFile, options).then((data) => { + console.info('compressFile success'); + }).catch((errData) => { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + }) +} catch(errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} +``` + + + +## zlib.decompressFile9+ + +decompressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback\): void; + +Decompresses a file. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the decompressed file. | +| options | [Options](#options) | Yes | Decompression parameters. | +| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. | + +**Error codes** + +| ID| Error Message | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +**Example** + +```typescript +// Decompress a file. +// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +import zlib from '@ohos.zlib'; +let inFile = '/xx/xxx.zip'; +let outFile = '/xxx'; +let options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.decompressFile(inFile, outFile, options, (errData) => { + if (erData !== null) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + } + }) +} catch(errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} +``` + +decompressFile(inFile: string, outFile: string, options: Options): Promise\; + +Decompress a file. This API uses a promise to return the result. + +**System capability**: SystemCapability.BundleManager.Zlib + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the decompressed file. | +| options | [Options](#options) | Yes | Decompression parameters. | + +**Error codes** + +| ID| Error Message | +| ------ | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | + +```typescript +// Decompress a file. +// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context. +import zlib from '@ohos.zlib'; +let inFile = '/xx/xxx.zip'; +let outFile = '/xxx'; +let options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY +}; + +try { + zlib.deCompressFile(inFile, outFile, options).then((data) => { + console.info('deCompressFile success'); + }).catch((errData) => { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + }) +} catch(errData) { + console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); +} ``` ## Options @@ -129,16 +321,6 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { | memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). | | strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).| -## zip.MemLevel - -**System capability**: SystemCapability.BundleManager.Zlib - -| Name | Value | Description | -| ----------------- | ---- | -------------------------------- | -| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.| -| MEM_LEVEL_MAX | 9 | Maximum memory used by the **zip** API during compression.| -| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.| - ## zip.CompressLevel **System capability**: SystemCapability.BundleManager.Zlib @@ -150,6 +332,16 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { | COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. | | COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. | +## zip.MemLevel + +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ----------------- | ---- | -------------------------------- | +| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.| +| MEM_LEVEL_MAX | 9 | Maximum memory used by the **zip** API during compression.| +| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.| + ## zip.CompressStrategy **System capability**: SystemCapability.BundleManager.Zlib diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 9710a01a6870933d3b832ce589e192fe0cbcb87d..74d546c622afe8785f4507ea8ab74ba18806febe 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -85,7 +85,7 @@ struct PopupExample { } }, onStateChange: (e) => { - console.info(e.isVisible.toString()) + console.info(JSON.stringify(e.isVisible)) if (!e.isVisible) { this.handlePopup = false } diff --git a/en/application-dev/reference/errorcodes/errcode-DistributedSchedule.md b/en/application-dev/reference/errorcodes/errcode-DistributedSchedule.md new file mode 100644 index 0000000000000000000000000000000000000000..e815e8e881396cde327155f2c4593778d277b19c --- /dev/null +++ b/en/application-dev/reference/errorcodes/errcode-DistributedSchedule.md @@ -0,0 +1,375 @@ +# Distributed Scheduler Error Codes + +## 16600001 The system ability works abnormally. + +**Error Message** + +The system ability works abnormally. + +**Description** + +This error code is reported when the system ability is abnormal. + +**Possible Causes** + +The possible causes are as follows: +1. The DMS service is not started. +2. The **binder** object of DMS is not obtained. +3. Other services on which ability continuation depends are not started or the **binder** object is not obtained. + +**Solution** + +Try again later or restart the device. + +## 16600002 The specified token or callback is not registered. + +**Description** + +This error code is reported if the token or callback used in an API of **continuationManager** is not registered when the API is called. + +**Error Message** + +The specified token or callback is not registered. + +**Possible Causes** + +The specified token or callback is not registered. + +**Solution** + +Register the token or callback before calling the API. + +## 16600003 The number of token registration times has reached the upper limit. + +**Description** + +This error code is reported when the number of times that the **continuationManager.registerContinuation** API is called has reached the upper limit. + +**Error Message** + +The number of token registration times has reached the upper limit. + +**Possible Causes** + +The number of token registration times has reached the upper limit. + +**Solution** + +Use a registered token. Do not register the token too frequently. + +## 16600004 The specified callback has been registered. + +**Description** + +This error code is reported when the **continuationManager.on** API is called with a callback the same as a previous one. + +**Error Message** + +The specified callback has been registered. + +**Possible Causes** + +The same callback is used for repeated registration. + +**Solution** + +Use a different callback for registration. + +## 16300501 The system ability works abnormally. + +**Description** + +This error code is reported when the system ability is abnormal. + +**Error Message** + +The system ability works abnormally. + +**Possible Causes** + +The possible causes are as follows: +1. The DMS service is not started. +2. The **binder** object of DMS is not obtained. +3. Other services on which ability continuation depends are not started or the **binder** object is not obtained. + +**Solution** + +Try again later or restart the device. + +## 16300502 Failed to get the missionInfo of the specified missionId. + +**Description** + +This error code is reported when calling the **distributedMissionManager.continueMission** API fails. + +**Error Message** + +Failed to get the missionInfo of the specified missionId. + +**Possible Causes** + +The possible causes are as follows: +1. The mission ID is incorrect. +2. The mission information corresponding to the mission ID does not exist. + +**Solution** + +Verify the mission ID. + +## 16300503 The application is not installed on the remote end and installation-free is not supported. + +**Description** + +This error code is reported if the application is not installed on the remote end and the installation-free feature is not supported when the **distributedMissionManager.continueMission** API is called. + +**Error Message** + +The application is not installed on the remote end and installation-free is not supported. + +**Possible Causes** + +The application to continue is not installed on the remote end, and the installation-free feature is not supported. + +**Solution** + +1. Check whether the application has been installed on the remote end. +2. Check whether the remote end supports installation-free. + +## 16300504 The application is not installed on the remote end and installation-free is supported. Try again with the freeInstall flag. + +**Description** + +This error code is reported if the application is not installed on the remote end and installation-free is supported when the **distributedMissionManager.continueMission** API is called. + +**Error Message** + +The application is not installed on the remote end and installation-free is supported. Try again with the freeInstall flag. + +**Possible Causes** + +The application to continue is not installed on the remote end, and installation-free is supported. However, the **freeInstall** flag is not carried. + +**Solution** + +Try again with the **freeInstall** flag. + +## 16300505 The operation device must be the device where the application to be continued is currently located or the target device. + +**Description** + +This error code is reported if the operation device is not the device where the application to be continued is currently located (source device) or the target device when the **distributedMissionManager.continueMission** API is called. + +**Error Message** + +The operation device must be the device where the application to be continued is currently located or the target device. + +**Possible Causes** + +The operation device is not the source or target device. + +**Solution** + +Use the source or target device for the operation. + +## 16300506 The local continuation task is already in progress. + +**Description** + +This error code is reported if the local continuation task is in progress when the **distributedMissionManager.continueMission** API is called. + +**Error Message** + +The local continuation task is already in progress. + +**Possible Causes** + +The continuation task has been initiated and is not complete yet. + +**Solution** + +Wait until the continuation task is complete. + +## 3 Failed to flatten the object. + +**Description** + +This error code is reported if the system parameter **DMS_PROXY_INTERFACE_TOKEN** fails flattening when an API of **continuationManager** is called. + +**Error Message** + +Failed to flatten the object. + +**Possible Causes** + +The system parameter **DMS_PROXY_INTERFACE_TOKEN** fails to be written in serialization. + +**Solution** + +Make sure the system functions properly. Restart the system when needed. + +## 7 The object is null. + +**Error Message** + +The object is null. + +**Description** + +This error code is reported if DMS and other objects are empty or reading in serialization fails when an API of **continuationManager** is called. + +**Possible Causes** + +The possible causes are as follows: +1. Reading the input parameters in serialization fails. +2. The DMS service is not started or the **binder** object is not obtained. +3. Other services on which DMS depends are not started or the **binder** object is not obtained. + +**Solution** + +1. Check whether the input parameters are valid. +2. Check whether the DMS service is started normally. Restart the service or device when needed. +3. Check whether other services on which DMS depends are started normally. Restart the services or device when needed. + +## 29360207 The number of registrations has reached the upper limit. + +**Description** + +This error code is reported when the number of times that the **continuationManager.register** API is called exceeds the upper limit. + +**Error Message** + +The number of registrations has reached the upper limit. + +**Possible Causes** + +The number of device registration times has reached the upper limit. + +**Solution** + +Restart the service and avoid frequent registration. + +## 29360208 The token is not registered. + +**Description** + +This error code is reported when an API of **continuationManager** is called with an unregistered token. + +**Error Message** + +The token is not registered. + +**Possible Causes** + +The token is not registered. + +**Solution** + +Register a token and use it in the API. + +## 29360209 The callback has been registered. + +**Description** + +This error code is reported when the **continuationManager.on** API is called with a callback the same as a previous one. + +**Error Message** + +The callback has been registered. + +**Possible Causes** + +The specified callback has been registered. + +**Solution** + +Do not use the same callback for repeated registration. + +## 29360210 The callback is not registered. + +**Description** + +This error code is reported when the **off**, **updateConnectStatus**, or **startDeviceManager** API of **continuationManager** is called with a callback that has been not registered by calling **on**. + +**Error Message** + +The callback is not registered. + +**Possible Causes** + +The specified callback is not registered. + +**Solution** + +Register a callback and use it in the API. + +## 29360211 Failed to connect to the ability. + +**Description** + +This error code is reported if connection to the specified ability fails when the **startDeviceManager** API of **continuationManager** is called. + +**Error Message** + +Failed to connect to the ability. + +**Possible Causes** + +The specified token is invalid or the target ability is not working properly. + +**Solution** + +Check whether the token is valid and whether the corresponding ability is normal. Restart the service or device when needed. + +## 29360214 The type of callback is not supported. + +**Description** + +This error code is reported when the **callback** parameter in the **on** or **off** API of **continuationManager** is set to an incorrect type. + +**Error Message** + +The type of callback is not supported. + +**Possible Causes** + +The callback type is not supported. + +**Solution** + +Pass a supported type for the **callback** parameter. + +## 29360215 Invalid connection state. + +**Description** + +This error code is reported when the **status** parameter in the **updateConnectStatus** API of **continuationManager** is invalid. + +**Error Message** + +Invalid connection state. + +**Possible Causes** + +The **status** parameter is invalid. + +**Solution** + +Use a valid value for the **status** parameter. + +## 29360216 Invalid continuation mode. + +**Error Message** + +Invalid continuation mode. + +**Description** + +This error code is reported when the **ContinuationExtraParams.continuationMode** parameter in the **register** or **startDeviceManager** API of **continuationManager** is invalid. + +**Possible Causes** + +The **ContinuationExtraParams.continuationMode** parameter is invalid. + +**Solution** + +Use a valid value for the **ContinuationExtraParams.continuationMode** parameter. diff --git a/en/application-dev/reference/errorcodes/errcode-bundle.md b/en/application-dev/reference/errorcodes/errcode-bundle.md new file mode 100644 index 0000000000000000000000000000000000000000..a7a0b452137bf1cbd66af1e0e541d9421b491eb1 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errcode-bundle.md @@ -0,0 +1,371 @@ +# Bundle Error Codes + +## 17700001 Nonexistent Bundle Name + +**Error Message** +The specified bundle name is not found. + +**Description** +This error code is reported when the bundle name passed in the API does not exist. + +**Possible Causes** +1. The bundle name is misspelled. +2. The corresponding application is not installed. + +**Solution** +1. Check whether the spelling of the bundle name is correct. +2. Check whether the corresponding application is installed. + +## 17700002 Nonexistent Module Name + +**Error Message** +The specified module name is not found. + +**Description** +This error code is reported when the module name passed in the API does not exist. + +**Possible Causes** +1. The module name is misspelled. +2. The module is not installed for the application. + +**Solution** +1. Check whether the spelling of the module name is correct. +2. Check whether the module is installed for the application. + +## 17700003 Nonexistent Ability Name + +**Error Message** +The specified ability name is not found. + +**Description** +This error code is reported when the ability name passed in the API does not exist. + +**Possible Causes** +1. The ability name is misspelled. +2. The corresponding application is not installed. + +**Solution** +1. Check whether the spelling of the ability name is correct. +2. Check whether the ability is installed for the application. + +## 17700004 Nonexistent User ID + +**Error Message** +The specified user id is not found. + +**Description** +This error code is reported when the user ID passed in the API does not exist. + +**Possible Causes** +The user ID is incorrect. The user does not exist. + +**Solution** +1. Check whether the user ID is correct. +2. Check whether the user exists. + +## 17700005 Nonexistent Application ID + +**Error Message** +The specified appId is not found. + +**Description** +This error code is reported when the value of **appId** passed in the API is an empty string. + +**Possible Causes** +**appId** is an empty string. + +**Solution** +Check whether **appId** is an empty string. + +## 17700006 Nonexistent Permission + +**Error Message** +The specified permission is not found. + +**Description** +This error code is reported when the permission passed in the API does not exist. + +**Possible Causes** +1. The permission name is misspelled. +2. The permission does not exist. + +**Solution** +1. Check whether the spelling of the permission name is correct. +2. Check whether the permission exists. + +## 17700007 Incorrect Device ID + +**Error Message** +The specified deviceId is not found. + +**Description** +This error code is reported when the device ID passed in the API is incorrect. + +**Possible Causes** +1. The device ID is incorrect. +2. The device ID does not exist. + +**Solution** +1. Check whether the device ID is correct. +2. Check whether the device ID exists. + +## 17700010 Application Installation Failure Due to File Parsing Failure + +**Error Message** +Failed to install the hap since the hap fails to be parsed. + +**Description** +This error code is reported when the application fails to be installed because the HAP fails to be parsed. + +**Possible Causes** +1. The HAP is not in ZIP format. +2. The configuration file in the HAP is not in JSON format. +3. Necessary fields are missing in the configuration file. + +**Solution** +1. Check whether the HAP is in ZIP format. +2. Check whether the configuration file is in [JSON format](../../quick-start/stage-structure.md). +3. Check whether an error message is displayed when DevEco Studio compiles the HAP. If necessary fields are missing, an error message will be displayed. + +## 17700011 Application Installation Failure Due to Signature Verification Failure + +**Error Message** +Failed to install the hap since the hap signature fails to be verified. + +**Description** +This error code is reported when the application fails to be installed due to signature verification failure. + +**Possible Causes** + +1. The HAP is not signed. +2. The source of the HAP signature information is unreliable. +3. The signature information of the HAP used for an upgrade is different from that of the installed HAP. +4. The signature information of multiple HAPs is inconsistent. + +**Solution** +1. Check whether the HAP is signed. +2. Check whether the same certificate is used for signing multiple HAPs. +3. Check whether the certificate used for signing the upgrade HAP is the same as the certificate used for signing the installed HAP. + +## 17700012 Application Installation Failure Due to Invalid File Path or Too Large File + +**Error Message** +Failed to install the hap since the path of the hap is invalid or too large size. + +**Description** +This error code is reported when the application fails to be installed because the HAP path is invalid or the HAP is too large. + +**Possible Causes** +1. The path of the HAP does not exist. +2. The path of the HAP is inaccessible. +3. The size of the HAP exceeds the upper limit 4 GB. + +**Solution** +1. Check whether the HAP path exists. +2. Check whether the HAP is read only or executable. +3. Check whether the size of the HAP exceeds 4 GB. + +## 17700015 Application Installation Failure Due to Different Configuration Information of Multiple HAP Packages + +**Error Message** +Failed to install haps since the configuration information of multi haps is inconsistent. + +**Description** +This error code is reported when the application fails to be installed because the HAPs have different configuration information. + +**Possible Causes** +The fields under **app** in the configuration files of these HAPs are inconsistent. + +**Solution** +Check whether the fields under **app** are the same. + +## 17700016 Application Installation Failure Due to Insufficient System Disk Space + +**Error Message** +Failed to install the hap since the system disk space is insufficient. + +**Description** +This error code is reported when the application fails to be installed due to insufficient system disk space. + +**Possible Causes** +The system disk space is insufficient. + +**Solution** +Check whether the system has sufficient disk space. + +## 17700017 Application Installation Failure Because the Version to Install is Too Earlier + +**Error Message** +Failed to install the hap since the version of the newly installed hap is too early. + +**Description** +This error code is reported when the version number of the application to install is earlier than the version in use. + +**Possible Causes** +The version number is earlier than the version in use. + +**Solution** +Ensure that the version of the application to install is later than the version in use. + +## 17700020 Failure to Uninstall Preinstalled Applications + +**Error Message** +The preinstalled app cannot be uninstalled. + +**Description** +This error code is reported when you attempt to uninstall a preinstalled application. + +**Possible Causes** +1. You might want to uninstall a non-preinstalled application but passed the bundle name of a preinstalled app. +2. The preinstalled application cannot be uninstalled. + +**Solution** +1. Check whether the bundle name is correct. +1. Check whether the preinstalled application can be uninstalled. + +## 17700021 Invalid UID + +**Error Message** +The specified uid is invalid. + +**Description** +This error code is reported when the UID passed in the API is invalid. + +**Possible Causes** +1. The UID is misspelled. +2. The UID does not exist. + +**Solution** +1. Check whether the UID is correct. +2. Check whether the UID exists. + +## 17700022 Invalid Source File + +**Error Message** +The input source file is invalid. + +**Description** +This error code is reported when the source file to be parsed is invalid. + +**Possible Causes** +1. The source file to be parsed does not exist. +2. The source file to be parsed is not in ZIP format. + +**Solution** +1. Check whether the source file to be parsed exists. +2. Check whether the source file to be parsed is in ZIP format. + +## 17700023 Nonexistent Default Application + +**Error Message** +The specified default app does not exist. + +**Description** +This error code is reported when the specified default application does not exist. + +**Possible Causes** +No default application is set for the device. + +**Solution** +Check whether the default application is set on the device. + +## 17700024 Nonexistent Configuration File + +**Error Message** +Failed to get profile since no profile in the hap. + +**Description** +This error code is reported when you attempt to obtain the configuration file that does not exist. + +**Possible Causes** +1. The metadata name passed in the API does not exist in the configuration file. +2. The content of the configuration file is not in JSON format. + +**Solution** +1. Check whether the metadata name in the **ability** or **extensionAbility** to be queried exists. +2. Check whether the content of the profile to be queried is in JSON format. + +## 17700025 Invalid Type + +**Error Message** +The specified type is invalid. + +**Description** +The type is invalid. + +**Possible Causes** +1. The type passed in the API is misspelled. +2. The type passed in the API does not exist. + +**Solution** +Check whether the spelling of type is correct. + +## 17700026 Application Disabled + +**Error Message** +The specified bundle is disabled. + +**Description** +This error code is reported when the specified application is disabled. + +**Possible Causes** +The application on the device has been disabled and cannot be queried. + +**Solution** +Check whether the application on the device is disabled. + +## 17700027 Distributed Service Not Started + +**Error Message** +The distributed service is not running. + +**Description** +This error code is reported when the distributed service is not started. + +**Possible Causes** +The device is not networked. + +**Solution** +Check whether the device is networked. +## 17700028 Mismatch Between Ability and Type + +**Error Message** +The ability does not match the type. + +**Description** +This error code is reported when the ability and type passed in the API do not match. + +**Possible Causes** +The ability and type are misspelled. + +**Solution** +Check whether the spellings of ability and type are correct. + +## 17700029 Disabled Ability + +**Error Message** +The specified ability is disabled. + +**Description** +This error code is reported when the specified ability is disabled. + +**Possible Causes** +The specified ability is disabled. + +**Solution** +Check whether the ability is disabled. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information. + +## 17700030 Failure in Clearing Cache Files + +**Error Message** +The specified bundle does not support clearing cache files. + +**Description** +This error code is reported when the application does not support cache file clearing. + +**Possible Causes** +The application is a system application and the **AllowAppDataNotCleared** field is configured in the signing certificate. + +**Solution** +1. Check whether the application is a system application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **isSystemApp** is **true**. +2. Check whether the **AllowAppDataNotCleared** field is configured for the application. You can run the [bm commands](../../../readme/bundle-management.md#bm-commands) to query the application information and check whether the value of **userDataClearable** is **true**. diff --git a/en/application-dev/reference/errorcodes/errorcode-AccessToken.md b/en/application-dev/reference/errorcodes/errorcode-AccessToken.md new file mode 100644 index 0000000000000000000000000000000000000000..306ad41da505db3a42a8d6668ce00b47c7e3f60e --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-AccessToken.md @@ -0,0 +1,140 @@ +# Access Token Error Codes + +## 401 Parameter Error + +### Error Message +Parameter error.${messageInfo}. + +### Possible Causes +This error code is reported if an error occurs during JS parameter parsing. The possible causes are as follows: +1. The number of input parameters is insufficient. +2. The parameter type is incorrect. + +### Solution +1. Add input parameters. +2. Correct parameter types. + + +## 201 Permission denied. + +### Error Message +Permission denied.${messageInfo}. + +### Possible Causes +This error code is reported if the application process that calls an API is not granted the required permission. The possible causes are as follows: +1. The application process is not granted the required permission. +2. The permission requires user authorization to take effect, but the application process does not obtain the user authorization. + +### Solution +1. Check whether the application process is granted the required permission. +2. Check whether the application process has obtained the user authorization if the permission requires user authorization to take effect. + + +## 12100001 Invalid Parameters + +### Error Message +Parameter invalid, message is ${messageInfo}. + +### Possible Causes +This error code is reported if an error occurs during parameter verification. The possible causes are as follows: +1. The value of **tokenId** is **0**. +2. The specified permission name is empty or contains more than 256 characters. +3. The **flag** value in the permission authorization or revocation request is invalid. +4. The input parameters specified for registering a listener are incorrect. + +### Solution +1. Correct the invalid parameter values. + + +## 12100002 TokenId does not exist. + +### Error Message +TokenId does not exist. + +### Possible Causes +1. The specified **tokenId** does not exist. +2. The process corresponding to the specified **tokenId** is not an application process. + +### Solution +Set a correct **tokenId**, and make sure that the process corresponding to the specified **tokenId** is an application process. + + +## 12100003 Permission Not Exist + +### Error Message +Permission does not exist. + +### Possible Causes +1. The specified **permissionName** does not exist. +2. The specified **permissionName** does not match the specified **tokenId** in the permission authorization or revocation scenario. +3. The specified **permissionName** is not a sensitive permission that requires user authorization. + +### Solution +Set the **permissionName** parameter correctly. For details, see [permission-list](../../security/permission-list.md). + + +## 12100004 Listener APIs Not Used in Pairs + +### Error Message +The listener interface is not used together. + +### Possible Causes +This error code is reported if listener APIs are not used in pairs. The possible causes are as follows: +1. The listener APIs that need to be used in pairs are repeatedly called. +2. The listener APIs that need to be used in pairs are independently called. + +### Solution +1. Check whether the API needs to be used in pairs. That is, if an API is called to enable listening, an API with the same input parameters cannot be called unless an API is called to stop listening first. +2. Check whether the API needs to be used in pairs. That is, an API for disabling listening or unregistering a listener can only be called after the API for enabling listening or registering a listener is called. + + +## 12100005 Listener Overflow + +### Error Message +The number of listeners exceeds the limit. + +### Possible Causes +The number of listeners exceeds 200 (the upper limit). + +### Solution +Abandon unused listeners in a timely manner. + + +## 12100006 Permission Granting or Revocation Not Supported for the Specified Application + +### Error Message +The specified application does not support the permissions granted or ungranted as specified. + +### Possible Causes +1. The specified **tokenId** is the identity of the remote device. Distributed granting and revocation are not yet supported. +2. The specified **tokenId** belongs to a sandbox application, which is not allowed to apply for the specified permission. + +### Solution +1. Check whether the method of obtaining **tokenId** is correct. +2. Check whether the sandbox application works in restrictive mode. Most permissions cannot be granted to a sandbox application in restrictive mode. + + +## 12100007 System Services Not Working Properly + +### Error Message +Service is abnormal. + +### Possible Causes +This error code is reported if system services are not working properly. The possible causes are as follows: +1. The permission management service cannot be started properly. +2. An error occurs while reading or writing IPC data. + +### Solution +System services do not work properly. Try again later or restart the device. + + +## 12100008 Out of Memory + +### Error Message +Out of memory. + +### Possible Causes +The system memory is insufficient. + +### Solution +Try again later or restart the device. diff --git a/en/application-dev/reference/errorcodes/errorcode-audio.md b/en/application-dev/reference/errorcodes/errorcode-audio.md new file mode 100644 index 0000000000000000000000000000000000000000..31825c31e8990d94d7c8abf5253cdd6e82216bde --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-audio.md @@ -0,0 +1,131 @@ +# Audio Error Codes + +## 6800101 Invalid Parameter + +**Error Message** + +invalid parameter. + +**Description** + +A parameter passed in the API is invalid. + +**Possible Causes** + +The parameter is invalid. For example, the parameter value is not within the range supported. + +**Solution** + +Pass the correct parameters in the API. + +## 6800102 Memory Allocation Failure + +**Error Message** + +allocate memory failed. + +**Description** + +When the API is called, the memory fails to be allocated or a null pointer occurs. + +**Possible Causes** + +1. The system does not have sufficient memory for mapping. +2. Invalid instances are not destroyed in time to release the memory. + +**Solution** + +1. Destroy the existing instances. +2. Create a new instance. If the creation fails, stop related operations. + +## 6800103 Unsupported State + +**Error Message** + +Operation not permit at current state. + +**Description** + +This operation is not allowed in the current state. + +**Possible Causes** + +The operation is not supported in the current state. For example, data is played before streams are started. + +**Solution** + +1. Check whether this operation is supported in the current state. +2. Switch the instance to the correct state and perform the operation. + +## 6800104 Unsupported Parameter Value + +**Error Message** + +unsupported operation. + +**Description** + +The parameter value is not supported. + +**Possible Causes** + +The value of the input parameter is not within the range supported. + +**Solution** + +1. Check the enums or other input parameters supported by the API. +2. Use a supported value. + +## 6800105 Processing Timeout + +**Error Message** + +time out. + +**Description** + +Waiting for external processing times out. + +**Possible Causes** + +Waiting for external processing times out. For example, waiting for the application to fill in audio data times out. + +**Solution** + +Control the time of the write operation, for example, adding delayed processing. + +## 6800201 Too Many Audio Streams + +**Error Message** + +stream number limited. + +**Description** + +The number of audio streams reaches the upper limit. + +**Possible Causes** + +Invalid audio streams are not released in time. + +**Solution** + +Release audio streams that are no longer used. + +## 6800301 System Error + +**Error Message** + +system error. + +**Description** + +The system processing is abnormal. + +**Possible Causes** + +The system processing is abnormal, for example, system service restart or IPC exceptions. + +**Solution** + +Create the service again. diff --git a/en/application-dev/reference/errorcodes/errorcode-cert.md b/en/application-dev/reference/errorcodes/errorcode-cert.md new file mode 100644 index 0000000000000000000000000000000000000000..1aab03ff6f10cb18bf9c780c993f16c97789679b --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-cert.md @@ -0,0 +1,133 @@ +# Certificate Error Codes + +## 19020001 Memory Error + +**Error Message** + +Memory error. + +**Possible Causes** + +The memory allocation failed. + +**Solution** + +1. Check whether the system is running properly. +2. Check whether the service data is too long. + +## 19020002 Runtime Error + +**Error Message** + +Runtime error. + +**Possible Causes** + +An unexpected error occurs. + +**Solution** + +Check whether the system is running properly. + +## 19030001 Crypto Operation Error + +**Error Message** + +Crypto operation error. + +**Possible Causes** + +An error occurs when the cryptography framework interacts with a third-party algorithm library. + +**Solution** + +1. Check whether the input parameters are correct. +2. Check whether the third-party algorithm library functions properly. + +## 19030002 Certificate Signature Verification Failed + +**Error Message** + +The certificate signature verification failed. + +**Possible Causes** + +Incorrect certificate signature information is found during the signature verification. + +**Solution** + +Check whether the certificate is correct. + +## 19030003 Certificate Has Not Taken Effect + +**Error Message** + +The certificate has not taken effect. + +**Possible Causes** + +The certificate has not taken effect. The effective time of the certificate is later than the current system time or the time specified by the service. + +**Solution** + +1. Check whether the certificate is correct. +2. Check whether the system time is correct. +3. Compare the certificate effective time with the current system time to determine whether the certificate has taken effect. + +## 19030004 Certificate Expired + +**Error Message** + +The certificate has expired. + +**Possible Causes** + +The certificate has expired. The certificate expiration time is earlier than the current system time or the time specified by the service. + +**Solution** + +1. Check whether the certificate is correct. +2. Check whether the system time is correct. +3. Compare the certificate expiration time time with the current system time to determine whether the certificate has expired. + +## 19030005 Failed to Obtain the Certificate Issuer + +**Error Message** + +Failed to obtain the certificate issuer. + +**Possible Causes** + +The certificate issuer cannot be obtained during certificate verification. + +**Solution** + +Check whether the certificate is correct. + +## 19030006 Key Cannot be Used for Signing a Certificate + +**Error Message** + +The key cannot be used for signing a certificate. + +**Possible Causes** + +The key cannot be used to sign certificates. + +**Solution** + +Check whether the certificate is correct. + +## 19030007 Key Cannot be Used for Digital Signature + +**Error Message** + +The key cannot be used for digital signature. + +**Possible Causes** + +The key cannot be used for digital signature. + +**Solution** + +Check whether the certificate is correct. diff --git a/en/application-dev/reference/errorcodes/errorcode-crypto-framework.md b/en/application-dev/reference/errorcodes/errorcode-crypto-framework.md new file mode 100644 index 0000000000000000000000000000000000000000..59dc2e59239c06f3111e0a481a65651b06f266d8 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-crypto-framework.md @@ -0,0 +1,45 @@ +# Crypto Framework Error Codes + +## 17620001 Memory Error + +**Error Message** + +Memory error. + +**Possible Causes** + +The memory allocation failed. + +**Solution** + +1. Check whether the system is running properly. +2. Check whether the service data is too long. + +## 17620002 Runtime Error + +**Error Message** + +Runtime error. + +**Possible Causes** + +An unexpected error occurs. + +**Solution** + +Check whether the system is running properly. + +## 19030001 Crypto Operation Error + +**Error Message** + +Crypto operation error. + +**Possible Causes** + +An error occurs when the cryptography framework interacts with a third-party algorithm library. + +**Solution** + +1. Check whether the input parameters are correct. +2. Check whether the third-party algorithm library functions properly. diff --git a/en/application-dev/reference/errorcodes/errorcode-device-manager.md b/en/application-dev/reference/errorcodes/errorcode-device-manager.md index 3e0459cebcb89d3d501bc331f9526320cd7d72e6..3d23690c0ded759312b899c49cfb7d265f9f8e7d 100644 --- a/en/application-dev/reference/errorcodes/errorcode-device-manager.md +++ b/en/application-dev/reference/errorcodes/errorcode-device-manager.md @@ -10,7 +10,7 @@ Failed to execute the function. An error occurred during internal invocation. -**Procedure** +**Solution** Call the API again. @@ -24,7 +24,7 @@ Failed to obtain the service. The service is not started or fails to start. -**Procedure** +**Solution** Check whether the service is started normally and obtain the service again. @@ -52,7 +52,7 @@ Discovery invalid. The last discovery service is still in progress. -**Procedure** +**Solution** Wait until the last discovery service is complete and call the discovery API again. @@ -66,6 +66,6 @@ Publish invalid. The last publish service is still in progress. -**Procedure** +**Solution** Wait until the last publish service is complete and call the publish API again. diff --git a/en/application-dev/reference/errorcodes/errorcode-display.md b/en/application-dev/reference/errorcodes/errorcode-display.md index f86b0b10736c407cefb288e317288c66a9fd5a07..1a0fb96dbb909a8915569e0daf8f7aa497425038 100644 --- a/en/application-dev/reference/errorcodes/errorcode-display.md +++ b/en/application-dev/reference/errorcodes/errorcode-display.md @@ -2,42 +2,53 @@ ## 1400001 Invalid Display or Screen **Error Message** + Invalid display or screen. **Description** + This error code is reported when an invalid display, including a virtual screen, is operated. **Possible Causes** 1. The virtual screen has not been created. 2. The virtual screen has been destroyed. -**Procedure** +**Solution** + 1. Before operating the virtual screen, check whether the virtual screen has been created. 2. Check whether the virtual screen has been destroyed. ## 1400002 Unauthorized Operation **Error Message** + Unauthorized operation. **Description** + This error code is reported when the API does not have the required permissions to operate an object. **Possible Causes** + The virtual screen object of another process is operated. -**Procedure** +**Solution** + Check whether unauthorized operations are performed on the object of another process. If yes, delete the operations. ## 1400003 Abnormal Display Manager Service **Error Message** + This display manager service works abnormally. **Description** + This error code is reported when the display manager service is abnormal. **Possible Causes** + 1. The display manager service is not started normally. 2. The bottom-layer graphics synthesis and rendering are abnormal. -**Procedure** -Try again later or restart the device. +**Solution** + +Try again later or restart the device. \ No newline at end of file diff --git a/en/application-dev/reference/errorcodes/errorcode-faultlogger.md b/en/application-dev/reference/errorcodes/errorcode-faultlogger.md new file mode 100644 index 0000000000000000000000000000000000000000..5270787af4cd2697625975cb442beee5b9a40b4e --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-faultlogger.md @@ -0,0 +1,19 @@ +# faultLogger Error Codes + +## 10600001 Service Faulty or Not Started + +**Error Message** + +The service is not running or broken. + +**Description** + +This error code is reported when the service is not started or is faulty. + +**Possible Causes** + +The hiview service is not started. + +**Solution** + +Retry the operation. diff --git a/en/application-dev/reference/errorcodes/errorcode-huks.md b/en/application-dev/reference/errorcodes/errorcode-huks.md index 7bab2f0be7353cefecbe458b6435aaaf213429d4..66409a6381a59d5dfe3cace75fe90ca19cb8f52d 100644 --- a/en/application-dev/reference/errorcodes/errorcode-huks.md +++ b/en/application-dev/reference/errorcodes/errorcode-huks.md @@ -10,7 +10,7 @@ The API is supported, but certain features in the API, such as the algorithm, are not supported. -**Procedure** +**Solution** Modify the parameters and use the features supported. @@ -23,7 +23,7 @@ Failed to obtain `${messageInfo}`. It is not set in ParamSet. The key parameter is not set. -**Procedure** +**Solution** 1. Determine the missing parameter from the error message. 2. Set the parameter. @@ -38,7 +38,7 @@ Invalid `${messageInfo}`. An invalid parameter is found. -**Procedure** +**Solution** 1. Determine the invalid parameter from the error message. 2. Correct the invalid parameter. @@ -55,7 +55,7 @@ Failed to write the file. The file operation failed. -**Procedure** +**Solution** 1. Check whether the disk space is used up and whether the file system is abnormal. 2. Clear the disk space. @@ -72,7 +72,7 @@ Failed to obtain messages from IPC. IPC failed. -**Procedure** +**Solution** Locate and rectify the IPC failure. @@ -89,7 +89,7 @@ The algorithm library operation fails. The possible causes include the following 1. The encryption and decryption on the algorithm library failed due to incorrect ciphertext data. 2. Incorrect key parameters exist. -**Procedure** +**Solution** 1. Check and correct the ciphertext data. 2. Check and correct the key parameters. @@ -107,7 +107,7 @@ The possible causes include the following: 1. The key is configured with the user access control attribute and becomes invalid after the password is cleared. 2. The key is configured with the user access control attribute and becomes invalid after a new biometric feature is enrolled. -**Procedure** +**Solution** 1. Locate the cause of the authentication failure based on the log. 2. If the authentication fails due to the access control attribute configured, the key cannot be used any more. @@ -122,7 +122,7 @@ The authentication token verification failed. The authentication token verification failed due to an incorrect challenge value. -**Procedure** +**Solution** 1. Check whether the challenge for userIAM authentication is correctly assembled. 2. If the challenge value is incorrect, modify the assembly mode, use the bytes generated by HUKS to assembly challenge value, and pass it to userIAM for authentication. @@ -137,7 +137,7 @@ The Authentication token timed out. The authentication failed because the authentication token timed out. -**Procedure** +**Solution** The difference between the current time and the authentication token generation time must be less than the timeout interval. Otherwise, the access will be rejected. @@ -151,7 +151,7 @@ The number of key operation sessions has reached the limit. The number of concurrent key operation sessions has reached the maximum (15). -**Procedure** +**Solution** 1. Check whether there are multiple key session operations (**init** operations) for the same application. If yes, modify the code to avoid concurrent invoking. 2. If the key operation sessions are set up for different applications, wait until the sessions are released. @@ -166,7 +166,7 @@ The entity does not exist. The key corresponding to the key alias does not exist. -**Procedure** +**Solution** 1. Check whether the key alias is misspelled. 2. Check whether the key corresponding to the key alias is successfully generated. @@ -181,7 +181,7 @@ External error `${messageInfo}`. An external error, such as a hardware fault or file error occurs. -**Procedure** +**Solution** Provide the error code and log information to the related party. @@ -195,7 +195,7 @@ The credential does not exist. The credential, such as the PIN, fingerprint, or face image, is not enrolled. -**Procedure** +**Solution** Enroll the credential or change the authentication type bound to the key. @@ -209,7 +209,7 @@ Memory is insufficient. The system memory is insufficient. -**Procedure** +**Solution** Release memory or restart the device. @@ -223,6 +223,6 @@ Failed to call the `${messageInfo}` service to do `${messageInfo}`. The called system service has not started. -**Procedure** +**Solution** Wait for the system service to start and call the API again. diff --git a/en/application-dev/reference/errorcodes/errorcode-promptAction.md b/en/application-dev/reference/errorcodes/errorcode-promptAction.md index 7518de5a3f5a1202ece256f2c231039fa0b49542..15266ac738f9f330d1327b517e8494dce04971d1 100644 --- a/en/application-dev/reference/errorcodes/errorcode-promptAction.md +++ b/en/application-dev/reference/errorcodes/errorcode-promptAction.md @@ -14,6 +14,6 @@ This error code is reported when an internal error that cannot be rectified by d The operation for obtaining the rendering engine or parsing parameters fails. -**Procedure** +**Solution** NA diff --git a/en/application-dev/reference/errorcodes/errorcode-router.md b/en/application-dev/reference/errorcodes/errorcode-router.md index 0f99a215923ac8bfe1aee4ff3aac64ded07fd6ea..9a993e71c1fbcac9d28d8039b674770c1175174d 100644 --- a/en/application-dev/reference/errorcodes/errorcode-router.md +++ b/en/application-dev/reference/errorcodes/errorcode-router.md @@ -14,7 +14,7 @@ This error code is reported when an internal error that cannot be rectified by d The operation for obtaining the rendering engine or parsing parameters fails. -**Procedure** +**Solution** NA @@ -32,7 +32,7 @@ This error code is reported when the URI of the page to redirect is incorrect or The entered URI is incorrect or does not exist. -**Procedure** +**Solution** Ensure that the URI is correct. @@ -50,7 +50,7 @@ This error code is reported when more than 32 pages are pushed into the page sta Too many pages are pushed. -**Procedure** +**Solution** Delete unnecessary or invalid pages. @@ -68,6 +68,6 @@ This error code is reported when the URI of the page to be used for replacement The entered URI is incorrect or does not exist. -**Procedure** +**Solution** Ensure that the URI is correct. diff --git a/en/application-dev/reference/errorcodes/errorcode-sensor.md b/en/application-dev/reference/errorcodes/errorcode-sensor.md index 571156ec00328b0ba564cd6174e6fb81aa5154b1..3e4170b55dcd6235031e1c4aea41b048a6a883da 100644 --- a/en/application-dev/reference/errorcodes/errorcode-sensor.md +++ b/en/application-dev/reference/errorcodes/errorcode-sensor.md @@ -1,6 +1,6 @@ # Sensor Error Codes -## 14500101 Service exception. +## 14500101 Service Exception **Error Message** @@ -14,7 +14,7 @@ This error code is reported if the HDI service is abnormal when the **on**, **on The HDI service is abnormal. -**Procedure** +**Solution** 1. Retry the operation at a specified interval (for example, 1s) or at an exponential increase interval. 2. If the operation fails for three consecutive times, stop the retry. You can also attempt to obtain the sensor list to check for device availability. diff --git a/en/application-dev/reference/errorcodes/errorcode-sensors.md b/en/application-dev/reference/errorcodes/errorcode-sensors.md new file mode 100644 index 0000000000000000000000000000000000000000..155ff9263f550685e1b8dfc47016acc242ab5c9c --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-sensors.md @@ -0,0 +1,40 @@ +# Pan-Sensor Error Codes + +## 14500101 Service exception. + +### Error information + +Service exception. + +### Description + +This error code is reported if the HDI service is abnormal when the **on**, **once**, or **off** interface of the sensor module is called. + +### Possible Causes + +The HDI service is abnormal. + +### Procedure + +1. Retry the operation at a specified interval (for example, 1s) or at an exponential increase interval. +2. If the operation fails for three consecutive times, stop the attempt. You can also attempt to obtain the sensor list to check for device availability. + +## 14600101 Device operation failed. + +### Error Message + +Device operation failed. + +### Description + +This error code is reported if the HDI service is abnormal or the device is occupied when the **startVibration** interface of the vibrator module is called. + +### Possible Causes + +1. The HDI service is abnormal. +2. The device is occupied. + +### Procedure + +1. Retry the operation at a specified interval or at an exponential increase interval. If the operation fails for three consecutive times, stop the retry. You can also obtain the vibrator list to check for device availability. +2. Set a higher priority for the vibrator. diff --git a/en/application-dev/reference/errorcodes/errorcode-vibrator.md b/en/application-dev/reference/errorcodes/errorcode-vibrator.md index f5dc329c1e96d945f76c7625b365a53fe50477b4..f04a47bb5f5578d61eafa9b75ae650acdab41747 100644 --- a/en/application-dev/reference/errorcodes/errorcode-vibrator.md +++ b/en/application-dev/reference/errorcodes/errorcode-vibrator.md @@ -15,7 +15,7 @@ This error code is reported if the HDI service is abnormal or the device is occu 1. The HDI service is abnormal. 2. The device is occupied. -**Procedure** +**Solution** 1. Retry the operation at a specified interval or at an exponential increase interval. If the operation fails for three consecutive times, stop the retry. You can also obtain the vibrator list to check for device availability. 2. Set a higher priority for the vibrator. diff --git a/en/application-dev/reference/errorcodes/errorcode-window.md b/en/application-dev/reference/errorcodes/errorcode-window.md index 9e61c92b592c2e155ac6757f8e1dee4a01d762e9..5c034e88468111e4a67ad56da737ee62d8cbf536 100644 --- a/en/application-dev/reference/errorcodes/errorcode-window.md +++ b/en/application-dev/reference/errorcodes/errorcode-window.md @@ -2,78 +2,101 @@ ## 1300001 Repeated Operation **Error Message** + Repeated operation. **Description** + This error code is reported when a repeated operation is performed. **Possible Causes** + The window to create already exists. -**Procedure** +**Solution** + Before creating a window, check whether the window already exists. If it already exists, use it directly. ## 1300002 Abnormal Window State **Error Message** + This window state is abnormal. **Description** + This error code is reported when you operate a window in an abnormal state, for example, a window that has been destroyed. **Possible Causes** + The window has been destroyed when being operated. -**Procedure** +**Solution** + Before operating the window, check whether it exists. ## 1300003 Abnormal Window Manager Service **Error Message** + This window manager service works abnormally. **Description** + This error code is reported when the window manager service is abnormal. **Possible Causes** + The internal services of the window are not started normally. -**Procedure** +**Solution** + Try again later or restart the device. ## 1300004 Unauthorized Operation **Error Message** + Unauthorized operation. **Description** + This error code is reported when the API does not have the required permissions to operate an object. **Possible Causes** + The window object of another process is operated. -**Procedure** +**Solution** + Check whether unauthorized operations are performed on the object of another process. If yes, delete the operations. ## 1300005 Abnormal Window Stage **Error Message** + This window stage is abnormal. **Description** + This error code is reported when you operate a window stage in the abnormal state, for example, a window stage that has been destroyed. **Possible Causes** + The window stage has been destroyed when being operated. **Procedure** + Before operating a window stage, check whether it exists. ## 1300006 Abnormal Window Context **Error Message** + This window context is abnormal. **Description** + This error code is reported when you operate a window context in the abnormal state, for example, a window context that has been destroyed. **Possible Causes** + The window context has been destroyed when being operated. -**Procedure** -Before operating the window context, check whether it exists. +**Solution** +Before operating the window context, check whether it exists. \ No newline at end of file diff --git a/en/application-dev/reference/errorcodes/errorcode-zlib.md b/en/application-dev/reference/errorcodes/errorcode-zlib.md new file mode 100644 index 0000000000000000000000000000000000000000..ea2b330abea46f7f9a9eebfff7e427cf57197cc2 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-zlib.md @@ -0,0 +1,40 @@ +# zlib Error Codes + +## 900001 Invalid Source File + +**Error Message** + +The input source file is invalid. + +**Description** + +This error code is reported when the source file passed in the **compress** or **decompress** API is invalid. + +**Possible Causes** + +When the **compress** API is called, the file to compress does not exist. When the **decompress** API is called, the file to decompress does not exist. + +**Procedure** + +1. Check whether the source file exists. +2. Check whether the path of the source file exists and whether the path is the correct sandbox path. + +## 900002 Invalid Destination File + +**Error Message** + +The input destination file is invalid. + +**Description** + +This error code is reported when the destination file passed in the **compress** or **decompress** API is invalid. + +**Possible Causes** + +1. When the **compress** API is called, the passed destination file path is invalid, for example, a non-exist sandbox path. +2. When the **decompress** API is called, the destination folder does not exist. + +**Procedure** + +1. Check whether the destination file path is correct. If not, enter the correct sandbox path. +2. Check whether the destination folder exists. If not, create the folder. diff --git a/en/application-dev/reference/errorcodes/errorcodes-multimodalinput.md b/en/application-dev/reference/errorcodes/errorcodes-multimodalinput.md new file mode 100644 index 0000000000000000000000000000000000000000..bca5dbf90bcec2b16c36c45edee7576ef50f3358 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcodes-multimodalinput.md @@ -0,0 +1,43 @@ +# Screen Hopping Error Codes + +## 4400001 Incorrect Target Device Descriptor + +**Error Message** + +Incorrect descriptor for the target device. + +**Description** + +This error code is reported if an invalid device descriptor is passed to the screen hopping API. + +**Possible Causes** + +1. The target device does not exist, or the device is not networked. +2. The target device descriptor is empty. + +**Solution** + +1. Check whether the target device for screen hopping is correctly networked with the local device. +2. Set the target device descriptor correctly. + +## 4400002 Input Device Operation Failed + +**Error Message** + +Failed to operate the input device. + +**Description** + +This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. + +**Possible Causes** + +1. When screen hopping is initiated, the local device is in the hopped state. +2. When screen hopping is disabled, the local device is in the free state. +3. When screen hopping is disabled, the local device is in the hopping state. + +**Solution** + +1. When initiating screen hopping, make sure that the local device is not in the hopped state. +2. When disabling screen hopping, make sure that the local device is not in the free state. +3. When disabling screen hopping, make sure that the local device is not in the hopping state. diff --git a/en/application-dev/security/Readme-EN.md b/en/application-dev/security/Readme-EN.md index 4a2fc6dd307645d4bb529ed9a15172c552b2b440..ce9f1dd695f62073424c5b967207ba316cd079b5 100644 --- a/en/application-dev/security/Readme-EN.md +++ b/en/application-dev/security/Readme-EN.md @@ -11,6 +11,12 @@ - Key Management - [HUKS Overview](huks-overview.md) - [HUKS Development](huks-guidelines.md) +- Crypto Framework + - [Crypto Framework Overview](cryptoFramework-overview.md) + - [Crypto Framework Development](cryptoFramework-guidelines.md) +- Certificate + - [Certificate Overview](cert-overview.md) + - [Certificate Development](cert-guidelines.md) - hapsigner - [hapsigner Overview](hapsigntool-overview.md) - [hapsigner Guide](hapsigntool-guidelines.md) diff --git a/en/application-dev/security/cert-guidelines.md b/en/application-dev/security/cert-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..c6c2ec6ab092c9add82ea0c03af40b2da5e9b786 --- /dev/null +++ b/en/application-dev/security/cert-guidelines.md @@ -0,0 +1,498 @@ +# Certificate Development + +> **NOTE** +> +> This development guide applies to API version 9, OpenHarmony SDK version 3.2.9 or later, and JS development. + +## Using Certificates + +**When to Use** + +Typical operations involve the following: + +1. Parse X.509 certificate data to generate a certificate object. +2. Obtain certificate information, such as the version and serial number of the certificate. +3. Obtains the serialized data of the certificate object. +4. Obtain the certificate public key. +5. Verify the certificate signature. +6. Verify the certificate validity period. + +**Available APIs** + +For details about the APIs, see [Certificate](../reference/apis/js-apis-cert.md). + +The table below describes the APIs used in this guide. + +| Instance | API | Description | +| --------------- | ------------------------------------------------------------ | -------------------------------------------- | +| cryptoCert | createX509Cert(inStream : EncodingBlob, callback : AsyncCallback) : void | Parses certificate data to create an **X509Cert** instance. This API uses an asynchronous callback to return the result.| +| cryptoCert | createX509Cert(inStream : EncodingBlob) : Promise | Parses certificate data to create an **X509Cert** instance. This API uses a promise to return the result. | +| X509Cert | verify(key : cryptoFramework.PubKey, callback : AsyncCallback) : void | Verifies the certificate signature. This API uses an asynchronous callback to return the result. | +| X509Cert | verify(key : cryptoFramework.PubKey) : Promise | Verifies the certificate signature. This API uses a promise to return the result. | +| X509Cert | getEncoded(callback : AsyncCallback) : void | Obtains serialized certificate data. This API uses an asynchronous callback to return the result. | +| X509Cert | getEncoded() : Promise | Obtains serialized certificate data. This API uses a promise to return the result. | +| X509Cert | getPublicKey(callback : AsyncCallback) : void | Obtains the certificate public key. This API uses an asynchronous callback to return the result. | +| X509Cert | getPublicKey() : Promise | Obtains the certificate public key. This API uses a promise to return the result. | +| X509Cert | checkValidityWithDate(date: string, callback : AsyncCallback) : void | Verifies the certificate validity period. This API uses an asynchronous callback to return the result. | +| X509Cert | checkValidityWithDate(date: string) : Promise | Verifies the certificate validity period. This API uses a promise to return the result. | +| X509Cert | getVersion() : number | Obtains the certificate version. | +| X509Cert | getSerialNumber() : number | Obtains the certificate serial number. | +| X509Cert | getIssuerName() : DataBlob | Obtains the certificate issuer. | +| X509Cert | getSubjectName() : DataBlob | Obtains the certificate subject. | +| X509Cert | getNotBeforeTime() : string | Obtains the time from which the certificate takes effect. | +| X509Cert | getNotAfterTime() : string | Obtains the expiration time of the certificate. | +| X509Cert | getSignature() : DataBlob | Obtains the certificate signature. | +| X509Cert | getSignatureAlgName() : string | Obtain the certificate signing algorithm. | +| X509Cert | getSignatureAlgOid() : string | Obtains the certificate signing algorithm object identifier (OID). | +| X509Cert | getSignatureAlgParams() : DataBlob | Obtains the certificate signing algorithm parameters. | +| X509Cert | getKeyUsage() : DataBlob | Obtains the key usage of the certificate. | +| X509Cert | getExtKeyUsage() : DataArray | Obtains the usage of the certificate extension key. | +| X509Cert | getBasicConstraints() : number | Obtains the basic constraints on the certificate. | +| X509Cert | getSubjectAltNames() : DataArray | Obtains the Subject Alternative Names (SANs) of the certificate. | +| X509Cert | getIssuerAltNames() : DataArray | Obtains the Issuer Alternative Names (IANs) of the certificate. | + +**How to Develop** + +Example: Parse the X.509 certificate data to create an **X509Cert** instance and call APIs to perform certificate operations. + +```javascript +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// Certificate data, which is only an example. The certificate data varies with the service. +let certData = "-----BEGIN CERTIFICATE-----\n" ++ "IBzTCCAXCgAwIBAgIGAXKnMKNyMAwGCCqBHM9VAYN1BQAwSTELMAkGA1UEBhMC\n" ++ "04xDjAMBgNVBAoTBUdNU1NMMRAwDgYDVQQLEwdQS0kvU00yMRgwFgYDVQQDEw9S\n" ++ "290Q0EgZm9yIFRlc3QwIhgPMjAxNTEyMzExNjAwMDBaGA8yMDM1MTIzMDE2MDAw\n" ++ "FowSTELMAkGA1UEBhMCQ04xDjAMBgNVBAoTBUdNU1NMMRAwDgYDVQQLEwdQS0kv\n" ++ "00yMRgwFgYDVQQDEw9Sb290Q0EgZm9yIFRlc3QwWTATBgcqhkjOPQIBBggqgRzP\n" ++ "QGCLQNCAATj+apYlL+ddWXZ7+mFZXZJGbcJFXUN+Fszz6humeyWZP4qEEr2N0+a\n" ++ "dwo/21ft232yo0jPLzdscKB261zSQXSoz4wPDAZBgNVHQ4EEgQQnGnsD7oaOcWv\n" ++ "CTrspwSBDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIAxjAMBggqgRzP\n" ++ "QGDdQUAA0kAMEYCIQCEnW5BlQh0vmsOLxSoXYc/7zs++wWyFc1tnBHENR4ElwIh\n" ++ "I1Lwu6in1ruflZhzseWulXwcITf3bm/Y5X1g1XFWQUH\n" ++ "-----END CERTIFICATE-----\n"; + +// Convert the string into a Uint8Array. +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// Certificate example +function certSample() { + let encodingBlob = { + // Convert the certificate data string to a Uint8Array. + data: stringToUint8Array(certData), + // Certificate format. Only PEM and DER are supported. In this example, the certificate is in PEM format. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM + }; + + // Create an X509Cert instance. + cryptoCert.createX509Cert(encodingBlob, function (err, x509Cert) { + if (err != null) { + // Failed to create the X509Cert instance. + Console.log("createX509Cert failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // The X509Cert instance is successfully created. + Console.log("createX509Cert success"); + + // Obtain the certificate version. + let version = x509Cert.getVersion(); + + // Obtain the serialized data of the certificate. + x509Cert.getEncoded(function (err, data) { + if (err != null) { + // Failed to obtain the serialized data of the certificate. + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The serialized data of the certificate is successfully obtained. + Console.log("getEncoded success"); + } + }); + + // Obtain the certificate public key. + x509Cert.getPublicKey(function (err, pubKey) { + if (err != null) { + // Failed to obtain the certificate public key. + Console.log("getPublicKey failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The certificate public key is successfully obtained. + Console.log("getPublicKey success"); + } + }); + + // Obtain the public key object using the getPublicKey() of the upper-level certificate object or this (self-signed) certificate object. + let pubKey = null; + + // Verify the certificate signature. + x509Cert.verify(pubKey, function (err, data) { + if (err == null) { + // The signature verification is successful. + Console.log("verify success"); + } else { + // The signature verification failed. + Console.log("verify failed, errCode: " + err.code + ", errMsg: " + err.message); + } + }); + + // Time represented in a string. + let date = "150527000001Z"; + + // Verify the certificate validity period. + x509Cert.checkValidityWithDate(date, function (err, data) { + if (err != null) { + // Failed to verify the certificate validity period. + Console.log("checkValidityWithDate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The certificate validity period is verified successfully. + Console.log("checkValidityWithDate success"); + } + }); + }); +} +``` + +## Using the CRL + +**When to Use** + +Typical operations involve the following: + +1. Parse the X.509 CRL data to create an **X509Crl** instance. +2. Obtain the CRL information, such as the CRL version and type. +3. Obtain the serialized data of the CRL. +4. Check whether the certificate is revoked. +5. Verify the CRL signature. +6. Obtain the revoked certificates. + +**Available APIs** + +For details about the APIs, see [Certificate](../reference/apis/js-apis-cert.md). + +The table below describes the APIs used in this guide. + +| Instance | API | Description | +| --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| cryptoCert | createX509Crl(inStream : EncodingBlob, callback : AsyncCallback) : void | Parses the X.509 CRL data to create an **X509Crl** instance. This API uses an asynchronous callback to return the result.| +| cryptoCert | createX509Crl(inStream : EncodingBlob) : Promise | Parses the X.509 CRL data to create an **X509Crl** instance. This API uses a promise to return the result. | +| X509Crl | isRevoked(cert : X509Cert, callback : AsyncCallback) : void | Checks whether the certificate is revoked. This API uses an asynchronous callback to return the result. | +| X509Crl | isRevoked(cert : X509Cert) : Promise | Checks whether the certificate is revoked. This API uses a promise to return the result. | +| X509Crl | getType() : string | Obtains the CRL type. | +| X509Crl | getEncoded(callback : AsyncCallback) : void | Obtains the serialized CRL data. This API uses an asynchronous callback to return the result. | +| X509Crl | getEncoded() : Promise | Obtains the serialized CRL data. This API uses a promise to return the result. | +| X509Crl | verify(key : cryptoFramework.PubKey, callback : AsyncCallback) : void | Verifies the CRL signature. This API uses an asynchronous callback to return the result. | +| X509Crl | verify(key : cryptoFramework.PubKey) : Promise | Verifies the CRL signature. This API uses a promise to return the result. | +| X509Crl | getVersion() : number | Obtains the CRL version. | +| X509Crl | getIssuerName() : DataBlob | Obtains the CRL issuer. | +| X509Crl | getLastUpdate() : string | Obtains the date when the CRL was last updated. | +| X509Crl | getNextUpdate() : string | Obtains the next update date of the CRL. | +| X509Crl | getRevokedCert(serialNumber : number, callback : AsyncCallback) : void | Obtains the revoked certificate in the CRL based on the specified serial number. This API uses an asynchronous callback to return the result. | +| X509Crl | getRevokedCert(serialNumber : number) : Promise | Obtains the revoked certificate in the CRL based on the specified serial number. This API uses a promise to return the result. | +| X509Crl | getRevokedCertWithCert(cert : X509Cert, callback : AsyncCallback) : void | Obtains the specified X.509 certificate from the CRL. This API uses an asynchronous callback to return the result. | +| X509Crl | getRevokedCertWithCert(cert : X509Cert) : Promise | Obtains the specified X.509 certificate from the CRL. This API uses a promise to return the result. | +| X509Crl | getRevokedCerts(callback : AsyncCallback>) : void | Obtains all revoked certificates in the CRL. This API uses an asynchronous callback to return the result. | +| X509Crl | getRevokedCerts() : Promise> | Obtains all revoked certificates in the CRL. This API uses a promise to return the result. | +| X509Crl | getTbsInfo(callback : AsyncCallback) : void | Obtains the tbsCertList of the CRL. This API uses an asynchronous callback to return the result. | +| X509Crl | getTbsInfo() : Promise | Obtains the tbsCertList of the CRL. This API uses a promise to return the result. | +| X509Crl | getSignature() : DataBlob | Obtains the CRL signature. | +| X509Crl | getSignatureAlgName() : string | Obtains the CRL signing algorithm. | +| X509Crl | getSignatureAlgOid() : string | Obtains the signing algorithm OID of the CRL. | +| X509Crl | getSignatureAlgParams() : DataBlob | Obtains the signing algorithm parameters of the CRL. | + +**How to Develop** + +Example: Parse the X.509 CRL data to create an **X509Crl** instance and call APIs to perform CRL operations. + +```javascript +import cryptoCert from '@ohos.security.cert'; +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// CRL data, which is only an example. The CRL data varies with the service. +let crlData = "-----BEGIN X509 CRL-----\n" ++ "MIIBijB0AgEBMA0GCSqGSIb3DQEBCwUAMBMxETAPBgNVBAMMCHJvb3QtY2ExFw0y\n" ++ "MDA2MTkxNjE1NDhaFw0yMDA3MTkxNjE1NDhaMBwwGgIJAMsozRATnap1Fw0yMDA2\n" ++ "MTkxNjEyMDdaoA8wDTALBgNVHRQEBAICEAIwDQYJKoZIhvcNAQELBQADggEBACPs\n" ++ "9gQB+djaXPHHRmAItebZpD3iJ/e36Dxr6aMVkn9FkI8OVpUI4RNcCrywyCZHQJte\n" ++ "995bbPjP7f1sZstOTZS0fDPgJ5SPAxkKOQB+SQnBFrlZSsxoUNU60gRqd2imR0Rn\n" ++ "1r09rP69F6E4yPc9biEld+llLGgoImP3zPOVDD6fbfcvVkjStY3bssVEQ/vjp4a3\n" ++ "/I12U7ZnSe3jaKqaQBoVJppkTFOIOq7IOxf5/IkMPmvRHDeC2IzDMzcUxym0dkny\n" ++ "EowHrjzo0bZVqpHMA2YgKZuwTpVLHk9GeBEK2hVkIoPVISkmiU4HFg0S6z68C5yd\n" ++ "DrAA7hErVgXhtURLbAI=\n" ++ "-----END X509 CRL-----\n"; + +// Convert the string into a Uint8Array. +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// Example of a CRL. +function crlSample() { + let encodingBlob = { + // Convert the CRL data from a string to a Uint8Array. + data: stringToUint8Array(crlData), + // CRL format. Only PEM and DER are supported. In this example, the CRL is in PEM format. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM + }; + + // Create an X509Crl instance. + cryptoCert.createX509Crl(encodingBlob, function (err, x509Crl) { + if (err != null) { + // Failed to create the X509Crl instance. + Console.log("createX509Crl failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // The X509Crl instance is successfully created. + Console.log("createX509Crl success"); + + // Obtain the CRL version. + let version = x509Crl.getVersion(); + + // Obtain the serialized data of the CRL. + x509Crl.getEncoded(function (err, data) { + if (err != null) { + // Failed to obtain the serialized CRL data. + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The serialized CRL data is successfully obtained. + Console.log("getEncoded success"); + } + }); + + // Create an X509Cert instance by using createX509Cert() of cryptoFramework. + let x509Cert = null; + + // Check whether the certificate is revoked. + x509Crl.isRevoked(x509Cert, function (err, isRevoked) { + if (err != null) { + // The operation fails. + Console.log("isRevoked failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The operation is successful. + Console.log("isRevoked success, isRevoked? " + isRevoked); + } + }); + + // Obtain the PubKey instance by using generateKeyPair() or convertKey() of AsyKeyGenerator. The process is omitted here. + let pubKey = null; + + // Verify the CRL signature. + x509Crl.verify(pubKey, function (err, data) { + if (err == null) { + // The operation is successful. + Console.log("verify success"); + } else { + // The operation fails. + Console.log("verify failed, errCode: " + err.code + ", errMsg: " + err.message); + } + }); + + // Certificate serial number, which must be set based on the service. + let serialNumber = 1000; + + // Obtain the revoked certificate based on the serial number. + x509Crl.getRevokedCert(serialNumber, function (err, entry) { + if (err != null) { + // The operation fails. + Console.log("getRevokedCert failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The operation is successful. + Console.log("getRevokedCert success"); + } + }); + }); +} +``` + +## Verifying Certificate Chains + +**When to Use** + +You need to use the certificate chain validator in certificate chain verification. + +**Available APIs** + +For details about the APIs, see [Certificate](../reference/apis/js-apis-cert.md). + +The table below describes the APIs used in this guide. + +| Instance | API | Description | +| ------------------ | ------------------------------------------------------------ | -------------------------------- | +| cryptoCert | createCertChainValidator(algorithm :string) : CertChainValidator | Creates a **CertChainValidator** instance.| +| CertChainValidator | validate(certChain : CertChainData, callback : AsyncCallback) : void | Verifies the certificate chain. This API uses an asynchronous callback to return the result. | +| CertChainValidator | validate(certChain : CertChainData) : Promise | Verifies the certificate chain. This API uses a promise to return the result. | +| CertChainValidator | algorithm : string | Obtains the certificate chain validator algorithm. | + +**How to Develop** + +Example: Create a **CertChainValidator** instance and verify the certificate chain. + +```javascript +import cryptoCert from '@ohos.security.cert'; + +// CA certificate data, which is only an example. The CA certificate data varies with the service. +let caCertData = "-----BEGIN CERTIFICATE-----\n" ++ "...\n" ++ "...\n" ++ "...\n" ++ "-----END CERTIFICATE-----\n"; + +// End-entity certificate data, which is only an example. The certificate data varies with the service. +let secondCaCertData = "-----BEGIN CERTIFICATE-----\n" ++ "...\n" ++ "...\n" ++ "...\n" ++ "-----END CERTIFICATE-----\n"; + +// Convert the certificate data form a string to a Uint8Array. +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; i++) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// Certificate chain validator example. In this example, a two-level certificate chain is verified. +function certChainValidatorSample() { + // Certificate chain validator algorithm. Currently, only PKIX is supported. + let algorithm = "PKIX"; + + // Create a CertChainValidator instance. + let validator = cryptoCert.createCertChainValidator(algorithm); + + // CA certificate data. + let uint8ArrayOfCaCertData = stringToUint8Array(caCertData); + + // Length of the CA certificate data. + let uint8ArrayOfCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOfCaCertData.byteLength]).buffer); + + // End-entity certificate data. + let uint8ArrayOf2ndCaCertData = stringToUint8Array(secondCaCertData); + + // Length of the end-entity certificate data. + let uint8ArrayOf2ndCaCertDataLen = new Uint8Array(new Uint16Array([uint8ArrayOf2ndCaCertData.byteLength]).buffer); + + // Certificate chain binary data: end-entity certificate data length + end-entity certificate data + CA certificate data length + CA certificate data (in L-V format). + let encodingData = new Uint8Array(uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + uint8ArrayOfCaCertData.length); + for (var i = 0; i < uint8ArrayOf2ndCaCertDataLen.length; i++) { + encodingData[i] = uint8ArrayOf2ndCaCertDataLen[i]; + } + for (var i = 0; i < uint8ArrayOf2ndCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + i] = uint8ArrayOf2ndCaCertData[i]; + } + for (var i = 0; i < uint8ArrayOfCaCertDataLen.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + i] = uint8ArrayOfCaCertDataLen[i]; + } + for (var i = 0; i < uint8ArrayOfCaCertData.length; i++) { + encodingData[uint8ArrayOf2ndCaCertDataLen.length + uint8ArrayOf2ndCaCertData.length + + uint8ArrayOfCaCertDataLen.length + i] = uint8ArrayOfCaCertData[i]; + } + + let certChainData = { + // Uint8Array type: L-V format (certificate data length-certificate data) + data: encodingData, + // Number of certificates. It is 2 in this example. + count: 2, + // Certificate format. PEM and DER are supported. In this example, the certificate is in PEM format. + encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM + }; + + // Verify the certificate chain. + validator.validate(certChainData, function (err, data) { + if (err != null) { + // The operation fails. + Console.log("validate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The operation is successful. + Console.log("validate success"); + } + }); +} +``` + +## Managing Revoked Certificates + +**When to Use** + +Typical operations involve the following: + +1. Obtain a revoked certificate instance. +2. Obtain information, such as the serial number, issuer, and certificate revocation date, of the revoked certificate. +3. Obtain the serialized data of the revoked certificate. + +**Available APIs** + +For details about the APIs, see [Certificate](../reference/apis/js-apis-cert.md). + +The table below describes the APIs used in this guide. + +| Instance | API | Description | +| ------------ | ----------------------------------------------------------- | ------------------------------------------ | +| X509CrlEntry | getEncoded(callback : AsyncCallback) : void; | Obtains the serialized data of the revoked certificate. This API uses an asynchronous callback to return the result.| +| X509CrlEntry | getEncoded() : Promise; | Obtains the serialized data of the revoked certificate. This API uses a promise to return the result. | +| X509CrlEntry | getSerialNumber() : number; | Obtains the serial number of the revoked certificate. | +| X509CrlEntry | getCertIssuer(callback : AsyncCallback) : void; | Obtains the issuer of the revoked certificate. This API uses an asynchronous callback to return the result. | +| X509CrlEntry | getCertIssuer() : Promise; | Obtains the issuer of the revoked certificate. This API uses a promise to return the result. | +| X509CrlEntry | getRevocationDate(callback : AsyncCallback) : void; | Obtains the revocation date of the certificate. This API uses an asynchronous callback to return the result. | +| X509CrlEntry | getRevocationDate() : Promise; | Obtains the issuer of the revoked certificate. This API uses a promise to return the result. | + +**How to Develop** + +Example: Obtain a revoked certificate instance and call the APIs. + +```javascript +import cryptoCert from '@ohos.security.cert'; + +// Example of a revoked certificate. +function crlEntrySample() { + // Create an **X509Crl** instance by using createX509Crl() of cryptoFramework. + let x509Crl = null; + + // Obtain a revoked certificate instance. In this example, the instance is obtained by using getRevokedCert(). + let serialNumber = 1000; + x509Crl.getRevokedCert(serialNumber, function (err, crlEntry) { + if (err != null) { + // Failed to obtain the revoked certificate instance. + Console.log("getRevokedCert failed, errCode: " + err.code + ", errMsg: " + err.message); + return; + } + // The revoked certificate instance is successfully obtained. + Console.log("getRevokedCert success"); + + // Obtain the serial number of the revoked certificate. + let serialNumber = crlEntry.getSerialNumber(); + + // Obtain the revocation date of the revoked certificate. + crlEntry.getRevocationDate(function (err, date) { + if (err != null) { + // Failed to obtain the revocation date. + Console.log("getRevocationDate failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The revocation date is successfully obtained. + Console.log("getRevocationDate success, date is: " + date); + } + }); + + // Obtain the serialized data of the revoked certificate instance. + crlEntry.getEncoded(function (err, data) { + if (err != null) { + // Failed to obtain the serialized data. + Console.log("getEncoded failed, errCode: " + err.code + ", errMsg: " + err.message); + } else { + // The serialized data is successfully obtained. + Console.log("getEncoded success"); + } + }); + }); +} +``` diff --git a/en/application-dev/security/cert-overview.md b/en/application-dev/security/cert-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..2e48b4830432e266c315b093ac53a3e3ed7b37b6 --- /dev/null +++ b/en/application-dev/security/cert-overview.md @@ -0,0 +1,24 @@ +# Certificate Overview +The **Certificate** module provides APIs for X.509 certificate operations. You can use the APIs to implement quick development. + +## Basic Concepts + +A digital certificate provides a method of digitally verifying the identity of a user, device, or service. X.509 is an international standard format public key certificates that securely associate cryptographic key pairs with identifies such as websites, individuals, or organizations. The crypto framework provides the following capabilities: + +- X.509 certificate capabilities: parsing and serializing X.509 certificates, verifying X.509 certificate signatures, and querying certificate information. +- X.509 certificate revocation list (CRL) capabilities: parsing, serializing, and querying the X.509 CRL. +- Certificate chain validator capabilities: verifying the certificate chain (excluding the certificate validity period) and querying certificate chain algorithms. + +## Constraints + +- Multi-thread concurrent operations are not supported. + +### Certificate Specifications + +- Certificate chain verification + + The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use **checkValidityWithDate()** of the **X509Cert** class. + +- Certificate formats + + Currently, only the certificates in DER and PEM formats are supported. diff --git a/en/application-dev/security/cryptoFramework-guidelines.md b/en/application-dev/security/cryptoFramework-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..35784280547f6f5064fc13f15d651801ea0d0b02 --- /dev/null +++ b/en/application-dev/security/cryptoFramework-guidelines.md @@ -0,0 +1,1159 @@ +# Crypto Framework Development + +> **NOTE** +> +> This development guide applies to API version 9, OpenHarmony SDK version 3.2.7 or later, and JS development. + +## Generating and Converting Keys + +**When to Use** + +Typical key generation operations involve the following: + +1. Randomly create a key instance. This instance can be used for subsequent encryption and decryption. +2. Convert external or stored binary data into a key instance. This instance can be used for subsequent encryption and decryption. +3. Obtain the binary data of a key for storage or transmission. +> **NOTE** +> +> The key instance can be a symmetric key instance (**SymKey**) or an asymmetric key pair instance (**KeyPair**). The **KeyPair** instance consists a public key (PubKey) and a private key (**PriKey**). For details about the relationship between keys, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +The table below describes the APIs used in this guide. + +|Instance|API|Description| +|---|---|---| +|cryptoFramework|createAsyKeyGenerator(algName : string) : AsyKeyGenerator|Creates an **AsyKeyGenerator** instance.| +|cryptoFramework|createSymKeyGenerator(algName : string) : SymKeyGenerator|Creates a **SymKeyGenerator** instance.| +|AsyKeyGenerator|generateKeyPair(callback : AsyncCallback\) : void|Generates an asymmetric key pair randomly. This API uses an asynchronous callback to return the result.| +|AsyKeyGenerator|generateKeyPair() : Promise\|Generates an asymmetric key pair randomly. This API uses a promise to return the result.| +|SymKeyGenerator|generateSymKey(callback : AsyncCallback\) : void|Generates a symmetric key randomly. This API uses an asynchronous callback to return the result.| +|SymKeyGenerator|generateSymKey() : Promise\|Generates a symmetric key randomly. This API uses a promise to return the result.| +| AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob, callback : AsyncCallback\) : void | Converts binary data into a key pair. This API uses an asynchronous callback to return the result.
(**pubKey** or **priKey** can be **null**. That is, you can pass in only **pubKey** or **priKey**. As a result, the return **KeyPair** instance contains only the public or private key.) | +| AsyKeyGenerator | convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\ | Converts the binary public key and private key data into a key pair. This API uses a promise to return the result.
(**pubKey** or **priKey** can be **null**. That is, you can pass in only **pubKey** or **priKey**. As a result, the returned **KeyPair** instance contains only the public or private key.) | +| SymKeyGenerator | convertKey(key : DataBlob, callback : AsyncCallback\) : void| Converts binary data into a symmetric key. This API uses an asynchronous callback to return the result.| +| SymKeyGenerator |convertKey(pubKey : DataBlob, priKey : DataBlob) : Promise\| Converts binary data into a symmetric key. This API uses a promise to return the result.| +| Key | getEncoded() : DataBlob; | Obtains the binary data of a key. (The child class instances of **Key** include **SymKey**, **PubKey**, and **PriKey**.)| + +**How to Develop** + +Example 1: Randomly generate an asymmetric key pair and obtain its binary data. + +1. Create an **AsyKeyGenerator** instance. +2. Randomly generate an asymmetric key pair using **AsyKeyGenerator**. +3. Obtain binary data of the key pair generated. + +For example, randomly generate an RSA key (1024 bits and two primes) using promise-based APIs. + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function generateAsyKey() { + // Create an AsyKeyGenerator instance. + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + // Use the key generator to randomly generate an asymmetric key pair. + let keyGenPromise = rsaGenerator.generateKeyPair(); + keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + let pubKey = globalKeyPair.pubKey; + let priKey = globalKeyPair.priKey; + // Obtain the binary data of the asymmetric key pair. + pkBlob = pubKey.getEncoded(); + skBlob = priKey.getEncoded(); + AlertDialog.show({ message : "pk bin data" + pkBlob.data} ); + AlertDialog.show({ message : "sk bin data" + skBlob.data} ); + }) +} +``` + +Example 2: Randomly generate a symmetric key and obtain its binary data. + +1. Create a **SymKeyGenerator** instance. +2. Randomly generate a symmetric key using **SymKeyGenerator**. +3. Obtain binary data of the key generated. + +For example, randomly generate an AES key (256 bits) using promise-based APIs. + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// Output the byte streams in hexadecimal format. +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +function testGenerateAesKey() { + // Create a SymKeyGenerator instance. + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('AES256'); + // Use the key generator to randomly generate a symmetric key. + let promiseSymKey = symKeyGenerator.generateSymKey(); + promiseSymKey.then( key => { + // Obtain the binary data of the symmetric key and output a 256-bit byte stream. + let encodedKey = key.getEncoded(); + console.info('key hex:' + uint8ArrayToShowStr(encodedKey.data)); + }) +} +``` + +Example 3: Generate an asymmetric key pair from the binary RSA key data. + +1. Obtain the binary data of the RSA public or private key. The public key must comply with the ASN.1 syntax, X.509 specifications, and DER encoding format. The private key must comply with the ASN.1 syntax, PKCS #8 specifications, and DER encoding format. +2. Create an **AsyKeyGenerator** instance and call **convertKey()** to convert the key binary data (data of the private or public key, or both) passed in to a **KeyPair** instance. + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +function convertAsyKey() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024"); + let pkval = new Uint8Array([48,129,159,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,129,141,0,48,129,137,2,129,129,0,174,203,113,83,113,3,143,213,194,79,91,9,51,142,87,45,97,65,136,24,166,35,5,179,42,47,212,79,111,74,134,120,73,67,21,19,235,80,46,152,209,133,232,87,192,140,18,206,27,106,106,169,106,46,135,111,118,32,129,27,89,255,183,116,247,38,12,7,238,77,151,167,6,102,153,126,66,28,253,253,216,64,20,138,117,72,15,216,178,37,208,179,63,204,39,94,244,170,48,190,21,11,73,169,156,104,193,3,17,100,28,60,50,92,235,218,57,73,119,19,101,164,192,161,197,106,105,73,2,3,1,0,1]); + let pkBlob = {data : pkval}; + rsaGenerator.convertKey(pkBlob, null, function(err, keyPair) { + if (keyPair == null) { + AlertDialog.show({message : "Convert keypair fail"}); + } + AlertDialog.show({message : "Convert KeyPair success"}); + }) +} +``` + +**NOTE** + +The public key returned by **convertKey()** must be in the DER format complying with X.509 specifications, and the private key must be in the DER format complying with PKCS #8 specifications. + +Example 4: Generate an asymmetric key pair from the binary ECC key data. + +1. Obtain the ECC binary key data and encapsulate it into a **DataBlob** instance. +2. Call **convertKey()** to convert the key binary data (data of the private or public key, or both) passed in to a **KeyPair** instance. + +```javascript +function convertEccAsyKey() { + let pubKeyArray = new Uint8Array([4,196,55,233,100,227,224,38,38,5,128,81,53,112,129,7,59,189,116,105,182,87,190,85,31,248,172,116,213,7,206,85,190,65,169,193,138,173,232,187,74,54,78,251,29,131,192,223,251,227,170,138,80,7,98,193,216,168,235,114,255,188,70,134,104]); + let priKeyArray = new Uint8Array([255,70,89,220,189,19,41,157,175,173,83,60,74,216,195,96,24,181,231,23,112,247,150,126,15,155,24,79,33,97,31,225]); + let pubKeyBlob = { data: pubKeyArray }; + let priKeyBlob = { data: priKeyArray }; + let generator = cryptoFrameWork.createAsyKeyGenerator("ECC256"); + generator.convertKey(pubKeyBlob, priKeyBlob, (error, data) => { + if (error) { + AlertDialog.show({message : "Convert keypair fail"}); + } + AlertDialog.show({message : "Convert KeyPair success"}); + }) +} +``` + +Example 5: Generate a symmetric key from binary key data. + +1. Create a **SymKeyGenerator** instance. +2. Generate a symmetric key from the binary data passed in. +3. Obtain binary data of the key generated. + +For example, generate a 3DES key (192 bits only) using callback-based APIs. + +```javascript +import cryptoFramework from '@ohos.security.cryptoFramework'; + +// Output the byte streams in hexadecimal format. +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + +function testConvertAesKey() { + // Create a SymKeyGenerator instance. + let symKeyGenerator = cryptoFramework.createSymKeyGenerator('3DES192'); + // Generate a symmetric key based on the specified data. + let keyMaterialBlob = genKeyMaterialBlob(); + try { + symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { + if (error) { // If the service logic fails to be executed, return the error information in the first parameter of the callback. + console.error(`convertKey error, ${error.code}, ${error.message}`); + return; + } + console.info(`key algName: ${key.algName}`); + console.info(`key format: ${key.format}`); + let encodedKey = key.getEncoded(); // Obtain the binary data of the symmetric key and output a 192-bit byte stream. + console.info('key getEncoded hex: ' + uint8ArrayToShowStr(encodedKey.data)); + }) + } catch (error) { // Throw an exception immediately in synchronous mode when an error is detected during the parameter check. + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } +} +``` + +## Encrypting and Decrypting Data + +**When to Use** + +Important data needs to be encrypted in data storage or transmission for security purposes. Typical encryption and decryption operations involve the following: +1. Encrypt and decrypt data using a symmetric key. +2. Encrypt and decrypt data using an asymmetric key pair. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +The table below describes the APIs used in this guide. + +|Instance|API|Description| +|---|---|---| +|cryptoFramework|createCipher(transformation : string) : Cipher|Creates a **Cipher** instance.| +|Cipher|init(opMode : CryptoMode, key : Key, params : ParamsSpec, callback : AsyncCallback\) : void|Sets a key and initializes the **Cipher** instance. This API uses an asynchronous callback to return the result.| +|Cipher|init(opMode : CryptoMode, key : Key, params : ParamsSpec) : Promise\|Sets a key and initializes the **Cipher** instance. This API uses a promise to return the result.| +|Cipher|update(data : DataBlob, callback : AsyncCallback\) : void|Updates the data for encryption and decryption. This API uses an asynchronous callback to return the result.| +|Cipher|update(data : DataBlob) : Promise\|Updates the data for encryption and decryption. This API uses a promise to return the result.| +|Cipher|doFinal(data : DataBlob, callback : AsyncCallback\) : void|Finalizes the encryption or decryption. This API uses an asynchronous callback to return the result.| +|Cipher|doFinal(data : DataBlob) : Promise\|Finalizes the encryption or decryption. This API uses a promise to return the result.| + +**How to Develop** + +Example 1: Encrypt and decrypt data using a symmetric key. + +1. Create a **SymKeyGenerator** instance. +2. Use the key generator to generate a symmetric key. +3. Create a **Cipher** instance. +4. Encrypt or decrypt data. + +For example, use AES GCM to encrypt and decrypt data using promise-based APIs. + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +var globalCipher; +var globalGcmParams; +var globalKey; +var globalCipherText; + +function genGcmParamsSpec() { + let arr = [0, 0, 0, 0 , 0, 0, 0, 0, 0, 0 , 0, 0]; // 12 bytes + let dataIv = new Uint8Array(arr); + let ivBlob = {data : dataIv}; + + arr = [0, 0, 0, 0 , 0, 0, 0, 0]; // 8 bytes + let dataAad = new Uint8Array(arr); + let aadBlob = {data : dataAad}; + + arr = [0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0]; // 16 bytes + let dataTag = new Uint8Array(arr); + let tagBlob = {data : dataTag}; + let gcmParamsSpec = {iv : ivBlob, aad : aadBlob, authTag : tagBlob, algoName : "GcmParamsSpec"}; + return gcmParamsSpec; +} + +// Convert strings in plaintext into byte streams. +function stringToUint8Array(str) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// Convert byte streams into strings in plaintext. +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +// Output the byte streams in hexadecimal format. +function uint8ArrayToString(array) { + let arrayString = ''; + for (let i = 0; i < array.length; i++) { + arrayString += String.fromCharCode(array[i]); + } + return arrayString; +} + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + + +// Automatically generate a key in AES GCM mode and return the result in a promise. +function testAesGcm() { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve('testAesGcm'); + }, 10) + }).then(() => { + // Create a SymKeyGenerator instance. + let symAlgoName = 'AES128'; + let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); + if (symKeyGenerator == null) { + console.error('createSymKeyGenerator failed'); + return; + } + console.info(`symKeyGenerator algName: ${symKeyGenerator.algName}`); + // Use the key generator to randomly generate a 128-bit symmetric key. + let promiseSymKey = symKeyGenerator.generateSymKey(); + // Constructor + globalGcmParams = genGcmParamsSpec(); + + // Create a Cipher instance. + let cipherAlgoName = 'AES128|GCM|PKCS7'; + try { + globalCipher = cryptoFramework.createCipher(cipherAlgoName); + console.info(`cipher algName: ${globalCipher.algName}`); + } catch (error) { + console.error(`createCipher failed, ${error.code}, ${error.message}`); + return; + } + return promiseSymKey; + }).then(key => { + let encodedKey = key.getEncoded(); + console.info('key hex:' + uint8ArrayToShowStr(encodedKey.data)); + globalKey = key; + return key; + }).then(key => { + // Initialize the cipher environment and start encryption. + let mode = cryptoFramework.CryptoMode.ENCRYPT_MODE; + let promiseInit = globalCipher.init(mode, key, globalGcmParams); // init + return promiseInit; + }).then(() => { + let plainText = {data : stringToUint8Array('this is test!')}; + let promiseUpdate = globalCipher.update(plainText); // update + return promiseUpdate; + }).then(updateOutput => { + globalCipherText = updateOutput; + let promiseFinal = globalCipher.doFinal(null); // doFinal + return promiseFinal; + }).then(authTag => { + // Obtain the authentication information after encryption. + globalGcmParams.authTag = authTag; + return; + }).then(() => { + // Initialize the cipher environment and start decryption. + let mode = cryptoFramework.CryptoMode.DECRYPT_MODE; + let promiseInit = globalCipher.init(mode, globalKey, globalGcmParams); // init + return promiseInit; + }).then(() => { + let promiseUpdate = globalCipher.update(globalCipherText); // update + return promiseUpdate; + }).then(updateOutput => { + console.info('decrypt plainText: ' + uint8ArrayToString(updateOutput.data)); + let promiseFinal = globalCipher.doFinal(null); // doFinal + return promiseFinal; + }).then(finalOutput => { + if (finalOutput == null) { + console.info('GCM finalOutput is null'); + } + }).catch(error => { + console.error(`catch error, ${error.code}, ${error.message}`); + }) +} +``` + +For example, 3DES ECB is used. Generate a key from the existing data to encrypt and decrypt data using callback-based APIs. + +```js +import cryptoFramework from '@ohos.security.cryptoFramework'; + +var globalCipher; +var globalGcmParams; +var globalKey; +var globalCipherText; + +// Convert strings in plaintext into byte streams. +function stringToUint8Array(str) { + let arr = []; + for (let i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + return new Uint8Array(arr); +} + +// Convert byte streams into strings in plaintext. +function uint8ArrayToShowStr(uint8Array) { + return Array.prototype.map + .call(uint8Array, (x) => ('00' + x.toString(16)).slice(-2)) + .join(''); +} + +// Output the byte streams in hexadecimal format. +function uint8ArrayToString(array) { + let arrayString = ''; + for (let i = 0; i < array.length; i++) { + arrayString += String.fromCharCode(array[i]); + } + return arrayString; +} + +function genKeyMaterialBlob() { + let arr = [ + 0xba, 0x3d, 0xc2, 0x71, 0x21, 0x1e, 0x30, 0x56, + 0xad, 0x47, 0xfc, 0x5a, 0x46, 0x39, 0xee, 0x7c, + 0xba, 0x3b, 0xc2, 0x71, 0xab, 0xa0, 0x30, 0x72]; // keyLen = 192 (24 bytes) + let keyMaterial = new Uint8Array(arr); + return {data : keyMaterial}; +} + +// For example, 3DES ECB is used. Use existing data to generate a key to encrypt and decrypt data, and return the result in a callback. +function test3DesEcb() { + // Create a SymKeyGenerator instance. + let symAlgoName = '3DES192'; + let symKeyGenerator = cryptoFramework.createSymKeyGenerator(symAlgoName); + if (symKeyGenerator == null) { + console.error('createSymKeyGenerator failed'); + return; + } + console.info(`symKeyGenerator algName: ${symKeyGenerator.algName}`); + + // Create a Cipher instance. + let cipherAlgoName = '3DES192|ECB|PKCS7'; + try { + globalCipher = cryptoFramework.createCipher(cipherAlgoName); + console.info(`cipher algName: ${globalCipher.algName}`); + } catch (error) { + console.error(`createCipher failed, ${error.code}, ${error.message}`); + return; + } + + // Generate a symmetric key based on the specified data. + let keyMaterialBlob = genKeyMaterialBlob(); + try { + symKeyGenerator.convertKey(keyMaterialBlob, (error, key) => { + if (error) { + console.error(`convertKey error, ${error.code}, ${error.message}`); + return; + } + console.info(`key algName: ${key.algName}`); + console.info(`key format: ${key.format}`); + let encodedKey = key.getEncoded(); + console.info('key getEncoded hex: ' + uint8ArrayToShowStr(encodedKey.data)); + globalKey = key; + + // Initialize the cipher environment and start encryption. + let mode = cryptoFramework.CryptoMode.ENCRYPT_MODE; + // init + globalCipher.init(mode, key, null, (err, ) => { + let plainText = {data : stringToUint8Array('this is test!')}; + // update + globalCipher.update(plainText, (err, updateOutput) => { + globalCipherText = updateOutput; + //doFinal + globalCipher.doFinal(null, (err, finalOutput) => { + if (error) { + console.error(`doFinal error, ${error.code}, ${error.message}`); + return; + } + if (finalOutput != null) { + globalCipherText = Array.from(globalCipherText.data); + finalOutput = Array.from(finalOutput.data); + globalCipherText = globalCipherText.concat(finalOutput); + globalCipherText = new Uint8Array(globalCipherText); + globalCipherText = {data : globalCipherText}; + } + // Initialize the cipher environment and start decryption. + let mode = cryptoFramework.CryptoMode.DECRYPT_MODE; + // init + globalCipher.init(mode, globalKey, null, (err, ) => { + // update + globalCipher.update(globalCipherText, (err, updateOutput) => { + console.info('decrypt plainText: ' + uint8ArrayToString(updateOutput.data)); + // doFinal + globalCipher.doFinal(null, (error, finalOutput) => { + if (finalOutput != null) { + console.info("decrypt plainText:" + uint8ArrayToString(finalOutput.data)); + } + }) + }) + }) + }) + }) + }) + }) + } catch (error) { + console.error(`convertKey failed, ${error.code}, ${error.message}`); + return; + } +} +``` + +Example 2: Encrypt and decrypt data using an asymmetric key pair. + +1. Generate an RSA key pair. + + Call **createAsyKeyGenerator()** to create an **AsyKeyGenerator** instance and generate an RSA asymmetric key pair. + +2. Create a **Cipher** instance. + + Call **createCipher()** to create a **Cipher** instance, and set the key and encryption/decryption mode. + +3. Perform encryption and decryption operations. + + Call **doFinal()** provided by the **Cipher** instance to encrypt data or decrypt data. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let plan = "This is cipher test."; + +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpArray = new Uint8Array(arr); + return tmpArray; +} + +function encryptMessageProMise() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + let cipher = cryptoFramework.createCipher("RSA1024|PKCS1"); + let keyGenPromise = rsaGenerator.generateKeyPair(); + keyGenPromise.then(rsaKeyPair => { + let pubKey = rsaKeyPair.pubKey; + return cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null); + }).then(() => { + let input = { data : stringToUint8Array(plan) }; + return cipher.doFinal(input); + }).then(dataBlob => { + console.info("EncryptOutPut is " + dataBlob.data); + }); +} + +function encryptMessageCallback() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + let cipher = cryptoFramework.createCipher("RSA1024|PKCS1"); + rsaGenerator.generateKeyPair(function (err, keyPair) { + let pubKey = keyPair.pubKey; + cipher.init(cryptoFramework.CryptoMode.ENCRYPT_MODE, pubKey, null, function (err, data) { + let input = {data : stringToUint8Array(plan) }; + cipher.doFinal(input, function (err, data) { + console.info("EncryptOutPut is " + data.data); + }) + }) + }) +} +``` + +**NOTE** + +- In RSA encryption and decryption, **init()** cannot be repeatedly called to initialize the **Cipher** instance. You must create a **Cipher** instance for each of encryption and decryption. +- The RSA encryption has a limit on the length of the plaintext to be encrypted. For details, see "Basic Concepts" in [Crypto Framework Overview](cryptoFramework-overview.md). +- In RSA decryption, the length of the ciphertext to be decrypted each time is the number of bits of the RSA key divided by 8. + +## Signing Data and Verifying Signatures + +**When to Use** + +A digital signature can be used to verify the authenticity of a message. Typical signing and signature verification operations involve the following: +1. Use RSA to sign data and verify the signature. +2. Use ECC to sign data and verify the signature. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +|Instance|API|Description| +|---|---|---| +|cryptoFramework|createSign(algName : string) : Sign|Creates a **Sign** instance.| +|Sign|init(priKey : PriKey, callback : AsyncCallback\) : void|Sets a key and initializes the **Sign** instance. This API uses an asynchronous callback to return the result.| +|Sign|init(priKey : PriKey) : Promise\|Sets a key and initializes the **Sign** instance. This API uses a promise to return the result.| +|Sign|update(data : DataBlob, callback : AsyncCallback\) : void|Updates the data for signing. This API uses an asynchronous callback to return the result.| +|Sign|update(data : DataBlob) : Promise\|Updates the data for signing. This API uses a promise to return the result.| +|Sign|sign(data : DataBlob, callback : AsyncCallback) : void|Signs the data. This API uses an asynchronous callback to return the result.| +|Sign|sign(data : DataBlob) : Promise|Signs the data. This API uses a promise to return the result.| +|cryptoFramework|function createVerify(algName : string) : Verify|Creates a **Verify** instance.| +|Verify|init(priKey : PriKey, callback : AsyncCallback\) : void|Sets a key and initializes the **Verify** instance. This API uses an asynchronous callback to return the result.| +|Verify|init(priKey : PriKey) : Promise\|Sets a key and initializes the **Verify** instance. This API uses a promise to return the result.| +|Verify|update(data : DataBlob, callback : AsyncCallback\) : void|Updates the data for signature verification. This API uses an asynchronous callback to return the result.| +|Verify|update(data : DataBlob) : Promise\|Updates the data for signature verification. This API uses a promise to return the result.| +|Verify|verify(data : DataBlob, signatureData : DataBlob, callback : AsyncCallback) : void|Verifies the signature. This API uses an asynchronous callback to return the result.| +|Verify|verify(data : DataBlob, signatureData : DataBlob) : Promise|Verifies the signature. This API uses a promise to return the result.| + +**How to Develop** + +Example 1: Use RSA to sign data and verify the signature. +1. Generate an RSA key pair. + + Call **createAsyKeyGenerator()** to create an **AsyKeyGenerator** instance and generate an RSA asymmetric key pair. + +2. Create a **Sign** instance. + + Call **createSign()** to create a **Sign** instance, initialize the **Sign** instance, and set a private key for signing. + +3. Generate a signature. + + Call **update()** provided by the **Sign** class to add the data for signing and call **sign()** to generate a signature. + +4. Create a **Verify** instance. + + Call **createVerify()** to create a **Verify** instance, initialize the instance, and set a public key for signature verification. + +5. Verify the signature. + + Call **update()** provided by the **Verify** class to add signature data and call **verify()** to verify the signature. +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpArray = new Uint8Array(arr); + return tmpArray; +} + +let globalKeyPair; +let SignMessageBlob; +let plan1 = "This is Sign test plan1"; +let plan2 = "This is Sign test plan1"; +let input1 = { data : stringToUint8Array(plan1) }; +let input2 = { data : stringToUint8Array(plan2) }; + +function signMessagePromise() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + let signer = cryptoFramework.createSign("RSA1024|PKCS1|SHA256"); + let keyGenPromise = rsaGenerator.generateKeyPair(); + keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + return signer.init(priKey); + }).then(() => { + return signer.update(input1); + }).then(() => { + return signer.sign(input2); + }).then(dataBlob => { + SignMessageBlob = dataBlob; + console.info("sign output is " + SignMessageBlob.data); + }); +} + +function verifyMessagePromise() { + let verifyer = cryptoFramework.createVerify("RSA1024|PKCS1|SHA256"); + let verifyInitPromise = verifyer.init(globalKeyPair.pubKey); + verifyInitPromise.then(() => { + return verifyer.update(input1); + }).then(() => { + return verifyer.verify(input2, SignMessageBlob); + }).then(res => { + console.log("Verify result is " + res); + }); +} + +function signMessageCallback() { + let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024|PRIMES_2"); + let signer = cryptoFramework.createSign("RSA1024|PKCS1|SHA256"); + rsaGenerator.generateKeyPair(function (err, keyPair) { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + signer.init(priKey, function (err, data) { + signer.update(input1, function (err, data) { + signer.sign(input2, function (err, data) { + SignMessageBlob = data; + console.info("sign output is " + SignMessageBlob.data); + }); + }); + }); + }); +} + +function verifyMessageCallback() { + let verifyer = cryptoFramework.createVerify("RSA1024|PKCS1|SHA256"); + verifyer.init(globalKeyPair.pubKey, function (err, data) { + verifyer.update(input1, function(err, data) { + verifyer.verify(input2, SignMessageBlob, function(err, data) { + console.info("verify result is " + data); + }); + }); + }) +} +``` + +Example 2: Using ECC to sign data and verify the signature. +1. Generate an ECC key. + + Call **createAsyKeyGenerator()** to create an **AsyKeyGenerator** instance and generate an ECC asymmetric key pair. + +2. Create a **Sign** instance. + + Call **createSign()** to create a **Sign** instance, initialize the **Sign** instance, and set a private key for signing. + +3. Generate a signature. + + Call **update()** provided by the **Sign** class to add the data for signing and call **doFinal()** to generate a signature. + +4. Create a **Verify** instance. + + Call **createVerify()** to create a **Verify** instance, initialize the instance, and set a public key for signature verification. + +5. Verify the signature. + + Call **update()** provided by the **Verify** class to add signature data and call **doFinal()** to verify the signature. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpArray = new Uint8Array(arr); + return tmpArray; +} + +let globalKeyPair; +let SignMessageBlob; +let plan1 = "This is Sign test plan1"; +let plan2 = "This is Sign test plan1"; +let input1 = { data : stringToUint8Array(plan1) }; +let input2 = { data : stringToUint8Array(plan2) }; + +function signMessagePromise() { + let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); + let signer = cryptoFramework.createSign("ECC256|SHA256"); + let keyGenPromise = eccGenerator.generateKeyPair(); + keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + return signer.init(priKey); + }).then(() => { + return signer.update(input1); + }).then(() => { + return signer.sign(input2); + }).then(dataBlob => { + SignMessageBlob = dataBlob; + console.info("sign output is " + SignMessageBlob.data); + }); +} + +function verifyMessagePromise() { + let verifyer = cryptoFramework.createVerify("ECC256|SHA256"); + let verifyInitPromise = verifyer.init(globalKeyPair.pubKey); + verifyInitPromise.then(() => { + return verifyer.update(input1); + }).then(() => { + return verifyer.verify(input2, SignMessageBlob); + }).then(res => { + console.log("Verify result is " + res); + }); +} + +function signMessageCallback() { + let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); + let signer = cryptoFramework.createSign("ECC256|SHA256"); + eccGenerator.generateKeyPair(function (err, keyPair) { + globalKeyPair = keyPair; + let priKey = globalKeyPair.priKey; + signer.init(priKey, function (err, data) { + signer.update(input1, function (err, data) { + signer.sign(input2, function (err, data) { + SignMessageBlob = data; + console.info("sign output is " + SignMessageBlob.data); + }); + }); + }); + }); +} + +function verifyMessageCallback() { + let verifyer = cryptoFramework.createVerify("ECC256|SHA256"); + verifyer.init(globalKeyPair.pubKey, function (err, data) { + verifyer.update(input1, function(err, data) { + verifyer.verify(input2, SignMessageBlob, function(err, data) { + console.info("verify result is " + data); + }); + }); + }) +} +``` + +## Generating a Digest + +**When to Use** + +A message digest is a fixed size numeric representation of the content of a message, computed by a has function. The message digest is sent with the message. The receiver can generate a digest for the message and compare it with the digest received. If the two digests are the same, the message integrity is verified. + +Typical message digest operations involve the following: + +1. Create an **Md** instance. +2. Add one or more segments of data for generating a digest. +3. Compute a digest. +4. Obtain the algorithm and length of a digest. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +| Instance | API | Description | +| --------------- | ------------------------------------------------------------ | -------------------------------------------------- | +| cryptoFramework | function createMd(algName : string) : Md; | Creates an **Md** instance. | +| Md | update(input : DataBlob, callback : AsyncCallback\) : void; | Updates the data for a digest. This API uses an asynchronous callback to return the result.| +| Md | update(input : DataBlob) : Promise\; | Updates the data for a digest. This API uses a promise to return the result. | +| Md | digest(callback : AsyncCallback\) : void; | Generates the digest. This API uses an asynchronous callback to return the result. | +| Md | digest() : Promise\; | Generates the digest. This API uses a promise to return the result. | +| Md | getMdLength() : number; | Obtains the digest length based on the specified digest algorithm. | +| Md | readonly algName : string; | Obtains the digest algorithm. | + +**How to Develop** + +1. Call **createMd()** to create an **Md** instance. +2. Call **update()** to update the data for computing a digest. **update()** can be called multiple times to update the data by segment. +3. Call **digest()** to compute a digest. +4. Obtain the digest algorithm and length of the digest generated. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Convert string into uint8Arr. +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} + +// Generate a dataBlob of the given length. +function GenDataBlob(dataBlobLen) { + var dataBlob; + if (dataBlobLen == 12) { + dataBlob = {data: stringToUint8Array("my test data")}; + } else { + console.error("GenDataBlob: dataBlobLen is invalid"); + dataBlob = {data: stringToUint8Array("my test data")}; + } + return dataBlob; +} + +// Compute a message digest using promise-based APIs. +function doMdByPromise(algName) { + var md; + try { + md = cryptoFramework.createMd(algName); + } catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); + } + console.error("[Promise]: Md algName is: " + md.algName); + var promiseMdUpdate = md.update(GenDataBlob(12)); + promiseMdUpdate.then(() => { + var PromiseMdDigest = md.digest(); + return PromiseMdDigest; + }).then(mdOutput => { + console.error("[Promise]: MD result: " + mdOutput.data); + var mdLen = md.getMdLength(); + console.error("[Promise]: MD len: " + mdLen); + }).catch(error => { + console.error("[Promise]: error: " + error.message); + }); +} + +// Compute a message digest using callback-based APIs. +function doMdByCallback(algName) { + var md; + try { + md = cryptoFramework.createMd(algName); + } catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); + } + console.error("[Callback]: Md algName is: " + md.algName); + md.update(GenDataBlob(12), (err,) => { + if (err) { + console.error("[Callback]: err: " + err.code); + } + md.digest((err1, mdOutput) => { + if (err1) { + console.error("[Callback]: err: " + err1.code); + } else { + console.error("[Callback]: MD result: " + mdOutput.data); + var mdLen = md.getMdLength(); + console.error("[Callback]: MD len: " + mdLen); + } + }); + }); +} +``` + +## Performing Key Agreement + +**When to Use** + +Key agreement allows two parties to establish a shared secret over an insecure channel. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +|Instance|API|Description| +|---|---|---| +|cryptoFramework|createKeyAgreement(algName : string) : KeyAgreement|Creates a **KeyAgreement** instance.| +|KeyAgreement|generateSecret(priKey : PriKey, pubKey : PubKey, callback : AsyncCallback\) : void|Generates a shared secret. This API uses an asynchronous callback to return the result.| +|KeyAgreement|generateSecret(priKey : PriKey, pubKey : PubKey) : Promise\|Generates a shared secret. This API uses a promise to return the result.| + +**How to Develop** + +1. Generate an ECC key. + + Call **createAsyKeyGenerator()** to create an **AsyKeyGenerator** instance and generate an ECC asymmetric key pair. + +2. Generate a shared secret by using the private and public ECC keys. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +let globalKeyPair; + +function ecdhPromise() { + let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); + let eccKeyAgreement = cryptoFramework.createKeyAgreement("ECC256"); + let keyGenPromise = eccGenerator.generateKeyPair(); + keyGenPromise.then( keyPair => { + globalKeyPair = keyPair; + return eccKeyAgreement.generateSecret(keyPair.priKey, keyPair.pubKey); + }).then((secret) => { + console.info("ecdh output is " + secret.data); + }).catch((error) => { + console.error("ecdh error."); + }); +} + +function ecdhCallback() { + let eccGenerator = cryptoFramework.createAsyKeyGenerator("ECC256"); + let eccKeyAgreement = cryptoFramework.createKeyAgreement("ECC256"); + eccGenerator.generateKeyPair(function (err, keyPair) { + globalKeyPair = keyPair; + eccKeyAgreement.generateSecret(keyPair.priKey, keyPair.pubKey, function (err, secret) { + if (err) { + console.error("ecdh error."); + return; + } + console.info("ecdh output is " + secret.data); + }); + }); +} +``` + +## Generating a MAC + +**When to Use** + +A message authentication code (MAC) can be used to verify both the integrity and authenticity of a message using a shared secret. + +Typical MAC operations involve the following: + +1. Create a **Mac** instance. +2. Initialize the **Mac** instance, add one or more segments of data for generating a MAC, and generate a MAC. +3. Obtain the algorithm and length of a MAC. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +| Instance | API | Description | +| --------------- | ------------------------------------------------------------ | --------------------------------------------------- | +| cryptoFramework | function createMac(algName : string) : Md; | Creates a **Mac** instance. | +| Mac | init(key : SymKey, callback : AsyncCallback\) : void; | Initializes the MAC operation. This API uses an asynchronous callback to return the result.| +| Mac | init(key : SymKey) : Promise\; | Initializes the MAC operation. This API uses a promise to return the result. | +| Mac | update(input : DataBlob, callback : AsyncCallback\) : void; | Updates the data for the MAC operation. This API uses an asynchronous callback to return the result. | +| Mac | update(input : DataBlob) : Promise\; | Updates the data for the MAC operation. This API uses a promise to return the result. | +| Mac | doFinal(callback : AsyncCallback\) : void; | Finalizes the MAC operation to generate a MAC. This API uses an asynchronous callback to return the result. | +| Mac | doFinal() : Promise\; | Finalizes the MAC operation to generate a MAC. This API uses a promise to return the result. | +| Mac | getMacLength() : number; | Obtains the length of the MAC based on the specified algorithm. | +| Mac | readonly algName : string; | Obtains the algorithm. | + +**How to Develop** + +1. Call **createMac()** to create a **Mac** instance. +2. Call **init()** to initialize the **Mac** instance with the symmetric key passed in. +3. Call **update()** one or more times to add the data for computing a MAC. +4. Call **doFinal()** to generate a MAC. +5. Obtain the algorithm and length of the MAC. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Convert string into uint8Arr. +function stringToUint8Array(str) { + var arr = []; + for (var i = 0, j = str.length; i < j; ++i) { + arr.push(str.charCodeAt(i)); + } + var tmpUint8Array = new Uint8Array(arr); + return tmpUint8Array; +} + +// Generate a blob. +function GenDataBlob(dataBlobLen) { + var dataBlob; + if (dataBlobLen == 12) { + dataBlob = {data: stringToUint8Array("my test data")}; + } else { + console.error("GenDataBlob: dataBlobLen is invalid"); + dataBlob = {data: stringToUint8Array("my test data")}; + } + return dataBlob; +} + +// Generate a MAC using promise-based APIs. +function doHmacByPromise(algName) { + var mac; + try { + mac = cryptoFramework.createMac(algName); + } catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); + } + console.error("[Promise]: Mac algName is: " + mac.algName); + var KeyBlob = { + data : stringToUint8Array("12345678abcdefgh") + } + var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + var promiseConvertKey = symKeyGenerator.convertKey(KeyBlob); + promiseConvertKey.then(symKey => { + var promiseMacInit = mac.init(symKey); + return promiseMacInit; + }).then(() => { + var promiseMacUpdate = mac.update(GenDataBlob(12)); + return promiseMacUpdate; + }).then(() => { + var PromiseMacDoFinal = mac.doFinal(); + return PromiseMacDoFinal; + }).then(macOutput => { + console.error("[Promise]: HMAC result: " + macOutput.data); + var macLen = mac.getMacLength(); + console.error("[Promise]: MAC len: " + macLen); + }).catch(error => { + console.error("[Promise]: error: " + error.message); + }); +} + +// Generate a MAC using callback-based APIs. +function doHmacByCallback(algName) { + var mac; + try { + mac = cryptoFramework.createMac(algName); + } catch (error) { + AlertDialog.show({message: "[Callback]: error code: " + error.code + ", message is: " + error.message}); + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); + } + var KeyBlob = { + data : stringToUint8Array("12345678abcdefgh") + } + var symKeyGenerator = cryptoFramework.createSymKeyGenerator("AES128"); + symKeyGenerator.convertKey(KeyBlob, (err, symKey) => { + if (err) { + console.error("[Callback]: err: " + err.code); + } + mac.init(symKey, (err1, ) => { + if (err1) { + console.error("[Callback]: err: " + err1.code); + } + mac.update(GenDataBlob(12), (err2, ) => { + if (err2) { + console.error("[Callback]: err: " + err2.code); + } + mac.doFinal((err3, macOutput) => { + if (err3) { + console.error("[Callback]: err: " + err3.code); + } else { + console.error("[Callback]: HMAC result: " + macOutput.data); + var macLen = mac.getMacLength(); + console.error("[Callback]: MAC len: " + macLen); + } + }); + }); + }); + }); +} +``` + + + +## Generating Random Numbers + +**When to Use** + +Typical random number operations involve the following: + +1. Generate a random number. +2. Set a seed based on the random number generated. + +**Available APIs** + +For details about the APIs, see [Crypto Framework](../reference/apis/js-apis-cryptoFramework.md). + +| Instance | API | Description | +| --------------- | ------------------------------------------------------------ | ---------------------------------------------- | +| cryptoFramework | function createRandom() : Random; | Creates a **Random** instance. | +| Random | generateRandom(len : number, callback: AsyncCallback\) : void; | Generates a random number. This API uses an asynchronous callback to return the result. | +| Random | generateRandom(len : number) : Promise\; | Generates a random number. This API uses a promise to return the result. | +| Random | setSeed(seed : DataBlob, callback : AsyncCallback\) : void; | Sets a seed. This API uses an asynchronous callback to return the result.| +| Random | setSeed(seed : DataBlob) : Promise\; | Sets a seed. This API uses a promise to return the result. | + +**How to Develop** + +1. Call **createRandom()** to create a **Random** instance. +2. Call **generateRandom()** to generate a random number of the given length. +3. Call **setSeed()** to set a seed. + +```javascript +import cryptoFramework from "@ohos.security.cryptoFramework" + +// Generate a random number and set a seed using promise-based APIs. +function doRandByPromise(len) { + var rand; + try { + rand = cryptoFramework.createRandom(); + } catch (error) { + console.error("[Promise]: error code: " + error.code + ", message is: " + error.message); + } + var promiseGenerateRand = rand.generateRandom(len); + promiseGenerateRand.then(randData => { + console.error("[Promise]: rand result: " + randData.data); + var promiseSetSeed = rand.setSeed(randData); + return promiseSetSeed; + }).then(() => { + console.error("[Promise]: setSeed success"); + }).catch(error => { + console.error("[Promise]: error: " + error.message); + }); +} + +// Generate a random number and set a seed using callback-based APIs. +function doRandByCallback(len) { + var rand; + try { + rand = cryptoFramework.createRandom(); + } catch (error) { + console.error("[Callback]: error code: " + error.code + ", message is: " + error.message); + } + rand.generateRandom(len, (err, randData) => { + if (err) { + console.error("[Callback]: err: " + err.code); + } else { + console.error("[Callback]: generate random result: " + randData.data); + rand.setSeed(randData, (err1,) => { + if (err1) { + console.error("[Callback] err: " + err1.code); + } else { + console.error("[Callback]: setSeed success"); + } + }); + } + }); +} +``` diff --git a/en/application-dev/security/cryptoFramework-overview.md b/en/application-dev/security/cryptoFramework-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..afaa9658f3b9bd55754f3d830090ff3eece4e26a --- /dev/null +++ b/en/application-dev/security/cryptoFramework-overview.md @@ -0,0 +1,314 @@ +# Crypto Framework Overview +The crypto framework shields the implementation differences of third-party cryptographic algorithm libraries and implements encryption and decryption, signing and signature verification, message authentication code (MAC), hash, and secure random number. You can use the APIs provided by this framework to implement cipher development quickly. +## Working Principles +The crypto framework provides components in the following layers: + +- Interface layer: provides unified JS interface externally. +- Plugin layer: implements third-party algorithm libraries. +- Framework layer: flexibly loads the plugins in the plugin layer to adapt to third-party algorithm libraries and shields the implement differences between the third-party algorithm libraries. + +## Basic Concepts +### Symmetric Key + +A symmetric key is a key used both to encrypt and decrypt data. In symmetric encryption, the sender converts information in plaintext into ciphertext using a key and certain algorithm for security purposes. The receiver converts the ciphertext into plaintext using the same key and algorithm. + +- AES + + Advanced Encryption Standard (AES) is the most common symmetric encryption algorithm. AES is a block cipher. A block cipher divides plaintext into fixed-length groups of bits, called blocks. A block is encrypted each time until the entire plaintext is encrypted. The block size in AES is 128 bits. That is, each block contains 16 bytes (8 bits/byte). The key length can be 128 bits, 192 bits, or 256 bits. +- 3DES + + Triple Data Encryption Standard (3DES), also called 3DESede or Triple DES, applies the DES cipher three times to each data block. It uses three 64-bit keys to encrypt a data block three times. Compared with DES, 3DES provides higher security due to longer key length, but its processing speed is lower. The AES is faster and more secure than 3DES. + +### Asymmetric Key + +In the asymmetric cryptography, a private and public key pair is required. The private key is used to encrypt the plaintext, and the public key is used to decrypt the ciphertext. The public key is public and open to anyone in the system, while the private key is private. For signing and signature verification, the private key is used to sign the plaintext, and the public key is used to verify the signature data. + +- RSA key + + The security of RSA relies on the factoring problem, that is, the difficulty of factoring the product of two large prime numbers. The keys for the RSA algorithm are generated as follows: + + 1. Generate two large prime numbers **p** and **q**. + + 2. Compute **n** = **p** x **q**. + + **n** is used as the modulus for both the public and private keys, and is released as part of the public key. + + 3. Choose an integer **e** such that 1 < **e** < (**p** - 1) x (**q** - 1), that is, **e** and (**p** - 1) x (**q** - 1) are coprime. + + 4. Compute **d**. + + **e** x **d** - 1 is a multiple of (**p** - 1) and (**q** - 1). + + The public key consists of the modulus **n** and the public exponent **e**. The private key consists of **n** and the private exponent **d**. + + In addition to the default RSA key generation from two primes, the crypto framework provides key generation from multiple primes. You can set the **primes** parameter (PRIMES_2, PRIMES_3, PRIMES_4, PRIMES_5) to specify the number of primes during key generation. The keys generated from multiple primes help reduce the computation workload in decryption and signing (Chinese remainder theorem). However, such keys are weak. The algorithm library defines specifications based on the rules for using OpenSSL prime numbers. For details, see **Constraints**. + +- ECC key + + Elliptic-Curve Cryptography (ECC) is a public-key encryption based on the algebraic structure of elliptic curve over finite fields. The crypto framework provides a variety of ECC key generation capabilities. + +### Encryption and Decryption + +- Symmetric AES encryption and decryption + + The algorithm library provides the following cipher modes of operation for AES: ECB, CBC, OFB, CFB, CTR, GCM, and CCM. + + AES is a block cipher, with a fixed block size of 128 bits. In actual applications, the last block of plaintext may be less than 128 bits and needs to be padded. The padding options are as follows: + + - **NoPadding**: no padding. + + - **PKCS5**: pads a block cipher with a block size of 8 bytes. + - **PKCS7**: The PKCS #7 padding scheme is the same as that of PKCS #5 padding except that PKCS #5 padding is defined for 8-byte block sizes, while PKCS #5 padding works for any block size from 1 to 255 bytes. + + > **NOTE** + > + > In ECB and CBC modes, the plaintext length is not an integer multiple of 128 bits and must be padded. + +- Symmetric 3DES encryption and decryption + + 3DES encryption and decryption apply the DES cipher three times to each data block obtain the ciphertext or plaintext. + + The algorithm library provides the following cipher modes of operation for 3DES encryption and decryption: ECB, CBC, OFB, and CFB. + + DES is a block cipher, with a fixed block size of 64 bits. In actual applications, the last block of plaintext may be less than 64 bits and needs to be padded. The padding options are as follows: + + - **NoPadding**: no padding. + - **PKCS5**: pads a block cipher with a block size of 8 bytes. + - **PKCS7**: The PKCS #7 padding scheme is the same as that of PKCS #5 padding except that PKCS #5 padding is defined for 8-byte block sizes, while PKCS #5 padding works for any block size from 1 to 255 bytes. + + > **NOTE** + > + > In ECB and CBC, the plaintext length is not an integer multiple of 64 bits and must be padded. + +- Asymmetric RSA encryption and decryption + + After the RSA public key (n, e) and private key (n, d) are held, the RSA encryption process is as follows: + + Ciphertext = Plaintext ^ **e** mod **n** + + The decryption process is as follows: + + Plaintext = Ciphertext ^ **d** mod **n** + + The algorithm library provides the following modes of operation for RSA encryption and decryption: **PKCS1**, **PKCS1_ OAEP**, and **NoPadding**. + + RSA is a block cipher, with fixed-length blocks. In actual applications, diverse padding modes are used. The padding options are as follows: + + - **NoPadding**: No padding is required. The length of the input or output data must be the same as that of the RSA key modulus. + + - **PKCS1**: PKCS #1 v1.5 is the default padding mode for RSA encryption and decryption. The length of the input data must be less than or equal to the RSA key modulus minus 11, and the length of the output data must be the same as that of the RSA key modulus. + + - **PKCS1_OAEP**: The RSA_PKCS1_OAEP_PADDING is a new padding mode provided by PKCS #1. In this mode, two digests (**md** and **mgf1_md**) must be set. The length of the input data must be less than RSA key modulus length minus **md** length, **mgf1_md** length, and two. The length of the output data must be the same as that of the RSA key modulus. + + **NOTE** + + Length of the RSA key modulus = (Number of RSA bits + 7)/8 + +### Signing and Signature Verification + +- RSA signing and signature verification + + After the RSA public key (n, e) and private key (n, d) are held, the RSA signature is generated as follows: + + Signature = Message ^ **d** mod **n** + + The signature verification process is as follows: + + Message = Signature ^ **d** mod **n** + + The sender sends the message and the signature signed by the private key. The receiver decrypts the signature using the public key to verify the signature. Generally, the message sent is longer than the RSA key modulus. Therefore, the crypto framework provides two padding modes to extract the hash value of the message digest and then sign the message. The crypto framework provides the following padding modes for signing and signature verification: + + - **PKCS1**: PKCS #1 v1.5 is the default padding mode for RSA encryption and decryption. When this mode is used, the digest (**md**) must be set. + - **PSS**: The PSS mode is a padding algorithm based on the RSA algorithm. When it is used, the digest (**md**) and mask function (**mgf1_md**) are required. + +- ECDSA + + The Elliptic Curve Digital Signature Algorithm (ECDSA) is a Digital Signature Algorithm (DSA) that uses the ECC. Compared with the ordinary Discrete Logarithm Problem (DLP) and Integer Factorization Problem (IFP), the unit bit strength of ECC is higher than that of other public-key cryptographic systems. The crypto framework provides the ECDSA that combines multiple elliptic curve and digest algorithms. + +### Key Agreement + +**ECDH** + +Elliptic Curve Diffie-Hellman (ECDH) allows two parties to establish a shared secret over an insecure channel. The crypto framework provides a variety of ECDH capabilities based on the open-source algorithm library. + +### Digest + +The message digest algorithm allows a fixed-length digest to be generated from data of arbitrary size by using the hash algorithm. The message digest algorithm is used for sensitive information encryption because it is infeasible to invert or reverse the computation. The MD algorithm is also referred to as a hash algorithm or a one-way hash algorithm. +When the same digest algorithm is used, the generated digest (hash value) has the following features: + +- The same message always results in the same hash value. +- The digest generated is of the fixed length no matter the length of messages. (The digest length is determined by the algorithm used). +- It is almost impossible to find two different messages with the same hash value (the probability still exists, depending on the length of the digest). + +There are three types of message digest algorithms: MD, SHA, and MAC. For details, see section "**HMAC**". +MD algorithms include MD2, MD4, and MD5. +Major SHA algorithms include SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512. + +### HMAC + +Hash-based Message Authentication Code (HMAC) is a key-based message authentication code algorithm. HMAC provides authentication using a shared secret instead of using a digital signature. The MAC generated can be used to verify both the integrity and authenticity of the message. The length of the MAC generated by HMAC is fixed. + +### Random Number + +Random numbers are mainly used to generate temporary session keys or keys in asymmetric encryption. Random numbers can be generated by a hardware random number generator or software-based pseudo-random number generator. In encryption and decryption, a secure random number generator must feature randomness, repeatability, and unpredictability. The random numbers generated by the Cryptography Secure Random Number Generator (CSPRNG) meet the requirements of cryptography security pseudo-randomness. + +- Internal state + + A value in the random number generator memory. The same internal state produces the same sequence of the random number. + +- Seed + + A number used to initialize the internal state of a pseudorandom number generator. The random number generator generates a series of random sequences based on the seeds. + + +## Constraints + +- The crypto framework does not support concurrent operations of multiple threads. + +### Key Generation Specifications + +**Symmetric Key Generation Specifications** + +The following parameters are supported: + +|Symmetric Key Algorithm|Key Length|String for Generating a Key| +|---|---|---| +|3DES|192|3DES192| +|AES|128|AES128| +|AES|192|AES192| +|AES|256|AES256| + +**Asymmetric Key Generation Specifications** +- **RSA key generation** + + The following parameters are supported: + + |Asymmetric Key Algorithm|Key Length|Number of Primes|String for Generating a Key| + |---|---|---|---| + |RSA|512|2|RSA512\|PRIMES_2| + |RSA|768|2|RSA768\|PRIMES_2| + |RSA|1024|2|RSA1024\|PRIMES_2| + |RSA|1024|3|RSA1024\|PRIMES_3| + |RSA|2048|2|RSA2048\|PRIMES_2| + |RSA|2048|3|RSA2048\|PRIMES_3| + |RSA|3072|2|RSA3072\|PRIMES_2| + |RSA|3072|3|RSA3072\|PRIMES_3| + |RSA|4096|2|RSA4096\|PRIMES_2| + |RSA|4096|3|RSA4096\|PRIMES_3| + |RSA|4096|4|RSA4096\|PRIMES_4| + |RSA|8192|2|RSA8192\|PRIMES_2| + |RSA|8192|3|RSA8192\|PRIMES_3| + |RSA|8192|4|RSA8192\|PRIMES_4| + |RSA|8192|5|RSA8192\|PRIMES_5| + + > **NOTE** + > + > When the RSA asymmetric key is generated, the default number of primes is 2 and the **PRIMES_2** parameter can be omitted. + +- **ECC key generation** + + The following parameters are supported: + + |Asymmetric Key Algorithm|Key Length| + |---|---| + |ECC|ECC224| + |ECC|ECC256| + |ECC|ECC384| + |ECC|ECC512| + +### Encryption and Decryption Specifications + +**Symmetric Encryption and Decryption** + +The following symmetric encryption algorithms are supported: + +|Algorithm|Block Cipher Mode|Algorithm String| +|---|---|---| +|3DES|ECB|3DES192\|ECB\|[NoPadding\|PKCS5\|PKCS7]| +|3DES|CBC|3DES192\|CBC\|[NoPadding\|PKCS5\|PKCS7]| +|3DES|OFB|3DES192\|OFB\|[NoPadding\|PKCS5\|PKCS7]| +|3DES|CFB|3DES192\|CFB\|[NoPadding\|PKCS5\|PKCS7]| +|AES|ECB|AES[128\|192\|256]\|ECB\|[NoPadding\|PKCS5\|PKCS7]| +|AES|CBC|AES[128\|192\|256]\|CBC\|[NoPadding\|PKCS5\|PKCS7]| +|AES|CTR|AES[128\|192\|256]\|CTR\|[NoPadding\|PKCS5\|PKCS7]| +|AES|OFB|AES[128\|192\|256]\|OFB\|[NoPadding\|PKCS5\|PKCS7]| +|AES|CFB|AES[128\|192\|256]\|CFB\|[NoPadding\|PKCS5\|PKCS7]| +|AES|GCM|AES[128\|192\|256]\|GCM\|[NoPadding\|PKCS5\|PKCS7]| +|AES|CCM|AES[128\|192\|256]\|CCM\|[NoPadding\|PKCS5\|PKCS7]| + +> **NOTE** +> +> The options included in the square brackets ([]) are mutually exclusive. + +**Asymmetric RSA Encryption and Decryption** + +The following padding modes are involved in RSA encryption and decryption: **NoPadding**, **PKCS1**, and **PKCS1_OAEP**. +- When **NoPadding** is used, you can specify the following parameters: + + [RSA512|RSA768|RSA1024|RSA2048|RSA3072|RSA4096|RSA8192]|NoPadding + +- When **PKCS1** is used, you can specify the following parameters: + + [RSA512|RSA768|RSA1024|RSA2048|RSA3072|RSA4096|RSA8192]|PKCS1 + +- When **PKCS1_OAEP** is used, you can specify the following parameters: + + [RSA512|RSA768|RSA1024|RSA2048|RSA3072|RSA4096|RSA8192]|PKCS1_OAEP|[MD5|SHA1|SHA224|SHA256|SHA384|SHA512]|[MGF1_MD5|MGF1_SHA1|MGF1_SHA224|MGF1_SHA256|MGF1_SHA384|MGF1_SHA512] + +> **NOTE** +> +> The options included in the square brackets ([]) are mutually exclusive. The options outside the square brackets are fixed values. + +### Signing and Signature Verification Specifications + +**RSA Signing and Signature Verification** + +The following padding modes are involved in RSA encryption and decryption: **PKCS1** and **PSS**. +- When **PKCS1** is used, you can specify the following parameters: + + [RSA512|RSA768|RSA1024|RSA2048|RSA3072|RSA4096|RSA8192]|PKCS1|[MD5|SHA1|SHA224|SHA256|SHA384|SHA512] + +- When **PSS** is used, you can specify the following parameters: + + [RSA512|RSA768|RSA1024|RSA2048|RSA3072|RSA4096|RSA8192]|PSS|[MD5|SHA1|SHA224|SHA256|SHA384|SHA512]|[MGF1_MD5|MGF1_SHA1|MGF1_SHA224|MGF1_SHA256|MGF1_SHA384|MGF1_SHA512] +> **NOTE** +> +> The options included in the square brackets ([]) are mutually exclusive. The options outside the square brackets are fixed values. + +**ECDSA Signing and Signature Verification** + +The following ECDSA parameters are supported: + +|Asymmetric Key Algorithm|Supported Types| +|---|---| +|ECC|ECC224| +|ECC|ECC256| +|ECC|ECC384| +|ECC|ECC512| + +|Digest Algorithm|Supported Types| +|---|---| +|HASH|SHA-1| +|HASH|SHA-224| +|HASH|SHA-256| +|HASH|SHA-384| +|HASH|SHA-512| + +### Key Agreement Specifications + +**ECDH** + + The following ECDH parameters are supported: + +|Asymmetric Key Algorithm|Supported Types| +|---|---| +|ECC|ECC224| +|ECC|ECC256| +|ECC|ECC384| +|ECC|ECC512| + +### MD Algorithm Specifications +The crypto framework supports only MD5. + +### SHA Algorithm Specifications +The crypto framework supports only SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512. diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 8116d311b340c020f1ac5c07e6aa0269fa690a2d..9f4a69cf61b3e6967575bdfd8e60660b8481af19 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -4,10 +4,9 @@ - Getting Started - [Preparations](quick-start/start-overview.md) - - [Getting Started with eTS in Stage Model](quick-start/start-with-ets-stage.md) - - [Getting Started with eTS in FA Model](quick-start/start-with-ets-fa.md) + - [Getting Started with ArkTS in Stage Model](quick-start/start-with-ets-stage.md) + - [Getting Started with ArkTS in FA Model](quick-start/start-with-ets-fa.md) - [Getting Started with JavaScript in FA Model](quick-start/start-with-js-fa.md) - - Development Fundamentals - [Application Package Structure Configuration File (FA Model)](quick-start/package-structure.md) - [Application Package Structure Configuration File (Stage Model)](quick-start/stage-structure.md) @@ -176,6 +175,7 @@ - Access Control - [Access Control Overview](security/accesstoken-overview.md) - [Access Control Development](security/accesstoken-guidelines.md) + - [Permission Verification Guide](security/permission-verify-guidelines.md) - [Permission List](security/permission-list.md) - User Authentication - [User Authentication Overview](security/userauth-overview.md) @@ -265,6 +265,7 @@ - [Drawing Development](napi/drawing-guidelines.md) - [Raw File Development](napi/rawfile-guidelines.md) - [Native Window Development](napi/native-window-guidelines.md) + - [Using MindSpore Lite for Model Inference](napi/mindspore-lite-guidelines.md) - Tools - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials @@ -579,6 +580,7 @@ - [@ohos.application.formInfo](reference/apis/js-apis-formInfo.md) - [@ohos.application.formProvider](reference/apis/js-apis-formprovider.md) - [@ohos.application.missionManager](reference/apis/js-apis-missionManager.md) + - [@ohos.application.quickFixManager](reference/apis/js-apis-application-quickFixManager.md) - [@ohos.application.Want](reference/apis/js-apis-application-Want.md) - [@ohos.continuation.continuationManager](reference/apis/js-apis-continuation-continuationExtraParams.md) - [@ohos.continuation.continuationManager](reference/apis/js-apis-continuation-continuationManager.md) @@ -610,6 +612,7 @@ - [ApplicationInfo](reference/apis/js-apis-bundle-ApplicationInfo.md) - [BundleInfo](reference/apis/js-apis-bundle-BundleInfo.md) - [BundleInstaller](reference/apis/js-apis-bundle-BundleInstaller.md) + - [BundleStatusCallback](reference/apis/js-apis-Bundle-BundleStatusCallback.md) - [CustomizeData](reference/apis/js-apis-bundle-CustomizeData.md) - [DispatchInfo](reference/apis/js-apis-dispatchInfo.md) - [ElementName](reference/apis/js-apis-bundle-ElementName.md) @@ -618,6 +621,7 @@ - [LauncherAbilityInfo](reference/apis/js-apis-bundle-LauncherAbilityInfo.md) - [Metadata](reference/apis/js-apis-bundle-Metadata.md) - [ModuleInfo](reference/apis/js-apis-bundle-ModuleInfo.md) + - [PackInfo](reference/apis/js-apis-bundle-PackInfo.md) - [PermissionDef](reference/apis/js-apis-bundle-PermissionDef.md) - [RemoteAbilityInfo](reference/apis/js-apis-bundle-remoteAbilityInfo.md) - [ShortcutInfo](reference/apis/js-apis-bundle-ShortcutInfo.md) @@ -631,6 +635,7 @@ - [@ohos.animation.windowAnimationManager](reference/apis/js-apis-windowAnimationManager.md) - [@ohos.display](reference/apis/js-apis-display.md) - [@ohos.effectKit](reference/apis/js-apis-effectKit.md) + - [@ohos.graphics.colorSpaceManager](reference/apis/js-apis-colorSpaceManager.md) - [@ohos.screen](reference/apis/js-apis-screen.md) - [@ohos.screenshot](reference/apis/js-apis-screenshot.md) - [@ohos.window](reference/apis/js-apis-window.md) @@ -677,6 +682,7 @@ - [@ohos.document](reference/apis/js-apis-document.md) - [@ohos.environment](reference/apis/js-apis-environment.md) - [@ohos.fileio](reference/apis/js-apis-fileio.md) + - [@ohos.filemanagement.userfile_manager](reference/apis/js-apis-userfilemanager.md) - [@ohos.multimedia.medialibrary](reference/apis/js-apis-medialibrary.md) - [@ohos.securityLabel](reference/apis/js-apis-securityLabel.md) - [@ohos.statfs](reference/apis/js-apis-statfs.md) @@ -692,8 +698,13 @@ - [@ohos.telephony.sms](reference/apis/js-apis-sms.md) - Network Management - [@ohos.net.connection](reference/apis/js-apis-net-connection.md) + - [@ohos.net.ethernet](reference/apis/js-apis-net-ethernet.md) - [@ohos.net.http](reference/apis/js-apis-http.md) + - [@ohos.net.policy](reference/apis/js-apis-net-policy.md) + - [@ohos.net.sharing](reference/apis/js-apis-net-sharing.md) - [@ohos.net.socket](reference/apis/js-apis-socket.md) + - [@ohos.net.statistics](reference/apis/js-apis-net-statistics.md) + - [@ohos.net.tlsSocket](reference/apis/js-apis-tlsSocket.md) - [@ohos.net.webSocket](reference/apis/js-apis-webSocket.md) - [@ohos.request](reference/apis/js-apis-request.md) - Connectivity @@ -819,7 +830,7 @@ - [Guide to Switching to Full SDK](quick-start/full-sdk-switch-guide.md) - [Ability Framework Development](faqs/faqs-ability.md) - [ArkUI (JavaScript) Development](faqs/faqs-ui-js.md) - - [ArkUI (eTS) Development](faqs/faqs-ui-ets.md) + - [ArkUI (ArkTS) Development](faqs/faqs-ui-ets.md) - [Graphics and Image Development](faqs/faqs-graphics.md) - [File Management Development](faqs/faqs-file-management.md) - [Network and Connection Development](faqs/faqs-connectivity.md) diff --git a/en/device-dev/driver/driver-peripherals-external-des.md b/en/device-dev/driver/driver-peripherals-external-des.md index 8c17105189ef7fef5ad99f01fa8222ea95570b80..efaf1d14e916222840d56537b48e2e19b83fb844 100644 --- a/en/device-dev/driver/driver-peripherals-external-des.md +++ b/en/device-dev/driver/driver-peripherals-external-des.md @@ -5,7 +5,7 @@ ### WLAN -The Wireless Local Area Network (WLAN) Driver module in OpenHarmony is developed based on the Hardware Driver Foundation (HDF). It features cross-OS porting, self-adaptation to component differences, and modular assembly and build. +The Wireless Local Area Network (WLAN) Driver module in OpenHarmony is developed based on the Hardware Driver Foundation (HDF). It provides cross-OS porting, self-adaptation to component differences, and module assembly and building. ### Working Principles @@ -44,7 +44,7 @@ The WLAN driver consists of the following modules: 8. NetBuf: encapsulates the unified data structure of the Linux or LiteOS native network data buffer and the operation interfaces for network data. -9. FlowCtl: performs flow control. +9. FlowCtl: processes data based on the priority when the data volume is too large. 10. HCC-CFG: configures WLAN parameters, including the board configuration, driver configuration, and module configuration. @@ -74,20 +74,10 @@ The WLAN module provides the following types of APIs: ![image](figures/WLAN_driver_APIs.png "WLAN Driver APIs") -- The WLAN module provides HDI APIs for upper-layer services (applicable to the standard system). **Table 1** describes the major APIs. - - **Table 1** IWlanInterface.idl - - | API| Description| - | -------- | -------- | - | CreateFeature([in] int type, [out] struct HdfFeatureInfo ifeature);| Creates an **ifeature** instance.| - | DestroyFeature([in] struct HdfFeatureInfo ifeature);| Destroys an **ifeature** instance.| - | GetPowerMode([in] struct HdfFeatureInfo ifeature, [out] unsigned char mode);| Obtains the power mode.| - | SetPowerMode([in] struct HdfFeatureInfo ifeature, [in] unsigned char mode);| Sets the power mode.| - The WLAN module provides HAL APIs for upper-layer services (applicable to small and mini systems). **Table 2** and **Table 3** describe some APIs. - **Table 2** wifi_hal.h + **Table 1** wifi_hal.h | API| Description| | -------- | -------- | @@ -96,7 +86,7 @@ The WLAN module provides the following types of APIs: | int32_t (\*start)(struct IWiFi \*)| Creates a channel between the HAL and the driver and obtains the NICs supported by the driver.| | int32_t (\*stop)(struct IWiFi \*)| Stops the channel between the HAL and the driver.| - **Table 3** wifi_hal_base_feature.h + **Table 2** wifi_hal_base_feature.h | API| Description| | -------- | -------- | @@ -107,387 +97,370 @@ The WLAN module provides the following types of APIs: - The WLAN Driver module also provides APIs that you need to fill in the implementation. **Table 4** describes some APIs. - **Table 4** net_device.h + **Table 3** net_device.h | API| Description| | -------- | -------- | - | int32_t (\*init)(struct NetDevice \*netDev) | Initializes a network device.| - | struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev) | Obtains the state of a network device.| - | int32_t (\*setMacAddr)(struct NetDevice \*netDev, void \*addr) | Sets the MAC address.| - | void (\*deInit)(struct NetDevice \*netDev) | Deinitializes a network device.| - | int32_t (\*open)(struct NetDevice \*netDev) | Opens a network device.| - | int32_t (\*stop)(struct NetDevice \*netDev) | Stops a network device.| + | int32_t (\*init)(struct NetDevice \*netDev)| Initializes a network device.| + | struct NetDevStats \*(\*getStats)(struct NetDevice \*netDev)| Obtains the state of a network device.| + | int32_t (\*setMacAddr)(struct NetDevice \*netDev, void \*addr)| Sets the MAC address.| + | void (\*deInit)(struct NetDevice \*netDev)| Deinitializes a network device.| + | int32_t (\*open)(struct NetDevice \*netDev)| Opens a network device.| + | int32_t (\*stop)(struct NetDevice \*netDev)| Stops a network device.| - The WLAN Driver module provides APIs that you can directly use to create or release a **WifiModule**, connect to or disconnect from a WLAN hotspot, request or release a **NetBuf**, and convert between the **pbuf** structure of Lightweight IP (lwIP) and a **NetBuf**. Tables 5 to 7 describe the APIs. - **Table 5** wifi_module.h + **Table 4** wifi_module.h | API| Description| | -------- | -------- | - | struct WifiModule \*WifiModuleCreate(const struct HdfConfigWifiModuleConfig \*config) | Creates a **WifiModule**.| - | void WifiModuleDelete(struct WifiModule \*module) | Deletes a **WifiModule** and releases its data.| - | int32_t DelFeature(struct WifiModule \*module, uint16_t featureType) | Deletes a feature from a **WifiModule**.| - | int32_t AddFeature(struct WifiModule \*module, uint16_t featureType, struct WifiFeature \*featureData) | Adds a feature to a **WifiModule**.| + | struct WifiModule \*WifiModuleCreate(const struct HdfConfigWifiModuleConfig \*config)| Creates a **WifiModule**.| + | void WifiModuleDelete(struct WifiModule \*module)| Deletes a **WifiModule** and releases its data.| + | int32_t DelFeature(struct WifiModule \*module, uint16_t featureType)| Deletes a feature from a **WifiModule**.| + | int32_t AddFeature(struct WifiModule \*module, uint16_t featureType, struct WifiFeature \*featureData)| Adds a feature to a **WifiModule**.| - **Table 6** wifi_mac80211_ops.h + **Table 5** wifi_mac80211_ops.h | API| Description| | -------- | -------- | - | int32_t (\*startAp)(NetDevice \*netDev) | Starts an AP.| - | int32_t (\*stopAp)(NetDevice \*netDev) | Stops an AP.| - | int32_t (\*connect)(NetDevice \*netDev, WifiConnectParams \*param) | Connects to a hotspot.| - | int32_t (\*disconnect)(NetDevice \*netDev, uint16_t reasonCode) | Disconnects from a hotspot.| + | int32_t (\*startAp)(NetDevice \*netDev)| Starts an AP.| + | int32_t (\*stopAp)(NetDevice \*netDev)| Stops an AP.| + | int32_t (\*connect)(NetDevice \*netDev, WifiConnectParams \*param)| Connects to a hotspot.| + | int32_t (\*disconnect)(NetDevice \*netDev, uint16_t reasonCode)| Disconnects from a hotspot.| - **Table 7** hdf_netbuf.h + **Table 6** hdf_netbuf.h | API| Description| | -------- | -------- | - | static inline void NetBufQueueInit(struct NetBufQueue \*q) | Initializes a **NetBuf** queue.| - | struct NetBuf \*NetBufAlloc(uint32_t size) | Allocates a **NetBuf**.| + | static inline void NetBufQueueInit(struct NetBufQueue \*q)| Initializes a **NetBuf** queue.| + | struct NetBuf \*NetBufAlloc(uint32_t size)| Allocates a **NetBuf**.| | void NetBufFree(struct NetBuf \*nb) | Releases a **NetBuf**.| - | struct NetBuf \*Pbuf2NetBuf(const struct NetDevice \*netdev, struct pbuf \*lwipBuf) | Converts the **pbuf** structure of lwIP to a **NetBuf**.| - | struct pbuf \*NetBuf2Pbuf(const struct NetBuf \*nb) | Converts a **NetBuf** to the **pbuf** structure of lwIP.| + | struct NetBuf \*Pbuf2NetBuf(const struct NetDevice \*netdev, struct pbuf \*lwipBuf)| Converts the **pbuf** structure of lwIP to a **NetBuf**.| + | struct pbuf \*NetBuf2Pbuf(const struct NetBuf \*nb)| Converts a **NetBuf** to the **pbuf** structure of lwIP.| ### How to Develop +#### WLAN Framework Adaptation -The WLAN driver module developed based on the HDF and Platform frameworks provides a unified driver model for WLAN modules of different vendors regardless of the OS and system on a chip (SoC). +The WLAN driver framework developed based on the HDF and Platform framework provides a unified driver model regardless of the OS and system on a chip (SoC). When developing your WLAN driver, you need to configure data based on the WLAN driver framework. +**Development Procedure** - 1. Configure hardware (such as modules and chips) parameters in the **wlan_platform.hcs** file. This file can be parsed by the APIs in the HDF to generate structure objects with full configuration. +1. Configure hardware (such as modules and chips) parameters in the **wlan_platform.hcs** file. The HDF parses the file to generate structure objects with full configuration. - 2. Implement initialization and deinitialization of the WLAN module (such as initialize and deinitialize the WLAN chip and WLAN chip driver). +2. Implement initialization and deinitialization of the WLAN module (such as initialize and deinitialize the WLAN chip and WLAN chip driver). - 3. Implement the delivery of control flow commands. +3. Implement the delivery of control flow commands. - 4. Implement event reporting. +4. Implement event reporting. -### Development Example +**Development Example** The following uses the Hi3881 WLAN chip as an example to describe how to initialize a WLAN module. -1. Configure hardware parameters. - - ```text - /* Configure parameters in wlan_platform.hcs based on the hardware you use. The following is an example of WLAN platform configuration. */ - hisi :& deviceList { - device0 :: deviceInst { - deviceInstId = 0; - powers { - power0 { - powerSeqDelay = 0; /* Power sequence delay. */ - powerType = 1; /* Power supply type. The value 0 indicates that the device is always on. The value 1 indicates power supply through GPIO. */ - gpioId = 1; /* GPIO pin number. */ - activeLevel=1; /* Active level. The value 0 indicates low level, and 1 indicates high level. */ +1. Configure the HDF configuration source (HCS) for the driver. + + The HCS includes device configuration and component configuration. + + - Device configuration + + The configuration file contains the power supply, reset, and bus configuration. + + Configuration file path: **vendor///hdf_config/khdf/wifi** + + Configure device parameters in **wlan_platform.hcs** based on the device you use. The following is an example of WLAN platform configuration. + ```text + hisi :& deviceList { + device0 :: deviceInst { + deviceInstId = 0; + powers { + power0 { + powerSeqDelay = 0; /* Power sequence delay. */ + powerType = 1; /* Power supply type. The value 0 indicates that the device is always on. The value 1 indicates power supply through GPIO. */ + gpioId = 1; /* GPIO pin number. */ + activeLevel=1; /* Active level. The value 0 indicates low level, and 1 indicates high level. */ + } + power1 { + powerSeqDelay = 0; /* Power sequence delay. */ + powerType = 0; /* Power supply type. The value 0 indicates that the device is always on. The value 1 indicates power supply through GPIO. */ + } } - power1 { - powerSeqDelay = 0; /* Power sequence delay. */ - powerType = 0; /* Power supply type. The value 0 indicates that the device is always on. The value 1 indicates power supply through GPIO. */ + reset { + resetType = 0; /* Reset type. The value 0 indicates that reset is dynamically determined, and 1 indicates reset through GPIO. */ + gpioId = 2; /* GPIO pin number. */ + activeLevel=1; /* Active level. The value 0 indicates low level, and 1 indicates high level. */ + resetHoldTime = 30; /* Hold time (ms) after a reset. */ + } + bootUpTimeout = 30; /* Boot timeout duration (ms). */ + bus { + busEnable = 1; /* Whether to initialize the bus. The value 1 means to initialize the bus; the value 0 means the opposite. */ + busType = 0; /* Bus type. The value 0 indicates SDIO. */ + busId = 2; /* Bus number. */ + funcNum = [1]; /* SDIO function number. */ + timeout = 1000; /* Timeout duration for data read/write. */ + blockSize = 512; /* Size of the data block to read or write. */ } - } - reset { - resetType = 0; /* Reset type. The value 0 indicates that reset is dynamically determined, and 1 indicates reset through GPIO. */ - gpioId = 2; /* GPIO pin number. */ - activeLevel=1; /* Active level. The value 0 indicates low level, and 1 indicates high level. */ - resetHoldTime = 30; /* Hold time (ms) after a reset. */ - } - bootUpTimeout = 30; /* Boot timeout duration (ms). */ - bus { - busEnable = 1; /* Whether to initialize the bus. The value 1 means to initialize the bus; the value 0 means the opposite. */ - busType = 0; /* Bus type. The value 0 indicates SDIO. */ - busId = 2; /* Bus number. */ - funcNum = [1]; /* SDIO function number. */ - timeout = 1000; /* Timeout duration for data read/write. */ - blockSize = 512; /* Size of the data block to read or write. */ } } - } - /* Add the configuration file wlan_chip_.hcs (for example, wlan_chip_hi3881.hcs) for each chip and set parameters. The following uses the Hi3881 chip as an example. */ - root { - wlan_config { - hi3881 :& chipList { - chipHi3881 :: chipInst { - match_attr = "hdf_wlan_chips_hi3881"; /* Attribute used to match the chip. */ - chipName = "hi3881"; /* WLAN chip name. */ - bus { - vendorId = 0x0296; /* Vendor ID. */ - deviceId = [0x5347]; /* Device ID. */ + ``` + - Component configuration + + Add a configuration file **wlan_chip_.hcs** for each chip, for example, **wlan_chip_hi3881.hcs**, and configure related parameters. The following is a configuration example of hi3881. + ```text + root { + wlan_config { + hi3881 :& chipList { + chipHi3881 :: chipInst { + match_attr = "hdf_wlan_chips_hi3881"; /* Attribute used to match the chip. */ + chipName = "hi3881"; /* WLAN chip name. */ + bus { + vendorId = 0x0296; /* Vendor ID. */ + deviceId = [0x5347]; /* Device ID. */ + } } } } } - } - ``` + ``` 2. Hook the **init** and **deinit** functions of the WLAN chip and WLAN chip driver. + - Implementing the driver adaptation entry function - ```c - #include "hdf_device_desc.h" - #include "hdf_wifi_product.h" - #include "hdf_log.h" - #include "osal_mem.h" - #include "hdf_wlan_chipdriver_manager.h" - #include "securec.h" - #include "wifi_module.h" - #include "hi_wifi_api.h" - #include "hi_types_base.h" - - #define HDF_LOG_TAG Hi3881Driver - - /* Functions for initializing and deinitializing a WLAN chip. */ - int32_t InitHi3881Chip(struct HdfWlanDevice *device); - int32_t DeinitHi3881Chip(struct HdfWlanDevice *device); - /* Functions for initializing and deinitializing a WLAN chip driver. */ - int32_t Hi3881Deinit(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice); - int32_t Hi3881Init(struct HdfChipDriver* chipDriver, struct NetDevice *netDevice); - - /* Initialize mac80211 by hooking the functions of the chip. */ - hi_void HiMac80211Init(struct HdfChipDriver *chipDriver); - - static const char* const HI3881_DRIVER_NAME = "hisi"; - - /* Hook the functions of the WLAN chip driver, mac80211, and chip. */ - static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex) - { - struct HdfChipDriver *specificDriver = NULL; - if (device == NULL) { - HDF_LOGE("%s fail: channel is NULL!", __func__); - return NULL; - } - (void)ifIndex; - specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver)); - if (specificDriver == NULL) { - HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__); - return NULL; - } - if (memset_s(specificDriver, sizeof(struct HdfChipDriver), 0, sizeof(struct HdfChipDriver)) != EOK) { - HDF_LOGE("%s fail: memset_s fail!", __func__); - OsalMemFree(specificDriver); - return NULL; - } - - if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) { - HDF_LOGE("%s fail: strcpy_s fail!", __func__); - OsalMemFree(specificDriver); - return NULL; - } - specificDriver->init = Hi3881Init; - specificDriver->deinit = Hi3881Deinit; - - HiMac80211Init(specificDriver); - - return specificDriver; - } - - /* Release the WLAN chip driver. */ - static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver) - { - if (chipDriver == NULL) { - return; - } - if (strcmp(chipDriver->name, HI3881_DRIVER_NAME) != 0) { - HDF_LOGE("%s:Not my driver!", __func__); - return; - } - OsalMemFree(chipDriver); - } - - static uint8_t GetHi3881GetMaxIFCount(struct HdfChipDriverFactory *factory) { - (void)factory; - return 1; - } - - /* Register WLAN chip functions. */ - static int32_t HDFWlanRegHisiDriverFactory(void) - { - static struct HdfChipDriverFactory tmpFactory = { 0 }; - struct HdfChipDriverManager *driverMgr = NULL; - driverMgr = HdfWlanGetChipDriverMgr(); - if (driverMgr == NULL) { - HDF_LOGE("%s fail: driverMgr is NULL!", __func__); - return HDF_FAILURE; - } - tmpFactory.driverName = HI3881_DRIVER_NAME; - tmpFactory.GetMaxIFCount = GetHi3881GetMaxIFCount; - tmpFactory.InitChip = InitHi3881Chip; - tmpFactory.DeinitChip = DeinitHi3881Chip; - tmpFactory.Build = BuildHi3881Driver; - tmpFactory.Release = ReleaseHi3881Driver; - tmpFactory.ReleaseFactory = NULL; - if (driverMgr->RegChipDriver(&tmpFactory) != HDF_SUCCESS) { - HDF_LOGE("%s fail: driverMgr is NULL!", __func__); - return HDF_FAILURE; - } - - return HDF_SUCCESS; - } - - static int32_t HdfWlanHisiChipDriverInit(struct HdfDeviceObject *device) - { - (void)device; - return HDFWlanRegHisiDriverFactory(); - } - - struct HdfDriverEntry g_hdfHisiChipEntry = { + Define a variable of the HdfDriverEntry type based on the chip to hook functions of **Bind()**, **Init()**, and **Release()**. Call **HDF_INIT** to register the driver entry with the HDF. During driver loading, the HDF calls the **Bind** function and then the **Init** function to load the driver. If **Init()** fails to be called, the HDF calls **Release()** to release driver resources. + ```c + struct HdfDriverEntry g_hdfHisiChipEntry = { .moduleVersion = 1, .Bind = HdfWlanHisiDriverBind, .Init = HdfWlanHisiChipDriverInit, .Release = HdfWlanHisiChipRelease, .moduleName = "HDF_WLAN_CHIPS" - }; - - HDF_INIT(g_hdfHisiChipEntry); - ``` - - For details about initialization of the chip and chip driver, see hdfinit_3881.c. The functions are as follows: - - ```c - #include "hdf_wifi_product.h" - #include "hi_wifi_api.h" - #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) - #include "oal_thread.h" - #include "osal_time.h" - #endif - #include "wifi_mac80211_ops.h" - #include "wal_cfg80211.h" - #include "net_adapter.h" - #include "hdf_wlan_utils.h" - - #define HDF_LOG_TAG Hi3881Driver - - /* Initialize the WLAN chip. */ - int32_t InitHi3881Chip(struct HdfWlanDevice *device) - { - uint8_t maxPortCount = 3; - int32_t ret = HI_SUCCESS; - uint8_t maxRetryCount = 3; - if (device == NULL || device->bus == NULL) { - HDF_LOGE("%s:NULL ptr!", __func__); - return HI_FAIL; - } - - do { - if (ret != HI_SUCCESS) { - if (device->reset != NULL && device->reset->Reset != NULL) { - device->reset->Reset(device->reset); - } - HDF_LOGE("%s:Retry init hi3881!last ret=%d", __func__, ret); - } - ret = hi_wifi_init(maxPortCount, device->bus); - } while (ret != 0 && --maxRetryCount > 0); - - if (ret != 0) { - HDF_LOGE("%s:Init hi3881 driver failed!", __func__); - return ret; - } - return HI_SUCCESS; - } - - /* Deinitializing the WLAN chip. */ - int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) - { - (void)device; - int32_t ret = hi_wifi_deinit(); - if (ret != 0) { - HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret); - } - return ret; - } - - /* Initializing the WLAN chip driver. */ - int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) - { - hi_u16 mode; - int32_t ret; - nl80211_iftype_uint8 type; - (void)chipDriver; - HDF_LOGI("%s: start...", __func__); - mode = wal_get_vap_mode(); - if (mode >= WAL_WIFI_MODE_BUTT) { - oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); - return HI_FAIL; - } - if (mode == WAL_WIFI_MODE_STA) { - type = NL80211_IFTYPE_STATION; - #ifdef _PRE_WLAN_FEATURE_P2P - if (InitNetdev(netDevice, NL80211_IFTYPE_P2P_DEVICE) != HI_SUCCESS) { - return HI_FAIL; - } - #endif - } else if (mode == WAL_WIFI_MODE_AP) { - type = NL80211_IFTYPE_AP; - } else { - oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); - return HI_FAIL; - } - ret = wal_init_drv_wlan_netdev(type, WAL_PHY_MODE_11N, netDevice); - if (ret != HI_SUCCESS) { - oam_error_log2(0, OAM_SF_ANY, "wal_init_drv_netdev %s failed.l_return:%d\n", netDevice->name, ret); - } - return ret; - } - - /* Deinitializing the WLAN chip driver. */ - int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) - { - int32_t ret; - (void)chipDriver; - ret = DeinitNetdev(NL80211_IFTYPE_P2P_DEVICE); - if (ret != HI_SUCCESS) { - oam_error_log1(0, OAM_SF_ANY, "Hi3881Deinit: DeinitNetdev p2p device fail, ret = %d\n", ret); - return ret; - } - return wal_deinit_drv_wlan_netdev(netDevice); - } - - ``` - - During the chip initialization process, call **NetDeviceInit()** to initialize a network device, call **NetDeviceAdd()** to add the network device to a protocol stack, and hook function pointers of **netdev**. - - ```c - hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, oal_net_device_stru *netdev) - { - hi_char *ac_mode_str = NULL; - hi_s32 ret; - if (oal_unlikely(netdev == HI_NULL)) { - oam_error_log0(0, OAM_SF_ANY, "{netdev is null!}"); - return HI_ERR_CODE_PTR_NULL; - } - - do { - /* Initialize the network device. */ - ret = wal_init_netdev(type, netdev); - if (ret != HI_SUCCESS) { - break; - } - - ret = wal_init_netif(type, netdev); - if (ret != HI_SUCCESS) { - break; - } - ac_mode_str = "11bgn"; - if (mode == WAL_PHY_MODE_11G) { - ac_mode_str = "11bg"; - } else if (mode == WAL_PHY_MODE_11B) { - ac_mode_str = "11b"; - } - - ret = wal_ioctl_set_mode(netdev, ac_mode_str); - } while (false); - - if (ret != HI_SUCCESS) { - wal_deinit_wlan_vap(netdev); - oal_net_unregister_netdev(netdev); - oal_net_clear_netdev(netdev); - return HI_FAIL; - } - - return HI_SUCCESS; - } - - /* Hook function pointers of netdev. For details, see NetDeviceInterFace. */ - oal_net_device_ops_stru g_wal_net_dev_ops = - { + }; + + HDF_INIT(g_hdfHisiChipEntry); + ``` + + - Registering the functions for initializing the chip and chip driver + + Hook the chip initialization function to **InitChip()** and the chip deinitialization function to **DeinitChip()**. + + Hook the chip driver initialization function to **Build()** and the chip driver deinitialization function to **Release()**. + + ```c + /* Register WLAN chip functions. */ + static int32_t HDFWlanRegHisiDriverFactory(void) + { + static struct HdfChipDriverFactory tmpFactory = { 0 }; + struct HdfChipDriverManager *driverMgr = NULL; + driverMgr = HdfWlanGetChipDriverMgr(); + if (driverMgr == NULL) { + HDF_LOGE("%s fail: driverMgr is NULL!", __func__); + return HDF_FAILURE; + } + tmpFactory.driverName = HI3881_DRIVER_NAME; + tmpFactory.GetMaxIFCount = GetHi3881GetMaxIFCount; + tmpFactory.InitChip = InitHi3881Chip; + tmpFactory.DeinitChip = DeinitHi3881Chip; + tmpFactory.Build = BuildHi3881Driver; + tmpFactory.Release = ReleaseHi3881Driver; + tmpFactory.ReleaseFactory = NULL; + if (driverMgr->RegChipDriver(&tmpFactory) != HDF_SUCCESS) { + HDF_LOGE("%s fail: driverMgr is NULL!", __func__); + return HDF_FAILURE; + } + + return HDF_SUCCESS; + } + + static int32_t HdfWlanHisiChipDriverInit(struct HdfDeviceObject *device) + { + (void)device; + return HDFWlanRegHisiDriverFactory(); + } + ``` + + - Initializing and deinitializing the chip + ```c + /* Function for initializing the WLAN chip. */ + int32_t InitHi3881Chip(struct HdfWlanDevice *device) + { + uint8_t maxPortCount = 3; + int32_t ret = HI_SUCCESS; + uint8_t maxRetryCount = 3; + if (device == NULL || device->bus == NULL) { + HDF_LOGE("%s:NULL ptr!", __func__); + return HI_FAIL; + } + + do { + if (ret != HI_SUCCESS) { + if (device->reset != NULL && device->reset->Reset != NULL) { + device->reset->Reset(device->reset); + } + HDF_LOGE("%s:Retry init hi3881!last ret=%d", __func__, ret); + } + ret = hi_wifi_init(maxPortCount, device->bus); + } while (ret != 0 && --maxRetryCount > 0); + + if (ret != 0) { + HDF_LOGE("%s:Init hi3881 driver failed!", __func__); + return ret; + } + return HI_SUCCESS; + } + + /* Function for deinitializing the WLAN chip. */ + int32_t DeinitHi3881Chip(struct HdfWlanDevice *device) + { + (void)device; + int32_t ret = hi_wifi_deinit(); + if (ret != 0) { + HDF_LOGE("%s:Deinit failed!ret=%d", __func__, ret); + } + return ret; + } + ``` + - Initializing and deinitializing the chip driver + ```c + /* Hook the functions of the WLAN chip driver, mac80211, and chip. */ + static struct HdfChipDriver *BuildHi3881Driver(struct HdfWlanDevice *device, uint8_t ifIndex) + { + struct HdfChipDriver *specificDriver = NULL; + if (device == NULL) { + HDF_LOGE("%s fail: channel is NULL!", __func__); + return NULL; + } + (void)ifIndex; + specificDriver = (struct HdfChipDriver *)OsalMemCalloc(sizeof(struct HdfChipDriver)); + if (specificDriver == NULL) { + HDF_LOGE("%s fail: OsalMemCalloc fail!", __func__); + return NULL; + } + if (memset_s(specificDriver, sizeof(struct HdfChipDriver), 0, sizeof(struct HdfChipDriver)) != EOK) { + HDF_LOGE("%s fail: memset_s fail!", __func__); + OsalMemFree(specificDriver); + return NULL; + } + + if (strcpy_s(specificDriver->name, MAX_WIFI_COMPONENT_NAME_LEN, HI3881_DRIVER_NAME) != EOK) { + HDF_LOGE("%s fail: strcpy_s fail!", __func__); + OsalMemFree(specificDriver); + return NULL; + } + specificDriver->init = Hi3881Init; + specificDriver->deinit = Hi3881Deinit; + + HiMac80211Init(specificDriver); + + return specificDriver; + } + + /* Release the WLAN chip driver. */ + static void ReleaseHi3881Driver(struct HdfChipDriver *chipDriver) + { + if (chipDriver == NULL) { + return; + } + if (strcmp(chipDriver->name, HI3881_DRIVER_NAME) != 0) { + HDF_LOGE("%s:Not my driver!", __func__); + return; + } + OsalMemFree(chipDriver); + } + + /* Function for initializing the WLAN chip driver. */ + int32_t Hi3881Init(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) + { + hi_u16 mode; + int32_t ret; + nl80211_iftype_uint8 type; + (void)chipDriver; + HDF_LOGI("%s: start...", __func__); + mode = wal_get_vap_mode(); + if (mode >= WAL_WIFI_MODE_BUTT) { + oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); + return HI_FAIL; + } + if (mode == WAL_WIFI_MODE_STA) { + type = NL80211_IFTYPE_STATION; + #ifdef _PRE_WLAN_FEATURE_P2P + if (InitNetdev(netDevice, NL80211_IFTYPE_P2P_DEVICE) != HI_SUCCESS) { + return HI_FAIL; + } + #endif + } else if (mode == WAL_WIFI_MODE_AP) { + type = NL80211_IFTYPE_AP; + } else { + oam_error_log1(0, 0, "wal_init_drv_netdev:: invalid mode[%d]", mode); + return HI_FAIL; + } + ret = wal_init_drv_wlan_netdev(type, WAL_PHY_MODE_11N, netDevice); + if (ret != HI_SUCCESS) { + oam_error_log2(0, OAM_SF_ANY, "wal_init_drv_netdev %s failed.l_return:%d\n", netDevice->name, ret); + } + return ret; + } + + /* Function for deinitializing the WLAN chip driver. */ + int32_t Hi3881Deinit(struct HdfChipDriver *chipDriver, struct NetDevice *netDevice) + { + int32_t ret; + (void)chipDriver; + ret = DeinitNetdev(NL80211_IFTYPE_P2P_DEVICE); + if (ret != HI_SUCCESS) { + oam_error_log1(0, OAM_SF_ANY, "Hi3881Deinit: DeinitNetdev p2p device fail, ret = %d\n", ret); + return ret; + } + return wal_deinit_drv_wlan_netdev(netDevice); + } + + ``` + + During the chip initialization process, call **NetDeviceInit()** to initialize a network device, call **NetDeviceAdd()** to add the network device to a protocol stack, and hook function pointers of **netdev**. + + ```c + hi_s32 wal_init_drv_wlan_netdev(nl80211_iftype_uint8 type, wal_phy_mode mode, oal_net_device_stru *netdev) + { + hi_char *ac_mode_str = NULL; + hi_s32 ret; + if (oal_unlikely(netdev == HI_NULL)) { + oam_error_log0(0, OAM_SF_ANY, "{netdev is null!}"); + return HI_ERR_CODE_PTR_NULL; + } + + do { + /* Initialize the network device. */ + ret = wal_init_netdev(type, netdev); + if (ret != HI_SUCCESS) { + break; + } + + ret = wal_init_netif(type, netdev); + if (ret != HI_SUCCESS) { + break; + } + ac_mode_str = "11bgn"; + if (mode == WAL_PHY_MODE_11G) { + ac_mode_str = "11bg"; + } else if (mode == WAL_PHY_MODE_11B) { + ac_mode_str = "11b"; + } + + ret = wal_ioctl_set_mode(netdev, ac_mode_str); + } while (false); + + if (ret != HI_SUCCESS) { + wal_deinit_wlan_vap(netdev); + oal_net_unregister_netdev(netdev); + oal_net_clear_netdev(netdev); + return HI_FAIL; + } + + return HI_SUCCESS; + } + + /* Hook function pointers of netdev. For details, see NetDeviceInterFace. */ + oal_net_device_ops_stru g_wal_net_dev_ops = + { .getStats = wal_netdev_get_stats, .open = wal_netdev_open, .stop = wal_netdev_stop, @@ -496,26 +469,21 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial .changeMtu = oal_net_device_change_mtu, .init = oal_net_device_init, .deInit = oal_net_free_netdev, - #if (defined(_PRE_WLAN_FEATURE_FLOWCTL) || defined(_PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL)) - .selectQueue = wal_netdev_select_queue, - #endif - .setMacAddr = wal_netdev_set_mac_addr, - #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) - .netifNotify = HI_NULL, - #endif - .specialEtherTypeProcess = SpecialEtherTypeProcess, - }; + + ... - hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev) - { - /* Add the network device to the protocol stack. */ - hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); + }; - ... + hi_s32 wal_init_netif(nl80211_iftype_uint8 type, oal_net_device_stru *netdev, const oal_wireless_dev *wdev) + { + /* Add the network device to the protocol stack. */ + hi_u32 ret = NetDeviceAdd(netdev, (Protocol80211IfType)type); - return HI_SUCCESS; - } - ``` + ... + + return HI_SUCCESS; + } + ``` 3. Bind the commands to be delivered, including setting the MAC address and transmit power, implement STA connection and scan, start APs, and setting the country code. @@ -580,8 +548,10 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial 4. Invoke the event reporting APIs. - The WLAN framework provides the event reporting APIs. For details, see hdf_wifi_event.c. For example, call **HdfWiFiEventNewSta AP** to report information about the newly associated STA. - + The WLAN framework provides the event reporting APIs. For details, see **hdf_wifi_event.c**. + + For example, call **HdfWiFiEventNewSta AP** to report information about the newly associated STA. + ```c hi_u32 oal_cfg80211_new_sta(oal_net_device_stru *net_device, const hi_u8 *mac_addr, hi_u8 addr_len, oal_station_info_stru *station_info, oal_gfp_enum_uint8 en_gfp) @@ -595,13 +565,15 @@ The following uses the Hi3881 WLAN chip as an example to describe how to initial info.assocReqIesLen = station_info->assoc_req_ies_len; HdfWifiEventNewSta(net_device, mac_addr, WLAN_MAC_ADDR_LEN, &info); hi_unref_param(en_gfp); - hi_unref_param(addr_len); + hi_unref_param(addr_len); #endif return HI_SUCCESS; } ``` -## Verification + + +**Verification** Develop test cases in the WLAN module unit test to verify the basic features of the WLAN module. The following uses Hi3516D V300 standard system as an example. @@ -678,7 +650,7 @@ Develop test cases in the WLAN module unit test to verify the basic features of exit 0 ``` - - Create a **udhcpd.conf** file (used to start the **udhcpd**) and copy the following content to the file. In the following, **opt dns** *x.x.x.x* *x.x.x.x* indicates two DNS servers configured. You can configure DNS servers as required. + - Create a **udhcpd.conf** file (used to start the **udhcpd**) and copy the following content to the file. In the following, **opt dns** *x.x.x.x* *x.x.x.x* indicates two DNS servers configured. You can configure DNS servers as required. ```text start 192.168.12.2 @@ -737,45 +709,55 @@ Develop test cases in the WLAN module unit test to verify the basic features of The network name and password are configured in the **hostapd.conf** file. You can see that network name in the connected Wi-Fi list if the connection is successful. 5. Ping the test terminal from the development board. - + ```shell busybox ping xxx.xxx.xxx.xxx ``` In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. - - Verify basic STA features. + - 1. Start the STA on the development board, and enable the hotspot on the test terminal. (The hotspot name and password are configured in the **hostapd.conf** file. The hotspot name is **test**, and the password is **12345678**.) + - Verify basic STA features. + 1. Start the STA on the development board, and enable the hotspot on the test terminal. + + The hotspot name and password are configured in the **hostapd.conf** file. The hotspot name is **test**, and the password is **12345678**. + 2. Run the following command in the **cmd** window: - + ```shell hdc shell wpa_supplicant -i wlan0 -d -c wpa_supplicant.conf ``` - + + + 3. Run the following commands in another **cmd** window: - + ```shell hdc shell mount -o rw,remount / mount -o rw,remount /vendor busybox udhcpc -i wlan0 -s system/lib/dhcpc.sh ``` + The IP addresses of the board and test terminal are displayed if the command is successful. - + 4. Ping the test terminal from the development board. - + ```shell busybox ping xxx.xxx.xxx.xxx ``` + + In the command, *xxx.xxx.xxx.xxx* indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. + - In the command, xxx.xxx.xxx.xxx indicates the IP address of the test terminal. If the test terminal can be pinged, the WLAN driver provides basic features normally. - -3. Verify the unit test cases. +#### **API Invocation** +The WLAN driver module provides two types of capability interfaces for the upper layer: HDI interface and HAL interface. +- HDI API invocation - To test a specified interface of the HDI module, perform the following steps: + The following uses **GetSupportFeature** as an example to describe the development procedure: 1. Call **WlanInterfaceGetInstance()** to obtain a WLAN service instance. @@ -788,23 +770,22 @@ Develop test cases in the WLAN module unit test to verify the basic features of 5. Call **WlanInterfaceRelease()** to destroy the WLAN service instance. The sample code is as follows: - - ```c - #include "v1_0/iwlan_interface.h" - #include "wlan_callback_impl.h" - #include "wlan_impl.h" + ```c + #include "v1_0/iwlan_interface.h" + #include "wlan_callback_impl.h" + #include "wlan_impl.h" - #define PROTOCOL_80211_IFTYPE_NUM 11; - #define HDF_SUCCESS 0 - #define HDF_FAILURE (-1) - - static int32_t hdi_main() - { - int32_t rc; - const char *WLAN_SERVICE_NAME = "wlan_hal_c_service"; - static struct IWlanInterface *g_wlanObj = NULL; - uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0}; - uint32_t supTypeLen = PROTOCOL_80211_IFTYPE_NUM + 1; + #define PROTOCOL_80211_IFTYPE_NUM 11 + #define HDF_SUCCESS 0 + #define HDF_FAILURE (-1) + + static int32_t hdi_main() + { + int32_t rc; + const char *WLAN_SERVICE_NAME = "wlan_hal_c_service"; + static struct IWlanInterface *g_wlanObj = NULL; + uint8_t supType[PROTOCOL_80211_IFTYPE_NUM + 1] = {0}; + uint32_t supTypeLen = PROTOCOL_80211_IFTYPE_NUM + 1; /* Obtain the WLAN service instance. */ g_wlanObj = WlanInterfaceGetInstance(WLAN_SERVICE_NAME); @@ -842,7 +823,30 @@ Develop test cases in the WLAN module unit test to verify the basic features of } return rc; } - ``` + + ``` + + Building: + + 1. Add the dependent library file to the build script. + + ```text + deps = [ + "//drivers/peripheral/wlan/hdi_service:hdi_wlan_service", + ] + ``` + 2. Add the dependent header files to the build script. + ```text + include_dirs = [ + "//drivers/peripheral/wlan/interfaces/include", + "//drivers/peripheral/wlan/hdi_service", + "//drivers/peripheral/wlan/client/include", + "//drivers/peripheral/wlan/hal/include", + ] + ``` + 3. Run the build script and check whether the build is successful. + +- HAL API invocation To test a specified interface of the HAL module, perform the following steps: @@ -856,67 +860,65 @@ Develop test cases in the WLAN module unit test to verify the basic features of 5. Call **destroyFeature()** to destroy the **apFeature** instance. - 6. Call **stop()** to destroy the channel between the HAL and the driver. + 6. Call **Stop()** to destroy the channel between the HAL and the driver. 7. Call **WifiDestruct()** to destroy the **IWiFi** instance. The sample code is as follows: - ```c + ```c #include "wifi_hal.h" #include "wifi_hal_sta_feature.h" #include "wifi_hal_ap_feature.h" #include "wifi_hal_cmd.h" - #include "wifi_hal_event.h" #define MAC_LEN 6 #define HDF_SUCCESS 0 #define HDF_FAILURE (-1) - ``` - static int32_t hal_main() { int32_t ret; struct IWiFi *wifi; + struct IWiFiAp *apFeature; /* Create an IWiFi instance. */ ret = WifiConstruct(&wifi); if (ret != HDF_SUCCESS || wifi == NULL) { return HDF_FAILURE; } - + /* Create a channel between the HAL and the driver and obtain the driver NIC information. */ ret = wifi->start(wifi); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } - + /* Create an apFeature instance. */ ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } - + /* Obtain the MAC address of the device. */ unsigned char mac[MAC_LEN] = {0}; ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } - + /* Destroy the apFeature instance. */ ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } - + /* Destroy the channel between the HAL and the driver. */ ret = wifi->stop(wifi); if (ret != HDF_SUCCESS) { return HDF_FAILURE; } - + /* Destroy the IWiFi instance. */ ret = WifiDestruct(&wifi); if (ret != HDF_SUCCESS) { @@ -924,31 +926,30 @@ Develop test cases in the WLAN module unit test to verify the basic features of } return ret; } - ``` - -4. Verify the test cases. - 1. Push the test cases to the development board. - - ```shell - hdc file send /xxx /data - ``` - - In the command, xxx indicates the path of the test cases of the development board. - - 2. Modify the permissions on the test cases and execute the test cases. - - ```shell - hdc shell - cd data - chmod 777 Test_case_name - ./ Test case name. - ``` - - - - 3. Check the test case execution result. + ``` + Building: + 1. Add the dependent library file to the build script. + + ```text + deps = [ + "//drivers/peripheral/wlan/client:wifi_driver_client", + "//drivers/peripheral/wlan/hal:wifi_hal", + ] + ``` + + 2. Add the dependent header files to the build script. + ```text + include_dirs = [ + "//drivers/peripheral/wlan/interfaces/include", + "//drivers/peripheral/wlan/hdi_service", + "//drivers/peripheral/wlan/client/include", + "//drivers/peripheral/wlan/hal/include", + ] + ``` + 3. Run the build script and check whether the build is successful. + - + ## Reference @@ -962,34 +963,19 @@ Develop test cases in the WLAN module unit test to verify the basic features of - Code paths: - - Adaptation of WLAN FlowCtl component on LiteOS: - - **//drivers/hdf_core/adapter/khdf/liteos/model/network/wifi** - - - Adaptation of HDF network model on LiteOS: - - **//drivers/hdf_core/adapter/khdf/liteos/model/network** - - - Adaptation of WLAN FlowCtl component on Linux, build of the HDF WLAN model, and build of the vendor's WLAN driver: - - **//drivers/hdf_core/adapter/khdf/linux/model/network/wifi** - - - Core code for implementing the WLAN module: - - **//drivers/hdf_core/framework/model/network/wifi** - - - External APIs of the WLAN module: + - Adaptation of WLAN FlowCtl component on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network/wifi** + - Adaptation of HDF network model on LiteOS: **//drivers/hdf_core/adapter/khdf/liteos/model/network** + + - Adaptation of WLAN FlowCtl component on Linux, build of the HDF WLAN model, and build of the vendor's WLAN driver: **//drivers/hdf_core/adapter/khdf/linux/model/network/wifi** + - Core code for implementing the WLAN module: **//drivers/hdf_core/framework/model/network/wifi** + - External APIs of the WLAN module: **//drivers/hdf_core/framework/include/wifi** + - HDF network model APIs: **//drivers/hdf_core/framework/include/net** + - WLAN HDI server implementation: **//drivers/peripheral/wlan** - **//drivers/hdf_core/framework/include/wifi** - - HDF network model APIs: - **//drivers/hdf_core/framework/include/net** - - WLAN HDI server implementation: - **//drivers/peripheral/wlan** - - External APIs of the WLAN HDI: - **//out/{product_name}/gen/drivers/interface/wlan/v1_0** + diff --git a/en/device-dev/faqs/figures/en-us_image_0000001251196005.png b/en/device-dev/faqs/figures/en-us_image_0000001251196005.png deleted file mode 100644 index 527fe8b9836daf35c8300e0e84bdb2ca390f85a5..0000000000000000000000000000000000000000 Binary files a/en/device-dev/faqs/figures/en-us_image_0000001251196005.png and /dev/null differ diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md index b244824c3be958bf35bbf78f6d2f689d2e931a6a..08809554460c986eae58f3d0a0ece2b6bb58904d 100644 --- a/en/device-dev/get-code/sourcecode-acquire.md +++ b/en/device-dev/get-code/sourcecode-acquire.md @@ -180,14 +180,14 @@ The table below provides only the sites for downloading the latest OpenHarmony L | Hi3518 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz.sha256)| | Hi3516 solution-LiteOS (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz)| | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | -| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | +| Release Notes | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | | **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**| -| Full code base (for mini, small, and standard systems)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)| -| RK3568 standard system solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)| -| Hi3861 solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) | -| Hi3516 solution-LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)| -| Hi3516 solution-Linux (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256)| -| RELEASE-NOTES | 3.2 Beta2 | [Download](../../release-notes/OpenHarmony-v3.2-beta2.md)| - | +| Full code base (for mini, small, and standard systems)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz.sha256)| +| RK3568 standard system solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)| +| Hi3861 solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz.sha256) | +| Hi3516 solution-LiteOS (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz.sha256)| +| Hi3516 solution-Linux (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_Linux.tar.gz.sha256)| +| Release Notes | 3.2 Beta3 | [Download](../../release-notes/OpenHarmony-v3.2-beta3.md)| - | | **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**| | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | diff --git a/en/device-dev/kernel/figures/overall-file-system-architecture.png b/en/device-dev/kernel/figures/overall-file-system-architecture.png deleted file mode 100644 index 07ca835af056e96dbbf0f08f9015eb2ea1c45380..0000000000000000000000000000000000000000 Binary files a/en/device-dev/kernel/figures/overall-file-system-architecture.png and /dev/null differ diff --git a/en/device-dev/porting/porting-chip-board.md b/en/device-dev/porting/porting-chip-board.md deleted file mode 100644 index 3776faeedf617c422ac7974c728af8f62a34e470..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-chip-board.md +++ /dev/null @@ -1,17 +0,0 @@ -# Board-Level OS Porting - -- **[Porting Overview](porting-chip-board-overview.md)** - -- **[Board-Level Driver Adaptation](porting-chip-board-driver.md)** - -- **[Implementation of APIs at the HAL](porting-chip-board-hal.md)** - -- **[System Modules](porting-chip-board-component.md)** - -- **[lwIP Module Adaptation](porting-chip-board-lwip.md)** - -- **[Third-party Module Adaptation](porting-chip-board-bundle.md)** - -- **[XTS](porting-chip-board-xts.md)** - - diff --git a/en/device-dev/porting/porting-chip-kernel.md b/en/device-dev/porting/porting-chip-kernel.md deleted file mode 100644 index 7b2a628f3481ac80a59be513df869d91e9acb298..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-chip-kernel.md +++ /dev/null @@ -1,9 +0,0 @@ -# Kernel Porting - -- **[Porting Overview](porting-chip-kernel-overview.md)** - -- **[Basic Kernel Adaptation](porting-chip-kernel-adjustment.md)** - -- **[Kernel Porting Verification](porting-chip-kernel-verify.md)** - - diff --git a/en/device-dev/porting/porting-chip-prepare.md b/en/device-dev/porting/porting-chip-prepare.md deleted file mode 100644 index 44cb5673ddc7e7f7a2df08defe0c70b0d9ee2277..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-chip-prepare.md +++ /dev/null @@ -1,7 +0,0 @@ -# Porting Preparations - -- **[Before You Start](porting-chip-prepare-knows.md)** - -- **[Building Adaptation Process](porting-chip-prepare-process.md)** - - diff --git a/en/device-dev/porting/porting-minichip-cases.md b/en/device-dev/porting/porting-minichip-cases.md deleted file mode 100644 index 1b550e80b5b3864eaf47157b8306d64086411d0e..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-minichip-cases.md +++ /dev/null @@ -1,4 +0,0 @@ -# Mini System SoC Porting Cases - -- **[Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md)** -- **[Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md)** diff --git a/en/device-dev/porting/porting-smallchip-driver.md b/en/device-dev/porting/porting-smallchip-driver.md deleted file mode 100644 index 04eea1a6abd5ad0f7dcb8a54c96cd156fc8946a1..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-smallchip-driver.md +++ /dev/null @@ -1,9 +0,0 @@ -# Driver Porting - -- **[Porting Overview](porting-smallchip-driver-overview.md)** - -- **[Platform Driver Porting](porting-smallchip-driver-plat.md)** - -- **[Device Driver Porting](porting-smallchip-driver-oom.md)** - - diff --git a/en/device-dev/porting/porting-smallchip-kernel.md b/en/device-dev/porting/porting-smallchip-kernel.md deleted file mode 100644 index 6dc319b5e1d3e370e6aa5a328766ed8eefed79e9..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-smallchip-kernel.md +++ /dev/null @@ -1,7 +0,0 @@ -# Kernel Porting - -- **[LiteOS Cortex-A](porting-smallchip-kernel-a.md)** - -- **[Linux Kernel](porting-smallchip-kernel-linux.md)** - - diff --git a/en/device-dev/porting/porting-smallchip-prepare.md b/en/device-dev/porting/porting-smallchip-prepare.md deleted file mode 100644 index 29017d1e3985912cf68e7a30c96c6f99ad8edc88..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-smallchip-prepare.md +++ /dev/null @@ -1,7 +0,0 @@ -# Porting Preparations - -- **[Before You Start](porting-smallchip-prepare-needs.md)** - -- **[Compilation and Building](porting-smallchip-prepare-building.md)** - - diff --git a/en/device-dev/porting/porting-smallchip.md b/en/device-dev/porting/porting-smallchip.md deleted file mode 100644 index bfbe8b6af1bb60858013d9b7a4cf6600846a955e..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-smallchip.md +++ /dev/null @@ -1,9 +0,0 @@ -# Small System SoC Porting Guide - -- **[Porting Preparations](porting-smallchip-prepare.md)** - -- **[Kernel Porting](porting-smallchip-kernel.md)** - -- **[Driver Porting](porting-smallchip-driver.md)** - - diff --git a/en/device-dev/porting/porting-standardchip.md b/en/device-dev/porting/porting-standardchip.md deleted file mode 100644 index 3fe4b8e441c3784cd94134c2f28617b1cafda279..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-standardchip.md +++ /dev/null @@ -1,7 +0,0 @@ -# Standard System SoC Porting Guide - - - -- **[Standard System Porting Guide](standard-system-porting-guide.md)** - -- **[A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting-linux-kernel.md)** \ No newline at end of file diff --git a/en/device-dev/porting/porting-thirdparty.md b/en/device-dev/porting/porting-thirdparty.md deleted file mode 100644 index e85e40325130aa7608c6f1db6fea86879cdf8d86..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting-thirdparty.md +++ /dev/null @@ -1,9 +0,0 @@ -# Third-Party Library Porting Guide for Mini and Small Systems - -- **[Overview](porting-thirdparty-overview.md)** - -- **[Porting a Library Built Using CMake](porting-thirdparty-cmake.md)** - -- **[Porting a Library Built Using Makefile](porting-thirdparty-makefile.md)** - - diff --git a/en/device-dev/porting/porting.md b/en/device-dev/porting/porting.md deleted file mode 100644 index 3e5a13a8b792dd17e16dd6dda9d957dc043c767f..0000000000000000000000000000000000000000 --- a/en/device-dev/porting/porting.md +++ /dev/null @@ -1,8 +0,0 @@ -# Porting - -- **[Mini System SoC Porting Guide](porting-minichip.md)** -- **[Small System SoC Porting Guide](porting-smallchip.md)** -- **[Standard System Porting Guide](standard-system-porting-guide.md)** -- **[Third-Party Library Porting Guide for Mini and Small Systems](porting-thirdparty.md)** - - diff --git a/en/device-dev/website.md b/en/device-dev/website.md index 6cfcbb65bcd6cf29218f11a58f8f67667d061f9c..9463578e645cb0c4aa816dac2bd47ef8d3faf5c2 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -197,10 +197,28 @@ - [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md) - [Obtaining Source Code](get-code/sourcecode-acquire.md) +- Privacy and Security - [Privacy Protection](security/security-privacy-protection.md) - [Security Guidelines](security/security-guidelines-overall.md) - Porting + - Mini System SoC Porting Guide + - Porting Preparations + - [Before You Start](porting/porting-chip-prepare-knows.md) + - [Building Adaptation Process](porting/porting-chip-prepare-process.md) + - Kernel Porting + - [Overview](porting/porting-chip-kernel-overview.md) + - [Basic Kernel Adaptation](porting/porting-chip-kernel-adjustment.md) + - [Kernel Porting Verification](porting/porting-chip-kernel-verify.md) + - Board-Level OS Porting + - [Overview](porting/porting-chip-board-overview.md) + - [Board-Level Driver Adaptation](porting/porting-chip-board-driver.md) + - [Implementation of APIs at the HAL](porting/porting-chip-board-hal.md) + - [System Modules](porting/porting-chip-board-component.md) + - [lwIP Module Adaptation](porting/porting-chip-board-lwip.md) + - [Third-party Module Adaptation](porting/porting-chip-board-bundle.md) + - [XTS](porting/porting-chip-board-xts.md) + - [FAQs](porting/porting-chip-faqs.md) - Small System SoC Porting Guide - Porting Preparations @@ -469,18 +487,18 @@ - [Build System Coding Specifications and Best Practices](subsystems/subsys-build-gn-coding-style-and-best-practice.md) - [Building the Kconfig Visual Configuration](subsystems/subsys-build-gn-kconfig-visual-config-guide.md) - References - - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules) - - [Product Configuration Rules](subsystems/subsys-build-product.md#configuration-rules) - - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules) - - [Component Configuration Rules](subsystems/subsys-build-component.md#configuration-rules) - - [Module Configuration Rules](subsystems/subsys-build-module.md#configuration-rules) - - [Chipset Solution Configuration Rules](subsystems/subsys-build-chip_solution.md#configuration-rules) - - [Feature Configuration Rules](subsystems/subsys-build-feature.md#configuration-rules) - - [System Capabilities Configuration Rules](subsystems/subsys-build-syscap.md#configuring-system-capabilities-for-a-component) - - [deps and external_deps](subsystems/subsys-build-reference.md#deps-and-external_deps) - - [Information Collected by the Open Source Software Notice](subsystems/subsys-build-reference.md#information-collected-by-the-open-source-software-notice) - - [Parameters for Accelerating Local Build](subsystems/subsys-build-reference.md#parameters-for-accelerating-local-build) - - [Viewing Ninja Build Information](subsystems/subsys-build-reference.md#viewing-ninja-build-information) + - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md + - [Product Configuration Rules](subsystems/subsys-build-product.md) + - [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md) + - [Component Configuration Rules](subsystems/subsys-build-component.md) + - [Module Configuration Rules](subsystems/subsys-build-module.md) + - [Chipset Solution Configuration Rules](subsystems/subsys-build-chip_solution.md) + - [Feature Configuration Rules](subsystems/subsys-build-feature.md) + - [System Capabilities Configuration Rules](subsystems/subsys-build-syscap.md) + - [deps and external_deps](subsystems/subsys-build-reference.md) + - [Information Collected by the Open Source Software Notice](subsystems/subsys-build-reference.md) + - [Parameters for Accelerating Local Build](subsystems/subsys-build-reference.md) + - [Viewing Ninja Build Information](subsystems/subsys-build-reference.md) - [HAP Build Guide](subsystems/subsys-build-gn-hap-compilation-guide.md) - [FAQs](subsystems/subsys-build-FAQ.md) - [Distributed Remote Startup](subsystems/subsys-remote-start.md) diff --git a/en/readme/account.md b/en/readme/account.md index 604106428bc13c2fc74f6383ec47f659bc34b550..bda9addb1394b0cbfec6be7dc0ac4853cc967c7b 100755 --- a/en/readme/account.md +++ b/en/readme/account.md @@ -1,39 +1,86 @@ -# Account +# Account -## Introduction +## Introduction -In a standard system, the Account subsystem supports login status management of distributed cloud accounts, interconnection with vendors' cloud account apps on the device side, and query and update of the cloud account login status. +In the standard system, the Account subsystem provides basic capabilities such as OS account lifecycle management, distributed account login status management, and app account information management. -## Architecture +## Architecture -**Figure 1** Account subsystem architecture +**Figure 1** Account subsystem architecture -![](figures/en-us_image_0000001079026550.png) +![](figures/en_image_account_struct.png) -## Directory Structure +## Directory Structure ``` -/base/account -└── os_account # OS account module - ├── common # Common basic code - ├── interfaces # APIs exposed externally - ├── kits # Development framework - ├── sa_profile # SA profile - ├── services # Service code - └── test # Test code - └── resource # Test resources +/base/account/os_account +├── dfx +│ ├── hidumper_adapter # Code of the adapter for exporting system service information +│ ├── hisysevent_adapter # Code of the system event logging adapter +├── figures # Figures +├── frameworks # Code of the account subsystem +│ ├── account_iam # Internal API code for account identity authentication and access management +│ │ └── src # Code for implementing internal APIs for account identity authentication and access management +│ ├── appaccount # Internal API code of the app account module +│ │ └── native # Code for implementing the internal APIs of the app account module +│ ├── common # Code of the common module +│ │ ├── account_error # Error codes +│ │ ├── database # Database code +│ │ ├── file_operator # File operator code +│ │ ├── log # Code for printing logs +│ │ ├── perf_stat # Code for performance statistics +│ │ └── test # Test code for the common module +│ ├── ohosaccount # Internal API code of the distributed account module +│ │ ├── native # Code for implementing the internal APIs of the distributed account module +│ │ └── test # Test code for the distributed account internal APIs +│ └── osaccount # Internal API code of the OS account module +│ ├── core # OS account IPC +│ └── native # Code for implementing the internal APIs of the OS account module +├── interfaces # Account subsystem APIs exposed externally +│ ├── innerkits # Internal API header files +│ │ ├── account_iam # Account identity authentication and access management +│ │ ├── appaccount # Header files of the app account internal APIs +│ │ ├── ohosaccount # Header files of the distributed account internal APIs +│ │ └── osaccount # Header files of the OS account internal APIs +│ └── kits # Encapsulation of external APIs +│ └── napi # External API encapsulation code of the account subsystem +├── sa_profile # SA profile directory of the account subsystem +├── services # accountmgr service code +│ └── accountmgr # Account subsystem service code +│ ├── include # Service code header files +│ ├── src # Source code of the account subsystem service code +│ └── test # Test of the account subsystem service code +├── test # Test code +│ ├── fuzztest # Fuzzy test code +│ ├── resource # Test resource files +│ └── systemtest # System test code +└── tools # Tool code + ├── acm # acm tool code + │ ├── include # acm header files + │ └── src # acm source file + └── test # acm test code ``` -## Usage Guidelines +## Description -Using the available classes for managing distributed accounts, you can query and update the account login status, including login, logout, unregistration, and token expiration. +### Modules -To query and update the login status of a distributed account, you must obtain the required system permission. These APIs are supported only by system apps. +| Module | Description | +| ---------- | ------------------------------------------------------------ | +| OS account | Provides APIs for adding, deleting, querying, modifying, and starting OS accounts and subscribing to OS account information. | +| Distributed account| Provides APIs for managing distributed account login status, supports interactions with cloud account applications on devices, and provides capabilities for querying and updating cloud account login status.| +| App account | Provides APIs for adding, deleting, querying, modifying, and authenticating app accounts. | -## Repositories Involved -**Account subsystem** +### How to Use -[account_os_account](https://gitee.com/openharmony/account_os_account) +- [OS Account Management](../application-dev/reference/apis/js-apis-osAccount.md) +- [Distributed Account Management](../application-dev/reference/apis/js-apis-distributed-account.md) +- [App Account Management](../application-dev/reference/apis/js-apis-appAccount.md) +## Repositories Involved + +**Account Subsystem** + +[account_os_account](https://gitee.com/openharmony/account_os_account) \ No newline at end of file diff --git a/en/readme/figures/en_image_account_struct.png b/en/readme/figures/en_image_account_struct.png new file mode 100644 index 0000000000000000000000000000000000000000..db5671e5fde629b5cdf57e2a8974b87f44455707 Binary files /dev/null and b/en/readme/figures/en_image_account_struct.png differ diff --git a/en/readme/location.md b/en/readme/location.md index 369f272c6ec8d1af651f9b69ae4db2d893df464e..035cec4b31d6ddb0b432b7de28bd5a8367c0c002 100644 --- a/en/readme/location.md +++ b/en/readme/location.md @@ -28,9 +28,8 @@ Location awareness helps determine where a mobile device locates. The system ide WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A high density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network. -**Figure 1** ** Location subsystem architecture** +**Figure 1** Location subsystem architecture** -![](figures/location_En-1.png) ![](figures/location_En-1.png) ## Directory Structure @@ -116,7 +115,7 @@ The following table describes APIs available for obtaining device location infor If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. - You can declare the required permission in your application's configuration file. For details, see [Application Package Structure Configuration File](../application-dev/quick-start/stage-structure.md). + You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../application-dev/security/accesstoken-guidelines.md). 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. diff --git a/en/release-notes/OpenHarmony-v3.0.6-LTS.md b/en/release-notes/OpenHarmony-v3.0.6-LTS.md new file mode 100644 index 0000000000000000000000000000000000000000..652e61e0c16152b9ac13a6c821b695ed52701781 --- /dev/null +++ b/en/release-notes/OpenHarmony-v3.0.6-LTS.md @@ -0,0 +1,107 @@ +# OpenHarmony 3.0.6 LTS + + +## Version Description + +OpenHarmony 3.0.6 LTS is a maintenance version of OpenHarmony 3.0 LTS. It has rectified certain issues detected in OpenHarmony 3.0.5 LTS. + + +## Version Mapping + + **Table 1** Version mapping of software and tools + +| Software/Tool| Version| Remarks| +| -------- | -------- | -------- | +| OpenHarmony | 3.0.6 LTS| NA | +| (Optional) HUAWEI DevEco Studio| 3.0 Beta1| Recommended for developing OpenHarmony applications| +| (Optional) HUAWEI DevEco Device Tool| 2.2 Beta2 | Recommended for developing OpenHarmony smart devices| + + +## Source Code Acquisition + + +### Prerequisites + +1. Register your account with Gitee. + +2. Register an SSH public key for access to Gitee. + +3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure user information. + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. Run the following commands to install the **repo** tool: + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the permission, download the tool to another directory and configure it as an environment variable by running the chmod a+x /usr/local/bin/repo command. + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### Acquiring Source Code Using the repo Tool + +**Method 1 (recommended)**: Use the **repo** tool to download the source code over SSH. (You must have an SSH public key for access to Gitee.) + + +``` +repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0.6-LTS --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + +**Method 2**: Use the **repo** tool to download the source code over HTTPS. + + +``` +repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0.6-LTS --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + + +### Acquiring Source Code from Mirrors + + **Table 2** Mirrors for acquiring source code + +| LTS Code| Version| Mirror| SHA-256 Checksum| +| -------- | -------- | -------- | -------- | +| Full code base (for mini, small, and standard systems)| 3.0.6 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/code-v3.0.6-LTS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/code-v3.0.6-LTS.tar.gz.sha256)| +| Standard system Hi3516 solution (binary)| 3.0.6 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/standard.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/standard.tar.gz.sha256)| +| Mini system Hi3861 solution (binary)| 3.0.6 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_pegasus.tar.gz.sha256)| +| Small system Hi3516 solution - LiteOS (binary)| 3.0.6 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_taurus.tar.gz.sha256)| +| Small system Hi3516 solution - Linux (binary)| 3.0.6 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0.6/hispark_taurus_linux.tar.gz.sha256)| + + +## What's New + + +### Feature Updates + +This version does not involve feature updates. + + +### API Updates + +This version does not involve API updates. + + +### Chip and Development Board Adaptation + +For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md). + + +## Fixed Security Vulnerabilities + + **Table 3** Fixed security vulnerabilities + +| Issue No.| Description| PR Link| +| -------- | -------- | -------- | +| I5MTWL | Security vulnerabilities of the kernel_linux_5.10 component: CVE-2022-36123, CVE-2022-20369, CVE-2022-2588, CVE-2022-2586, CVE-2022-2585, and CVE-2022-20368.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/402) | +| 5FYFI | Security vulnerabilities of the kernel_linux_5.10 component: CVE-2022-34918, CVE-2022-2318, and CVE-2022-2380.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/331) | +| 5FYFI | Security vulnerabilities of the kernel_linux_5.10 component: CVE-2022-26365, CVE-2022-33742, CVE-2022-33743, CVE-2022-33740, and CVE-2022-33741.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/352) | +| I5LUE0 | Security vulnerability of the third_party_zlib component: CVE-2022-37434.| [PR](https://gitee.com/openharmony/third_party_zlib/pulls/44) | +| I5NCH4 | When **/bin/wms_server** is run over the serial port of the Hi3516 development board in the small system, the memory address and layout information are printed.| [PR](https://gitee.com/openharmony/distributedschedule_samgr_lite/pulls/1) | diff --git a/en/release-notes/OpenHarmony-v3.1.3-release.md b/en/release-notes/OpenHarmony-v3.1.3-release.md new file mode 100644 index 0000000000000000000000000000000000000000..8029072be5610bf4b065f4295c44dc54183c33b8 --- /dev/null +++ b/en/release-notes/OpenHarmony-v3.1.3-release.md @@ -0,0 +1,142 @@ +# OpenHarmony 3.1.3 Release + + +## Version Description + +OpenHarmony 3.1.3 Release provides enhanced system security over OpenHarmony 3.1.2 Release by rectifying certain known vulnerabilities in open-source components such as Linux kernel and Python. + + +## Version Mapping + + **Table 1** Version mapping of software and tools + +| Software/Tool| Version| Remarks| +| -------- | -------- | -------- | +| OpenHarmony | 3.1.3 Release | NA | +| Full SDK| Ohos_sdk_full 3.1.7.7 (API Version 8 Release)| This toolkit is intended for original equipment manufacturers (OEMs) and contains system APIs that require system permissions.
To use the Full SDK, you must manually obtain it from the mirror and switch to it in DevEco Studio. For details, see [Guide to Switching to Full SDK](../application-dev/quick-start/full-sdk-switch-guide.md). | +| Public SDK| Ohos_sdk_public 3.1.7.7 (API Version 8 Release)| This toolkit is intended for application developers and does not contain system APIs that require system permissions.
It is provided as standard in DevEco Studio 3.0 Beta4 or later.| +| (Optional) HUAWEI DevEco Studio| 3.0 Release for OpenHarmony| Recommended for developing OpenHarmony applications| +| (Optional) HUAWEI DevEco Device Tool| 3.0 Release| Recommended for developing OpenHarmony smart devices| + + +## Source Code Acquisition + + +### Prerequisites + +1. Register your account with Gitee. + +2. Register an SSH public key for access to Gitee. + +3. Install the [git client](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [git-lfs](https://gitee.com/vcs-all-in-one/git-lfs?_from=gitee_search#downloading), and configure user information. + + ``` + git config --global user.name "yourname" + git config --global user.email "your-email-address" + git config --global credential.helper store + ``` + +4. Run the following commands to install the **repo** tool: + + ``` + curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo # If you do not have the permission, download the tool to another directory and configure it as an environment variable by running the chmod a+x /usr/local/bin/repo command. + pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests + ``` + + +### Acquiring Source Code Using the repo Tool + +**Method 1 (recommended)** + +Use the **repo** tool to download the source code over SSH. (You must have an SSH public key for access to Gitee.) + + +``` +repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.3-Release --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + +**Method 2** + +Use the **repo** tool to download the source code over HTTPS. + + +``` +repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.1.3-Release --no-repo-verify +repo sync -c +repo forall -c 'git lfs pull' +``` + + +### Acquiring Source Code from Mirrors + +**Table 2** Mirrors for acquiring source code + +| Source Code| Version| Mirror| SHA-256 Checksum| +| -------- | -------- | -------- | -------- | +| Full code base (for mini, small, and standard systems)| 3.1.3 Release | [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz.sha256)| +| Hi3516 standard system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_hi3516.tar.gz.sha256)| +| RK3568 standard system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/code-v3.1.3-Release.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/standard_rk3568.tar.gz.sha256)| +| Hi3861 mini system solution (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_pegasus.tar.gz.sha256)| +| Hi3516 small system solution - LiteOS (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus.tar.gz.sha256)| +| Hi3516 small system solution - Linux (binary)| 3.1.3 Release| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz)| [Download](https://mirrors.huaweicloud.com/openharmony/os/3.1.3/hispark_taurus_linux.tar.gz.sha256)| +| Full SDK package for the standard system (macOS)| 3.1.7.7 | [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-mac-full.tar.gz)| [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-mac-full.tar.gz.sha256) | +| Full SDK package for the standard system (Windows/Linux)| 3.1.7.7 | [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-full.tar.gz)| [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-full.tar.gz.sha256)| +| Public SDK package for the standard system (macOS)| 3.1.7.7 | [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-mac-public.tar.gz)| [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-mac-public.tar.gz.sha256)| +| Public SDK package for the standard system (Windows/Linux)| 3.1.7.7 | [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-public.tar.gz)| [Download](https://gitee.com/link?target=https%3A%2F%2Fmirrors.huaweicloud.com%2Fopenharmony%2Fos%2F3.1.2%2Fsdk-patch%2Fohos-sdk-public.tar.gz.sha256)| + + +## What's New + +This version has the following updates to OpenHarmony 3.1.2 Release. + +### Feature Updates + +This version does not involve feature updates. + +### API Updates + +This version does not involve API updates. + +### Chip and Development Board Adaptation + +For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md). + + +## Resolved Issues + +**Table 3** Resolved issues + +| Subsystem| Description| +| -------- | -------- | +| Multimedia subsystem| There is a possibility that the board restarts unexpectedly when a video in **Gallery** is played in the Hi3516 development board of the standard system. ([I5N70Z](https://gitee.com/openharmony/kernel_linux_config/issues/I5N70Z))| + + +## Fixed Security Vulnerabilities + +**Table 4** Fixed security vulnerabilities + +| Issue No.| Description| PR Link| +| -------- | -------- | -------- | +| I5QAEX | When the test device connects to a Wi-Fi hotspot provided by a mobile phone, the IP address is printed in the log.| [PR](https://gitee.com/openharmony/communication_netmanager_base/pulls/527) | +| I5QBQD | The startup log of dsoftbus_standard contains plaintext MAC addresses.| [PR](https://gitee.com/openharmony/communication_dsoftbus/pulls/2328) | +| I5R13H | The startup log of dhd contains plaintext MAC addresses.| [PR](https://gitee.com/openharmony/kernel_linux_patches/pulls/304) | +| I5MVEM | Security vulnerability of the css-what component: CVE-2021-33587.| [PR](https://gitee.com/openharmony/third_party_css-what/pulls/8) | +| I5QBNS | Security vulnerability of the curl component: CVE-2022-35252.| [PR](https://gitee.com/openharmony/third_party_curl/pulls/83) | +| I5MR1V | Security vulnerabilities of the linux_kernel component: CVE-2022-2588, CVE-2022-2585, CVE-2022-20369, and CVE-2022-20368.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/426) | +| I5MQS0 | Security vulnerability of the linux_kernel component: CVE-2022-2586.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/427) | +| I5P0W4 | Security vulnerabilities of the linux_kernel component: CVE-2022-2959 and CVE-2022-2991.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/428) | +| I5P0TX | Security vulnerability of the linux_kernel component: CVE-2022-2938.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/430) | +| I5QBWI | Security vulnerabilities of the linux_kernel component: CVE-2022-3028, CVE-2022-2977, and CVE-2022-2964.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/440) | +| I5QC1O | Security vulnerabilities of the linux_kernel component: CVE-2022-39188, CVE-2022-3078, CVE-2022-2905, and CVE-2022-39842.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/450) | +| I5P0WN | Security vulnerability of the linux_kernel component: CVE-2022-26373| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/461) | +| I5NZKV | Security vulnerability of the linux_kernel component: CVE-2022-2503.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/431) | +| I5R2L0 | Security vulnerability of the linux_kernel component: CVE-2022-3061.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/443) | +| I5R2JQ | Security vulnerabilities of the linux_kernel component: CVE-2022-2663, CVE-2022-39190, and CVE-2022-39189.| [PR](https://gitee.com/openharmony/kernel_linux_5.10/pulls/445) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2021-29921.| [PR](https://gitee.com/openharmony/third_party_python/pulls/19) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2022-0391.| [PR](https://gitee.com/openharmony/third_party_python/pulls/23) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2021-3737.| [PR](https://gitee.com/openharmony/third_party_python/pulls/20) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2021-4189.| [PR](https://gitee.com/openharmony/third_party_python/pulls/21) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2021-3733.| [PR](https://gitee.com/openharmony/third_party_python/pulls/22) | +| I5R8X1 | Security vulnerability of the Python component: CVE-2021-28861.| [PR](https://gitee.com/openharmony/third_party_python/pulls/24) | diff --git a/en/release-notes/Readme.md b/en/release-notes/Readme.md index d7efa0580a1a901e20428a1e7160f7861075cefd..36430bb2fd1f920166bfe0f29e88ac42d02c5035 100644 --- a/en/release-notes/Readme.md +++ b/en/release-notes/Readme.md @@ -5,10 +5,12 @@ - [OpenHarmony v3.2 Beta2 (2022-07-30)](OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.1 Release (2022-03-30)](OpenHarmony-v3.1-release.md) + - [OpenHarmony v3.1.3 Release (2022-09-30)](OpenHarmony-v3.1.3-release.md) - [OpenHarmony v3.1.2 Release (2022-08-24)](OpenHarmony-v3.1.2-release.md) - [OpenHarmony v3.1.1 Release (2022-05-31)](OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](OpenHarmony-v3.1-beta.md) - [OpenHarmony v3.0 LTS (2021-09-30)](OpenHarmony-v3.0-LTS.md) + - [OpenHarmony v3.0.6 LTS (2022-09-15)](OpenHarmony-v3.0.6-LTS.md) - [OpenHarmony v3.0.5 LTS (2022-07-01)](OpenHarmony-v3.0.5-LTS.md) - [OpenHarmony v3.0.3 LTS (2022-04-08)](OpenHarmony-v3.0.3-LTS.md) - [OpenHarmony v3.0.2 LTS (2022-03-18)](OpenHarmony-v3.0.2-LTS.md) diff --git a/en/release-notes/api-change/v3.1-Release/Readme-EN.md b/en/release-notes/api-change/v3.1-Release/Readme-EN.md index d84adb9e93c862893399d0c1276a2cde150a44fb..e7465982e34f079913c30cf77dd1865e5f85a3e2 100644 --- a/en/release-notes/api-change/v3.1-Release/Readme-EN.md +++ b/en/release-notes/api-change/v3.1-Release/Readme-EN.md @@ -4,3 +4,4 @@ This directory records the API changes in OpenHarmony 3.1 Release over OpenHarmo - [JS API Differences](js-apidiff-v3.1-release.md) - [Native API Differences](native-apidiff-v3.1-release.md) +- [Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release)](changelog-v3.1-release.md) diff --git a/en/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md b/en/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md new file mode 100644 index 0000000000000000000000000000000000000000..597bda22e9a8564f20be1ca5dfa4d1b8d25f023c --- /dev/null +++ b/en/release-notes/api-change/v3.1-Release/changelog-v3.1-release.md @@ -0,0 +1,56 @@ +# Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release) + +### Added Validity Verification for Color Values in Color.json + +Validity verification is added for color values in the **color.json** file. The verification rules are as follows: + +- The hexadecimal color code is used in any of the following formats: + - #rgb: red(0-f) green(0-f) blue(0-f) + - #argb: transparency(0-f) red(0-f) green(0-f) blue(0-f) + - #rrggbb: red(00-ff) green(00-ff) blue(00-ff) + - #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff) +- The dollar sign ($) is used to reference resources defined in the application. The format is as follows: + - $color:xxx + +**Change Impacts** + +If the verification rules are not met, an error is reported during compilation. + +**Key API/Component Changes** + +None + +### Restrictions on Declaring Multiple Data Types of State Variables + +If a **@State**, **@Provide**, **@Link**, or **@Consume** decorated state variable supports multiple data types, they must be all simple data types or references at one time. + +Example: + +```ts +@Entry +@Component +struct Index { + // Incorrect: @State message: string | Resource = 'Hello World' + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(`${ this.message }`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` + +**Change Impacts** + +When the defined state variable type contains both the simple data types and references, an error is reported during compilation. + +**Key API/Component Changes** + +If the defined state variable type contains both the simple data types and references, change the type to one of them, as shown in the preceding sample code. diff --git a/en/release-notes/api-change/v3.2-beta2/Readme-EN.md b/en/release-notes/api-change/v3.2-beta2/Readme-EN.md index 21548e70cc7276031e010cd063888682d7d79cb9..9c0ced90f4aaeb828bdc7aeffe8d52204cfd1f67 100644 --- a/en/release-notes/api-change/v3.2-beta2/Readme-EN.md +++ b/en/release-notes/api-change/v3.2-beta2/Readme-EN.md @@ -31,5 +31,6 @@ This directory records the API changes in OpenHarmony 3.2 Beta2 over OpenHarmony - [Web subsystem](js-apidiff-web.md) - [Window manager subsystem](js-apidiff-window.md) - ChangeLog - - [Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1](changelog-v3.2-beta2.md) + - [Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2)](changelog-v3.2-beta2.md) - [Adaptation Guide for the Application Sandbox](application-sandbox-adaptation-guide.md) + diff --git a/en/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md b/en/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md index 418b75ae1af0a1dba20d7dabe86a06243e956e46..087c63757f0fc93730cb637b15df1d5e7c1e8d3e 100644 --- a/en/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md +++ b/en/release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md @@ -1,4 +1,4 @@ -# Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1 +# Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2) ## Introduced Application Sandbox diff --git a/en/release-notes/api-change/v3.2-beta3/Readme-EN.md b/en/release-notes/api-change/v3.2-beta3/Readme-EN.md index af4d7cc1dd326b2a086cacd23eebeb5f49bb1b78..816c48c5c111e2d70682fd7125cae3563cc33a0a 100644 --- a/en/release-notes/api-change/v3.2-beta3/Readme-EN.md +++ b/en/release-notes/api-change/v3.2-beta3/Readme-EN.md @@ -30,3 +30,4 @@ This directory records the API changes in OpenHarmony 3.2 Beta3 over OpenHarmony - [Update subsystem](js-apidiff-update.md) - [Web subsystem](js-apidiff-web.md) - [Window manager subsystem](js-apidiff-window.md) +- [Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3)](changelog-v3.2-beta3.md) diff --git a/en/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md b/en/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md new file mode 100644 index 0000000000000000000000000000000000000000..0070fc5fd80a26c7d2611af75272011357b5727a --- /dev/null +++ b/en/release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md @@ -0,0 +1,234 @@ +# Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3) + +## Bundle Management Framework + +The privilege control capability is added for preset applications. The capability can be divided into two parts: permission control for preset applications and configuration of preset applications. +Application privileges are high-level capabilities of an application, for example, restricting an application from being uninstalled or restricting application data from being deleted. +OpenHarmony provides both general and device-specific application privileges. The latter can be configured by device vendors for applications on different devices. OpenHarmony supports differentiated configuration of preset applications on different devices. In addition, OpenHarmony provides **GetCfgDirList** for your application to obtain the preset directories, such as **system**, **chipset**, **sys_prod**, and **chip_prod**, in ascending order of priority. For example, the priority of **chip_prod** is higher than that of **system**. + +### Changed Installation Mode for Preset Applications + +In earlier versions, preset applications are installed by automatically scanning and installing HAP files in the **/system/app** directory. From this version, preset applications are configured based on the trustlist. Specifically, only the HAP file configured with **app-dir** in the **install_list.json** file can be automatically installed as a preset application. + +**Change Impacts** + +JS and native APIs are not involved, and application development is not affected. + +**Key API/Component Changes** + +N/A + +**Adaptation Guide** + +Configure related fields in the [/system/etc/app/install_list.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list.json) file. The **app_dir** field specifies the directory where the HAP file is located, and **removable** specifies whether the HAP file can be uninstalled after being installed. + +Example: + +```json +{ + "install_list" : [ + { + "app_dir" : "/system/app/com.ohos.systemui", + "removable" : false + }, + { + "app_dir" : "/system/app/demo.hap", + "removable" : true + } + ] +} +``` + +### Changes in General Application Privilege Control + +For a specific application, the general application privileges remain unchanged on all types of devices. The general application privileges are as follows: +| Permission| Description | +| ---------------- | ------------------------------------------------------------ | +| AllowAppDataNotCleared | Allows application data to be deleted.| +| AllowAppMultiProcess | Allows the application to run on multiple processes.| +| AllowAppDesktopIconHide | Allows the application icon to be hidden from the home screen.| +| AllowAbilityPriorityQueried | Allows an ability to configure and query the priority. | +| AllowAbilityExcludeFromMissions | Allows an ability to be hidden in the mission stack.| +| AllowAppUsePrivilegeExtension | Allows the application to use Service Extension and Data Extension abilities.| +| AllowFormVisibleNotify | Allows a widget to be visible on the home screen.| + +In earlier versions, these privileges are configured in the **config.json** or **module.json** file and distinguished based on the application type (preset or system application). From this version, the privileges are configured based on the signing certificate and preset trustlist. + +**Change Impacts** + +JS and native APIs are not involved. If your application needs to use any of these privileges, apply for it. For details about how to apply for and configure the privileges, see [Application Privilege Configuration](../device-dev/subsystems/subsys-app-privilege-config-guide.md). + +**Key API/Component Changes** + +N/A + +**Adaptation Guide** + +See [Application Privilege Configuration](../device-dev/subsystems/subsys-app-privilege-config-guide.md). + +```json +{ + "version-name": "1.0.0", + ... + "bundle-info": { + "developer-id": "OpenHarmony", + ... + }, + "issuer": "pki_internal", + "app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // The application data cannot be deleted, and the icon can be hidden on the home screen. +} +``` + +### Changes in Device-specific Application Privilege Control +In addition to general application privileges, device vendors can define device-specific privileges for an application, as described in the table below. + +| Permission | Type | Default Value| Description | +| --------------------- | -------- | ------ | ------------------------------------------------- | +| removable | bool | true | Allows the application to be uninstalled. This permission takes effect only for preset applications. | +| keepAlive | bool | false | Allows the application to remain resident in the background. | +| singleton | bool | false | Allows the application to be installed for a single user (User 0). | +| allowCommonEvent | string[] | - | Allows the application to be started by a static broadcast. | +| associatedWakeUp | bool | false | Allows the application in the FA model to be woken up by an associated application. | +| runningResourcesApply | bool | false | Allows the application to request running resources, such as CPU, event notifications, and Bluetooth.| + +In earlier versions, these privileges are configured in the **config.json** or **module.json** file and distinguished based on the application type (preset or system application). From this version, the privileges can be configured based on the preset trustlist. For details, see [install_list_capability.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json). + +**Change Impacts** + +JS and native APIs are not involved. If your application needs to use any of these privileges, apply for it. For details, see [Configuration Mode](../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-mode). + +**Key API/Component Changes** + +N/A + +**Adaptation Guide** + +See [Configuration Mode](../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-mode). + +```json +{ + "install_list": [ + { + "bundleName": "com.example.kikakeyboard", + "singleton": true, // The application is installed for a single user. + "keepAlive": true, // The application remains resident in the background. + "runningResourcesApply": true, // The application can apply for running resources such as CPU, event notifications, and Bluetooth. + "associatedWakeUp": true, // The application in the FA model can be woken up by an associated application. + "app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // The setting takes effect only when the configured certificate fingerprint is the same as the HAP certificate fingerprint. + "allowCommonEvent": ["usual.event.SCREEN_ON", "usual.event.THERMAL_LEVEL_CHANGED"] + } +} +``` + +### Fingerprint Verification for Pre-authorization Trustlist + +The pre-authorization file [install_list_permissions.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) is moved from **system/etc/permission** to **system/etc/app/** on the development board. The **app_signature** field is added to specify the fingerprint of the HAP file. Multiple fingerprints can be configured. Authorization can be performed only when the fingerprint is matched. + +**Change Impacts** + +JS and native APIs are not involved. If your application uses pre-authorization, add the fingerprint to the pre-authorization file. + +**Key API/Component Changes** + +N/A + +**Adaptation Guide** + +Refer to the following code: + +```json +{ +[ + { + "bundleName" : "com.ohos.screenshot", + "app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"], + "permissions" : [ + { + "name" : "ohos.permission.MEDIA_LOCATION", + "userCancellable" : true + }, + { + "name" : "ohos.permission.READ_MEDIA", + "userCancellable" : true + }, + { + "name" : "ohos.permission.WRITE_MEDIA", + "userCancellable" : true + } + ] + } +} +``` + +## ArkUI Development Framework + +### Rectified Variable Sharing Issue of the Common Module in Release HAP Mode During Building in the FA Model + +Assume that two pages depend on the same object (foodData) of a file. If page A modifies the object, page B obtains the new value when reading the object. This implements object sharing for the common module. + +**Change Impacts** + +Application compilation is not affected, and no interface adaptation is required. + +**Key API/Component Changes** + +N/A + +### Restrictions on Declaring Multiple Data Types of State Variables + +If a **@State**, **@Provide**, **@Link**, or **@Consume** decorated state variable supports multiple data types, they must be all simple data types or references at one time. + +Example: + +```ts +@Entry +@Component +struct Index { + // Incorrect: @State message: string | Resource = 'Hello World' + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(`${ this.message }`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +``` + +**Change Impacts** + +When the defined state variable type contains both the simple data types and references, an error is reported during compilation. + +**Key API/Component Changes** + +If the defined state variable type contains both the simple data types and references, change the type to one of them, as shown in the preceding sample code. + +## Globalization Subsystem + +### Added Validity Verification for Color Values in Color.json + +Validity verification is added for color values in the **color.json** file. The verification rules are as follows: + +- The hexadecimal color code is used in any of the following formats: + - #rgb: red(0-f) green(0-f) blue(0-f) + - #argb: transparency(0-f) red(0-f) green(0-f) blue(0-f) + - #rrggbb: red(00-ff) green(00-ff) blue(00-ff) + - #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff) +- The dollar sign ($) is used to reference resources defined in the application. The format is as follows: + - $color:xxx + +**Change Impacts** + +If the verification rules are not met, an error is reported during compilation. + +**Key API/Component Changes** + +N/A + + \ No newline at end of file diff --git a/en/website.md b/en/website.md index dcd1bc06fea931fb3fe160b92f1333ba2f416981..de3b7ad81739170af2395abac6a78fbb7940fc20 100644 --- a/en/website.md +++ b/en/website.md @@ -8,18 +8,23 @@ - [OpenHarmony v3.2 Beta2 (2022-07-30)](release-notes/OpenHarmony-v3.2-beta2.md) - [OpenHarmony v3.2 Beta1 (2022-05-31)](release-notes/OpenHarmony-v3.2-beta1.md) - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) + - [OpenHarmony v3.1.3 Release (2022-09-30)](release-notes/OpenHarmony-v3.1.3-release.md) - [OpenHarmony v3.1.2 Release (2022-08-24)](release-notes/OpenHarmony-v3.1.2-release.md) - [OpenHarmony v3.1.1 Release (2022-05-31)](release-notes/OpenHarmony-v3.1.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) + - [OpenHarmony v3.0.6 LTS (2022-09-15)](release-notes/OpenHarmony-v3.0.6-LTS.md) - [OpenHarmony v3.0.5 LTS (2022-07-01)](release-notes/OpenHarmony-v3.0.5-LTS.md) - [OpenHarmony v3.0.3 LTS (2022-04-08)](release-notes/OpenHarmony-v3.0.3-LTS.md) - [OpenHarmony v3.0.2 LTS (2022-03-18)](release-notes/OpenHarmony-v3.0.2-LTS.md) - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) + - OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) + - OpenHarmony 1.x Releases + - [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md) - [OpenHarmony v1.1.5 LTS (2022-08-24)](release-notes/OpenHarmony-v1.1.5-LTS.md) - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) @@ -27,7 +32,7 @@ - [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md) - [OpenHarmony v1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md) - [OpenHarmony v1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md) - + - API Differences - OpenHarmony 3.2 Beta3 - JS API Differences @@ -58,6 +63,7 @@ - [Update subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-update.md) - [Web subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-web.md) - [Window manager subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-window.md) + - [Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3)](release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md) - OpenHarmony 3.2 Beta2 - JS API Differences - [Ability framework](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md) @@ -88,7 +94,7 @@ - [Web subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-web.md) - [Window manager subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-window.md) - ChangeLog - - [Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1](release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md) + - [Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2)](release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md) - [Adaptation Guide for the Application Sandbox](release-notes/api-change/v3.2-beta2/application-sandbox-adaptation-guide.md) - OpenHarmony 3.2 Beta1 - JS API Differences @@ -143,10 +149,11 @@ - [User IAM subsystem](release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md) - [Window manager subsystem](release-notes/api-change/v3.1-Release/js-apidiff-window.md) - [Native API Differences](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md) + - [Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release)](release-notes/api-change/v3.1-Release/changelog-v3.1-release.md) - OpenHarmony 3.1 Beta - [JS API Differences](release-notes/api-change/v3.1-beta/js-apidiff-v3.1-beta.md) - [Native API Differences](release-notes/api-change/v3.1-beta/native-apidiff-v3.1-beta.md) - - [Updates Between OpenHarmony 3.1 Beta and OpenHarmony 3.0](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md) + - [Updates (OpenHarmony 3.0 -> OpenHarmony 3.1 Beta)](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md) - OpenHarmony 3.0 LTS - [JS API Differences](release-notes/api-change/v3.0-LTS/js-apidiff-v3.0-lts.md) - OpenHarmony v2.2 Beta2 diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index b46bb3d89e7ffb99bde5bda90c7e2664e7547cdf..90378b11ecb5a1b4f9c490cef182bd55c9ce0be7 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -15,7 +15,6 @@ - [应用包结构说明(FA模型)](quick-start/package-structure.md) - [应用包结构说明(Stage模型)](quick-start/stage-structure.md) - [SysCap说明](quick-start/syscap.md) - - [HarmonyAppProvision配置文件](quick-start/app-provision-structure.md) - [资源分类与访问](quick-start/resource-categories-and-access.md) - 学习ArkTS语言 - [初识ArkTS语言](quick-start/arkts-get-started.md) diff --git a/zh-cn/application-dev/ability/ability-brief.md b/zh-cn/application-dev/ability/ability-brief.md index 149bd6429f51455539145b3e1fef2e59b38e8882..f7a4e18664f1c9bc0b0dd5d7478b2a3f40bea66c 100644 --- a/zh-cn/application-dev/ability/ability-brief.md +++ b/zh-cn/application-dev/ability/ability-brief.md @@ -1,22 +1,26 @@ # Ability框架概述 -Ability是应用所具备能力的抽象,也是应用程序的重要组成部分。Ability是系统调度应用的最小单元,是能够完成一个独立功能的组件。一个应用可以包含一个或多个Ability。 +Ability是OpenHarmony系统对应用的基本抽象。 + +每个Ability是完成独立业务的应用组件,是系统调度应用的最小单元。一个应用可以包含一个或多个Ability。 Ability框架模型具有两种形态: -- 第一种形态为FA模型。API 8及其更早版本的应用程序只能使用FA模型进行开发。FA模型将Ability分为FA(Feature Ability)和PA(Particle Ability)两种类型,其中FA支持Page Ability,PA支持Service Ability、Data Ability、以及FormAbility。 -- 第二种形态为Stage模型。从API 9开始,Ability框架引入了Stage模型作为第二种应用框架形态,Stage模型将Ability分为PageAbility和ExtensionAbility两大类,其中ExtensionAbility又被扩展为ServiceExtensionAbility、FormExtensionAbility、DataShareExtensionAbility等一系列ExtensionAbility,以便满足更多的使用场景。 +- 第一种形态称为FA模型。API 8及其更早版本的应用只能使用FA模型。FA模型将Ability分为Page Ability、Service Ability以及Data Ability几种类型。 +- 第二种形态称为Stage模型,这是自API 9新增的模型。Stage模型将Ability分为UIAbility和ExtensionAbility两大类,其中ExtensionAbility又被扩展为ServiceExtensionAbility、FormExtensionAbility、DataShareExtensionAbility等一系列ExtensionAbility,以便满足更多的使用场景。 + +自API 9开始,Stage模型是主推的开发模型。 Stage模型的设计,主要是为了开发者更加方便地开发出分布式环境下的复杂应用。下表给出了两种模型在设计上的差异: | 对比 | FA模型 | Stage模型 | | -------------- | ------------------------------------------------------------ | -------------------------------------------------------- | -| 开发方式 | 提供类Web的API,UI开发与Stage模型一致。 | 提供面向对象的开发方式,UI开发与FA模型一致。 | -| 引擎实例 | 每个进程内的每个Ability实例独享一个JS VM引擎实例。 | 每个进程内的多个Ability实例共享一个JS VM引擎实例。 | +| 应用组件开发方式 | 类Web的开发方式。 | 面向对象的开发方式。 | +| 引擎实例 | 每个Ability实例独占一个虚拟机实例。 | 多个Ability实例可以共享同一个虚拟机实例。 | | 进程内对象共享 | 不支持。 | 支持。 | -| 包描述文件 | 使用config.json描述HAP包和组件信息,组件必须使用固定的文件名。 | 使用module.json5描述HAP包和组件信息,可以指定入口文件名。 | -| 组件 | 提供PageAbility(页面展示),ServiceAbility(服务),DataAbility(数据分享)以及FormAbility(卡片)。 | 提供Ability(页面展示)、Extension(基于场景的服务扩展)。 | - +| 包描述文件 | 使用`config.json`描述HAP包和组件信息,组件必须使用固定的文件名。 | 使用`module.json5`描述HAP包和组件信息,可以指定入口文件名。 | +| 组件 | 提供PageAbility(页面展示),ServiceAbility(服务),DataAbility(数据分享)以及FormAbility(卡片)。 | 提供UIAbility(页面展示)、Extension(基于场景的服务扩展)。 | + 除了上述设计上的差异外,对于开发者而言,两种模型的主要区别在于: * Ability类型存在差异; @@ -29,7 +33,15 @@ Stage模型的设计,主要是为了开发者更加方便地开发出分布式 两种模型的基本介绍,详见[FA模型综述](fa-brief.md)及[Stage模型综述](stage-brief.md)。 -## 相关实例 -针对Ability开发,有以下相关实例可供参考: +## 相关实例 + +### FA 模型 + +- [Page内和Page间导航跳转(ArkTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) + +### Stage 模型 -- [Page内和Page间导航跳转(ArkTS)(API8)](https://gitee.com/openharmony/codelabs/tree/master/Ability/PageAbility) \ No newline at end of file +- [Stage模型介绍(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/StageModel) +- [窗口扩展(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/WindowExtAbility) +- [系统任务管理(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/MissionManager) +- [仿桌面应用(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/ability/Launcher) diff --git a/zh-cn/application-dev/ability/context-userguide.md b/zh-cn/application-dev/ability/context-userguide.md index d40657d3228af81ce89c480f24c3913983301968..b1fa53b741e85db4da2e1eaeffe9b5d222d27c64 100644 --- a/zh-cn/application-dev/ability/context-userguide.md +++ b/zh-cn/application-dev/ability/context-userguide.md @@ -94,13 +94,13 @@ export default { **示例** ```javascript -import AbilityStage from "@ohos.application.AbilityStage"; +import Ability from "@ohos.application.Ability"; var lifecycleid; -export default class MyAbilityStage extends AbilityStage { +export default class MainAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MainAbility onCreate") let AbilityLifecycleCallback = { onAbilityCreate(ability){ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); @@ -139,11 +139,11 @@ export default class MyAbilityStage extends AbilityStage { // 2.通过applicationContext注册监听应用内生命周期 lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); - } + }, onDestroy() { let applicationContext = this.context.getApplicationContext(); applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { - console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); }); } } diff --git a/zh-cn/application-dev/ability/fa-brief.md b/zh-cn/application-dev/ability/fa-brief.md index 3d8989bc1f7c56a6e9b614b3a6cfb7647d21f865..a752d73dd3918bba9fb1a09489f06b18d1952661 100644 --- a/zh-cn/application-dev/ability/fa-brief.md +++ b/zh-cn/application-dev/ability/fa-brief.md @@ -1,29 +1,36 @@ # FA模型综述 ## 整体架构 -OpenHarmony用户程序的开发本质上就是开发Ability。OpenHarmony系统是通过对Ability调度,结合系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。 -Ability框架在API 8及更早版本使用FA模型。FA模型中Ability分为PageAbility、ServiceAbility、DataAbility、FormAbility几种类型。其中: -- PageAbility是具备ArkUI实现的Ability,是用户具体可见并可以交互的Ability实例。 -- ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行。 -- DataAbility也是没有UI的Ability,提供其他Ability进行数据的增删查服务,在后台运行。 -- FormAbility是卡片Ability,是一种界面展示形式。 +OpenHarmony应用的开发,是以Ability为入口展开的。 + +对于Ability的开发,通常是以生命周期的回调处理为中心。 + +Ability框架在API 8及更早版本仅支持FA模型。FA模型中Ability分为PageAbility、ServiceAbility、DataAbility、FormAbility几种类型。其中: +- PageAbility使用ArkUI实现用户界面,是用户可见并可以交互的Ability实例。 +- ServiceAbility也是Ability一种,但是没有用户界面。它提供了其他Ability调用的自定义服务,ServiceAbility在后台运行。 +- DataAbility也是没有界面的Ability,提供其他Ability进行数据的增删查服务,它同样在后台运行。 +- FormAbility是实现卡片的Ability,卡片是OpenHarmomny系统上的一种界面展示形式。 + +> 注:自API 9开始,Stage模型是主推的开发模型。 ## 生命周期 -在所有Ability中,PageAbility因为具有界面,也是应用的交互入口,因此生命周期更加复杂。 +在所有Ability中,PageAbility因为具有界面,也是应用的交互入口,因此其生命周期更加复杂。 **PageAbility生命周期回调如下图所示:** ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png) -其他类型Ability的生命周期可参考PageAbility生命周期去除前后台切换以及`onShow`的部分进行理解。 -开发者可以在 `app.js/app.ets` 中重写生命周期函数,在对应的生命周期函数内处理应用相应逻辑。 - -目前`app.js`环境中仅支持onCreate和onDestroy回调,`app.ets`环境支持全量生命周期回调。 +其他类型Ability的生命周期可参考PageAbility生命周期去除前后台切换以及`onShow`及`onHide`的部分来理解。 +开发者可以在 `app.js/app.ets` 中重写生命周期函数,在对应的生命周期回调内处理应用的相应逻辑。 +目前`app.js`仅支持`onCreate`和`onDestroy`回调,但`app.ets`支持全量生命周期回调。 ## 进程线程模型 -应用独享独立进程,Ability独享独立线程,应用进程在Ability第一次启动时创建,并为启动的Ability创建线程,应用启动后再启动应用内其他Ability,会为每一个Ability创建相应的线程。每个Ability绑定一个独立的JSRuntime实例,因此Ability之间是隔离的。 + +每个应用运行在不同的进程中,在FA模型中,每个Ability运行在独立的虚拟机中。 + +应用进程在Ability启动时创建,此时会为Ability创建相应的线程。当一个应用有多个Ability时,每一个Ability在独立线程中运行。在FA模型中,每个Ability绑定一个独立的虚拟机实例,因此Ability之间是隔离的。 ![fa-threading-model](figures/fa-threading-model.png) diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index 162f45f14406b52de45c9bf13e1c9fe08882e73c..56f4f3393afd9602d9be30edf27cb92949c0c18e 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -128,7 +128,7 @@ let promise = featureAbility.startAbility( 使用OpenHarmony IDL(OpenHarmony Interface Definition Language)来自动生成对应客户端服务端及IRemoteObject代码,具体示例代码和说明请参考: - - [`OpenHarmony IDL`:TS开发步骤](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#ts开发步骤) + - [`OpenHarmony IDL`:TS开发步骤](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/IDL/idl-guidelines.md#ts%E5%BC%80%E5%8F%91%E6%AD%A5%E9%AA%A4) 2. 在对应文件编写代码 @@ -176,7 +176,7 @@ let promise = featureAbility.startAbility( ```javascript import featureAbility from '@ohos.ability.featureAbility'; - let connId = featureAbility.connectAbility( + let connectId = featureAbility.connectAbility( { bundleName: "com.jstest.service", abilityName: "com.jstest.service.ServiceAbility", @@ -293,7 +293,7 @@ function getRemoteDeviceId() { ```ts import featureAbility from '@ohos.ability.featureAbility'; -let connId = featureAbility.connectAbility( +let connectId = featureAbility.connectAbility( { deviceId: getRemoteDeviceId(), bundleName: "ohos.samples.etsDemo", diff --git a/zh-cn/application-dev/ability/stage-ability.md b/zh-cn/application-dev/ability/stage-ability.md index 2a05a5db1a6cda5f2b97c562af51df1fd084b999..ff7bdf0619c22796bf19e8f4f2f3eeefb0808ff2 100644 --- a/zh-cn/application-dev/ability/stage-ability.md +++ b/zh-cn/application-dev/ability/stage-ability.md @@ -315,7 +315,7 @@ struct Index { console.info('Index onPageShow') let newWant = globalThis.newWant if (newWant.hasOwnProperty("uri")) { - router.push({ uri: newWant.uri }); + router.push({ url: newWant.uri }); globalThis.newWant = undefined } } diff --git a/zh-cn/application-dev/ability/stage-brief.md b/zh-cn/application-dev/ability/stage-brief.md index 5adca9fd9cd56566346a079a5ecc3aee9b0fda47..3c8b11d15187935da2f5f06539e569d9e01631de 100644 --- a/zh-cn/application-dev/ability/stage-brief.md +++ b/zh-cn/application-dev/ability/stage-brief.md @@ -2,93 +2,98 @@ ## 设计思想 -​ Stage模型的设计,主要是为了解决FA模型无法解决的开发场景问题,方便开发者更加方便地开发出分布式环境下的复杂应用。 +​Stage模型的设计,是为了提供给开发者一个更好的开发方式,更好的适用于多设备、分布式场景。 -​ Stage模型的设计思想如下图所示。 +​Stage模型的设计思想如下图所示。 ![stagedesign](figures/stagedesign.png) -​ Stage模型的设计基于如下三个出发点: +​Stage模型的设计基于如下三个出发点: -- **应用的能力与系统总体功能和功耗的平衡** +- **应用进程的有序管理** - ​ 在系统运行过程中,前台应用的资源占用会被优先保障,与此同时由于应用能力不同而产生的功耗,也需要符合系统整体功耗的要求。Stage模型通过Ability与UI分离、严格的后台管控、基于场景的服务机制及单进程模型来达成这种应用能力与整体系统功耗的平衡。 +随着设备的内存越来越大,系统中同时运行的进程数量也越来越多。当数百个进程同时运行时,如果没有有效的管理措施,则系统整体的功耗和性能将无法得到保证。Stage模型中,通过短时任务、长时任务、托管任务和延迟任务四种方法对后台进程做了有序约束。这样做使得前台进程的资源得以保障,最终能获得更好的用户体验。 -- **原生支持组件级的迁移和协同** +- **原生支持跨端迁移和多端协同** - ​ OpenHarmony是原生支持分布式的操作系统,应用框架需要从架构设计上使得组件更易于实现迁移和协同。Stage模型通过Ability与UI分离及UI展示与服务能力合一等模型特性,实现这一设计目标。 +OpenHarmony是原生分布式的操作系统,应用框架需要从架构设计上使得组件更易于实现跨端迁移和多端协同。Stage模型通过Ability与UI分离及UI展示与服务能力合一等模型特性,实现这一设计目标。 -- **支持多设备和多窗口形态的特点** - - ​ 为了支持多种设备形态和更易于实现多种不同的窗口形态,需要组件管理服务和窗口管理服务在架构层面上是解耦的,从而方便裁剪,更有利于定制不同的窗口形态。Stage模型通过重新定义了Ability生命周期定义和设计组件管理服务和窗口管理服务的单向依赖解决这一问题。 +- **支持多种设备的不同窗口形态** +Stage模型重新定义了Ability的生命周期。系统在架构上,将应用组件管理服务和窗口管理服务进行了彼此解耦,这样做可以方便的针对特定设备进行适配,以实现出不同的窗口形态。 ## 基本概念 -​ 下图展示了Stage模型中的基本概念。 +下图展示了Stage模型中的基本概念。 ![stageconcept](figures/stageconcept.png) -- **HAP**:即HarmonyAbilityPackage,OpenHarmony应用编译、分发、加载的基本单位,也称为module,每个HAP都有一个应用内唯一的名称,称为moduleName; +- **HAP**:OpenHarmony应用编译、分发、加载的基本单位。与开发态的module一一对应。在应用内,moduleName是其唯一标识; - **Bundle**:通过appid标识的OpenHarmony应用,Bundle可以包含多个HAP,每个应用都有一个bundleName,但是bundleName并不能唯一标识一个应用,appid中包含bundleName以及其他的更多信息,能够唯一标识一个应用; -- **AbilityStage**:对应HAP的运行期类,在HAP首次加载到进程中时创建,运行期开发者可见; -- **Application**:对应Bundle的运行期类,运行期开发者不可见; -- **Context**:提供运行期开发者可以调用的各种能力,Ability组件和各种ExtensionAbility都有各自不同的context类,他们都继承自基类Context,基类提供包名、moduleName、路径等信息; -- **Ability**:提供生命周期回调,持有AbilityContext,支持组件迁移/协同; -- **ExtensionAbility**:基于场景的服务扩展能力统称,系统定义了多种基于场景的ExtensionAbility类,它们持有各自的ExtensionContext; +- **AbilityStage**:对应HAP的运行期对象,在HAP首次加载到进程中时创建,运行期开发者可见; +- **Application**:对应Bundle的运行期对象,运行期开发者不可见; +- **Context**:提供运行期开发者可以调用的各种能力,Ability组件和各种ExtensionAbility都有各自不同的Context类,他们都继承自基类Context,基类提供包名、moduleName、路径等信息; +- **Ability**:提供生命周期回调,持有AbilityContext,支持组件的跨端迁移和多端协同; +- **ExtensionAbility**:基于场景的扩展能力统称,系统定义了多种场景的ExtensionAbility类,它们持有各自的ExtensionContext; - **WindowStage**:本地窗口管理器; -- **Window**:窗口 管理器管理的基本单元,持有一个ArkUI引擎实例; -- **ArkUI Page**:方舟开发框架页面。 +- **Window**:应用窗口,持有一个ArkUI引擎实例; +- **ArkUI Page**:基于ArkUI开发的用户界面。 ## 生命周期 -​ Ability及AbilityStage的生命周期是应用的基本流程中最重要的概念。在[Ability框架概述](ability-brief.md)中,给出了FA模型与Stage模型的生命周期对比,这里重点对Ability生命周期切换以及和AbilityStage、WindowStage之间的调度关系进行介绍。 +AbilityStage及Ability是关于应用生命周期的关键对象。 + +在[Ability框架概述](ability-brief.md)中,给出了FA模型与Stage模型的生命周期对比,因此这里仅对Ability生命周期切换以及和AbilityStage、WindowStage之间的调度关系进行介绍。 ![stageabilitylifecyclecallback](figures/stageabilitylifecyclecallback.png) -​ 为了实现多设备形态上的裁剪和多窗口的可扩展性,OpenHarmony对组件管理和窗口管理进行了解耦。Stage模型定义Ability组件的生命周期,只包含创建、销毁、前后台等状态,而将与界面相关内容强相关的获焦、失焦状态放在WindowStage之中,从而实现Ability与窗口之间的弱耦合;在服务侧,窗口管理服务依赖于组件管理服务,前者通知后者前后台变化,这样组件管理服务仅感知前后台变化,不感知焦点变化。 +为了实现多设备形态上的适配和多窗口的扩展,OpenHarmony对组件管理和窗口管理进行了解耦。 + +Stage模型定义Ability组件的生命周期,只包含创建、销毁、前后台等状态,而将与界面强相关的获焦、失焦状态都放在WindowStage之中,从而实现Ability与窗口之间的弱耦合;在服务侧,窗口管理服务依赖于组件管理服务,前者通知后者前后台变化,这样组件管理服务仅感知前后台变化,不感知焦点变化。 -​ 需要注意的是,在Ability中存在两个与WindowStage相关的生命周期状态onWindowStageCreate和onWindowStageDestroy,这两个生命周期状态的变化仅存在于具有窗口显示能力的设备中。前者表示WindowStage已经创建完成,开发者可以通过执行loadContent的操作设置Ability需要加载的页面;后者在WindowStage销毁后调用,从而便于开发者对资源进行释放。 +需要注意的是,在Ability中存在两个与WindowStage相关的生命周期状态onWindowStageCreate和onWindowStageDestroy,这两个生命周期状态的变化仅存在于具有显示能力的设备中。前者表示WindowStage已经创建完成,开发者可以通过执行loadContent的操作设置Ability需要加载的页面;后者在WindowStage销毁后调用,以便开发者对资源进行释放。 ## Ability组件实例与任务 -​ Ability组件有三种启动类型: - -+ **Singleton**:应用进程中只存在一个该类型的Ability实例,如下图Ability1; - -+ **Standard**:每次startAbility调用,都会在应用进程中创建一个该类型的实例,如下图Ability2的两个实例; +Ability组件有三种启动类型: -+ **Specified**:允许开发者在系统创建Ability实例之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。 +* **Singleton**:应用进程中只存在一个该类型的Ability实例,如下图Ability1; +* **Standard**:每次startAbility调用,都会在应用进程中创建一个该类型的实例,如下图Ability2的两个实例; +* **Specified**:允许开发者在系统创建Ability实例之前,为该实例创建一个key,后续每次创建该类型的Ability实例都会询问应用使用哪个key对应的Ability实例,来响应startAbility请求,如下图Ability3。 -​ 每个Ability实例都对应了一个Launcher Recent中看到的Mission(任务)。 +每个Ability实例都对应了一个近期任务中的Mission(任务)。 -​ 每个Ability实例对应的Mission都留有该Ability实例的快照,Ability实例销毁后,Mission中的会保留Ability的类的信息和快照,直到用户删除,或者超过存储上限。 +每个Ability实例对应的Mission都留有该Ability实例的快照,Ability实例销毁后,Mission中会继续保留Ability的类的信息和快照,直到用户删除,或者超过存储上限。 ![AbilityComponentInstanceMission](figures/AbilityComponentInstanceMission.png) ## ExtensionAbility机制 -​ 不同于用于页面展示的Ability,ExtensionAbility提供的是一种受限的服务运行环境。ExtensionAbility具有如下特点: +不同于页面展示的Ability,ExtensionAbility提供的是一种受限的运行环境。 + +ExtensionAbility组件具有如下特点: -- 独立于主进程的单独进程运行,与主进程无IPC,共享一个存储沙箱; +- 运行在独立于主进程的单独进程中,与主进程无IPC,但共享一个存储沙箱; -- 独立的Context提供基于业务场景的api能力; +- 独立的Context提供基于相应业务场景的API能力; - 由系统触发创建,应用不能直接创建; - ExtensionAbility和进程的生命周期受系统管理。 -​ 下图以卡片服务使用场景为例进行展示,系统提供了FormExtensionAbility基类,开发者通过派生提供卡片的具体信息。FormExtensionAbility实例及其所在的ExtensionAbility进程的整个生命周期,都是由系统服务FormManagerService进行管理。 +下图以卡片使用场景为例进行展示。系统提供了FormExtensionAbility基类,开发者通过派生提供卡片的具体信息。FormExtensionAbility实例及其所在的ExtensionAbility进程的整个生命周期,都是由系统服务FormManagerService进行管理。 ![ExtensionAbility](figures/ExtensionAbility.png) ## 进程模型 -​ OpenHarmony系统中的应用均满足单进程模型。所谓的单进程模型,是指不允许应用配置多进程,应用中所有的进程都是由系统创建和管理的。每个应用至多并存三类进程: +OpenHarmony系统对于应用进程是有强管控策略的。对于开发者来说,没有自行配置多进程的能力。应用的所有进程都是由系统创建和管理的。 + +每个应用的进程可以分为三类: -- 主进程:运行所有的Ability组件、页面和业务逻辑; +- 主进程:运行UIAbility组件、页面和业务逻辑; - Extension进程:运行应用中的ExtensionAbility派生类,该进程由系统中的特定场景的服务管理其生命周期; diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index 3a89466da4747b55dae10e73bc1d17c1b2730ce4..5414bdccc785edac63a96ae75a2b0b2676bdc0c3 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -114,7 +114,10 @@ ### 设置分布式列表 ->**注意:** 在使用RdbStore的setDistributedTables、obtainDistributedTableName、sync、on、off接口时,需要请求相应的权限:ohos.permission.DISTRIBUTED_DATASYNC。 +> **说明:** +> +> - 在使用RdbStore的setDistributedTables、obtainDistributedTableName、sync、on、off接口时,需要请求相应的权限:ohos.permission.DISTRIBUTED_DATASYNC。 +> - 使用分布式列表前,需要先建立设备间组网,具体接口及使用可见[设备管理](../reference/apis/js-apis-device-manager.md)。 **设置分布式列表** diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md index 68fdf02768765624b98daf60e2b431bd3af11bf8..8df6e2ee0c5a87b0b400cc85ced09eeccc5fb6d8 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md @@ -277,7 +277,7 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics'; console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); } - // 无maNum参数异步方法promise方式 + // 无maxNum参数异步方法promise方式 try{ usageStatistics.queryModuleUsageRecords().then( res => { console.log('BUNDLE_ACTIVE queryModuleUsageRecords promise succeeded'); @@ -309,7 +309,7 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics'; console.log('BUNDLE_ACTIVE queryModuleUsageRecords throw error, code is: ' + error.code + ',message is: ' + error.message); } - // 无maNum参数异步方法callback方式 + // 无maxNum参数异步方法callback方式 try{ usageStatistics.queryModuleUsageRecords((err, res) => { if(err) { diff --git a/zh-cn/application-dev/device/sample-server-guidelines.md b/zh-cn/application-dev/device/sample-server-guidelines.md index 5e86789f8270c8ca37d232a9e3ea06a5d0bc0516..5f0d4cba664ac5e8b3218a7652fb485d03ba723f 100644 --- a/zh-cn/application-dev/device/sample-server-guidelines.md +++ b/zh-cn/application-dev/device/sample-server-guidelines.md @@ -175,7 +175,7 @@ "\"descriptPackageId\": \"abcdefg1234567ABCDEFG\"," "}]," "\"descriptInfo\": [{" - "\"descriptPackageId\": \"abcdefg1234567ABCDEFG\"," + "\"descriptionType\": 0," "\"content\": \"This package message is used for sampleContent\"" "}]" "}"; diff --git a/zh-cn/application-dev/device/sample-server-overview.md b/zh-cn/application-dev/device/sample-server-overview.md index 10d74586923c1c740d7709f2ebf6741880659a10..477c7f3da70bd874cbd6b4c949c0a53d6389d804 100644 --- a/zh-cn/application-dev/device/sample-server-overview.md +++ b/zh-cn/application-dev/device/sample-server-overview.md @@ -30,7 +30,7 @@ "descriptPackageId": "abcdefg1234567ABCDEFG" }], "descriptInfo": [{ - "descriptPackageId": "abcdefg1234567ABCDEFG", + "descriptionType": 0, "content": "This package is used for update." }] } diff --git a/zh-cn/application-dev/internationalization/intl-guidelines.md b/zh-cn/application-dev/internationalization/intl-guidelines.md index 585764dac20d89d1e7d5691bfa0a0e240c945f57..f1062d33423467bebafb95bfb218d21135d8e17d 100644 --- a/zh-cn/application-dev/internationalization/intl-guidelines.md +++ b/zh-cn/application-dev/internationalization/intl-guidelines.md @@ -41,7 +41,7 @@ ```js var locale = "zh-CN"; - var options = {caseFirst: false, calendar: "chinese", collation: "pinyin"}; + var options = {caseFirst: "false", calendar: "chinese", collation: "pinyin"}; var localeObj = new intl.Locale(locale, options); ``` @@ -324,4 +324,4 @@ -[`International`:国际化(JS)(API8)](https://gitee.com/openharmony/applications_app_samples/tree/master/UI/International) --[`International`:国际化(ArkTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/International) \ No newline at end of file +-[`International`:国际化(ArkTS)(API8)(Full SDK)](https://gitee.com/openharmony/applications_app_samples/tree/master/common/International) diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001266934142.png b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001266934142.png index 9d0e3aefa778fef8bb9237aeea3ecb3ef4bba01a..5c0064c082c774564b2f016810b73cba3bc4de31 100644 Binary files a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001266934142.png and b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001266934142.png differ diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001267573986.png b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001267573986.png index 1f8cfba17f6a99750d26bc8a4446fb6a1681c4e7..f07433811690c6949a3310d1c0cea6f0b58d8e30 100644 Binary files a/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001267573986.png and b/zh-cn/application-dev/key-features/multi-device-app-dev/figures/zh-cn_image_0000001267573986.png differ diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/start-with-a-example.md b/zh-cn/application-dev/key-features/multi-device-app-dev/start-with-a-example.md index d7416c1fb2ed844a5887f2efa642a65cbc549639..ec3fd3dbca88638bddc82cddfdacf92fa2348f78 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/start-with-a-example.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/start-with-a-example.md @@ -50,7 +50,7 @@ 如此,既在各设备上体现了UX的一致性,也在各设备上体现了UX的差异性,从而既可以保障各设备上应用界面的体验,也可以最大程度复用界面代码。 -在本文[应用UX设计章节](ux-design.md)中,将详细介绍应用的UX设计规则。 +在本文[应用UX设计章节](design-principles.md)中,将详细介绍应用的UX设计规则。 ## 工程管理及调试 @@ -271,3 +271,5 @@ struct Home { - 在使用特定系统能力前,通过canIUse接口判断系统能力是否存在,进而执行不同的逻辑。 在本文的[功能开发的一多能力介绍](development-intro.md)章节中,将详细展开介绍。 + + \ No newline at end of file diff --git a/zh-cn/application-dev/media/Readme-CN.md b/zh-cn/application-dev/media/Readme-CN.md index e1115fafee7fa9f5fb6fdfabb59b64bc17b10a36..dbbe0823c4f646dd8db29fee4c85f320e9a50cd1 100755 --- a/zh-cn/application-dev/media/Readme-CN.md +++ b/zh-cn/application-dev/media/Readme-CN.md @@ -10,6 +10,8 @@ - [OpenSL ES播放开发指导](opensles-playback.md) - [OpenSL ES录音开发指导](opensles-capture.md) - [音频焦点模式开发指导](audio-interruptmode.md) + - [音量管理开发指导](audio-volume-manager.md) + - [路由、设备管理开发指导](audio-routing-manager.md) - 视频 - [视频播放开发指导](video-playback.md) diff --git a/zh-cn/application-dev/media/image.md b/zh-cn/application-dev/media/image.md index 8d69c76aca22570ed3a875670be6d0c3496bfa74..e36f90f47891eed3165ef79156a622f348ef5814 100644 --- a/zh-cn/application-dev/media/image.md +++ b/zh-cn/application-dev/media/image.md @@ -96,7 +96,7 @@ pixelmap.writeBufferToPixels(writeColor).then(() => { }) // 用于获取图片信息 -pixelmap.getImageInfo( imageInfo => { +pixelmap.getImageInfo((error, imageInfo) => { if (imageInfo !== null) { console.log('Succeeded in getting imageInfo'); } @@ -171,17 +171,13 @@ catch(error => { }) // 用于获取像素每行字节数 -pixelmap.getBytesNumberPerRow( num => { - console.log('Succeeded in getting BytesNumber PerRow.'); -}) +var num = pixelmap.getBytesNumberPerRow(); // 用于获取像素总字节数 -pixelmap.getPixelBytesNumber(num => { - console.log('Succeeded in getting PixelBytesNumber.'); -}) +var pixelSize = pixelmap.getPixelBytesNumber(); // 用于获取pixelmap信息 -pixelmap.getImageInfo( imageInfo => {}) +pixelmap.getImageInfo().then( imageInfo => {}); // 用于释放pixelmap pixelmap.release(()=>{ @@ -229,7 +225,7 @@ imagePackerApi.packing(imageSourceApi, packOpts) imagePackerApi.release(); // 用于获取imagesource信息 -imageSourceApi.getImageInfo(imageInfo => { +imageSourceApi.getImageInfo((err, imageInfo) => { console.log('Succeeded in getting imageInfo'); }) @@ -249,8 +245,9 @@ public async init(surfaceId: any) { var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1); // 获取Surface ID - var surfaceId = await receiver.getReceivingSurfaceId(); - + receiver.getReceivingSurfaceId((err, surfaceId) => { + console.info("receiver getReceivingSurfaceId success"); + }); // 注册Surface的监听,在surface的buffer准备好后触发 receiver.on('imageArrival', () => { // 去获取Surface中最新的buffer diff --git a/zh-cn/application-dev/napi/Readme-CN.md b/zh-cn/application-dev/napi/Readme-CN.md index 99e16d5ce95c7c565a768d8d9df737bb98300fca..e6626f0373a002a6344fe7b8c934b99d9b7209b6 100644 --- a/zh-cn/application-dev/napi/Readme-CN.md +++ b/zh-cn/application-dev/napi/Readme-CN.md @@ -5,3 +5,4 @@ - [Rawfile开发指导](rawfile-guidelines.md) - [Window开发指导](native-window-guidelines.md) - [使用MindSpore Lite引擎进行模型推理](mindspore-lite-guidelines.md) +- [Neural Network Runtime对接AI推理框架开发指导](neural-network-runtime-guidelines.md) \ No newline at end of file diff --git a/zh-cn/application-dev/napi/figures/02.png b/zh-cn/application-dev/napi/figures/02.png new file mode 100644 index 0000000000000000000000000000000000000000..1e31c1ce7f4e93ed9bd2e8acda0facce7a9a00f7 Binary files /dev/null and b/zh-cn/application-dev/napi/figures/02.png differ diff --git a/zh-cn/application-dev/napi/neural-network-runtime-guidelines.md b/zh-cn/application-dev/napi/neural-network-runtime-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..d1db02f381152821b699ffcc3870081a46742641 --- /dev/null +++ b/zh-cn/application-dev/napi/neural-network-runtime-guidelines.md @@ -0,0 +1,491 @@ +# Neural Network Runtime对接AI推理框架开发指导 + +## 场景介绍 + +Neural Network Runtime作为AI推理引擎和加速芯片的桥梁,为AI推理引擎提供精简的Native接口,满足推理引擎通过加速芯片执行端到端推理的需求。 + +本文以图1展示的`Add`单算子模型为例,介绍Neural Network Runtime的开发流程。`Add`算子包含两个输入、一个参数和一个输出,其中的`activation`参数用于指定`Add`算子中激活函数的类型。 + +**图1** Add单算子网络示意图 +!["Add单算子网络示意图"](figures/02.png) + +## 环境准备 + +### 环境要求 + +Neural Network Runtime部件的环境要求如下: + +- 系统版本:OpenHarmony master分支。 +- 开发环境:Ubuntu 18.04及以上。 +- 接入设备:OpenHarmony定义的标准设备,并且系统中内置的硬件加速器驱动,已通过HDI接口对接Neural Network Runtime。 + +由于Neural Network Runtime通过OpenHarmony Native API对外开放,需要通过OpenHarmony的Native开发套件编译Neural Network Runtime应用。在社区的[每日构建](http://ci.openharmony.cn/dailys/dailybuilds)下载对应系统版本的ohos-sdk压缩包,从压缩包中提取对应平台的Native开发套件。以Linux为例,Native开发套件的压缩包命名为`native-linux-{版本号}.zip`。 + +### 环境搭建 + +1. 打开Ubuntu编译服务器的终端。 +2. 把下载好的Native开发套件压缩包拷贝至当前用户根目录下。 +3. 执行以下命令解压Native开发套件的压缩包。 +```shell +unzip native-linux-{版本号}.zip +``` + +解压缩后的内容如下(随版本迭代,目录下的内容可能发生变化,请以最新版本的Native API为准): +```text +native/ +├── build // 交叉编译工具链 +├── build-tools // 编译构建工具 +├── docs +├── llvm +├── nativeapi_syscap_config.json +├── ndk_system_capability.json +├── NOTICE.txt +├── oh-uni-package.json +└── sysroot // Native API头文件和库 +``` +## 接口说明 + +这里给出Neural Network Runtime开发流程中通用的接口,具体请见下列表格。 + +### 结构体 + +| 结构体名称 | 描述 | +| --------- | ---- | +| typedef struct OH_NNModel OH_NNModel | Neural Network Runtime的模型句柄,用于构造模型。 | +| typedef struct OH_NNCompilation OH_NNCompilation | Neural Network Runtime的编译器句柄,用于编译AI模型。 | +| typedef struct OH_NNExecutor OH_NNExecutor | Neural Network Runtime的执行器句柄,用于在指定设备上执行推理计算。 | + +### 模型构造相关接口 + +| 接口名称 | 描述 | +| ------- | --- | +| OH_NNModel_Construct() | 创建OH_NNModel类型的模型实例。 | +| OH_NN_ReturnCode OH_NNModel_AddTensor(OH_NNModel *model, const OH_NN_Tensor *tensor) | 向模型实例中添加张量。 | +| OH_NN_ReturnCode OH_NNModel_SetTensorData(OH_NNModel *model, uint32_t index, const void *dataBuffer, size_t length) | 设置张量的数值。 | +| OH_NN_ReturnCode OH_NNModel_AddOperation(OH_NNModel *model, OH_NN_OperationType op, const OH_NN_UInt32Array *paramIndices, const OH_NN_UInt32Array *inputIndices, const OH_NN_UInt32Array *outputIndices) | 向模型实例中添加算子。 | +| OH_NN_ReturnCode OH_NNModel_SpecifyInputsAndOutputs(OH_NNModel *model, const OH_NN_UInt32Array *inputIndices, const OH_NN_UInt32Array *outputIndices) | 指定模型的输入输出。 | +| OH_NN_ReturnCode OH_NNModel_Finish(OH_NNModel *model) | 完成模型构图。| +| void OH_NNModel_Destroy(OH_NNModel **model) | 释放模型实例。 | + +### 模型编译相关接口 + +| 接口名称 | 描述 | +| ------- | --- | +| OH_NNCompilation *OH_NNCompilation_Construct(const OH_NNModel *model) | 创建OH_NNCompilation类型的编译实例。 | +| OH_NN_ReturnCode OH_NNCompilation_SetDevice(OH_NNCompilation *compilation, size_t deviceID) | 指定模型编译和计算的硬件。 | +| OH_NN_ReturnCode OH_NNCompilation_SetCache(OH_NNCompilation *compilation, const char *cachePath, uint32_t version) | 设置编译后的模型缓存路径和缓存版本。 | +| OH_NN_ReturnCode OH_NNCompilation_Build(OH_NNCompilation *compilation) | 进行模型编译。 | +| void OH_NNCompilation_Destroy(OH_NNCompilation **compilation) | 释放OH_NNCompilation对象。 | + +### 执行推理相关接口 + +| 接口名称 | 描述 | +| ------- | --- | +| OH_NNExecutor *OH_NNExecutor_Construct(OH_NNCompilation *compilation) | 创建OH_NNExecutor类型的执行器实例。 | +| OH_NN_ReturnCode OH_NNExecutor_SetInput(OH_NNExecutor *executor, uint32_t inputIndex, const OH_NN_Tensor *tensor, const void *dataBuffer, size_t length) | 设置模型单个输入的数据。 | +| OH_NN_ReturnCode OH_NNExecutor_SetOutput(OH_NNExecutor *executor, uint32_t outputIndex, void *dataBuffer, size_t length) | 设置模型单个输出的缓冲区。 | +| OH_NN_ReturnCode OH_NNExecutor_Run(OH_NNExecutor *executor) | 执行推理。 | +| void OH_NNExecutor_Destroy(OH_NNExecutor **executor) | 销毁OH_NNExecutor实例,释放实例占用的内存。 | + +### 设备管理相关接口 + +| 接口名称 | 描述 | +| ------- | --- | +| OH_NN_ReturnCode OH_NNDevice_GetAllDevicesID(const size_t **allDevicesID, uint32_t *deviceCount) | 获取对接到 Neural Network Runtime 的硬件ID。 | + + +## 开发步骤 + +Neural Network Runtime的开发流程主要包含**模型构造**、**模型编译**和**推理执行**三个阶段。以下开发步骤以`Add`单算子模型为例,介绍调用Neural Network Runtime接口,开发应用的过程。 + +1. 创建应用样例文件。 + + 首先,创建Neural Network Runtime应用样例的源文件。在项目目录下执行以下命令,创建`nnrt_example/`目录,在目录下创建 `nnrt_example.cpp` 源文件。 + + ```shell + mkdir ~/nnrt_example && cd ~/nnrt_example + touch nnrt_example.cpp + ``` + +2. 导入Neural Network Runtime。 + + 在 `nnrt_example.cpp` 文件的开头添加以下代码,引入Neural Network Runtime模块。 + + ```cpp + #include + #include + #include + + #include "neural_network_runtime/neural_network_runtime.h" + + // 常量,用于指定输入、输出数据的字节长度 + const size_t DATA_LENGTH = 4 * 12; + ``` + +3. 构造模型。 + + 使用Neural Network Runtime接口,构造`Add`单算子样例模型。 + + ```cpp + OH_NN_ReturnCode BuildModel(OH_NNModel** pModel) + { + // 创建模型实例,进行模型构造 + OH_NNModel* model = OH_NNModel_Construct(); + if (model == nullptr) { + std::cout << "Create model failed." << std::endl; + return OH_NN_MEMORY_ERROR; + } + + // 添加Add算子的第一个输入Tensor,类型为float32,张量形状为[1, 2, 2, 3] + int32_t inputDims[4] = {1, 2, 2, 3}; + OH_NN_Tensor input1 = {OH_NN_FLOAT32, 4, inputDims, nullptr, OH_NN_TENSOR}; + OH_NN_ReturnCode ret = OH_NNModel_AddTensor(model, &input1); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, add Tensor of first input failed." << std::endl; + return ret; + } + + // 添加Add算子的第二个输入Tensor,类型为float32,张量形状为[1, 2, 2, 3] + OH_NN_Tensor input2 = {OH_NN_FLOAT32, 4, inputDims, nullptr, OH_NN_TENSOR}; + ret = OH_NNModel_AddTensor(model, &input2); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, add Tensor of second input failed." << std::endl; + return ret; + } + + // 添加Add算子的参数Tensor,该参数Tensor用于指定激活函数的类型,Tensor的数据类型为int8。 + int32_t activationDims = 1; + int8_t activationValue = OH_NN_FUSED_NONE; + OH_NN_Tensor activation = {OH_NN_INT8, 1, &activationDims, nullptr, OH_NN_ADD_ACTIVATIONTYPE}; + ret = OH_NNModel_AddTensor(model, &activation); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, add Tensor of activation failed." << std::endl; + return ret; + } + + // 将激活函数类型设置为OH_NN_FUSED_NONE,表示该算子不添加激活函数。 + ret = OH_NNModel_SetTensorData(model, 2, &activationValue, sizeof(int8_t)); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, set value of activation failed." << std::endl; + return ret; + } + + // 设置Add算子的输出,类型为float32,张量形状为[1, 2, 2, 3] + OH_NN_Tensor output = {OH_NN_FLOAT32, 4, inputDims, nullptr, OH_NN_TENSOR}; + ret = OH_NNModel_AddTensor(model, &output); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, add Tensor of output failed." << std::endl; + return ret; + } + + // 指定Add算子的输入、参数和输出索引 + uint32_t inputIndicesValues[2] = {0, 1}; + uint32_t paramIndicesValues = 2; + uint32_t outputIndicesValues = 3; + OH_NN_UInt32Array paramIndices = {¶mIndicesValues, 1}; + OH_NN_UInt32Array inputIndices = {inputIndicesValues, 2}; + OH_NN_UInt32Array outputIndices = {&outputIndicesValues, 1}; + + // 向模型实例添加Add算子 + ret = OH_NNModel_AddOperation(model, OH_NN_OPS_ADD, ¶mIndices, &inputIndices, &outputIndices); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, add operation failed." << std::endl; + return ret; + } + + // 设置模型实例的输入、输出索引 + ret = OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, specify inputs and outputs failed." << std::endl; + return ret; + } + + // 完成模型实例的构建 + ret = OH_NNModel_Finish(model); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed, error happened when finishing model construction." << std::endl; + return ret; + } + + *pModel = model; + return OH_NN_SUCCESS; + } + ``` + +4. 查询Neural Network Runtime已经对接的加速芯片。 + + Neural Network Runtime支持通过HDI接口,对接多种加速芯片。在执行模型编译前,需要查询当前设备下,Neural Network Runtime已经对接的加速芯片。每个加速芯片对应唯一的ID值,在编译阶段需要通过设备ID,指定模型编译的芯片。 + ```cpp + void GetAvailableDevices(std::vector& availableDevice) + { + availableDevice.clear(); + + // 获取可用的硬件ID + const size_t* devices = nullptr; + uint32_t deviceCount = 0; + OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(&devices, &deviceCount); + if (ret != OH_NN_SUCCESS) { + std::cout << "GetAllDevicesID failed, get no available device." << std::endl; + return; + } + + for (uint32_t i = 0; i < deviceCount; i++) { + availableDevice.emplace_back(devices[i]); + } + } + ``` + +5. 在指定的设备上编译模型。 + + Neural Network Runtime使用抽象的模型表达描述AI模型的拓扑结构,在加速芯片上执行前,需要通过Neural Network Runtime提供的编译模块,将抽象的模型表达下发至芯片驱动层,转换成可以直接推理计算的格式。 + ```cpp + OH_NN_ReturnCode CreateCompilation(OH_NNModel* model, const std::vector& availableDevice, OH_NNCompilation** pCompilation) + { + // 创建编译实例,用于将模型传递至底层硬件编译 + OH_NNCompilation* compilation = OH_NNCompilation_Construct(model); + if (compilation == nullptr) { + std::cout << "CreateCompilation failed, error happended when creating compilation." << std::endl; + return OH_NN_MEMORY_ERROR; + } + + // 设置编译的硬件、缓存路径、性能模式、计算优先级、是否开启float16低精度计算等选项 + + // 选择在第一个设备上编译模型 + OH_NN_ReturnCode ret = OH_NNCompilation_SetDevice(compilation, availableDevice[0]); + if (ret != OH_NN_SUCCESS) { + std::cout << "CreateCompilation failed, error happened when setting device." << std::endl; + return ret; + } + + // 将模型编译结果缓存在/data/local/tmp目录下,版本号指定为1 + ret = OH_NNCompilation_SetCache(compilation, "/data/local/tmp", 1); + if (ret != OH_NN_SUCCESS) { + std::cout << "CreateCompilation failed, error happened when setting cache path." << std::endl; + return ret; + } + + // 完成编译设置,进行模型编译 + ret = OH_NNCompilation_Build(compilation); + if (ret != OH_NN_SUCCESS) { + std::cout << "CreateCompilation failed, error happened when building compilation." << std::endl; + return ret; + } + + *pCompilation = compilation; + return OH_NN_SUCCESS; + } + ``` + +6. 创建执行器。 + + 完成模型编译后,需要调用Neural Network Runtime的执行模块,创建推理执行器。执行阶段,设置模型输入、获取模型输出和触发推理计算的操作均围绕执行器完成。 + ```cpp + OH_NNExecutor* CreateExecutor(OH_NNCompilation* compilation) + { + // 创建执行实例 + OH_NNExecutor* executor = OH_NNExecutor_Construct(compilation); + return executor; + } + ``` + +7. 执行推理计算,并打印计算结果。 + + 通过执行模块提供的接口,将推理计算所需要的输入数据传递给执行器,触发执行器完成一次推理计算,获取模型的推理计算结果。 + ```cpp + OH_NN_ReturnCode Run(OH_NNExecutor* executor) + { + // 构造示例数据 + float input1[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + float input2[12] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22}; + + int32_t inputDims[4] = {1, 2, 2, 3}; + OH_NN_Tensor inputTensor1 = {OH_NN_FLOAT32, 4, inputDims, nullptr, OH_NN_TENSOR}; + OH_NN_Tensor inputTensor2 = {OH_NN_FLOAT32, 4, inputDims, nullptr, OH_NN_TENSOR}; + + // 设置执行的输入 + + // 设置执行的第一个输入,输入数据由input1指定 + OH_NN_ReturnCode ret = OH_NNExecutor_SetInput(executor, 0, &inputTensor1, input1, DATA_LENGTH); + if (ret != OH_NN_SUCCESS) { + std::cout << "Run failed, error happened when setting first input." << std::endl; + return ret; + } + + // 设置执行的第二个输入,输入数据由input2指定 + ret = OH_NNExecutor_SetInput(executor, 1, &inputTensor2, input2, DATA_LENGTH); + if (ret != OH_NN_SUCCESS) { + std::cout << "Run failed, error happened when setting second input." << std::endl; + return ret; + } + + // 设置输出的数据缓冲区,OH_NNExecutor_Run执行计算后,输出结果将保留在output中 + float output[12]; + ret = OH_NNExecutor_SetOutput(executor, 0, output, DATA_LENGTH); + if (ret != OH_NN_SUCCESS) { + std::cout << "Run failed, error happened when setting output buffer." << std::endl; + return ret; + } + + // 执行计算 + ret = OH_NNExecutor_Run(executor); + if (ret != OH_NN_SUCCESS) { + std::cout << "Run failed, error doing execution." << std::endl; + return ret; + } + + // 打印输出结果 + for (uint32_t i = 0; i < 12; i++) { + std::cout << "Output index: " << i << ", value is: " << output[i] << "." << std::endl; + } + + return OH_NN_SUCCESS; + } + ``` + +8. 构建端到端模型构造-编译-执行流程。 + + 步骤3-步骤7实现了模型的模型构造、编译和执行流程,并封装成4个函数,便于模块化开发。以下示例代码将4个函数串联成完整的Neural Network Runtime开发流程。 + ```cpp + int main() + { + OH_NNModel* model = nullptr; + OH_NNCompilation* compilation = nullptr; + OH_NNExecutor* executor = nullptr; + std::vector availableDevices; + + // 模型构造阶段 + OH_NN_ReturnCode ret = BuildModel(&model); + if (ret != OH_NN_SUCCESS) { + std::cout << "BuildModel failed." << std::endl; + OH_NNModel_Destroy(&model); + return -1; + } + + // 获取可执行的设备 + GetAvailableDevices(availableDevices); + if (availableDevices.empty()) { + std::cout << "No available device." << std::endl; + OH_NNModel_Destroy(&model); + return -1; + } + + // 模型编译阶段 + ret = CreateCompilation(model, availableDevices, &compilation); + if (ret != OH_NN_SUCCESS) { + std::cout << "CreateCompilation failed." << std::endl; + OH_NNModel_Destroy(&model); + OH_NNCompilation_Destroy(&compilation); + return -1; + } + + // 创建模型的推理执行器 + executor = CreateExecutor(compilation); + if (executor == nullptr) { + std::cout << "CreateExecutor failed, no executor is created." << std::endl; + OH_NNModel_Destroy(&model); + OH_NNCompilation_Destroy(&compilation); + return -1; + } + + // 使用上一步创建的执行器,执行单步推理计算 + ret = Run(executor); + if (ret != OH_NN_SUCCESS) { + std::cout << "Run failed." << std::endl; + OH_NNModel_Destroy(&model); + OH_NNCompilation_Destroy(&compilation); + OH_NNExecutor_Destroy(&executor); + return -1; + } + + // 释放申请的资源 + OH_NNModel_Destroy(&model); + OH_NNCompilation_Destroy(&compilation); + OH_NNExecutor_Destroy(&executor); + + return 0; + } + ``` + +## 调测验证 + +1. 准备应用样例的编译配置文件。 + + 新建一个 `CMakeLists.txt` 文件,为开发步骤中的应用样例文件 `nnrt_example.cpp` 添加编译配置。以下提供简单的 `CMakeLists.txt` 示例: + ```text + cmake_minimum_required(VERSION 3.16) + project(nnrt_example C CXX) + + add_executable(nnrt_example + ./nnrt_example.cpp + ) + + target_link_libraries(nnrt_example + neural_network_runtime.z + ) + ``` + +2. 编译应用样例。 + + 执行以下命令,在当前目录下新建build/目录,在build/目录下编译 `nnrt_example.cpp`,得到二进制文件 `nnrt_example`。 + ```shell + mkdir build && cd build + cmake -DCMAKE_TOOLCHAIN_FILE={交叉编译工具链的路径}/build/cmake/ohos.toolchain.cmake -DOHOS_ARCH=arm64-v8a -DOHOS_PLATFORM=OHOS -DOHOS_STL=c++_static .. + make + ``` + +3. 执行以下代码,将样例推送到设备上执行。 + ```shell + # 将编译得到的 `nnrt_example` 推送到设备上,执行样例。 + hdc_std file send ./nnrt_example /data/local/tmp/. + + # 给测试用例可执行文件加上权限。 + hdc_std shell "chmod +x /data/local/tmp/nnrt_example" + + # 执行测试用例 + hdc_std shell "/data/local/tmp/nnrt_example" + ``` + + 如果样例执行正常,应该得到以下输出。 + ```text + Output index: 0, value is: 11.000000. + Output index: 1, value is: 13.000000. + Output index: 2, value is: 15.000000. + Output index: 3, value is: 17.000000. + Output index: 4, value is: 19.000000. + Output index: 5, value is: 21.000000. + Output index: 6, value is: 23.000000. + Output index: 7, value is: 25.000000. + Output index: 8, value is: 27.000000. + Output index: 9, value is: 29.000000. + Output index: 10, value is: 31.000000. + Output index: 11, value is: 33.000000. + ``` + +4. 检查模型缓存(可选)。 + + 如果在调测环境下,Neural Network Runtime对接的HDI服务支持模型缓存功能,执行完 `nnrt_example`, 可以在 `/data/local/tmp` 目录下找到生成的缓存文件。 + + > **说明:** + > + > 模型的IR需要传递到硬件驱动层,由HDI服务将统一的IR图,编译成硬件专用的计算图,编译的过程非常耗时。Neural Network Runtime支持计算图缓存的特性,可以将HDI服务编译生成的计算图,缓存到设备存储中。当下一次在同一个加速芯片上编译同一个模型时,通过指定缓存的路径,Neural Network Runtime可以直接加载缓存文件中的计算图,减少编译消耗的时间。 + + 检查缓存目录下的缓存文件: + ```shell + ls /data/local/tmp + ``` + + 以下为打印结果: + ```text + # 0.nncache cache_info.nncache + ``` + + 如果缓存不再使用,需要手动删除缓存,可以参考以下命令,删除缓存文件。 + ```shell + rm /data/local/tmp/*nncache + ``` + +## 相关实例 + +第三方AI推理框架对接Neural Network Runtime的流程,可以参考以下相关实例: +- [Tensorflow Lite接入NNRt Delegate开发指南](https://gitee.com/openharmony/neural_network_runtime/tree/master/example/deep_learning_framework) + diff --git a/zh-cn/application-dev/notification/notification-guidelines.md b/zh-cn/application-dev/notification/notification-guidelines.md index 8f2df9f689bd3ae019f779516c90ac121947fa60..5c2eb30a117305bb76b78f2337a525fe7dfe8945 100644 --- a/zh-cn/application-dev/notification/notification-guidelines.md +++ b/zh-cn/application-dev/notification/notification-guidelines.md @@ -133,7 +133,7 @@ var subscriber = { ##### 开启通知使能 -应用发布通知的使能开关默认是关闭的,所以应用发布通知前需要用户允许后才能发送。应用可以通过Notification.requestEnableNotification弹窗提醒用户允许发送通知。 +应用发布通知的使能开关默认是关闭的,需要通过下拉通知栏,在通知设置里打开通知开关。应用也可以通过调用Notification.requestEnableNotification接口,弹窗提示用户是否允许发送通知。 ```js Notification.requestEnableNotification().then((data) => { diff --git a/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md b/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md index 075dfa40213d997a7cd56171f729844e5d6656a2..8281cd8498043510f7539612e3026074c02842b3 100644 --- a/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md +++ b/zh-cn/application-dev/quick-start/arkts-restrictions-and-extensions.md @@ -111,14 +111,14 @@ struct IndexPage { 通过构造函数方法初始化成员变量,需要遵循如下规则: -| 从父组件中的变量(下)到子组件中的变量(右) | @State | @Link | @Prop | 常规变量 | -| ---------------------- | ------ | ----- | ----- | ---- | -| @State | 不允许 | 允许 | 允许 | 允许 | -| @Link | 不允许 | 允许 | 不推荐 | 允许 | -| @Prop | 不允许 | 不允许 | 允许 | 允许 | -| @StorageLink | 不允许 | 允许 | 不允许 | 允许 | -| @StorageProp | 不允许 | 不允许 | 不允许 | 允许 | -| 常规变量 | 允许 | 不允许 | 不允许 | 允许 | +| 从父组件中的变量(下)到子组件中的变量(右) | @State | @Link | @Prop | 常规变量 | +| -------------------------------------------- | ------ | ------ | ------ | -------- | +| @State | 不允许 | 允许 | 允许 | 允许 | +| @Link | 不允许 | 允许 | 不推荐 | 允许 | +| @Prop | 不允许 | 不允许 | 允许 | 允许 | +| @StorageLink | 不允许 | 允许 | 不允许 | 不允许 | +| @StorageProp | 不允许 | 不允许 | 不允许 | 允许 | +| 常规变量 | 允许 | 不允许 | 不允许 | 允许 | 从上表中可以看出: diff --git a/zh-cn/application-dev/quick-start/figures/alarm.png b/zh-cn/application-dev/quick-start/figures/alarm.png new file mode 100644 index 0000000000000000000000000000000000000000..f67efbb6671e08d02e91e9747f5d57f6b188cd66 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/alarm.png differ diff --git a/zh-cn/application-dev/quick-start/figures/alarmHand.png b/zh-cn/application-dev/quick-start/figures/alarmHand.png new file mode 100644 index 0000000000000000000000000000000000000000..b824a0de7c6de1769ad330e90c82a11da8e609eb Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/alarmHand.png differ diff --git a/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md b/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md index 127195c13996d901aca61941cf0cb0c6959d96de..2cd8fee3503ca7a0cc38a8e3d90fa3d7c51bada5 100644 --- a/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md +++ b/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md @@ -94,4 +94,23 @@ full-SDK需要手动下载。请参考[版本说明书](../../release-notes/Open c.验证系统API接口 - ![image-20220613213038104](figures/zh-cn_image_0000001655129372.png) \ No newline at end of file + ![image-20220613213038104](figures/zh-cn_image_0000001655129372.png) + +## 附录:MacOS安全告警处理 + +官网下载的full-SDK放到MacOS上的DevEcoStudio中替换后,打开预览器会出现告警 + +![alarm](figures/alarm.png) + +我们可以操作以下步骤来处理此问题: + +1.打开Terminal终端应用 + +2.在终端中输入命令:sudo spctl -- master - disable + +3.进入系统偏好设置中的[安全与隐私]面板中,打开"任何来源"选项 + +![alarmHand](figures/alarmHand.png) + +此时第三方源下载安装的软件就都不会被阻止执行了,为了安全起见,使用后建议将这里的"任何来源"的选项进行变更。 + diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index c51e7a2855d52515c947406c6c1cbe0d178f938b..7305b7d1bb55bbbdf62dea9c6d83268e7858c8f5 100755 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -12,9 +12,9 @@ | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------ | ------------------------------------------------------------ | -------- | ---------- | -| app | 标识应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 不可缺省 | -| deviceConfig | 标识应用在具体设备上的配置信息。参考[deviceconfig对象内部结构](#deviceconfig对象的内部结构)。 | 对象 | 不可缺省 | -| module | 标识HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象的内部结构](#module对象的内部结构)。 | 对象 | 不可缺省 | +| app | 标识应用的全局配置信息。同一个应用的不同HAP包的app配置必须保持一致。参考[app对象内部结构](#app对象内部结构)。 | 对象 | 不可缺省。 | +| deviceConfig | 标识应用在具体设备上的配置信息。参考[deviceConfig对象内部结构](#deviceconfig对象的内部结构)。 | 对象 | 不可缺省。 | +| module | 标识HAP包的配置信息。该标签下的配置只对当前HAP包生效。参考[module对象的内部结构](#module对象的内部结构)。 | 对象 | 不可缺省。 | config.json示例: @@ -88,26 +88,28 @@ app对象包含应用全局配置信息,内部结构说明参见表2。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------------- | ------------------------------------------------------------ | -------- | --------------------------- | -| bundleName | 标识应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。包名通常采用反向域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 不可缺省 | -| vendor | 标识对应用开发厂商的描述。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空 | +| bundleName | 标识应用的包名,用于标识应用的唯一性。包名是由字母、数字、下划线(_)和点号(.)组成的字符串,必须以字母开头。支持的字符串长度为7~127字节。包名通常采用反向域名形式表示(例如,"com.example.myapplication")。建议第一级为域名后缀"com",第二级为厂商/个人名,也可以采用多级。 | 字符串 | 不可缺省。 | +| vendor | 标识对应用开发厂商的描述。字符串长度不超过255字节。 | 字符串 | 可缺省,缺省值为空。 | | version | 标识应用的版本信息。参考表3。 | 对象 | 否 | -| apiVersion | 标识应用程序所依赖的OpenHarmony API版本。参考表4。 | 对象 | 可缺省,缺省值为空 | +| apiVersion | 标识应用程序所依赖的OpenHarmony API版本。参考表4。 | 对象 | 可缺省,缺省值为空。 | +| smartWindowSize | 标识应用在模拟器中运行时使用的屏幕尺寸。 | 字符串 | 可缺省,缺省值为空。 | +| smartWindowDeviceType | 标识应用在模拟器中运行时可以模拟的设备。 | 字符串数组 | 可缺省,缺省值为空。 | 表3 version内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------------ | ------------------------------------------------------------ | -------- | -------------------------- | -| name | 标识应用的版本号,用于向应用的终端用户呈现。取值可以自定义,长度不超过127字节。自定义规则如下:
API5及更早的版本:推荐使用三段数字版本号(也兼容两段式版本号),如A.B.C(也兼容A.B),其中A、B、C取值为0-999范围内的整数。除此之外不支持其他格式。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示修订版本号(Patch)。
API6版本起:推荐采用四段式数字版本号,如A.B.C.D,其中A、B、C取值为0-99范围内的整数,D的取值为0-999范围内的整数。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示特性版本号(Feature)。
D段,一般表示修订版本号(Patch)。 | 数值 | 不可缺省 | -| code | 标识应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31以内的非负整数,但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省 | -| minCompatibleVersionCode | 标识应用可兼容的最低版本号,用于跨设备场景下,判断其他设备上该应用的版本是否兼容。
格式与version.code字段的格式要求相同。 | 数值 | 可缺省,缺省值为code标签值 | +| name | 标识应用的版本号,用于向应用的终端用户呈现。取值可以自定义,长度不超过127字节。自定义规则如下:
API5及更早的版本:推荐使用三段数字版本号(也兼容两段式版本号),如A.B.C(也兼容A.B),其中A、B、C取值为0-999范围内的整数。除此之外不支持其他格式。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示修订版本号(Patch)。
API6版本起:推荐采用四段式数字版本号,如A.B.C.D,其中A、B、C取值为0-99范围内的整数,D的取值为0-999范围内的整数。
A段,一般表示主版本号(Major)。
B段,一般表示次版本号(Minor)。
C段,一般表示特性版本号(Feature)。
D段,一般表示修订版本号(Patch)。 | 数值 | 不可缺省。 | +| code | 标识应用的版本号,仅用于OpenHarmony管理该应用,不对应用的终端用户呈现。取值规则如下:
API5及更早版本:二进制32位以内的非负整数,需要从version.name的值转换得到。转换规则为:
code值=A * 1,000,000 + B * 1,000 + C 例如,version.name字段取值为2.2.1,则code值为2002001。
API6版本起:code的取值不与version.name字段的取值关联,开发者可自定义code取值,取值范围为2^31以内的非负整数,但是每次应用版本的更新,均需要更新code字段的值,新版本code取值必须大于旧版本code的值。 | 数值 | 不可缺省。 | +| minCompatibleVersionCode | 标识应用可兼容的最低版本号,用于跨设备场景下,判断其他设备上该应用的版本是否兼容。
格式与version.code字段的格式要求相同。 | 数值 | 可缺省,缺省值为code标签值。 | 表4 apiVersion内部结构 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------- | ----------------------------------------------------------- | -------- | ---------- | -| compatible | 运行应用所需要的最低API版本,取值范围为0~2147483647。 | 整数 | 可缺省 | -| target | 用于标识应用运行所需的目标API版本,取值范围为0~2147483647。 | 整数 | 可缺省 | -| releaseType | 用于标识应用运行所需的目标API版本的类型。 | 字符串 | 可缺省 | +| compatible | 运行应用所需要的最低API版本,取值范围为0~2147483647。 | 数值 | 配置在build.profile中,打包时由IDE填充到config.json中。 | +| target | 用于标识应用运行所需的目标API版本,取值范围为0~2147483647。 | 数值 | 配置在build.profile中,打包时由IDE填充到config.json中。 | +| releaseType | 用于标识应用运行所需的目标API版本的类型。 | 字符串 | 配置在build.profile中,打包时由IDE填充到config.json中。 | app实例: @@ -116,12 +118,12 @@ app实例: "bundleName": "com.example.myapplication", "vendor": "example", "version": { - "code": 1, - "name": "1.0" + "code": 8, + "name": "8.0.1" }, "apiVersion": { - "compatible": 4, - "target": 5, + "compatible": 8, + "target": 9, "releaseType": "Beta1" } } @@ -129,60 +131,44 @@ app实例: ### deviceConfig对象的内部结构 -deviceConfig包含设备上的应用配置信息,可以包含default,tv,car,wearable等属性。default标签内的配置是适用于所有通用设备,其他设备类型如果有特殊的需求,则需要在该设备类型的标签下进行配置。内部结构说明参见表5。 +deviceConfig包含设备上的应用配置信息,可以包含default,tv,car,wearable等属性。default标签内的配置适用于所有通用设备,其他设备类型如果有特殊的需求,则需要在该设备类型的标签下进行配置。内部结构说明参见表5。 表5 deviceConfig对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ----------------------------------------- | -------- | ------------------ | -| default | 标识所有设备通用的应用配置信息。参考表6。 | 对象 | 否 | -| tablet | 标识平板的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | -| tv | 标识智慧屏特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | -| car | 标识车机特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | -| wearable | 标识智能穿戴特有的应用配置信息。参考表6。 | 对象 | 可缺省,缺省值为空 | +| default | 能够使用全部系统能力的OpenHarmony设备。 | 对象 | 可缺省,缺省值为空。 | +| tablet | 标识平板的应用配置信息。 | 对象 | 可缺省,缺省值为空。 | +| tv | 标识智慧屏特有的应用配置信息。 | 对象 | 可缺省,缺省值为空。 | +| car | 标识车机特有的应用配置信息。 | 对象 | 可缺省,缺省值为空。 | +| wearable | 标识智能穿戴特有的应用配置信息。| 对象 | 可缺省,缺省值为空。 | -default、tablet、tv、car、wearable等对象的内部结构说明,可参见表6。 +default、tablet、tv、car、wearable等对象的内部结构说明如下: -表6 不同设备的内部结构说明 +表6 deviceConfig设备对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------ | ------------------------------------------------------------ | -------- | ----------------------- | -| process | 标识应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于默认设备、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 是 | -| keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。该标签为布尔类型,可缺省,缺省值为false,如果配置为true,应用将始终保持为运行状态,并在系统启动的时候被系统驱动起来,应用进程退出后,系统也会重新启动应用进程。 | 布尔值 | 可缺省,缺省值为false | -| supportBackup | 标识应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"false" | -| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为"true" | -| directLaunch | 指定设备被锁定时是否可以启动应用程序。如果要在不解锁设备的情况下启动应用程序,请将此设备设置为"true"。运行OHOS的设备不支持此属性。 | 布尔值 | 可缺省,缺省值为"false" | -| ark | 标识maple配置信息。参考表7。 | 对象 | 可缺省,缺省为空。 | -| network | 标识网络安全性配置。该标签允许应用通过配置文件的安全声明来自定义其网络安全,无需修改应用代码。参考表9。 | 对象 | 可缺省,缺省值为空 | +| process | 标识应用或者Ability的进程名。如果在deviceConfig标签下配置了process标签,则该应用的所有Ability都运行在这个进程中。如果在abilities标签下也为某个Ability配置了process标签,则该Ability就运行在这个进程中。该标签仅适用于默认设备、平板、智慧屏、车机、智慧穿戴。该标签最大长度为31。 | 字符串 | 可缺省,缺省值为空。 | +| keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。该标签为布尔类型,可缺省,缺省值为false,如果配置为true,应用将始终保持为运行状态,并在系统启动的时候被系统驱动起来,应用进程退出后,系统也会重新启动应用进程。 | 布尔值 | 可缺省,缺省值为false。 | +| supportBackup | 标识应用是否支持备份和恢复。如果配置为"false",则不支持为该应用执行备份或恢复操作。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为false。 | +| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP包。如果配置为"false",则libs库以不压缩的方式存储,HAP包在安装时无需解压libs,运行时会直接从HAP内加载libs库。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为false。 | +| network | 标识网络安全性配置。该标签允许应用通过配置文件的安全声明来自定义其网络安全,无需修改应用代码。参考表7。 | 对象 | 可缺省,缺省值为空。 | -表7 ark对象的内部结构说明· - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | -------------------------------- | -------- | ------------------------------ | -| reqVersion | 支持应用的maple版本号。参考表8。 | 对象 | 不可缺省 | -| flag | 指定maple应用程序的类型。 | 字符串 | 不可缺省且只能为"m","mo","z" | - -表8 reqVersion对象内部结构说明 - -| 属性名称 | 含义 | 数据类型 | 是否可缺省 | -| ---------- | --------------------------------------------------------- | -------- | ---------- | -| compatible | 标识支持应用程序的最低maple版本,采用32位无符号整形表示。 | 整数 | 不可缺省 | -| target | 指定maple应用程序的类型,采用32位无符号整形表示。 | 整数 | 不可缺省 | - -表9 network对象的内部结构说明 +表7 network对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | -------- | ----------------------- | -| cleartextTraffic | 标识是否允许应用使用明文网络流量(例如,明文HTTP)。
true:允许应用使用明文流量请求。
false:拒绝应用使用明文流量的请求。 | 布尔值 | 可缺省,缺省值为"false" | -| securityConfig | 标识应用的网络安全配置信息。参考表10。 | 对象 | 可缺省,缺省为空 | +| cleartextTraffic | 标识是否允许应用使用明文网络流量(例如,明文HTTP)。
true:允许应用使用明文流量请求。
false:拒绝应用使用明文流量的请求。 | 布尔值 | 可缺省,缺省值为false。 | +| securityConfig | 标识应用的网络安全配置信息。参考表8。 | 对象 | 可缺省,缺省值为空。 | -表10 securityConfig对象的内部结构说明 +表8 securityConfig对象的内部结构说明 | 属性名称 | 子属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------------- | ------------------ | ------------------------------------------------------------ | -------- | ---------------- | -| domainSettings | - | 标识自定义的网域范围的安全配置,支持多层嵌套,即一个domainSettings对象中允许嵌套更小网域范围的domainSettings对象。 | 对象类型 | 可缺省,缺省为空 | -| | cleartextPermitted | 标识自定义的网域范围内是否允许明文流量传输。当cleartextTraffic和security同时存在时,自定义网域是否允许明文流量传输以cleartextPermitted的取值为准。
true:允许明文流量传输。
false:拒绝明文流量传输。 | 布尔类型 | 不可缺省 | -| | domains | 标识域名配置信息,包含两个参数:subdomains和name。
subdomains(布尔类型):表示是否包含子域名。如果为"true",此网域规则将与相应网域及所有子网域(包括子网域的子网域)匹配。否则,该规则仅适用于精确匹配项。
name(字符串):表示域名名称。 | 对象数组 | 不可缺省 | +| domainSettings | - | 标识自定义的网域范围的安全配置,支持多层嵌套,即一个domainSettings对象中允许嵌套更小网域范围的domainSettings对象。 | 对象 | 可缺省,缺省值为空。 | +| | cleartextPermitted | 标识自定义的网域范围内是否允许明文流量传输。当cleartextTraffic和security同时存在时,自定义网域是否允许明文流量传输以cleartextPermitted的取值为准。
true:允许明文流量传输。
false:拒绝明文流量传输。 | 布尔值 | 可缺省,缺省值为空。 | +| | domains | 标识域名配置信息,包含两个参数:subdomains和name。
subdomains(布尔类型):表示是否包含子域名。如果为"true",此网域规则将与相应网域及所有子网域(包括子网域的子网域)匹配。否则,该规则仅适用于精确匹配项。
name(字符串):表示域名名称。 | 对象数组 | 可缺省,缺省值为空。 | deviceConfig示例: @@ -211,31 +197,29 @@ deviceConfig示例: ### module对象的内部结构 -module对象包含HAP包的配置信息,内部结构说明参见表11。 +module对象包含HAP包的配置信息,内部结构说明参见表9。 -表11 module对象的内部结构说明 +表9 module对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------------- | ------------------------------------------------------------ | ---------- | ------------------------------------------------------------ | -| mainAbility | 服务中心图标露出的ability,常驻进程拉起时会启动mainAbility。 | 字符串 | 如果存在page类型的ability,则该字段不可缺省。 | -| package | 标识HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度不超过127字节。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 不可缺省 | -| name | 标识HAP的类名。采用反向域名 方式标识,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 不可缺省 | -| description | 标识HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空 | -| supportedModes | 标识应用支持的运行模式,当前只定义了驾驶模式(drive)。该标签只适用于车机。 | 字符串数组 | 可缺省,缺省值为空 | -| deviceType | 标识允许Ability运行的设备类型。系统预定义的设备类型包括:tablet(平板)、tv(智慧屏)、car(车机)、wearable(智能穿戴)等。 | 字符串数组 | 不可缺省 | -| distro | 标识HAP发布的具体描述。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表12。 | 对象 | 不可缺省 | -| metaData | 标识HAP的元信息。参考表13。 | 对象 | 可缺省,缺省值为空 | -| abilities | 标识当前模块内的所有Ability。采用对象数据格式。其中的每个元素表示一个快捷方式对象。参考表17。 | 对象数组 | 可缺省,缺省值为空 | -| js | 标识基于ArkUI框架开发的JS模块集合,其中的每个元素代表一个JS模块的信息。参考表22。 | 对象数组 | 可缺省,缺省值为空 | -| shortcuts | 标识应用的快捷方式信息。采用对象数组格式,其中的每个元素表示一个快捷方式对象。参考表25。 | 对象数组 | 可缺省,缺省值为空 | -| reqPermissions | 标识应用运行时向系统申请的权限。参考表21。 | 对象数组 | 可缺省,缺省值为空 | -| colorMode | 标识应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto" | -| distroFilter | 标识应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Version、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表29。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | -| reqCapabilities | 标识运行应用程序所需的设备能力 | 字符串数组 | 可缺省,缺省为空 | -| commonEvents | 静态广播,参考表35。 | 对象数组 | 可缺省,缺省为空 | -| entryTheme | 此标签标识OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引。 | 字符串 | 可缺省,缺省值为空 | -| testRunner | 此标签用于支持对测试框架的配置,参考表36。 | 对象 | 可缺省,缺省值为空 | -| definePermissions | 标识hap定义的权限,仅支持系统应用配置,三方应用配置不生效。该应用的调用者必须申请这些权限才能正常调用该应用,参考表37。 | 对象 | 可缺省,缺省值为空 | +| mainAbility | 服务中心图标露出的ability,常驻进程拉起时会启动mainAbility。 | 字符串 | 可缺省,缺省值为空。 | +| package | 标识HAP的包结构名称,在应用内保证唯一性。采用反向域名格式(建议与HAP的工程目录保持一致)。字符串长度为1-127个字节。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 不可缺省。 | +| name | 标识HAP的类名。采用反向域名方式标识,前缀要与同级的package标签指定的包名一致,也可采用"."开头的命名方式。字符串长度不超过255字节。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| description | 标识HAP的描述信息。字符串长度不超过255字节。如果字符串超出长度或者需要支持多语言,可以采用资源索引的方式添加描述内容。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| supportedModes | 标识应用支持的运行模式,当前只定义了驾驶模式(drive)。该标签只适用于车机。 | 字符串数组 | 可缺省,缺省值为空。 | +| deviceType | 标识允许Ability运行的设备类型。系统预定义的设备类型包括:tablet(平板)、tv(智慧屏)、car(车机)、wearable(智能穿戴)等。 | 字符串数组 | 不可缺省。 | +| distro | 标识HAP发布的具体描述。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表10。 | 对象 | 不可缺省。 | +| metaData | 标识HAP的元信息。参考表11。 | 对象 | 可缺省,缺省值为空。 | +| abilities | 标识当前模块内的所有Ability。采用对象数据格式。参考表15。 | 对象数组 | 可缺省,缺省值为空。 | +| js | 标识基于ArkUI框架开发的JS模块集合,其中的每个元素代表一个JS模块的信息。参考表21。 | 对象数组 | 可缺省,缺省值为空。 | +| shortcuts | 标识应用的快捷方式信息。采用对象数组格式,其中的每个元素表示一个快捷方式对象。参考表24。 | 对象数组 | 可缺省,缺省值为空。 | +| reqPermissions | 标识应用运行时向系统申请的权限。参考表19。 | 对象数组 | 可缺省,缺省值为空。 | +| colorMode | 标识应用自身的颜色模式。
dark:表示按照深色模式选取资源。
light:表示按照浅色模式选取资源。
auto:表示跟随系统的颜色模式值选取资源。
该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"auto"。 | +| distroFilter | 标识应用的分发规则。
该标签用于定义HAP包对应的细分设备规格的分发策略,以便在应用市场进行云端分发应用包时做精准匹配。该标签可配置的分发策略维度包括API Version、屏幕形状、屏幕分辨率。在进行分发时,通过deviceType与这三个属性的匹配关系,唯一确定一个用于分发到设备的HAP。参考表28。 | 对象 | 可缺省,缺省值为空。但当应用中包含多个entry模块时,必须配置该标签。 | +| commonEvents | 定义了公共事件静态订阅者的信息,该字段中需要声明静态订阅者的名称、权限要求及订阅事件列表信息,当订阅的公共事件发送时,该公共事件静态订阅者将被拉起。这里的静态订阅者区分于常用的动态订阅者,前者无需在业务代码中主动调用订阅事件的接口,在公共事件发布时可能未被拉起,而动态订阅者则在业务代码中主动调用公共事件订阅的相关API,因此需要应用处于活动状态。参考表34。 | 对象数组 | 可缺省,缺省值为空。 | +| entryTheme | 此标签标识OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引。 | 字符串 | 可缺省,缺省值为空。 | +| testRunner | 此标签用于支持对测试框架的配置,参考表35。 | 对象 | 可缺省,缺省值为空。 | module示例: @@ -271,14 +255,14 @@ module示例: } ``` -表12 distro对象的内部结构说明 +表10 distro对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | -------- | ---------- | -| moduleName | 标识当前HAP的名称,最大长度为31。 | 字符串 | 不可缺省 | -| moduleType | 标识当前HAP的类型,包括两种类型:entry和feature。另外,如果表示HAR类型,请设置为har。 | 字符串 | 不可缺省 | -| installationFree | 标识当前HAP是否支持免安装特性。
true:表示支持免安装特性,且符合免安装约束。
false:表示不支持免安装特性。
另外还需注意:
当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为true。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务 需求配置true或false。 | 布尔值 | 不可缺省 | -| deliveryWithInstall | 标识当前HAP是否支持随应用安装。
true: 支持随应用安装。
false:不支持随应用安装。| 布尔值 | 不可缺省 | +| moduleName | 标识当前HAP的名称,最大长度为31个字节。 | 字符串 | 不可缺省。 | +| moduleType | 标识当前HAP的类型,包括三种类型:entry、feature和har。 | 字符串 | 不可缺省。 | +| installationFree | 标识当前HAP是否支持免安装特性。
true:表示支持免安装特性,且符合免安装约束。
false:表示不支持免安装特性。
另外还需注意:
当entry.hap该字段配置为true时,与该entry.hap相关的所有feature.hap该字段也需要配置为true。
当entry.hap该字段配置为false时,与该entry.hap相关的各feature.hap该字段可按业务 需求配置true或false。 | 布尔值 | 不可缺省。 | +| deliveryWithInstall | 标识当前HAP是否在用户主动安装HAP所在应用的时候一起安装。
true:安装应用时当前HAP随应用一起下载安装。
false:安装应用时当前HAP并不下载安装,后续使用时按需下载。| 布尔值 | 不可缺省。 | distro示例: @@ -291,31 +275,31 @@ distro示例: } ``` -表13 metaData对象的内部结构说明 +表11 metaData对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------- | ------------------------------------------------------------ | -------- | -------------------- | -| parameters | 标识调用Ability时所有调用参数的元信息。每个调用参数的元信息由以下三个标签组成:description、name、type。参考表14。 | 对象数组 | 可缺省,缺省值为空 | -| results | 标识Ability返回值的元信息。每个返回值的元信息由以下三个标签组成:description、name、type。参考表15。 | 对象数组 | 可缺省,缺省值为空。 | -| customizeData | 该标签标识父级组件的自定义元信息,Parameters和results在application不可配。参考表16 | 对象数组 | 可缺省,缺省值为空。 | +| parameters | 标识调用Ability时所有调用参数的元信息。每个调用参数的元信息由以下三个标签组成:description、name、type。参考表12。 | 对象数组 | 可缺省,缺省值为空。 | +| results | 标识Ability返回值的元信息。每个返回值的元信息由以下三个标签组成:description、name、type。参考表13。 | 对象数组 | 可缺省,缺省值为空。 | +| customizeData | 该标签标识父级组件的自定义元信息,Parameters和results在application不可配。参考表14 | 对象数组 | 可缺省,缺省值为空。 | -表14 parameters对象的内部结构说明 +表12 parameters对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | ------------------ | -| description | 标识对调用参数的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空 | -| name | 标识调用参数的名称。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空 | -| type | 标识调用参数的类型,如Integer。 | 字符串 | 不可缺省 | +| description | 标识对调用参数的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | +| name | 标识调用参数的名称。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | +| type | 标识调用参数的类型,如Integer。 | 字符串 | 不可缺省。 | -表15 results对象的内部结构说明 +表13 results对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------- | ------------------------------------------------------------ | -------- | -------------------- | -| description | 标识对返回值的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | -| name | 标识返回值的名字。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | -| type | 标识返回值的类型,如Integer。 | 字符串 | 不可缺省 | +| description | 标识对返回值的描述,可以是表示描述内容的字符串,也可以是对描述内容的资源索引以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | +| name | 标识返回值的名字。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | +| type | 标识返回值的类型,如Integer。 | 字符串 | 不可缺省。 | -表16 customizeData对象的内部结构说明 +表14 customizeData对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ---------------------------------------------------------- | -------- | -------------------- | @@ -345,48 +329,46 @@ metaData示例: } ``` -表17 abilities对象的内部结构说明 +表15 abilities对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------------- | ------------------------------------------------------------ | ---------- | -------------------------------------------------------- | -| process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。运行OHOS的设备不支持此属性。 | 字符串 | 可缺省,缺省值为空。 | -| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,即“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 不可缺省 | -| description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | +| process | 运行应用程序或Ability的进程名称。如果在deviceConfig标记中配置了进程,则应用程序的所有能力都在此进程中运行。您还可以为特定能力设置流程属性,以便该能力可以在此流程中运行。如果此属性设置为与其他应用程序相同的进程名称,则所有这些应用程序可以在同一进程中运行,前提是他们具有相同的联合用户ID和相同的签名。运行OHOS的设备不支持此属性。该标签最大字节数为31个字节。 | 字符串 | 可缺省,缺省值为空。 | +| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如“com.example.myapplication.MainAbility”;也可采用“.”开头的类名方式表示,如“.MainAbility”。
Ability的名称,需在一个应用的范围内保证唯一。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。
说明:在使用DevEco Studio新建项目时,默认生成首个Ability的配置,即“config.json”中“MainAbility”的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127。 | 字符串 | 不可缺省。 | +| description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | | icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。
说明:应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | | label | 标识Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 “action.system.home”,entities取值中包含“entity.system.home”,则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。
说明: 应用的“icon”和“label”是用户可感知配置项,需要区别于当前所有已有的应用“icon”或“label”(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255。 | 字符串 | 可缺省,缺省值为空。 | | uri | 标识Ability的统一资源标识符。该标签最大长度为255。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | | launchType | 标识Ability的启动模式,支持“standard”和“singleton”两种模式:
standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“singleton”。 | -| visible | 标识Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为“false”。 | +| visible | 标识Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔值 | 可缺省,缺省值为“false”。 | | permissions | 标识其他应用的Ability调用此Ability时需要申请的权限集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | | skills | 标识Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 | -| deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。 | 字符串数组 | 可缺省,缺省值为空。 | -| metaData | 元数据,参考表13。 | 对象 | 可缺省,缺省值为空。 | -| type | 标识Ability的类型。取值范围如下:
page:表示基于Page模板开发的FA,用于提供与用户交互的能力。
service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。
data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问抽象。
CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 不可缺省 | +| deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。该标签为数组,支持最多配置512个元素,单个元素最大字节长度为64。 | 字符串数组 | 可缺省,缺省值为空。 | +| metaData | 元数据,参考表11。 | 对象 | 可缺省,缺省值为空。 | +| type | 标识Ability的类型。取值范围如下:
page:表示基于Page模板开发的FA,用于提供与用户交互的能力。
service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。
data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问抽象。
CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 不可缺省。 | | orientation | 标识该Ability的显示模式。该标签仅适用于page类型的Ability。取值范围如下:
unspecified:由系统自动判断显示方向。
landscape:横屏模式。
portrait:竖屏模式。
followRecent:跟随栈中最近的应用。 | 字符串 | 可缺省,缺省值为“unspecified”。 | | backgroundModes | 标识后台服务的类型,可以为一个服务配置多个后台服务类型。该标签仅适用于service类型的Ability。取值范围如下:
dataTransfer:通过网络/对端设备进行数据下载、备份、分享、传输等业务。
audioPlayback:音频输出业务。
audioRecording:音频输入业务。
pictureInPicture:画中画、小窗口播放视频业务。
voip:音视频电话、VOIP业务。
location:定位、导航业务。
bluetoothInteraction:蓝牙扫描、连接、传输业务。
wifiInteraction:WLAN扫描、连接、传输业务。
screenFetch:录屏、截屏业务。
multiDeviceConnection:多设备互联业务 | 字符串数组 | 可缺省,缺省值为空。 | | grantPermission | 指定是否可以向Ability内任何数据授予权限。 | 布尔值 | 可缺省,缺省值为空。 | -| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | -| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为空。 | -| configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:
mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。
mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。
locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。
layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。
fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。
orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。
density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。
size:显示窗口大小发生变更。
smallestSize:显示窗口较短边的边长发生变更。
colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省为空。 | +| readPermission | 标识读取Ability的数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。 | +| configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:
mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。
mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。
locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。
layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。
fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。
orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。
density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。
size:显示窗口大小发生变更。
smallestSize:显示窗口较短边的边长发生变更。
colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省值为空。 | | mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省为应用的包名。 | | targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其它属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | -| multiUserShared | 标识Ability是否支持多用户状态进行共享,该标签仅适用于data类型的Ability。配置为“true”时,表示在多用户下只有一份存储数据。需要注意的是,该属性会使visible属性失效。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为“false”。 | -| supportPipMode | 标识Ability是否支持用户进入PIP模式(用于在页面最上层悬浮小窗口,俗称“画中画”,常见于视频播放等场景)。该标签仅适用于page类型的Ability。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 布尔值 | 可缺省,缺省值为“false”。 | | formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。
true:支持卡片能力。
false:不支持卡片能力。 | 布尔值 | 可缺省,缺省值为“false”。 | -| forms | 标识服务卡片的属性。该标签仅当formsEnabled为“true”时,才能生效。参考表27。 | 对象数组 | 可缺省,缺省值为空。 | -| srcLanguage | Ability开发语言的类型。 | 字符串 | 可缺省,取值为js或ets | -| srcPath | 该标签标识Ability对应的JS组件代码路径 | 字符串 | 可缺省,缺省值为空。 | -| uriPermission | 标识该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。运行OHOS的设备不支持此属性。参考表18。 | 对象 | 可缺省,缺省值为空。 | +| forms | 标识服务卡片的属性。该标签仅当formsEnabled为“true”时,才能生效。参考表26。 | 对象数组 | 可缺省,缺省值为空。 | +| srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,取值为js或ets | +| srcPath | 该标签标识Ability对应的JS组件代码路径,该标签最大长度为127字节。 | 字符串 | 可缺省,缺省值为空。 | +| uriPermission | 标识该Ability有权访问的应用程序数据。此属性由模式和路径子属性组成。此属性仅对类型提供者的能力有效。运行OHOS的设备不支持此属性。参考表16。 | 对象 | 可缺省,缺省值为空。 | | startWindowIcon | 标识该Ability启动页面图标资源文件的索引。该标签仅适用于page类型的ability。取值示例:$media:icon。 | 字符串 | 可缺省,缺省值为空。| | startWindowBackground | 标识该Ability启动页面背景颜色资源文件的索引。该标签仅适用于page类型的ability。取值示例:$color:red。 | 字符串 | 可缺省,缺省值为空。| | removeMissionAfterTerminate | 该标签标识ability销毁后是否从任务列表中移除任务。该标签仅适用于page类型的ability。true表示销毁后移除任务, false表示销毁后不移除任务。 | 布尔值 | 可缺省,缺省值为false。 | -表18 uriPermission对象的内部结构说明 +表16 uriPermission对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ----------------------- | -------- | ------------------------- | -| path | uriPermission标识的路径 | 字符串 | 不可缺省 | -| mode | uriPeimission的匹配模式 | 字符串 | 可缺省,缺省值为default。 | +| path | uriPermission标识的路径,该标签最大字节长度为255个字节。 | 字符串 | 不可缺省。 | +| mode | uriPermission的匹配模式 | 字符串 | 可缺省,缺省值为default。 | abilities示例: @@ -455,15 +437,15 @@ abilities示例: ] ``` -表19 skills对象的内部结构说明 +表17 skills对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | | actions | 标识能够接收的want的action值,可以包含一个或多个action。取值通常为系统预定义的action值。 | 字符串数组 | 可缺省,缺省值为空。 | | entities | 标识能够接收的want的Ability的类别(如视频、桌面应用等),可以包含一个或多个entity。 | 字符串数组 | 可缺省,缺省值为空。 | -| uris | 标识能够接收的want的uri,可以包含一个或者多个uri。参考表20。 | 对象数组 | 可缺省,缺省值为空。 | +| uris | 该标签标识向want过滤器添加数据规范集合。该规范可以是只有数据类型(mimeType属性),可以是只有URI,也可以是既有数据类型又有URI。URI由其各个部分的单独属性指定:\://\:\/[\\|\\|\]。其中,scheme字段配置为uri时必配;当只设置数据类型(mimeType)时,则scheme字段为非必配项。参考表18。 | 对象数组 | 可缺省,缺省值为空。 | -表20 uris对象的内部结构说明 +表18 uris对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------- | -------------------------- | -------- | -------------------- | @@ -499,38 +481,45 @@ skills示例: ] ``` -表21 reqPermissions权限申请字段说明 +表19 reqPermissions权限申请字段说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | -| name | 需要使用的权限名称。 | 字符串 | 否 | -| reason | 描述申请权限的原因。不能超过256个字节。需要做多语种适配。 | 字符串 | 分情况:当申请的权限为user_grant时,必须填写此字段,否则不允许在应用市场上架;其它权限可缺省,缺省为空 | -| usedScene | 描述权限使用的场景和时机。场景类型有:ability、when。ability:ability的名称,可配置多个。when:调用时机,可填的值有inuse(使用时)、always(始终) | 对象 | ability分情况:申请的权限有user_grant时,ability必填;没有user_grant时可缺省,缺省值为空。when可缺省,缺省值为“inuse” | +| name | 需要使用的权限名称。 | 字符串 | 不可缺省。 | +| reason | 描述申请权限的原因。需要做多语种适配。 | 字符串 | 分情况:当申请的权限为user_grant时,必须填写此字段,否则不允许在应用市场上架;其它权限可缺省,缺省值为空。 | +| usedScene | 描述权限使用的场景和时机。场景类型如下两种:
ability:ability的名称,可配置多个。
when:调用时机,可填的值有inuse(使用时)、always(始终) | 对象 | 可缺省,缺省值为空。when可缺省,缺省值为“inuse”。 | 具体示例可参考[访问控制开发指导](../security/accesstoken-guidelines.md#fa模型)。 -表22 js对象的内部结构说明 +表20 usedScene对象内部结构说明 + +| 属性名称 | 含义 | 数据类型 | 是否可缺省 | +| ------- | --------------------| -------- | ------ | +| ability | 标识哪些Ability需要此权限,里面配置Ability的名称。| 字符串数组 | 可缺省,缺省表示所有Ability都需要此权限。 | +| when | 标识使用此权限的使用时间:
inuse:使用时需要此权限。
always:所有时间都需要此权限。 | 枚举值 | 可缺省,缺省值为空。 | + +表21 js对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | ------------------------ | -| name | 标识JS Component的名字。该标签不可缺省,默认值为default。 | 字符串 | 不可缺省 | -| pages | 标识JS Component的页面用于列举JS Component中每个页面的路由信息[页面路径+页面名称]。该标签不可缺省,取值为数组,数组第一个元素代表JS FA首页。 | 数组 | 不可缺省 | -| window | 用于定义与显示窗口相关的配置。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表23。 | 对象 | 可缺省 | +| name | 标识JS Component的名字。该标签不可缺省,默认值为default。 | 字符串 | 不可缺省。 | +| pages | 标识JS Component的页面用于列举JS Component中每个页面的路由信息[页面路径+页面名称]。该标签不可缺省,取值为数组,数组第一个元素代表JS FA首页。 | 字符串数组 | 不可缺省。 | +| window | 用于定义与显示窗口相关的配置。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。参考表22。 | 对象 | 可缺省。 | | type | 标识JS应用的类型。取值范围如下:
normal:标识该JS Component为应用实例。
form:标识该JS Component为卡片实例。 | 字符串 | 可缺省,缺省值为“normal” | -| mode | 定义JS组件的开发模式。参考表24。 | 对象 | 可缺省,缺省值为空 | +| mode | 定义JS组件的开发模式。参考表23。 | 对象 | 可缺省,缺省值为空。 | -表23 window对象的内部结构说明 +表22 window对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | --------------- | ------------------------------------------------------------ | -------- | ----------------------- | -| designWidth | 标识页面设计基准宽度。以此为基准,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为720px | -| autoDesignWidth | 标识页面设计基准宽度是否自动计算。当配置为true时,designWidth将会被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为“false” | +| designWidth | 标识页面设计基准宽度。以此为基准,根据实际设备宽度来缩放元素大小。 | 数值 | 可缺省,缺省值为720px。 | +| autoDesignWidth | 标识页面设计基准宽度是否自动计算。当配置为true时,designWidth将会被忽略,设计基准宽度由设备宽度与屏幕密度计算得出。 | 布尔值 | 可缺省,缺省值为“false”。 | -表24 mode对象的内部结构说明 +表23 mode对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | -------------------- | ----------------------------------- | --------------------------- | -| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为pageAbility | -| syntax | 定义JS组件的语法类型 | 字符串,取值为"hml","ets" | 可缺省,默认值为"hml" | +| type | 定义JS组件的功能类型 | 字符串,取值为"pageAbility"、"form" | 可缺省,缺省值为pageAbility。 | +| syntax | 定义JS组件的语法类型 | 字符串,取值为"hml","ets" | 可缺省,缺省值为"hml"。 | js示例: @@ -551,16 +540,16 @@ js示例: ] ``` -表25 shortcuts对象的内部结构说明 +表24 shortcuts对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | -------- | ------------------ | -| shortcutId | 标识快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 不可缺省 | -| label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省为空。 | -| icon | 标识快捷方式的图标信息。取值为表示icon的资源索引。 | 字符串 | 可缺省,缺省为空。 | -| intents | 标识快捷方式内定义的目标intent信息集合,每个intent可配置两个子标签,targetClass, targetBundle。参考表26。 | 对象数组 | 可缺省,缺省为空。 | +| shortcutId | 标识快捷方式的ID。字符串的最大长度为63字节。 | 字符串 | 不可缺省。 | +| label | 标识快捷方式的标签信息,即快捷方式对外显示的文字描述信息。取值可以是描述性内容,也可以是标识label的资源索引。字符串最大长度为63字节。 | 字符串 | 可缺省,缺省值为空。 | +| icon | 标识快捷方式的图标信息。取值为表示icon的资源索引。 | 字符串 | 可缺省,缺省值为空。 | +| intents | 标识快捷方式内定义的目标intent信息集合,每个intent可配置两个子标签,targetClass, targetBundle。参考表25。 | 对象数组 | 可缺省,缺省值为空。 | -表26 intents对象的内部结构说明 +表25 intents对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------ | --------------------------------------- | -------- | -------------------- | @@ -584,27 +573,27 @@ shortcuts示例: ] ``` -表27 forms对象的内部结构说明 +表26 forms对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------------- | ------------------------------------------------------------ | ---------- | ------------------------ | -| name | 标识卡片的类名。字符串最大长度为127字节。 | 字符串 | 不可缺省 | -| description | 标识卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省为空。 | -| isDefault | 标识该卡片是否为默认卡片,每个Ability有且只有一个默认卡片。
true:默认卡片。
false:非默认卡片。 | 布尔值 | 不可缺省 | -| type | 标识卡片的类型。取值范围如下:
JS:JS卡片。 | 字符串 | 不可缺省 | +| name | 标识卡片的类名。字符串最大长度为127字节。 | 字符串 | 不可缺省。 | +| description | 标识卡片的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。字符串最大长度为255字节。 | 字符串 | 可缺省,缺省值为空。 | +| isDefault | 标识该卡片是否为默认卡片,每个Ability有且只有一个默认卡片。
true:默认卡片。
false:非默认卡片。 | 布尔值 | 不可缺省。 | +| type | 标识卡片的类型。取值范围如下:
JS:JS卡片。 | 字符串 | 不可缺省。 | | colorMode | 标识卡片的主题样式,取值范围如下:
auto:自适应。
dark:深色主题。
light:浅色主题。 | 字符串 | 可缺省,缺省值为“auto”。 | -| supportDimensions | 标识卡片支持的外观规格,取值范围:
1 * 2:表示1行2列的二宫格。
2 * 1:表示2行1列的二宫格。
2 * 2:表示2行2列的四宫格。
2 * 4:表示2行4列的八宫格。
4 * 4:表示4行4列的十六宫格。 | 字符串数组 | 不可缺省 | -| defaultDimension | 标识卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 不可缺省 | -| updateEnabled | 标识卡片是否支持周期性刷新,取值范围:
true:表示支持周期性刷新,可以在定时刷新(updateDuration)和定点刷新(scheduledUpdateTime)两种方式任选其一,优先选择定时刷新。
false:表示不支持周期性刷新。 | 布尔类型 | 不可缺省 | +| supportDimensions | 标识卡片支持的外观规格,取值范围:
1 * 2:表示1行2列的二宫格。
2 * 1:表示2行1列的二宫格。
2 * 2:表示2行2列的四宫格。
2 * 4:表示2行4列的八宫格。
4 * 4:表示4行4列的十六宫格。 | 字符串数组 | 不可缺省。 | +| defaultDimension | 标识卡片的默认外观规格,取值必须在该卡片supportDimensions配置的列表中。 | 字符串 | 不可缺省。 | +| updateEnabled | 标识卡片是否支持周期性刷新,取值范围:
true:表示支持周期性刷新,可以在定时刷新(updateDuration)和定点刷新(scheduledUpdateTime)两种方式任选其一,优先选择定时刷新。
false:表示不支持周期性刷新。 | 布尔值 | 不可缺省。 | | scheduledUpdateTime | 标识卡片的定点刷新的时刻,采用24小时制,精确到分钟。 | 字符串 | 可缺省,缺省值为“0:0”。 | | updateDuration | 标识卡片定时刷新的更新周期,单位为30分钟,取值为自然数。
当取值为0时,表示该参数不生效。
当取值为正整数N时,表示刷新周期为30*N分钟。 | 数值 | 可缺省,缺省值为“0”。 | | formConfigAbility | 标识用于调整卡片的设施或活动的名称。 | 字符串 | 可缺省,缺省值为空。 | | formVisibleNotify | 标识是否允许卡片使用卡片可见性通知 | 字符串 | 可缺省,缺省值为空。 | -| jsComponentName | 标识JS卡片的Component名称。字符串最大长度为127字节。仅当卡片类型为JS卡片时,需要配置该标签。 | 字符串 | 不可缺省 | -| metaData | 标识卡片的自定义信息,包含customizeData数组标签。参考表13。 | 对象 | 可缺省,缺省值为空。 | -| customizeData | 标识自定义的卡片信息。参考表28。 | 对象数组 | 可缺省,缺省值为空。 | +| jsComponentName | 标识JS卡片的Component名称。字符串最大长度为127字节。仅当卡片类型为JS卡片时,需要配置该标签。 | 字符串 | 不可缺省。 | +| metaData | 标识卡片的自定义信息,包含customizeData数组标签。参考表11。 | 对象 | 可缺省,缺省值为空。 | +| customizeData | 标识自定义的卡片信息。参考表27。 | 对象数组 | 可缺省,缺省值为空。 | -表28 customizeData对象内部结构说明 +表27 customizeData对象内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | --------------------------------------------------- | -------- | -------------------- | @@ -665,45 +654,45 @@ forms示例: ] ``` -表29 distroFilter对象的内部结构说明 +表28 distroFilter对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ------------- | ------------------------------------------------------------ | -------- | -------------------- | -| apiVersion | 标识支持的apiVersion范围。参考表30。 | 对象 | 可缺省,缺省值为空。 | -| screenShape | 标识屏幕形状的支持策略。参考表31。 | 对象数组 | 可缺省,缺省值为空。 | -| screenWindow | 标识应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表32。 | 对象数组 | 可缺省,缺省值为空。 | -| screenDensity | 标识屏幕的像素密度(dpi:Dots Per Inch)。参考表33。 | 对象数组 | 可缺省,缺省值为空。 | -| countryCode | 标识分发应用时的国家码。具体值参考ISO-3166-1的标准,支持多个国家和地区的枚举定义。参考表34。 | 对象数组 | 可缺省,缺省值为空。 | +| apiVersion | 标识支持的apiVersion范围。参考表29。 | 对象 | 可缺省,缺省值为空。 | +| screenShape | 标识屏幕形状的支持策略。参考表30。 | 对象数组 | 可缺省,缺省值为空。 | +| screenWindow | 标识应用运行时窗口的分辨率支持策略。该字段仅支持对轻量级智能穿戴设备进行配置。参考表31。 | 对象数组 | 可缺省,缺省值为空。 | +| screenDensity | 标识屏幕的像素密度(dpi:Dots Per Inch)。参考表32。 | 对象数组 | 可缺省,缺省值为空。 | +| countryCode | 标识分发应用时的国家码。具体值参考ISO-3166-1的标准,支持多个国家和地区的枚举定义。参考表33。 | 对象数组 | 可缺省,缺省值为空。 | -表30 apiVersion对象的内部结构说明 +表29 apiVersion对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 支持的取值为API Version存在的整数值,例如4、5、6。场景示例:某应用,针对相同设备型号,同时在网的为使用API 5和API 6开发的两个软件版本,则允许上架2个entry类型的安装包,分别支持到对应设备侧软件版本的分发。 | 数组 | 可缺省,缺省值为空。 | -表31 screenShape对象的内部结构说明 +表30 screenShape对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 支持的取值为circle(圆形)、rect(矩形)。场景示例:针对智能穿戴设备,可为圆形表盘和矩形表盘分别提供不同的HAP。 | 数组 | 可缺省,缺省值为空。 | -表32 screenWindow对象的内部结构说明 +表31 screenWindow对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 单个字符串的取值格式为:“宽 * 高”,取值为整数像素值,例如“454 * 454”。 | 数组 | 可缺省,缺省值为空。 | -表33 screenDensity对象的内部结构说明 +表32 screenDensity对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | -------- | -------------------- | | policy | 标识该子属性取值的黑白名单规则。配置为“exclude”或“include”。“include”表示该字段取值为白名单,满足value枚举值匹配规则的表示匹配该属性。 | 字符串 | 可缺省,缺省值为空。 | | value | 取值范围如下:
sdpi:表示小规模的屏幕密度(Small-scale Dots Per Inch),适用于dpi取值为(0,120]的设备。
mdpi:表示中规模的屏幕密度(Medium-scale Dots Per Inch),适用于dpi取值为(120,160]的设备。
ldpi:表示大规模的屏幕密度(Large-scale Dots Per Inch),适用于dpi取值为(160,240]的设备。
xldpi:表示特大规模的屏幕密度(Extra Large-scale Dots Per Inch),适用于dpi取值为(240,320]的设备。
xxldpi:表示超大规模的屏幕密度(Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(320,480]的设备。
xxxldpi:表示超特大规模的屏幕密度(Extra Extra Extra Large-scale Dots Per Inch),适用于dpi取值为(480,640]的设备。 | 数组 | 可缺省,缺省值为空。 | -表34 countryCode对象的内部结构说明 +表33 countryCode对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | @@ -737,15 +726,15 @@ distroFilter示例: } ``` -表35 commonEvents对象的内部结构说明 +表34 commonEvents对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ---------- | ------------------------------------------------------------ | ---------- | ------------------ | -| name | 标识静态广播名称 | 字符串 | 不可缺省 | -| permission | 此标签标识实现静态公共事件所需要申请的权限 | 字符串数组 | 可缺省,缺省值为空 | -| data | 标识配置当前静态公共事件要携带的附加数据数组 | 字符串数组 | 可缺省,缺省值为空 | -| type | 该标签用于配置当前静态公共事件的分类数组 | 字符串数组 | 可缺省,缺省值为空 | -| events | 此标签标识可接收的意图的一组事件值。一般由系统预定义,也可以自定义。 | 字符串数组 | 不可缺省 | +| name | 标识静态公共事件名称,该标签最大长度为127字节。 | 字符串 | 不可缺省。 | +| permission | 此标签标识实现静态公共事件所需要申请的权限,该标签最大长度为127字节。 | 字符串 | 可缺省,缺省值为空。 | +| data | 标识配置当前静态公共事件要携带的附加数据数组。 | 字符串数组 | 可缺省,缺省值为空。 | +| type | 该标签用于配置当前静态公共事件的分类数组。 | 字符串数组 | 可缺省,缺省值为空。 | +| events | 此标签标识可接收的意图的一组事件值。一般由系统预定义,也可以自定义。 | 字符串数组 | 不可缺省。 | commonEvents示例: @@ -766,29 +755,30 @@ commonEvents示例: ] ``` -表36 testRunner对象的内部结构说明 +表35 testRunner对象的内部结构说明 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | -------------------- | -------- | ---------- | -| name | 标识测试框架对象名称 | 字符串 | 不可缺省 | -| srcPath | 标识测试框架代码路径 | 字符串 | 不可缺省 | +| name | 标识测试框架对象名称,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | +| srcPath | 标识测试框架代码路径,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | ```json "testRunner": { - "name": "myTestRUnnerName", + "name": "myTestRunnerName", "srcPath": "etc/test/TestRunner.ts" } ``` -表37 definePermissions对象内部结构说明 +表36 definePermissions对象内部结构说明 + definePermission仅支持系统应用配置,三方应用配置不生效。 | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | ----------------------- | ------------------------------------------------------------ | -------- | ---------- | -| name | 标识权限的名称 | 字符串 | 不可缺省 | -| grantMode | 标识权限的授予方式,该标签可缺省,缺省值为system_grant。
授予模式如下:
system_grant:安装后系统自动授予该权限。
user_grant:使用时动态申请,用户授权后才可使用。 | 字符串 | 可缺省 | -| availableLevel | 标识权限限制门限。可选值为"system_code","system_basic","normal",该标签有缺省值,缺省值为normal。权限范围如下:
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限 | 字符串 | 可缺省 | -| provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限,该标签有缺省值,缺省值为true。配置为true标识需要开发者可以通过provision方式申请权限。 | 布尔值 | 可缺省 | -| distributedSceneEnabled | 标识权限是否支持分布式场景下使用该权限,该标签有缺省值,缺省值为false。 | 布尔值 | 可缺省 | -| label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省 | -| description | 标识权限的详细描述,可以是字符串,或者为对描述内容的资源索引。 | 字符串 | 可缺省 | +| name | 标识权限的名称,该标签最大长度为255字节。 | 字符串 | 不可缺省。 | +| grantMode | 标识权限的授予方式,支持如下两种授予模式:
system_grant:安装后系统自动授予该权限。
user_grant:使用时动态申请,用户授权后才可使用。 | 字符串 | 可缺省,缺省值为system_grant。 | +| availableLevel | 标识权限限制类别。可选值如下:
system_core:系统核心权限。
system_basic:系统基础权限。
normal:普通权限。所有应用允许申请的权限。 | 字符串 | 可缺省,缺省值为normal。 | +| provisionEnable | 标识权限是否支持证书方式申请权限,包括高级别的权限。配置为true标识需要开发者可以通过provision方式申请权限。 | 布尔值 | 可缺省,缺省值为true。 | +| distributedSceneEnabled | 标识权限是否支持分布式场景下使用该权限。 | 布尔值 | 可缺省,缺省值为false。 | +| label | 标识权限的简短描述,配置为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | +| description | 标识权限的详细描述,可以是字符串(最大长度255字节),或者为对描述内容的资源索引。 | 字符串 | 可缺省,缺省值为空。 | diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index b0acbfbbdeca2001712ad83c4002d04b5cfb96c0..017a04ce7ff21d653dc39e7d61c04bf06983f7d4 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,17 +1,23 @@ # 接口 + - [开发说明](development-intro.md) + - Ability框架 + - FA模型 + - [@ohos.ability.ability (Ability)](js-apis-ability-ability.md) - [@ohos.ability.featureAbility (FeatureAbility模块)](js-apis-featureAbility.md) - [@ohos.ability.particleAbility (particleAbility模块)](js-apis-particleAbility.md) - ability/[dataAbilityHelper (DataAbilityHelper模块)](js-apis-dataAbilityHelper.md) - app/[context (Context模块)](js-apis-Context.md) + - Stage模型 - [@ohos.application.Ability (Ability)](js-apis-application-ability.md) - [@ohos.application.AbilityConstant (AbilityConstant)](js-apis-application-abilityConstant.md) - [@ohos.application.AbilityStage (AbilityStage)](js-apis-application-abilitystage.md) - [@ohos.application.abilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md) - [@ohos.application.DataShareExtensionAbility (数据共享扩展能力)](js-apis-application-DataShareExtensionAbility.md) + - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-EnvironmentCallback.md) - [@ohos.application.FormExtension (FormExtension)](js-apis-formextension.md) - [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-service-extension-ability.md) - [@ohos.application.StartOptions (StartOptions)](js-apis-application-StartOptions.md) @@ -25,18 +31,16 @@ - application/[FormExtensionContext (FormExtensionContext)](js-apis-formextensioncontext.md) - application/[PermissionRequestResult (PermissionRequestResult)](js-apis-permissionrequestresult.md) - application/[ServiceExtensionContext (ServiceExtensionContext)](js-apis-service-extension-context.md) + - 通用 - [@ohos.ability.dataUriUtils (DataUriUtils模块)](js-apis-DataUriUtils.md) - [@ohos.ability.errorCode (ErrorCode)](js-apis-ability-errorCode.md) - [@ohos.ability.wantConstant (wantConstant)](js-apis-ability-wantConstant.md) - [@ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)](js-apis-abilityDelegatorRegistry.md) - [@ohos.application.abilityManager (AbilityManager)](js-apis-application-abilityManager.md) - - [@ohos.application.AccessibilityExtensionAbility (AccessibilityExtensionContext)](js-apis-accessibility-extension-context.md) - - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.application.appManager (appManager)](js-apis-appmanager.md) - - [@ohos.application.Configuration (Configuration)](js-apis-configuration.md) - - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-configurationconstant.md) - - [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-EnvironmentCallback.md) + - [@ohos.application.Configuration (Configuration)](js-apis-application-configuration.md) + - [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-application-configurationConstant.md) - [@ohos.application.errorManager (ErrorManager)](js-apis-errorManager.md) - [@ohos.application.formBindingData (卡片数据绑定类)](js-apis-formbindingdata.md) - [@ohos.application.formError (FormError)](js-apis-formerror.md) @@ -46,35 +50,51 @@ - [@ohos.application.missionManager (missionManager)](js-apis-missionManager.md) - [@ohos.application.quickFixManager (quickFixManager)](js-apis-application-quickFixManager.md) - [@ohos.application.Want (Want)](js-apis-application-Want.md) - - [@ohos.continuation.continuationManager (ContinuationExtraParams)](js-apis-continuation-continuationExtraParams.md) - [@ohos.continuation.continuationManager (continuationManager)](js-apis-continuation-continuationManager.md) - [@ohos.wantAgent (WantAgent模块)](js-apis-wantAgent.md) + - ability/[abilityResult (AbilityResult)](js-apis-ability-abilityResult.md) + - ability/[Want (Want)](js-apis-ability-Want.md) - application/[abilityDelegator (AbilityDelegator)](js-apis-application-abilityDelegator.md) - application/[abilityDelegatorArgs (AbilityDelegatorArgs)](js-apis-application-abilityDelegatorArgs.md) - application/[abilityMonitor (AbilityMonitor)](js-apis-application-abilityMonitor.md) - application/[AbilityRunningInfo (AbilityRunningInfo)](js-apis-abilityrunninginfo.md) - application/[ExtensionRunningInfo (ExtensionRunningInfo)](js-apis-extensionrunninginfo.md) - application/[MissionSnapshot (MissionSnapshot)](js-apis-application-MissionSnapshot.md) - - application/[ProcessRunningInfo (ProcessRunningInfo)](js-apis-processrunninginfo.md) - application/[ProcessRunningInformation (ProcessRunningInformation)](js-apis-processrunninginformation.md) - application/[shellCmdResult (ShellCmdResult)](js-apis-application-shellCmdResult.md) - - continuation/[ContinuationResult (ContinuationResult)](js-apis-continuation-continuationResult.md) + - continuation/[continuationExtraParams (ContinuationExtraParams)](js-apis-continuation-continuationExtraParams.md) + - continuation/[continuationResult (ContinuationResult)](js-apis-continuation-continuationResult.md) + - 公共事件与通知 - - [@ohos.commonEvent (公共事件模块)](js-apis-commonEvent.md) - - [@ohos.commonEventManager (新公共事件模块)](js-apis-commonEventManager.md) + - [@ohos.commonEventManager (公共事件模块)](js-apis-commonEventManager.md) - [@ohos.events.emitter (Emitter)](js-apis-emitter.md) - [@ohos.notification (Notification模块)](js-apis-notification.md) - application/[EventHub (EventHub)](js-apis-eventhub.md) + - 包管理 - [@ohos.bundle.appControl(appControl模块)](js-apis-appControl.md) - [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md) - - [@ohos.bundle.bundleMonitor(bundleMonitor模块)](js-apis-bundleMonitor.md) - - [@ohos.bundle.defaultAppManager(defaultAppManager模块)](js-apis-defaultAppManager.md) - - [@ohos.bundle.innerBundleManager (innerBundleManager模块)](js-apis-Bundle-InnerBundleManager.md) + - [@ohos.bundle.bundleMonitor (bundleMonitor模块)](js-apis-bundleMonitor.md) + - [@ohos.bundle.defaultAppManager (默认应用管理)](js-apis-defaultAppManager.md) - [@ohos.bundle.distributedBundle (distributedBundle模块)](js-apis-distributedBundle.md) - - [@ohos.bundle.freeInstall(freeInstall模块)](js-apis-freeInstall.md) - - [@ohos.bundle.installer(installer模块)](js-apis-installer.md) + - [@ohos.bundle.freeInstall (freeInstall模块)](js-apis-freeInstall.md) + - [@ohos.bundle.installer (installer模块)](js-apis-installer.md) + - [@ohos.bundle.launcherBundleManager (launcherBundleManager模块)](js-apis-launcherBundleManager.md) - [@ohos.zlib (Zip模块)](js-apis-zlib.md) + - bundleManager/[abilityInfo (AbilityInfo)](js-apis-bundleManager-abilityInfo.md) + - bundleManager/[applicationInfo (ApplicationInfo)](js-apis-bundleManager-applicationInfo.md) + - bundleManager/[bundleInfo (BundleInfo)](js-apis-bundleManager-bundleInfo.md) + - bundleManager/[dispatchInfo (DispatchInfo)](js-apis-bundleManager-dispatchInfo.md) + - bundleManager/[elementName (ElementName)](js-apis-bundleManager-elementName.md) + - bundleManager/[extensionAbilityInfo (ExtensionAbilityInfo)](js-apis-bundleManager-extensionAbilityInfo.md) + - bundleManager/[hapModuleInfo (HapModuleInfo)](js-apis-bundleManager-hapModuleInfo.md) + - bundleManager/[launcherAbilityInfo (LauncherAbilityInfo)](js-apis-bundleManager-launcherAbilityInfo.md) + - bundleManager/[metadata (Metadata)](js-apis-bundleManager-metadata.md) + - bundleManager/[packInfo (PackInfo)](js-apis-bundleManager-packInfo.md) + - bundleManager/[permissionDef (PermissionDef)](js-apis-bundleManager-permissionDef.md) + - bundleManager/[remoteAbilityInfo (RemoteAbilityInfo)](js-apis-bundleManager-remoteAbilityInfo.md) + - bundleManager/[shortcutInfo (ShortcutInfo)](js-apis-bundleManager-shortcutInfo.md) + - UI界面 - [@ohos.animator (动画)](js-apis-animator.md) - [@ohos.curves (插值计算)](js-apis-curve.md) @@ -82,6 +102,7 @@ - [@ohos.mediaquery (媒体查询)](js-apis-mediaquery.md) - [@ohos.promptAction (弹窗)](js-apis-promptAction.md) - [@ohos.router (页面路由)](js-apis-router.md) + - 图形图像 - [@ohos.animation.windowAnimationManager (窗口动画管理)](js-apis-windowAnimationManager.md) - [@ohos.display (屏幕属性)](js-apis-display.md) @@ -92,15 +113,19 @@ - [@ohos.window (窗口)](js-apis-window.md) - [webgl (WebGL)](js-apis-webgl.md) - [webgl2 (WebGL2)](js-apis-webgl2.md) + - 媒体 - [@ohos.multimedia.audio (音频管理)](js-apis-audio.md) + - [@ohos.multimedia.avsession (媒体会话管理)](js-apis-avsession.md) - [@ohos.multimedia.camera (相机管理)](js-apis-camera.md) - [@ohos.multimedia.image (图片处理)](js-apis-image.md) - [@ohos.multimedia.media (媒体服务)](js-apis-media.md) + - 资源管理 - [@ohos.i18n (国际化-I18n)](js-apis-i18n.md) - [@ohos.intl (国际化-Intl)](js-apis-intl.md) - [@ohos.resourceManager (资源管理)](js-apis-resource-manager.md) + - 资源调度 - [@ohos.distributedMissionManager (分布式任务管理)](js-apis-distributedMissionManager.md) - [@ohos.reminderAgentManager (后台代理提醒)](js-apis-reminderAgentManager.md) @@ -108,19 +133,16 @@ - [@ohos.resourceschedule.workScheduler (延迟任务调度)](js-apis-resourceschedule-workScheduler.md) - [@ohos.resourceschedule.usageStatistics (设备使用信息统计)](js-apis-resourceschedule-deviceUsageStatistics.md) - [@ohos.WorkSchedulerExtensionAbility (延迟任务调度回调)](js-apis-WorkSchedulerExtensionAbility.md) -- 定制管理 - - [@ohos.configPolicy (配置策略)](js-apis-config-policy.md) - - [@ohos.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) - - [@ohos.enterpriseDeviceManager (企业设备管理)](js-apis-enterprise-device-manager.md) - - enterpriseDeviceManager/[DeviceSettingsManager(设备设置管理)](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) + - 安全 - - [@ohos.abilityAccessCtrl (访问控制管理)](js-apis-abilityAccessCtrl.md) + - [@ohos.abilityAccessCtrl (程序访问控制管理)](js-apis-abilityAccessCtrl.md) - [@ohos.privacyManager (隐私管理)](js-apis-privacyManager.md) - [@ohos.security.cryptoFramework (加解密算法库框架)](js-apis-cryptoFramework.md) - [@ohos.security.huks (通用密钥库系统)](js-apis-huks.md) - [@ohos.userIAM.faceAuth (人脸认证)](js-apis-useriam-faceauth.md) - [@ohos.userIAM.userAuth (用户认证)](js-apis-useriam-userauth.md) - [@system.cipher (加密算法)](js-apis-system-cipher.md) + - 数据管理 - [@ohos.data.dataAbility (DataAbility谓词)](js-apis-data-ability.md) - [@ohos.data.dataShare (数据共享)](js-apis-data-dataShare.md) @@ -132,18 +154,19 @@ - [@ohos.data.rdb (关系型数据库)](js-apis-data-rdb.md) - [@ohos.data.ValuesBucket (数据集)](js-apis-data-ValuesBucket.md) - data/rdb/[resultSet (结果集)](js-apis-data-resultset.md) + - 文件管理 - - [@ohos.document (文件交互)](js-apis-document.md) - [@ohos.environment (目录环境能力)](js-apis-environment.md) - [@ohos.data.fileAccess (公共文件访问与管理)](js-apis-fileAccess.md) - [@ohos.fileExtensionInfo (公共文件访问与管理属性信息)](js-apis-fileExtensionInfo.md) - [@ohos.fileio (文件管理)](js-apis-fileio.md) - - [@ohos.filemanagement.userfile_manager (用户数据管理)](js-apis-userfilemanager.md) + - [@ohos.filemanagement.userFileManager (用户数据管理)](js-apis-userFileManager.md) - [@ohos.multimedia.medialibrary (媒体库管理)](js-apis-medialibrary.md) - [@ohos.securityLabel (数据标签)](js-apis-securityLabel.md) - [@ohos.statfs (statfs)](js-apis-statfs.md) - [@ohos.storageStatistics (应用空间统计)](js-apis-storage-statistics.md) - [@ohos.volumeManager (卷管理)](js-apis-volumemanager.md) + - 电话服务 - [@ohos.contact (联系人)](js-apis-contact.md) - [@ohos.telephony.call (拨打电话)](js-apis-call.md) @@ -152,6 +175,7 @@ - [@ohos.telephony.radio (网络搜索)](js-apis-radio.md) - [@ohos.telephony.sim (SIM卡管理)](js-apis-sim.md) - [@ohos.telephony.sms (短信服务)](js-apis-sms.md) + - 网络管理 - [@ohos.net.connection (网络连接管理)](js-apis-net-connection.md) - [@ohos.net.ethernet (以太网连接管理)](js-apis-net-ethernet.md) @@ -163,6 +187,7 @@ - [@ohos.net.tlsSocket (TLSSocket连接)](js-apis-tlsSocket.md) - [@ohos.net.webSocket (WebSocket连接)](js-apis-webSocket.md) - [@ohos.request (上传下载)](js-apis-request.md) + - 通信与连接 - [@ohos.bluetooth (蓝牙)](js-apis-bluetooth.md) - [@ohos.connectedTag (有源标签)](js-apis-connectedTag.md) @@ -171,20 +196,24 @@ - [@ohos.nfc.tag (标准NFC-Tag)](js-apis-nfcTag.md) - [@ohos.rpc (RPC通信)](js-apis-rpc.md) - [@ohos.wifi (WLAN)](js-apis-wifi.md) - - [@ohos.wifiext (WLAN)](js-apis-wifiext.md) + - [@ohos.wifiext (WLAN扩展接口)](js-apis-wifiext.md) - tag/[nfctech (标准NFC-Tag Nfc 技术)](js-apis-nfctech.md) - tag/[tagSession (标准NFC-Tag TagSession)](js-apis-tagSession.md) + - 系统基础能力 - [@ohos.accessibility (辅助功能)](js-apis-accessibility.md) - [@ohos.accessibility.config (系统辅助功能配置)](js-apis-accessibility-config.md) + - [@ohos.accessibility.GesturePath (手势路径)](js-apis-accessibility-GesturePath.md) + - [@ohos.accessibility.GesturePoint (手势触摸点)](js-apis-accessibility-GesturePoint.md) + - [@ohos.application.AccessibilityExtensionAbility (辅助功能扩展能力)](js-apis-application-AccessibilityExtensionAbility.md) - [@ohos.faultLogger (故障日志获取)](js-apis-faultLogger.md) - - [@ohos.hiAppEvent (应用打点)](js-apis-hiappevent.md) - [@ohos.hichecker (检测模式)](js-apis-hichecker.md) - [@ohos.hidebug (Debug调试)](js-apis-hidebug.md) - [@ohos.hilog (HiLog日志打印)](js-apis-hilog.md) - [@ohos.hiSysEvent (系统事件打点)](js-apis-hisysevent.md) - [@ohos.hiTraceChain (分布式跟踪)](js-apis-hitracechain.md) - [@ohos.hiTraceMeter (性能打点)](js-apis-hitracemeter.md) + - [@ohos.hiviewdfx.hiAppEvent (应用事件打点)](js-apis-hiviewdfx-hiappevent.md) - [@ohos.inputmethod (输入法框架)](js-apis-inputmethod.md) - [@ohos.inputmethodengine (输入法服务)](js-apis-inputmethodengine.md) - [@ohos.inputmethodextensionability (InputMethodExtensionAbility)](js-apis-inputmethod-extension-ability.md) @@ -198,13 +227,15 @@ - [@ohos.web.webview(Web)](js-apis-webview.md) - [console (日志打印)](js-apis-logs.md) - [Timer (定时器)](js-apis-timer.md) -- 设备管理 + - application/[AccessibilityExtensionContext (辅助功能扩展上下文)](js-apis-accessibility-extension-context.md) +- 设备管理 - [@ohos.batteryInfo (电量信息)](js-apis-battery-info.md) + - [@ohos.batteryStatistics (耗电统计)](js-apis-batteryStatistics.md) - [@ohos.brightness (屏幕亮度)](js-apis-brightness.md) - [@ohos.deviceInfo (设备信息)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (设备管理)](js-apis-device-manager.md) - - [@ohos.geolocation (位置服务)](js-apis-geolocation.md) + - [@ohos.geoLocationManager (位置服务)](js-apis-geoLocationManager.md) - [@ohos.multimodalInput.inputConsumer (组合按键)](js-apis-inputconsumer.md) - [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md) - [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越)](js-apis-cooperate.md) @@ -220,15 +251,23 @@ - [@ohos.runningLock (Runninglock锁)](js-apis-runninglock.md) - [@ohos.sensor (传感器)](js-apis-sensor.md) - [@ohos.settings (设置数据项名称)](js-apis-settings.md) - - [@ohos.systemParameter (系统属性)](js-apis-system-parameter.md) + - [@ohos.systemParameterV9 (系统属性)](js-apis-system-parameterV9.md) - [@ohos.thermal (热管理)](js-apis-thermal.md) - [@ohos.update (升级)](js-apis-update.md) - [@ohos.usbV9 (USB管理)](js-apis-usb.md) - [@ohos.vibrator (振动)](js-apis-vibrator.md) + - 帐号管理 - [@ohos.account.appAccount (应用帐号管理)](js-apis-appAccount.md) - [@ohos.account.distributedAccount (分布式帐号管理)](js-apis-distributed-account.md) - [@ohos.account.osAccount (系统帐号管理)](js-apis-osAccount.md) + +- 定制管理 + - [@ohos.configPolicy (配置策略)](js-apis-config-policy.md) + - [@ohos.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)](js-apis-EnterpriseAdminExtensionAbility.md) + - [@ohos.enterpriseDeviceManager (企业设备管理)](js-apis-enterprise-device-manager.md) + - enterpriseDeviceManager/[DeviceSettingsManager(设备设置管理)](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md) + - 语言基础类库 - [@ohos.buffer (Buffer)](js-apis-buffer.md) - [@ohos.convertxml (xml转换JavaScript)](js-apis-convertxml.md) @@ -252,19 +291,27 @@ - [@ohos.util.Vector (线性容器Vector)](js-apis-vector.md) - [@ohos.worker (启动一个Worker)](js-apis-worker.md) - [@ohos.xml (xml解析与生成)](js-apis-xml.md) + - 测试 - [@ohos.application.testRunner (TestRunner)](js-apis-testRunner.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md) + - 已停止维护的接口 - [@ohos.backgroundTaskManager (后台任务管理)](js-apis-backgroundTaskManager.md) - - [@ohos.bundle(包管理)](js-apis-Bundle.md) + - [@ohos.bundle (Bundle模块)](js-apis-Bundle.md) + - [@ohos.bundle.innerBundleManager (innerBundleManager模块)](js-apis-Bundle-InnerBundleManager.md) - [@ohos.bundleState (设备使用信息统计)](js-apis-deviceUsageStatistics.md) - [@ohos.bytrace (性能打点)](js-apis-bytrace.md) + - [@ohos.commonEvent (公共事件模块)](js-apis-commonEvent.md) - [@ohos.data.storage (轻量级存储)](js-apis-data-storage.md) - [@ohos.data.distributedData (分布式数据管理)](js-apis-distributed-data.md) - - [@ohos.distributedBundle(分布式包管理)](js-apis-Bundle-distributedBundle.md) + - [@ohos.distributedBundle (分布式包管理)](js-apis-Bundle-distributedBundle.md) + - [@ohos.document (文件交互)](js-apis-document.md) + - [@ohos.geolocation (位置服务)](js-apis-geolocation.md) + - [@ohos.hiAppEvent (应用打点)](js-apis-hiappevent.md) - [@ohos.prompt (弹窗)](js-apis-prompt.md) - [@ohos.reminderAgent (后台代理提醒)](js-apis-reminderAgent.md) + - [@ohos.systemParameter (系统属性)](js-apis-system-parameter.md) - [@ohos.usb (USB管理)](js-apis-usb-deprecated.md) - [@system.app (应用上下文)](js-apis-system-app.md) - [@system.battery (电量信息)](js-apis-system-battery.md) @@ -285,4 +332,17 @@ - [@system.sensor (传感器)](js-apis-system-sensor.md) - [@system.storage (数据存储)](js-apis-system-storage.md) - [@system.vibrator (振动)](js-apis-system-vibrate.md) - - [console (日志打印)](js-apis-logs.md) + - application/[ProcessRunningInfo (ProcessRunningInfo)](js-apis-processrunninginfo.md) + - bundle/[abilityInfo (AbilityInfo)](js-apis-bundle-AbilityInfo.md) + - bundle/[applicationInfo (ApplicationInfo)](js-apis-bundle-ApplicationInfo.md) + - bundle/[bundleInfo (BundleInfo)](js-apis-bundle-BundleInfo.md) + - bundle/[bundleInstaller (BundleInstaller)](js-apis-bundle-BundleInstaller.md) + - bundle/[bundleStatusCallback (BundleStatusCallback)](js-apis-Bundle-BundleStatusCallback.md) + - bundle/[customizeData (CustomizeData)](js-apis-bundle-CustomizeData.md) + - bundle/[elementName (ElementName)](js-apis-bundle-ElementName.md) + - bundle/[hapModuleInfo (HapModuleInfo)](js-apis-bundle-HapModuleInfo.md) + - bundle/[launcherAbilityInfo (LauncherAbilityInfo)](js-apis-bundle-LauncherAbilityInfo.md) + - bundle/[moduleInfo (ModuleInfo)](js-apis-bundle-ModuleInfo.md) + - bundle/[PermissionDef (PermissionDef)](js-apis-bundle-PermissionDef.md) + - bundle/[remoteAbilityInfo (RemoteAbilityInfo)](js-apis-bundle-remoteAbilityInfo.md) + - bundle/[shortcutInfo (shortcutInfo)](js-apis-bundle-ShortcutInfo.md) diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif index 2bb6aa6c2a2086f16ae6149e9d3e4b2340d6fe37..c3616f948289aa9a358bcd716c9731c98d1458de 100644 Binary files a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0005.gif differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif index 2a6cf73b491304e3f53cb0a333588cad2e42f30b..6a5fe369467d047364f518486d452ed2ac6aba96 100644 Binary files a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0006.gif differ diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md index d51482cbf6a0e7af6ca32209d8227119e956c456..bc19287abd6bf80a3f78211e937207df1ab4c58f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-BundleStatusCallback.md @@ -1,18 +1,20 @@ # BundleStatusCallback > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 从API version 9开始不再支持。建议使用[bundleMonitor](js-apis-bundleMonitor.md)替代。 + + +应用状态回调的信息,通过接口[innerBundleManager.on](js-apis-Bundle-InnerBundleManager.md)获取。 -应用包回调的信息,通过接口[innerBundleManager.on](js-apis-Bundle-InnerBundleManager.md)获取。 ## BundleStatusCallback(deprecated) -> 从API version 9开始不再维护。 +> 从API version 9开始不再支持。建议使用[bundleMonitor](js-apis-bundleMonitor.md)替代。 **系统API:** 此接口为系统接口,三方应用不支持调用。 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework。 -| 名称 | 类型 | 说明 | +| 监听类型 | 注册回调 | 说明 | | ------ | --------------------------------------------- | -------------------------------------- | | add | (bundleName : string, userId: number) => void | 获取应用安装时的信息。 | | update | (bundleName : string, userId: number) => void | 获取应用更新时的信息。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md index 7c0bf1054168d9f5a0bbd66840239a6af4f3ccbd..81c3c912a6b4c70996ab03b054887981b4b257d6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-InnerBundleManager.md @@ -1,14 +1,14 @@ -# innerBundleManager模块(JS端SDK接口) +# innerBundleManager模块(deprecated) -本模块提供内部包的管理 +本模块提供launcher应用使用的接口 -> **说明:** > > 本模块首批接口从API version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块从API version 9开始不再支持。建议使用[launcherBundleManager](js-apis-launcherBundleManager.md)及[bundleMonitor](js-apis-bundleMonitor.md)替代。 ## 导入模块 -``` +```typescript import innerBundleManager from '@ohos.bundle.innerBundleManager'; ``` @@ -16,20 +16,13 @@ import innerBundleManager from '@ohos.bundle.innerBundleManager'; SystemCapability.BundleManager.BundleFramework -## 权限列表 - -| 权限 | 权限等级 | 描述 | -| ------------------------------------------ | ------------ | ---------------------------- | -| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 | -| ohos.permission.LISTEN_BUNDLE_CHANGE | system_grant | 允许该应用获取应用变化消息。 | -权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) - -## innerBundleManager.getLauncherAbilityInfos +## innerBundleManager.getLauncherAbilityInfos(deprecated) getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; 以异步方法根据给定的包名获取LauncherAbilityInfos,使用callback形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getLauncherAbilityInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -45,19 +38,19 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | | bundleName | string | 是 | 要查询的应用程序包名称。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | callback | AsyncCallback\> | 是 | 程序启动作为入参的回调函数,返回程序信息。 | - -## innerBundleManager.getLauncherAbilityInfos +## innerBundleManager.getLauncherAbilityInfos(deprecated) getLauncherAbilityInfos(bundleName: string, userId: number) : Promise<Array<LauncherAbilityInfo>> 以异步方法根据给定的包名获取LauncherAbilityInfos,使用Promise形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getLauncherAbilityInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -73,7 +66,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ----------------------------------------------------- | | bundleName | string | 是 | 要查询的应用程序包名称。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -84,11 +77,12 @@ SystemCapability.BundleManager.BundleFramework | ------------------------------------------------------------ | ------------------------- | | Promise\> | Promise形式返回程序信息。 | -## innerBundleManager.on +## innerBundleManager.on(deprecated) on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback<string>) : void; 注册Callback。 +> 从API version 9开始不再支持。建议使用[bundleMonitor#on](js-apis-bundleMonitor.md)替代。 **需要权限:** @@ -104,17 +98,18 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | --------------------- | ---- | ---------------------------------------------------- | | type | string | 是 | 指示应执行命令,只支持BundleStatusChange。 | | bundleStatusCallback | [BundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md) | 是 | 指示要注册的回调。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回正确结果或错误信息。 | -## innerBundleManager.on +## innerBundleManager.on(deprecated) -on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise<string> +on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback) : Promise<string> 注册Callback。 +> 从API version 9开始不再支持。建议使用[bundleMonitor#on](js-apis-bundleMonitor.md)替代。 **需要权限:** @@ -130,7 +125,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------ | | type | string | 是 | 指示应执行命令,只支持BundleStatusChange。 | | bundleStatusCallback | [BundleStatusCallback](js-apis-Bundle-BundleStatusCallback.md) | 是 | 指示要注册的回调。 | @@ -141,11 +136,12 @@ SystemCapability.BundleManager.BundleFramework | --------------- | ----------------------------------- | | Promise\ | Promise形式返回正确结果或错误信息。 | -## innerBundleManager.off +## innerBundleManager.off(deprecated) off(type:"BundleStatusChange", callback: AsyncCallback<string>) : void; 取消注册Callback。 +> 从API version 9开始不再支持。建议使用[bundleMonitor#off](js-apis-bundleMonitor.md)替代。 **需要权限:** @@ -161,16 +157,17 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ---------------------------------------------------- | | type | string | 是 | 指示应执行命令,只支持BundleStatusChange。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回正确结果或错误信息。 | -## innerBundleManager.off +## innerBundleManager.off(deprecated) -off(type:"BundleStatusChange"): Promise<string> +off(type:"BundleStatusChange") : Promise<string> 取消注册Callback。 +> 从API version 9开始不再支持。建议使用[bundleMonitor#off](js-apis-bundleMonitor.md)替代。 **需要权限:** @@ -186,9 +183,9 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---- | ------ | ---- | ------------------------------------------ | -| type | string | 是 | 指示应执行命令,只支持BundleStatusChange。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------ | +| type | string | 是 | 指示应执行命令,只支持BundleStatusChange。 | **返回值:** @@ -196,11 +193,12 @@ SystemCapability.BundleManager.BundleFramework | --------------- | ----------------------------------- | | Promise\ | Promise形式返回正确结果或错误信息。 | -## innerBundleManager.getAllLauncherAbilityInfos +## innerBundleManager.getAllLauncherAbilityInfos(deprecated) getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback<Array<LauncherAbilityInfo>>) : void; 以异步方法获取所有的LauncherAbilityInfos,使用callback形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getAllLauncherAbilityInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -216,16 +214,17 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | | callback | AsyncCallback\> | 是 | 程序启动作为入参的回调函数,返回程序信息。 | -## innerBundleManager.getAllLauncherAbilityInfos +## innerBundleManager.getAllLauncherAbilityInfos(deprecated) getAllLauncherAbilityInfos(userId: number) : Promise<Array<LauncherAbilityInfo>> 以异步方法获取LauncherAbilityInfos,使用Promise形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getAllLauncherAbilityInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -241,7 +240,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ----------------------------------------------------- | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -251,11 +250,12 @@ SystemCapability.BundleManager.BundleFramework | ------------------------------------------------------------ | ------------------------- | | Promise\> | Promise形式返回程序信息。 | -## innerBundleManager.getShortcutInfos +## innerBundleManager.getShortcutInfos(deprecated) getShortcutInfos(bundleName :string, callback: AsyncCallback<Array<ShortcutInfo>>) : void; 以异步方法根据给定的包名获取快捷方式信息,使用callback形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getShortcutInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -271,16 +271,17 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------------------- | | bundleName | string | 是 | 要查询的应用程序包名称。 | | callback | AsyncCallback\> | 是 | 程序启动作为入参的回调函数,返回快捷方式信息。 | -## innerBundleManager.getShortcutInfos +## innerBundleManager.getShortcutInfos(deprecated) getShortcutInfos(bundleName : string) : Promise<Array<ShortcutInfo>> 以异步方法根据给定的包名获取快捷方式信息,使用Promise形式返回结果。 +> 从API version 9开始不再支持。建议使用[launcherBundleManager#getShortcutInfo](js-apis-launcherBundleManager.md)替代。 **需要权限:** @@ -296,7 +297,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------------------ | | bundleName | string | 是 | 要查询的应用程序包名称。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md index 33cd88b59c5953e0687672264df84eac590f6efb..472be9b1a763cf47d800450115c693648ce23971 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle-distributedBundle.md @@ -22,7 +22,7 @@ SystemCapability.BundleManager.DistributedBundleFramework | ------------------------------------------ | ------------ | ------------------ | | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 | -权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) +权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明) ## distributedBundle.getRemoteAbilityInfodeprecated diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index f10b2bea8943bb0f0b713d048267c902b9e9c335..696acdc370e7d3d87a16858890399352fbbca04b 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -20,7 +20,7 @@ import bundle from '@ohos.bundle'; | ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 | | ohos.permission.MANAGE_DISPOSED_APP_STATUS | system_core | 可设置和查询应用的处置状态 | -权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) +权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)。 ## bundle.getApplicationInfodeprecated @@ -40,7 +40,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的应用程序包名称。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | @@ -84,7 +84,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的应用程序包名称。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | @@ -125,7 +125,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的应用程序包名称。 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | @@ -164,7 +164,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------- | ---- | ------------------------------------------------------------ | | bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -207,7 +207,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | | callback | AsyncCallback> | 是 | 程序启动作为入参的回调函数,返回所有可用的BundleInfo。 | @@ -244,7 +244,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleFlag | BundleFlag | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -283,7 +283,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------- | ---- | --------------------------------------- | | bundleName | string | 是 | 包名 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | @@ -329,7 +329,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 包名 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | @@ -368,7 +368,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 包名 | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | @@ -442,7 +442,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ---------------- | | callback | AsyncCallback<[BundleInstaller](js-apis-bundle-BundleInstaller.md)> | 是 | 安装应用程序包。 | @@ -468,7 +468,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------- | ---- | ------------------------------------- | | bundleName | string | 是 | 指示要清除其缓存数据的应用程序包名称. | | callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | @@ -495,7 +495,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------------------------------- | | bundleName | string | 是 | 指示要清除其缓存数据的应用程序包名称. | @@ -527,7 +527,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------- | ---- | ----------------------------------------------- | | bundleName | string | 是 | 应用程序包名称。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | @@ -555,7 +555,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------- | ---- | ----------------------------------------------- | | bundleName | string | 是 | 应用程序包名称。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | @@ -588,11 +588,11 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ----------------------------------------------- | | info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability信息。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | -| callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | +| callback | AsyncCallback\ | 是 | 为返回操作结果而调用的回调。 | ## bundle.setAbilityEnableddeprecated @@ -616,7 +616,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ----------------------------------------------- | | info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability信息。 | | isEnable | boolean | 是 | 指定是否启用应用程序。true表示启用,false禁用。 | @@ -649,7 +649,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ | | permissionName | string | 是 | 指定权限的名称。 | | callback | AsyncCallback<[PermissionDef](js-apis-bundle-PermissionDef)> | 是 | 程序启动作为入参的回调函数,返回定义的权限信息。 | @@ -676,7 +676,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------------- | ------ | ---- | ---------------- | | permissionName | string | 是 | 指定权限的名称。 | @@ -705,7 +705,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -747,7 +747,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | @@ -786,7 +786,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag | | callback | AsyncCallback> | 是 | 程序启动作为入参的回调函数,返回应用信息列表。 | @@ -818,7 +818,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------ | | hapFilePath | string | 是 | HAP存放路径。路径应指向当前应用程序的数据目录的相对目录。 | | bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | @@ -855,7 +855,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------ | | hapFilePath | string | 是 | HAP存放路径。路径应指向当前应用程序的数据目录的相对目录。 | | bundleFlags | number | 是 | 用于指定要返回的BundleInfo对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag | @@ -894,7 +894,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---------------- | | bundleName | string | 是 | 应用程序包名。 | | abilityName | string | 是 | Ability名称。 | @@ -936,7 +936,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------ | ---- | ---------------- | | bundleName | string | 是 | 应用程序包名。 | | abilityName | string | 是 | Ability名称。 | @@ -974,7 +974,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---------------- | | bundleName | string | 是 | 应用程序包名。 | | abilityName | string | 是 | Ability名称。 | @@ -1016,7 +1016,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------- | ---- | ---------------- | | bundleName | string | 是 | 应用程序包名。 | | abilityName | string | 是 | Ability名称。 | @@ -1050,9 +1050,9 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---- | ----------- | ---- | ------------ | -| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability的配置信息 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------------------------------------- | ---- | ----------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability的配置信息 | **返回值:** @@ -1088,10 +1088,10 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------- | ----------------------- | ---- | --------------- | -| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability的配置信息 | -| callback | AsyncCallback\ | 是 | 返回boolean代表是否启用 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | ----------------------- | +| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | 是 | Ability的配置信息 | +| callback | AsyncCallback\ | 是 | 返回boolean代表是否启用 | **示例:** @@ -1123,9 +1123,9 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ------ | ---- | ------------ | -| bundleName | string | 是 | 要查询的应用程序包名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------ | +| bundleName | string | 是 | 要查询的应用程序包名称。 | **返回值:** @@ -1159,10 +1159,10 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ----------------------- | ---- | --------------- | -| bundleName | string | 是 | 要查询的应用程序包名称。 | -| callback | AsyncCallback\ | 是 | 返回boolean代表是否启用 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------- | ---- | ------------------------ | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| callback | AsyncCallback\ | 是 | 返回boolean代表是否启用 | **示例:** @@ -1195,7 +1195,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------------------- | | want | [Want](js-apis-application-Want.md) | 是 | 包含要查询的应用程序包名称的意图。 | | bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag | @@ -1244,7 +1244,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 | | bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag | @@ -1287,7 +1287,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | want | [Want](js-apis-application-Want.md) | 是 | 指示包含要查询的应用程序包名称的意图。 | | bundleFlags | number | 是 | 用于指定返回abilityInfo信息。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中Ability信息相关flag | @@ -1330,9 +1330,9 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ------ | ---- | ------------ | -| bundleName | string | 是 | 要查询的应用程序包名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------ | +| bundleName | string | 是 | 要查询的应用程序包名称。 | **返回值:** | 类型 | 说明 | @@ -1369,10 +1369,10 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | -------------------- | ---- | ------------------------------ | -| bundleName | string | 是 | 要查询的应用程序包名称。 | -| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | 是 | 程序启动作为入参的回调函数,返回拉起指定应用的want对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------------------- | ---- | -------------------------------------------------------- | +| bundleName | string | 是 | 要查询的应用程序包名称。 | +| callback | AsyncCallback\<[Want](js-apis-application-Want.md)> | 是 | 程序启动作为入参的回调函数,返回拉起指定应用的want对象。 | **示例:** @@ -1402,9 +1402,9 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---- | ------ | ---- | -------- | -| uid | number | 是 | 要查询的uid。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------- | +| uid | number | 是 | 要查询的uid。 | **返回值:** | 类型 | 说明 | @@ -1437,10 +1437,10 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | ------------------------- | -| uid | number | 是 | 要查询的uid。 | -| callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回指定uid的包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ----------------------------------------------- | +| uid | number | 是 | 要查询的uid。 | +| callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回指定uid的包名。 | **示例:** @@ -1474,10 +1474,10 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ----------- | ---------------------------------------- | ---- | ---------------------------------------- | -| bundleName | string | 是 | 要查询的bundleName。 | -| abilityName | string | 是 | 要查询的abilityName。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | --------------------- | +| bundleName | string | 是 | 要查询的bundleName。 | +| abilityName | string | 是 | 要查询的abilityName。 | **返回值:** | 类型 | 说明 | @@ -1515,7 +1515,7 @@ SystemCapability.BundleManager.BundleFramework **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | ---------------------------------------- | | bundleName | string | 是 | 要查询的bundleName。 | | abilityName | string | 是 | 要查询的abilityName。 | @@ -1540,28 +1540,28 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { **系统能力:** SystemCapability.BundleManager.BundleFramework -| 名称 | 默认值 | 说明 | -| ---------------------------------------- | ---- | ------------------------- | -| SUCCESS | 0 | 安装成功 | -| STATUS_INSTALL_FAILURE | 1 | 安装失败(不存在安装的应用) | -| STATUS_INSTALL_FAILURE_ABORTED | 2 | 安装中止 | -| STATUS_INSTALL_FAILURE_INVALID | 3 | 安装参数无效 | -| STATUS_INSTALL_FAILURE_CONFLICT | 4 | 安装冲突 (常见于升级和已有应用基本信息不一致) | -| STATUS_INSTALL_FAILURE_STORAGE | 5 | 存储包信息失败 | -| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | 安装不兼容(常见于版本降级安装或者签名信息错误) | -| STATUS_UNINSTALL_FAILURE | 7 | 卸载失败 (不存在卸载的应用) | -| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | 卸载中止 (没有使用) | -| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | 卸载中止 (参数无效导致) | -| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | 卸载冲突 (卸载系统应用失败, 结束应用进程失败) | -| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | 安装失败 (下载超时) | -| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | 安装失败 (下载失败) | -| STATUS_RECOVER_FAILURE_INVALID8+ | 0x0D | 恢复预置应用失败 | -| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability未找到 | -| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS服务错误 | -| STATUS_FAILED_NO_SPACE_LEFT8+ | 0x42 | 设备空间不足 | -| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED8+ | 0x43 | 应用授权失败 | -| STATUS_INSTALL_PERMISSION_DENIED8+ | 0x44 | 安装权限拒绝 | -| STATUS_UNINSTALL_PERMISSION_DENIED8+ | 0x45 | 卸载权限拒绝 | +| 名称 | 值 | 说明 | +| ---------------------------------------------------- | ---- | ------------------------------------------------ | +| SUCCESS | 0 | 安装成功 | +| STATUS_INSTALL_FAILURE | 1 | 安装失败(不存在安装的应用) | +| STATUS_INSTALL_FAILURE_ABORTED | 2 | 安装中止 | +| STATUS_INSTALL_FAILURE_INVALID | 3 | 安装参数无效 | +| STATUS_INSTALL_FAILURE_CONFLICT | 4 | 安装冲突 (常见于升级和已有应用基本信息不一致) | +| STATUS_INSTALL_FAILURE_STORAGE | 5 | 存储包信息失败 | +| STATUS_INSTALL_FAILURE_INCOMPATIBLE | 6 | 安装不兼容(常见于版本降级安装或者签名信息错误) | +| STATUS_UNINSTALL_FAILURE | 7 | 卸载失败 (不存在卸载的应用) | +| STATUS_UNINSTALL_FAILURE_BLOCKED | 8 | 卸载中止 (没有使用) | +| STATUS_UNINSTALL_FAILURE_ABORTED | 9 | 卸载中止 (参数无效导致) | +| STATUS_UNINSTALL_FAILURE_CONFLICT | 10 | 卸载冲突 (卸载系统应用失败, 结束应用进程失败) | +| STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT | 0x0B | 安装失败 (下载超时) | +| STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED | 0x0C | 安装失败 (下载失败) | +| STATUS_RECOVER_FAILURE_INVALID8+ | 0x0D | 恢复预置应用失败 | +| STATUS_ABILITY_NOT_FOUND | 0x40 | Ability未找到 | +| STATUS_BMS_SERVICE_ERROR | 0x41 | BMS服务错误 | +| STATUS_FAILED_NO_SPACE_LEFT8+ | 0x42 | 设备空间不足 | +| STATUS_GRANT_REQUEST_PERMISSIONS_FAILED8+ | 0x43 | 应用授权失败 | +| STATUS_INSTALL_PERMISSION_DENIED8+ | 0x44 | 缺少安装权限 | +| STATUS_UNINSTALL_PERMISSION_DENIED8+ | 0x45 | 缺少卸载权限 | ## BundleFlagdeprecated @@ -1571,20 +1571,20 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 默认值 | 说明 | -| ---------------------------------------- | ---------- | ------------------- | -| GET_BUNDLE_DEFAULT | 0x00000000 | 获取默认的应用信息 | -| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | 获取包括Ability信息的包信息 | -| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | 获取包括权限的Ability信息 | -| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | 获取包括应用的Ability信息 | -| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 | -| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 | -| GET_ABILITY_INFO_WITH_METADATA8+ | 0x00000020 | 获取ability的元数据信息 | -| GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | 获取应用的元数据信息 | -| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | 获取仅包括系统应用的ability信息 | -| GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | 获取包括被禁用的ability信息 | -| GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | 获取包括被禁用的应用信息 | -| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 | +| 名称 | 值 | 说明 | +| ----------------------------------------------- | ---------- | ------------------------------- | +| GET_BUNDLE_DEFAULT | 0x00000000 | 获取默认的应用信息 | +| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | 获取包括Ability信息的包信息 | +| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | 获取包括权限的Ability信息 | +| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | 获取包括Application的ability信息 | +| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | 获取包括权限的应用信息 | +| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | 获取包括所需权限的包信息 | +| GET_ABILITY_INFO_WITH_METADATA8+ | 0x00000020 | 获取ability的元数据信息 | +| GET_APPLICATION_INFO_WITH_METADATA8+ | 0x00000040 | 获取应用的元数据信息 | +| GET_ABILITY_INFO_SYSTEMAPP_ONLY8+ | 0x00000080 | 获取仅包括系统应用的ability信息 | +| GET_ABILITY_INFO_WITH_DISABLE8+ | 0x00000100 | 获取包括被禁用的ability信息 | +| GET_APPLICATION_INFO_WITH_DISABLE8+ | 0x00000200 | 获取包括被禁用的应用信息 | +| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 | ## BundleOptionsdeprecated > 从API version 9开始不再维护,不推荐使用。 @@ -1593,9 +1593,9 @@ bundle.getAbilityIcon(bundleName, abilityName, (err, data) => { **系统能力:** SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------ | ------ | ---- | ---- | ---------------------------- | -| userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | +| 参数名 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ----------------------------------------------------- | +| userId | number | 是 | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | ## AbilityTypedeprecated @@ -1605,12 +1605,12 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| ------- | ---- | ----------------- | -| UNKNOWN | 无 | 未知Ability类型 | -| PAGE | 无 | Ability有一个UI界面 | -| SERVICE | 无 | Ability没有UI界面 | -| DATA | 无 | Ability用于提供数据访问服务 | +| 参数名 | 类型 | 说明 | +| ------- | ---- | --------------------------- | +| UNKNOWN | 无 | 未知Ability类型 | +| PAGE | 无 | 表示基于Page模板开发的FA,用于提供与用户交互的能力 | +| SERVICE | 无 | 表示基于Service模板开发的PA,用于提供后台运行任务的能力 | +| DATA | 无 | 表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象 | ## DisplayOrientationdeprecated @@ -1620,12 +1620,12 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| ------------- | ---- | ------------- | -| UNSPECIFIED | 无 | 屏幕方向--不指定 | -| LANDSCAPE | 无 | 屏幕方向--横屏 | -| PORTRAIT | 无 | 屏幕方向--竖屏 | -| FOLLOW_RECENT | 无 | 屏幕方向--紧跟上一个组件 | +| 参数名 | 类型 | 说明 | +| ------------- | ---- | ------------------------ | +| UNSPECIFIED | 无 | 屏幕方向--不指定 | +| LANDSCAPE | 无 | 屏幕方向--横屏 | +| PORTRAIT | 无 | 屏幕方向--竖屏 | +| FOLLOW_RECENT | 无 | 屏幕方向--紧跟上一个组件 | ## LaunchModedeprecated > 从API version 9开始不再维护,建议使用[bundleManager.LaunchType](js-apis-bundleManager.md#launchtype)替代。 @@ -1634,10 +1634,10 @@ Ability类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| --------- | ---- | ------------- | -| SINGLETON | 0 | Ability只有一个示例 | -| STANDARD | 1 | Ability有多个示例 | +| 参数名 | 类型 | 说明 | +| --------- | ---- | ------------------- | +| SINGLETON | 0 | Ability只有一个实例 | +| STANDARD | 1 | Ability有多个实例 | ## AbilitySubTypedeprecated > 从API version 9开始不再维护,不推荐使用。 @@ -1646,9 +1646,9 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| ----------- | ---- | -------------------- | -| UNSPECIFIED | 0 | 未定义Ability子类型 | +| 参数名 | 类型 | 说明 | +| ----------- | ---- | ----------------------------- | +| UNSPECIFIED | 0 | 未定义Ability子类型 | | CA | 1 | Ability子类型是带有 UI 的服务 | ## ColorModedeprecated @@ -1658,8 +1658,8 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| ---------- | ---- | ---- | +| 参数名 | 类型 | 说明 | +| ---------- | ---- | -------- | | AUTO_MODE | -1 | 自动模式 | | DARK_MODE | 0 | 黑色模式 | | LIGHT_MODE | 1 | 亮度模式 | @@ -1673,7 +1673,7 @@ Ability的子类型 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework -| 名称 | 类型 | 说明 | -| ------------------ | ---- | ---- | -| PERMISSION_DENIED | -1 | 拒绝许可 | -| PERMISSION_GRANTED | 0 | 批准 | \ No newline at end of file +| 参数名 | 类型 | 说明 | +| ------------------ | ---- | ------------ | +| PERMISSION_DENIED | -1 | 拒绝授予权限 | +| PERMISSION_GRANTED | 0 | 授予权限 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index 9e171c87d7a9bf5342a08558ec1a46d724034888..f4dd816dc61aae56be4d7dcf006e7b786a21cea0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -4,7 +4,7 @@ Context模块提供了ability或application的上下文的能力,包括允许 > **说明:** > -> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块接口仅可在FA模型下使用。 ## 使用说明 @@ -12,9 +12,11 @@ Context模块提供了ability或application的上下文的能力,包括允许 Context对象是在featureAbility中创建实例,并通过featureAbility的getContext()接口返回,因此在使用Context时,必须导入@ohos.ability.featureAbility库。示例如下: ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getOrCreateLocalDir() +context.getOrCreateLocalDir().then((data) => { + console.info("getOrCreateLocalDir data: " + JSON.stringify(data)); +}); ``` ## Context.getOrCreateLocalDir7+ @@ -36,11 +38,11 @@ getOrCreateLocalDir(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getOrCreateLocalDir((err, data)=>{ - console.info("data=" + data); -}) + console.info("getOrCreateLocalDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -64,10 +66,10 @@ getOrCreateLocalDir(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getOrCreateLocalDir().then((data) => { - console.info("data=" + data); + console.info("getOrCreateLocalDir data: " + JSON.stringify(data)); }); ``` @@ -92,11 +94,13 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' -import bundle from '@ohos.bundle' +import featureAbility from '@ohos.ability.featureAbility'; +import bundle from '@ohos.bundle'; var context = featureAbility.getContext(); -bundle.getBundleInfo('com.context.test', 1, (err,datainfo) =>{ - context.verifyPermission("com.example.permission", {uid:datainfo.uid}); +bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{ + context.verifyPermission("com.example.permission", {uid:datainfo.uid}, (err, data) =>{ + console.info("verifyPermission err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); + }); }); ``` @@ -120,9 +124,11 @@ verifyPermission(permission: string, callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.verifyPermission("com.example.permission") +context.verifyPermission("com.example.permission", (err, data) =>{ + console.info("verifyPermission err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## Context.verifyPermission7+ @@ -149,12 +155,11 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\ { - console.info("======================>verifyPermissionCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("verifyPermission data: " + JSON.stringify(data)); }); ``` @@ -179,7 +184,7 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number, res **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.requestPermissionsFromUser( ["com.example.permission1", @@ -187,11 +192,11 @@ context.requestPermissionsFromUser( "com.example.permission3", "com.example.permission4", "com.example.permission5"], - 1,(err, data)=>{ - console.info("====>requestdata====>" + JSON.stringify(data)); - console.info("====>requesterrcode====>" + JSON.stringify(err.code)); + 1, + (err, data) => { + console.info("requestPermissionsFromUser err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); } -) +); ``` @@ -219,7 +224,7 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number): Pr **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.requestPermissionsFromUser( ["com.example.permission1", @@ -228,8 +233,9 @@ context.requestPermissionsFromUser( "com.example.permission4", "com.example.permission5"], 1).then((data)=>{ - console.info("====>requestdata====>" + JSON.stringify(data)); - }); + console.info("requestPermissionsFromUser data: " + JSON.stringify(data)); + } +); ``` @@ -251,9 +257,11 @@ getApplicationInfo(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getApplicationInfo() +context.getApplicationInfo((err, data) => { + console.info("getApplicationInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -275,11 +283,10 @@ getApplicationInfo(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getApplicationInfo().then((data) => { - console.info("=====================>getApplicationInfoCallback===================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getApplicationInfo data: " + JSON.stringify(data)); }); ``` @@ -302,9 +309,11 @@ getBundleName(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getBundleName() +context.getBundleName((err, data) => { + console.info("getBundleName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -326,11 +335,10 @@ getBundleName(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getBundleName().then((data) => { - console.info("=======================>getBundleNameCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getBundleName data: " + JSON.stringify(data)); }); ``` @@ -351,9 +359,11 @@ getDisplayOrientation(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getDisplayOrientation() +context.getDisplayOrientation((err, data) => { + console.info("getDisplayOrientation err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## Context.getDisplayOrientation7+ @@ -373,11 +383,10 @@ getDisplayOrientation(): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getDisplayOrientation().then((data) => { - console.info("=======================>getDisplayOrientationCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getDisplayOrientation data: " + JSON.stringify(data)); }); ``` @@ -398,9 +407,11 @@ getExternalCacheDir(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getExternalCacheDir() +context.getExternalCacheDir((err, data) => { + console.info("getExternalCacheDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## Context.getExternalCacheDir @@ -420,11 +431,10 @@ getExternalCacheDir(): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getExternalCacheDir().then((data) => { - console.info("=======================>getExternalCacheDirCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getExternalCacheDir data: " + JSON.stringify(data)); }); ``` @@ -446,12 +456,12 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCal **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' -import bundle from '@ohos.bundle' +import featureAbility from '@ohos.ability.featureAbility'; +import bundle from '@ohos.bundle'; var context = featureAbility.getContext(); var orientation=bundle.DisplayOrientation.UNSPECIFIED -context.setDisplayOrientation(orientation, (err) => { - console.log('---------- setDisplayOrientation fail, err: -----------', err); +context.setDisplayOrientation(orientation, (err, data) => { + console.info("setDisplayOrientation err: " + JSON.stringify(err)); }); ``` @@ -473,13 +483,12 @@ setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' -import bundle from '@ohos.bundle' +import featureAbility from '@ohos.ability.featureAbility'; +import bundle from '@ohos.bundle'; var context = featureAbility.getContext(); var orientation=bundle.DisplayOrientation.UNSPECIFIED context.setDisplayOrientation(orientation).then((data) => { - console.info("=======================>setDisplayOrientationCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("setDisplayOrientation data: " + JSON.stringify(data)); }); ``` @@ -501,11 +510,11 @@ setShowOnLockScreen(show: boolean, callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); var show=true -context.setShowOnLockScreen(show, (err) => { - console.log('---------- setShowOnLockScreen fail, err: -----------', err); +context.setShowOnLockScreen(show, (err, data) => { + console.info("setShowOnLockScreen err: " + JSON.stringify(err)); }); ``` @@ -532,12 +541,11 @@ setShowOnLockScreen(show: boolean): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); var show=true context.setShowOnLockScreen(show).then((data) => { - console.info("=======================>setShowOnLockScreenCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("setShowOnLockScreen data: " + JSON.stringify(data)); }); ``` @@ -559,11 +567,11 @@ setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); var wakeUp=true -context.setWakeUpScreen(wakeUp, (err) => { - console.log('---------- setWakeUpScreen fail, err: -----------', err); +context.setWakeUpScreen(wakeUp, (err, data) => { + console.info("setWakeUpScreen err: " + JSON.stringify(err)); }); ``` @@ -590,12 +598,11 @@ setWakeUpScreen(wakeUp: boolean): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); var wakeUp=true context.setWakeUpScreen(wakeUp).then((data) => { - console.info("=======================>setWakeUpScreenCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("setWakeUpScreen data: " + JSON.stringify(data)); }); ``` @@ -619,9 +626,11 @@ getProcessInfo(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getProcessInfo() +context.getProcessInfo((err, data) => { + console.info("getProcessInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -643,11 +652,10 @@ getProcessInfo(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getProcessInfo().then((data) => { - console.info("=======================>getProcessInfoCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getProcessInfo data: " + JSON.stringify(data)); }); ``` @@ -672,9 +680,11 @@ getElementName(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getElementName() +context.getElementName((err, data) => { + console.info("getElementName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -698,11 +708,10 @@ getElementName(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getElementName().then((data) => { - console.info("=======================>getElementNameCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getElementName data: " + JSON.stringify(data)); }); ``` @@ -723,9 +732,11 @@ getProcessName(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getProcessName() +context.getProcessName((err, data) => { + console.info("getProcessName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -747,11 +758,10 @@ getProcessName(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getProcessName().then((data) => { - console.info("=======================>getProcessNameCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getProcessName data: " + JSON.stringify(data)); }); ``` @@ -774,9 +784,11 @@ getCallingBundle(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); -context.getCallingBundle() +context.getCallingBundle((err, data) => { + console.info("getCallingBundle err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` @@ -798,11 +810,10 @@ getCallingBundle(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getCallingBundle().then((data) => { - console.info("======================>getCallingBundleCallback====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getCallingBundle data: " + JSON.stringify(data)); }); ``` @@ -823,14 +834,10 @@ getCacheDir(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getCacheDir((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getCacheDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -851,11 +858,10 @@ getCacheDir(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getCacheDir().then((data) => { - console.info("======================>getCacheDirPromsie====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getCacheDir data: " + JSON.stringify(data)); }); ``` @@ -876,14 +882,10 @@ getFilesDir(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getFilesDir((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getFilesDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -904,11 +906,10 @@ getFilesDir(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getFilesDir().then((data) => { - console.info("======================>getFilesDirPromsie====================>"); - console.info("====>data====>" + JSON.stringify(data)); + console.info("getFilesDir data: " + JSON.stringify(data)); }); ``` @@ -931,14 +932,10 @@ getOrCreateDistributedDir(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getOrCreateDistributedDir((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getOrCreateDistributedDir err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -961,10 +958,10 @@ getOrCreateDistributedDir(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getOrCreateDistributedDir().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("getOrCreateDistributedDir data: " + JSON.stringify(data)); }); ``` @@ -985,14 +982,10 @@ getAppType(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAppType((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getAppType err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -1013,10 +1006,10 @@ getAppType(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAppType().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("getAppType data: " + JSON.stringify(data)); }); ``` @@ -1037,14 +1030,10 @@ getHapModuleInfo(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getHapModuleInfo((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getHapModuleInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -1065,10 +1054,10 @@ getHapModuleInfo(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getHapModuleInfo().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("getHapModuleInfo data: " + JSON.stringify(data)); }); ``` @@ -1089,14 +1078,10 @@ getAppVersionInfo(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAppVersionInfo((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getAppVersionInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -1117,10 +1102,10 @@ getAppVersionInfo(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAppVersionInfo().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("getAppVersionInfo data: " + JSON.stringify(data)); }); ``` @@ -1141,14 +1126,10 @@ getAbilityInfo(callback: AsyncCallback\): void **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAbilityInfo((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("getAbilityInfo err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -1169,10 +1150,10 @@ getAbilityInfo(): Promise\ **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.getAbilityInfo().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("getAbilityInfo data: " + JSON.stringify(data)); }); ``` @@ -1193,7 +1174,7 @@ getApplicationContext(): Context **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext().getApplicationContext(); ``` @@ -1214,14 +1195,10 @@ isUpdatingConfigurations(callback: AsyncCallback\): void; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.isUpdatingConfigurations((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.info("isUpdatingConfigurations err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); }); ``` @@ -1242,10 +1219,10 @@ isUpdatingConfigurations(): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.isUpdatingConfigurations().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("isUpdatingConfigurations data: " + JSON.stringify(data)); }); ``` @@ -1266,14 +1243,10 @@ printDrawnCompleted(callback: AsyncCallback\): void; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.printDrawnCompleted((err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); + console.error('printDrawnCompleted err: ' + JSON.stringify(err)); }); ``` @@ -1294,10 +1267,10 @@ printDrawnCompleted(): Promise\; **示例:** ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext(); context.printDrawnCompleted().then((data) => { - console.info("====>data====>" + JSON.stringify(data)); + console.info("printDrawnCompleted data: " + JSON.stringify(data)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-Want.md b/zh-cn/application-dev/reference/apis/js-apis-ability-Want.md new file mode 100644 index 0000000000000000000000000000000000000000..0d58b674eeada7347da187882d6f8f5f5ee1534b --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-Want.md @@ -0,0 +1,67 @@ +# Want + +Want是对象间信息传递的载体, 可以用于应用组件间的信息传递。 Want的使用场景之一是作为startAbility的参数, 其包含了指定的启动目标, 以及启动时需携带的相关数据, 如bundleName和abilityName字段分别指明目标Ability所在应用的包名以及对应包内的Ability名称。当Ability A需要启动Ability B并传入一些数据时, 可使用Want作为载体将这些数据传递给Ability B。 + +> **说明:** +> +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | +| bundleName | 只读 | string | 否 | 表示包名。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | +| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中该字段同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。AbilityName需要在一个应用的范围内保证唯一。 | +| uri | 只读 | string | 否 | 表示Uri。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | +| type | 只读 | string | 否 | 表示MIME type类型,打开文件的类型,主要用于文管打开文件。比如:"text/xml" 、 "image/*"等,MIME定义参考:https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com。 | +| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](js-apis-featureAbility.md#flags说明)。 | +| action | 只读 | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。 | +| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:
ohos.aafwk.callerPid 表示拉起方的pid。
ohos.aafwk.param.callerToken 表示拉起方的token。
ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1)中的uid,应用包里应用程序的uid。 | +| entities | 只读 | Array\ | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器),在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。 | +| moduleName9+ | 只读 | string | 否 | 表示待启动的Ability所属的模块(module)。 | + +具体字段描述参考ability/want.d.ts文件 + +**示例:** + +- 基础用法 + + ``` ts + var want = { + "deviceId": "", // deviceId为空表示本设备 + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry" // moduleName非必选 + }; + this.context.startAbility(want, (error) => { + // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability + console.log("error.code = " + error.code) + }) + ``` + +- 传递FD数据,FD表示文件描述符(FileDescriptor) + + ``` ts + import fileio from '@ohos.fileio'; + var fd; + try { + fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); + } catch(e) { + console.log("openSync fail:" + JSON.stringify(e)); + } + var want = { + "deviceId": "", // deviceId为空表示本设备 + "bundleName": "com.extreme.test", + "abilityName": "MainAbility", + "moduleName": "entry", // moduleName非必选 + "parameters": { + "keyFd":{"type":"FD", "value":fd} + } + }; + this.context.startAbility(want, (error) => { + // 显式拉起Ability,通过bundleName、abilityName和moduleName可以唯一确定一个Ability + console.log("error.code = " + error.code) + }) + ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md b/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..5ff48efe1904e054c0fbefc92707039ba14a350a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-ability.md @@ -0,0 +1,38 @@ +# Ability + +Ability模块将二级模块API组织在一起方便开发者进行导出。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块接口仅可在FA模型下使用 + +## 导入模块 + +```ts +import ability from '@ohos.ability.ability' +``` + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| DataAbilityHelper | 只读 | number | 否 | DataAbilityHelper二级模块。 | +| PacMap | 只读 | Want | 否 | PacMap二级模块。 | +| DataAbilityOperation | 只读 | Want | 否 | DataAbilityOperation二级模块。 | +| DataAbilityResult | 只读 | Want | 否 | DataAbilityResult二级模块。 | +| AbilityResult | 只读 | Want | 否 | AbilityResult二级模块。 | +| ConnectOptions | 只读 | Want | 否 | ConnectOptions二级模块。 | +| StartAbilityParameter | 只读 | Want | 否 | StartAbilityParameter二级模块。 | + +**示例:** + + ```ts + let dataAbilityHelper: ability.DataAbilityHelper; + let pacMap: ability.PacMap; + let dataAbilityOperation: ability.DataAbilityOperation; + let dataAbilityResult: ability.DataAbilityResult; + let abilityResult: ability.AbilityResult; + let connectOptions: ability.ConnectOptions; + let startAbilityParameter: ability.StartAbilityParameter; + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-abilityResult.md b/zh-cn/application-dev/reference/apis/js-apis-ability-abilityResult.md new file mode 100644 index 0000000000000000000000000000000000000000..2305ac5a20596fb301c4857eccccaaa840dc9311 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-abilityResult.md @@ -0,0 +1,22 @@ +# AbilityResult7+ + +定义ability拉起、销毁之后返回的结果码和数据。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| resultCode | 只读 | number | 否 | 表示ability拉起、销毁之后返回的结果码。 | +| want | 只读 | [Want](js-apis-ability-Want.md) | 否 | 表示ability销毁之后返回的数据。 | + +**示例:** + ```ts + let want = { + bundleName: 'com.example.mydocapplication', + abilityName: 'MainAbility', + }; + this.context.startAbilityForResult(want, (error, data) => { + let resultCode = data.resultCode; + let want = data.want; + }); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 3bf7786bb7175ba951fbce561abe33050f5d8e52..15895ab2b64d8b76e8e5c1c928e812f37aeeff19 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -48,7 +48,7 @@ checkAccessToken(tokenID: number, permissionName: Permissions): Promise<Grant | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------- | ---- | ------------------------------------------ | -| tokenID | number | 是 | 要校验的目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 要校验的目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 需要校验的权限名称。 | **返回值:** @@ -135,7 +135,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permiss | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 被授予的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | @@ -190,7 +190,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: Permissions, permiss | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。| | permissionName | Permissions | 是 | 被授予的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | | callback | AsyncCallback<void> | 是 | 授予应用user grant权限。当授予权限成功时,err为undefine;否则为错误对象。 | @@ -242,7 +242,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permis | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 被撤销的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | @@ -297,7 +297,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: Permissions, permis | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 被撤销的权限名称。 | | permissionFlag | number | 是 | 授权选项,1表示下次仍需弹窗,2表示允许、禁止后不再提醒,3表示系统授权不允许更改。 | | callback | AsyncCallback<void> | 是 | 撤销应用user grant权限。当撤销权限成功时,err为undefine;否则为错误对象。 | @@ -349,7 +349,7 @@ getPermissionFlags(tokenID: number, permissionName: Permissions): Promise<num | 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------- | ---- | ------------------------------------------------------------ | -| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得 | +| tokenID | number | 是 | 目标应用的身份标识。可通过应用的[ApplicationInfo](js-apis-bundle-ApplicationInfo.md)获得。 | | permissionName | Permissions | 是 | 查询的权限名称。 | **返回值:** @@ -379,7 +379,7 @@ let permissionFlag = 1; try { atManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => { console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`); - }).catch((err) = > { + }).catch((err) => { console.log(`getPermissionFlags fail, err->${JSON.stringify(err)}`); }); } catch(err) { @@ -610,6 +610,6 @@ promise.then(data => { | 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | ------------------------- | ---- | ---- | ------------------ | -| change | [PermissionStateChangeType](#permissionstatechangetype9) | 是 | 否 | 权限授权状态变化类型 | -| tokenID | number | 是 | 否 | 被订阅的应用身份标识 | -| permissionName | Permissions | 是 | 否 | 当前授权状态发生变化的权限名 | +| change | [PermissionStateChangeType](#permissionstatechangetype9) | 是 | 否 | 权限授权状态变化类型。 | +| tokenID | number | 是 | 否 | 被订阅的应用身份标识。 | +| permissionName | Permissions | 是 | 否 | 当前授权状态发生变化的权限名。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md index 89e43e02cbb2de776cca4c6fa1f43cce120eac67..771686fc1c32393d01438c40774cc4e628ebb18e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePath.md @@ -22,7 +22,7 @@ import GesturePath from '@ohos.accessibility.GesturePath'; ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------ | ---------------------------------------- | ---- | ---- | ------ | | points | Array<[GesturePoint](js-apis-accessibility-GesturePoint.md#gesturepoint)> | 是 | 是 | 手势触摸点。 | | durationTime | number | 是 | 是 | 手势总耗时, 单位为毫秒。 | @@ -37,13 +37,12 @@ constructor(durationTime: number); **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | durationTime | number | 是 | 手势总耗时,单位为毫秒。 | **示例:** ```ts -let durationTime = 20; -let gesturePath = new GesturePath(durationTime); +let gesturePath = new GesturePath.GesturePath(20); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md index d787f38222017e3e524d8d4712f81af7873d5d41..2e1703d2afb51ed3c273b3a829112620231468b0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-GesturePoint.md @@ -22,7 +22,7 @@ import GesturePoint from '@ohos.accessibility.GesturePoint'; ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ------ | ---- | ---- | ------- | | positionX | number | 是 | 是 | 触摸点X坐标。 | | positionY | number | 是 | 是 | 触摸点Y坐标。 | @@ -37,7 +37,7 @@ constructor(positionX: number, positionY: number); **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | positionX | number | 是 | 触摸点X坐标。 | | positionY | number | 是 | 触摸点Y坐标。 | @@ -45,7 +45,5 @@ constructor(positionX: number, positionY: number); **示例:** ```ts -let positionX = 1; -let positionY = 2; -let gesturePoint = new GesturePoint(positionX, positionY); +let gesturePoint = new GesturePoint.GesturePoint(1, 2); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md index 4d7842e34181c20e99e296135c343b359a48d1e5..816a2e717534f23609ddeaf04983bd375c87f61e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-config.md @@ -16,7 +16,7 @@ import config from '@ohos.accessibility.config'; **系统能力**:以下各项对应的系统能力均为SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | highContrastText | [Config](#config)\| 是 | 是 | 表示高对比度文字功能启用状态。 | | invertColor | [Config](#config)\| 是 | 是 | 表示颜色反转功能启用状态。 | @@ -29,7 +29,7 @@ import config from '@ohos.accessibility.config'; | shortkey | [Config](#config)\| 是 | 是 | 表示辅助扩展快捷键功能启用状态。 | | shortkeyTarget | [Config](#config)\| 是 | 是 | 表示辅助扩展快捷键的目标配置。取值为辅助应用的名称,格式为:'bundleName/abilityName'。 | | captions | [Config](#config)\| 是 | 是 | 表示辅助字幕功能启用状态。 | -| captionsStyle | [Config](#config)\<[CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| 是 | 是 | 表示辅助字幕的配置。 | +| captionsStyle | [Config](#config)\<[accessibility.CaptionsStyle](js-apis-accessibility.md#captionsstyle8)>| 是 | 是 | 表示辅助字幕的配置。 | ## enableAbility @@ -41,10 +41,10 @@ enableAbility(name: string, capability: Array<accessibility.Capability>): **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 | -| capability | Array<[accessibility.Capability](js-apis-accessibility.md#capability)>) | 是 | 辅助应用的能力属性。 | +| capability | Array<[accessibility.Capability](js-apis-accessibility.md#capability)> | 是 | 辅助应用的能力属性。 | **返回值:** @@ -64,8 +64,9 @@ enableAbility(name: string, capability: Array<accessibility.Capability>): **示例:** ```ts +import accessibility from '@ohos.accessibility'; let name = 'com.ohos.example/axExtension'; -let capability = ['retrieve']; +let capability : accessibility.Capability[] = ['retrieve']; try { config.enableAbility(name, capability).then(() => { console.info('enable ability succeed'); @@ -75,7 +76,7 @@ try { } catch (exception) { console.error('failed to enable ability, because ' + JSON.stringify(exception)); }; - ``` +``` ## enableAbility @@ -87,7 +88,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 | | capability | Array<[accessibility.Capability](js-apis-accessibility.md#capability)> | 是 | 辅助应用的能力属性。 | @@ -105,10 +106,11 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c **示例:** ```ts +import accessibility from '@ohos.accessibility'; let name = 'com.ohos.example/axExtension'; -let capability = ['retrieve']; +let capability : accessibility.Capability[] = ['retrieve']; try { - config.enableAbility(name, capability, (err, data) => { + config.enableAbility(name, capability, (err) => { if (err) { console.error('failed to enable ability, because ' + JSON.stringify(err)); return; @@ -130,7 +132,7 @@ disableAbility(name: string): Promise<void>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 | @@ -153,7 +155,7 @@ disableAbility(name: string): Promise<void>; ```ts let name = 'com.ohos.example/axExtension'; try { - config.enableAbility(name).then(() => { + config.disableAbility(name).then(() => { console.info('disable ability succeed'); }).catch((err) => { console.error('failed to disable ability, because ' + JSON.stringify(err)); @@ -173,7 +175,7 @@ disableAbility(name: string, callback: AsyncCallback<void>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -213,7 +215,7 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void&g **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 | | callback | Callback<void> | 是 | 回调函数,在启用的辅助扩展的列表变化时通过此函数进行通知。 | @@ -224,12 +226,9 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback<void&g try { config.on('enabledAccessibilityExtensionListChange', () => { console.info('subscribe enabled accessibility extension list change state success'); - }).catch((err) => { - console.error('failed to subscribe enabled accessibility extension list change state, because ' + - JSON.stringify(err)); }); } catch (exception) { - console.error('failed to subscribe enabled accessibility extension list change state, because ' + + console.error('failed to subscribe enabled accessibility extension list change state, because ' + JSON.stringify(exception)); }; ``` @@ -244,9 +243,9 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 否 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 | +| type | string | 是 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 | | callback | Callback<void> | 否 | 要取消的监听回调函数。 | **示例:** @@ -254,13 +253,10 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void ```ts try { config.off('enabledAccessibilityExtensionListChange', () => { - console.info('unSubscribe enabled accessibility extension list change state success'); - }).catch((err) => { - console.error('failed to unSubscribe enabled accessibility extension list change state, because ' + - JSON.stringify(err)); + console.info('Unsubscribe enabled accessibility extension list change state success'); }); } catch (exception) { - console.error('failed to unSubscribe enabled accessibility extension list change state, because ' + + console.error('failed to Unsubscribe enabled accessibility extension list change state, because ' + JSON.stringify(exception)); }; ``` @@ -279,7 +275,7 @@ set(value: T): Promise<void>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | T | 是 | 设置的属性值。 | @@ -314,7 +310,7 @@ set(value: T, callback: AsyncCallback<void>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | T | 是 | 设置的属性值。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -372,9 +368,9 @@ get(callback: AsyncCallback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | 是 | 回调函数,返回属性值。 | +| callback | AsyncCallback<T> | 是 | 回调函数,返回属性值。 | **示例:** @@ -400,7 +396,7 @@ on(callback: Callback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | Callback<T> | 是 | 回调函数,在属性变化时通过此函数进行通知。 | @@ -408,12 +404,8 @@ on(callback: Callback<T>): void; ```ts try { - config.highContrastText.on((err, data) => { - if (err) { - console.error('failed subscribe highContrastText, because ' + JSON.stringify(err)); - return; - } - console.info('subscribe highContrastText success'); + config.highContrastText.on((data) => { + console.info('subscribe highContrastText success, result: ' + JSON.stringify(data)); }); } catch (exception) { console.error('failed subscribe highContrastText, because ' + JSON.stringify(exception)); @@ -430,19 +422,15 @@ off(callback?: Callback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | Callback<T> | 否 | 要取消的监听回调函数。 | **示例:** ```ts -config.highContrastText.off((err, data) => { - if (err) { - console.error('failed unSubscribe highContrastText, because ' + JSON.stringify(err)); - return; - } - console.info('unSubscribe highContrastText success'); +config.highContrastText.off((data) => { + console.info('Unsubscribe highContrastText success, result: ' + JSON.stringify(data)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md index 896b51ae188eec0a7851d8c6647a7939da71444e..8a27d422badf2f80b8a8015ccb072465796a58ab 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility-extension-context.md @@ -56,7 +56,7 @@ class MainAbility extends AccessibilityExtensionAbility { **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ---- | ---- | --------- | | left | number | 是 | 否 | 矩形区域的左边界。 | | top | number | 是 | 否 | 矩形区域的上边界。 | @@ -84,7 +84,7 @@ setTargetBundleName(targetNames: Array\): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------- | ---- | -------- | | targetNames | Array<string> | 是 | 关注的目标包名。 | @@ -119,7 +119,7 @@ setTargetBundleName(targetNames: Array\, callback: AsyncCallback\) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------- | ---- | -------- | | targetNames | Array<string> | 是 | 关注的目标包名。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果设置关注的目标包名失败,则AsyncCallback中err有数据返回。 | @@ -151,7 +151,7 @@ getFocusElement(isAccessibilityFocus?: boolean): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | isAccessibilityFocus | boolean | 否 | 获取的是否是无障碍焦点元素,默认为否。 | @@ -195,7 +195,7 @@ getFocusElement(callback: AsyncCallback\): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回当前对应的焦点元素。 | @@ -210,6 +210,7 @@ getFocusElement(callback: AsyncCallback\): void; **示例:** ```ts +let focusElement; try { axContext.getFocusElement((err, data) => { if (err) { @@ -234,7 +235,7 @@ getFocusElement(isAccessibilityFocus: boolean, callback: AsyncCallback\ { if (err) { @@ -265,7 +268,7 @@ getWindowRootElement(windowId?: number): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | windowId | number | 否 | 指定窗口的编号,未指定则从当前活跃窗口获取。 | @@ -309,7 +312,7 @@ getWindowRootElement(callback: AsyncCallback\): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回指定窗口的根节点元素。 | @@ -324,6 +327,7 @@ getWindowRootElement(callback: AsyncCallback\): void; **示例:** ```ts +let rootElement; try { axContext.getWindowRootElement((err, data) => { if (err) { @@ -348,7 +352,7 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\ { if (err) { @@ -388,7 +394,7 @@ getWindows(displayId?: number): Promise\>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | displayId | number | 否 | 指定的屏幕编号,未指定则从默认主屏幕获取。 | @@ -432,7 +438,7 @@ getWindows(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<Array<AccessibilityElement>> | 是 | 回调函数,返回指定屏幕的所有窗口。 | @@ -472,7 +478,7 @@ getWindows(displayId: number, callback: AsyncCallback\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | @@ -536,10 +542,11 @@ injectGesture(gesturePath: GesturePath): Promise\; ```ts import GesturePath from "@ohos.accessibility.GesturePath"; -let gesturePath = new GesturePath(100); +import GesturePoint from '@ohos.accessibility.GesturePoint'; +let gesturePath = new GesturePath.GesturePath(100); try { for (let i = 0; i < 10; i++) { - let gesturePoint = new GesturePoint(100, i * 200); + let gesturePoint = new GesturePoint.GesturePoint(100, i * 200); gesturePath.points.push(gesturePoint); } axContext.injectGesture(gesturePath).then(() => { @@ -561,7 +568,7 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | | callback | AsyncCallback<void> | 是 | 回调函数,表示注入手势执行结果的回调。 | @@ -578,10 +585,11 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void ```ts import GesturePath from "@ohos.accessibility.GesturePath"; -let gesturePath = new GesturePath(100); +import GesturePoint from '@ohos.accessibility.GesturePoint'; +let gesturePath = new GesturePath.GesturePath(100); try { for (let i = 0; i < 10; i++) { - let gesturePoint = new GesturePoint(100, i * 200); + let gesturePoint = new GesturePoint.GesturePoint(100, i * 200); gesturePath.points.push(gesturePoint); } axContext.injectGesture(gesturePath, (err, data) => { @@ -637,7 +645,7 @@ attributeNames\(callback: AsyncCallback\ **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback<Array<T>> | 是 | 回调函数,返回节点元素的所有属性名称。 | @@ -665,7 +673,7 @@ attributeValue\(attributeName: T): Promi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | attributeName | T | 是 | 表示属性的名称。 | @@ -687,10 +695,12 @@ attributeValue\(attributeName: T): Promi ```ts let attributeName = 'name'; +let attributeValue; +let rootElement; try { rootElement.attributeValue(attributeName).then((data) => { console.log('get attribute value by name success'); - attribtueValue = data; + attributeValue = data; }).catch((err) => { console.log('failed to get attribute value, because ' + JSON.stringify(err)); }); @@ -709,7 +719,7 @@ attributeValue\(attributeName: T, **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | attributeName | T | 是 | 表示属性的名称。 | | callback | AsyncCallback<ElementAttributeValues[T]> | 是 | 回调函数,返回根据节点属性名称获取的属性值。 | @@ -777,7 +787,7 @@ actionNames(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback<Array<string>> | 是 | 回调函数,返回节点元素支持的所有操作名称。 | @@ -805,7 +815,7 @@ performAction(actionName: string, parameters?: object): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | actionName | string | 是 | 表示属性的名称。 | | parameters | object | 否 | 表示执行操作时所需要的参数。 | @@ -848,7 +858,7 @@ performAction(actionName: string, callback: AsyncCallback\): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | actionName | string | 是 | 表示属性的名称。 | | callback | AsyncCallback<void> | 是 | 回调函数,表示执行指定操作的回调。| @@ -887,7 +897,7 @@ performAction(actionName: string, parameters: object, callback: AsyncCallback\9+
| Array<string> | 是 | 否 | 关注的目标包名。 | @@ -133,7 +133,7 @@ import accessibility from '@ohos.accessibility'; **系统能力**:以下各项对应的系统能力均为 SystemCapability.BarrierFree.Accessibility.Hearing -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | | fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | @@ -150,7 +150,7 @@ import accessibility from '@ohos.accessibility'; ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 | | style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 | @@ -163,7 +163,7 @@ on(type: 'enableChange', callback: Callback<boolean>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | | callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | @@ -171,16 +171,10 @@ on(type: 'enableChange', callback: Callback<boolean>): void; **示例:** ```ts -let result = false; let captionsManager = accessibility.getCaptionsManager(); try { - captionsManager.on('enableChange', (err, data) => { - if (err) { - console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(err)); - return; - } - result = data; - console.info('subscribe caption manager enable state change success'); + captionsManager.on('enableChange', (data) => { + console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data)); }); } catch (exception) { console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception)); @@ -195,7 +189,7 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | @@ -206,13 +200,9 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; let captionStyle; let captionsManager = accessibility.getCaptionsManager(); try { - captionsManager.on('styleChange', (err, data) => { - if (err) { - console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(err)); - return; - } + captionsManager.on('styleChange', (data) => { captionStyle = data; - console.info('subscribe caption manager style state change success'); + console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data)); }); } catch (exception) { console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception)); @@ -227,7 +217,7 @@ off(type: 'enableChange', callback?: Callback<boolean>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在字幕配置启用状态变化时将状态通过此函数进行通知。 | @@ -235,19 +225,13 @@ off(type: 'enableChange', callback?: Callback<boolean>): void; **示例:** ```ts -let result = false; let captionsManager = accessibility.getCaptionsManager(); try { - captionsManager.off('enableChange', (err, data) => { - if (err) { - console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(err)); - return; - } - result = data; - console.info('unSubscribe caption manager enable state change success'); + captionsManager.off('enableChange', (data) => { + console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(exception)); + console.error('failed to Unsubscribe caption manager enable state change, because ' + JSON.stringify(exception)); } ``` @@ -259,7 +243,7 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | @@ -270,16 +254,12 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; let captionStyle; let captionsManager = accessibility.getCaptionsManager(); try { - captionsManager.off('styleChange', (err, data) => { - if (err) { - console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(err)); - return; - } + captionsManager.off('styleChange', (data) => { captionStyle = data; - console.info('unSubscribe caption manager style state change success'); + console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(exception)); + console.error('failed to Unsubscribe caption manager style state change, because ' + JSON.stringify(exception)); } ``` @@ -291,7 +271,7 @@ try { ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | | windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | @@ -318,7 +298,7 @@ constructor(jsonObject) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 | @@ -395,7 +375,7 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -445,7 +425,7 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -489,7 +469,7 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -503,9 +483,9 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState) **示例:** ```ts -let abilityType = 'spoken'; -let abilityState = 'enable'; -let extensionList: accessibility.AccessibilityInfo[]; +let abilityType : accessibility.AbilityType = 'spoken'; +let abilityState : accessibility.AbilityState = 'enable'; +let extensionList: accessibility.AccessibilityAbilityInfo[] = []; try { accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => { for (let item of data) { @@ -526,7 +506,7 @@ try { ## accessibility.getAccessibilityExtensionList9+ -getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void +getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void 查询辅助应用列表,使用callback异步回调。 @@ -534,7 +514,7 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -543,9 +523,9 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, **示例:** ```ts -let abilityType = 'spoken'; -let abilityState = 'enable'; -let extensionList: accessibility.AccessibilityInfo[]; +let abilityType : accessibility.AbilityType = 'spoken'; +let abilityState : accessibility.AbilityState = 'enable'; +let extensionList: accessibility.AccessibilityAbilityInfo[] = []; try { accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => { if (err) { @@ -560,8 +540,6 @@ try { extensionList.push(item); } console.info('get accessibility extension list success'); - }).catch((err) => { - console.error('failed to get accessibility extension list because ' + JSON.stringify(err)); }); } catch (exception) { console.error('failed to get accessibility extension list because ' + JSON.stringify(exception)); @@ -598,7 +576,7 @@ on(type: 'accessibilityStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | | callback | Callback<boolean> | 是 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | @@ -607,12 +585,8 @@ on(type: 'accessibilityStateChange', callback: Callback<boolean>): void ```ts try { - accessibility.on('accessibilityStateChange', (err, data) => { - if (err) { - console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(err)); - return; - } - console.info('subscribe accessibility state change success'); + accessibility.on('accessibilityStateChange', (data) => { + console.info('subscribe accessibility state change, result: ' + JSON.stringify(data)); }); } catch (exception) { console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception)); @@ -629,7 +603,7 @@ on(type: 'touchGuideStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | | callback | Callback<boolean> | 是 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | @@ -638,12 +612,8 @@ on(type: 'touchGuideStateChange', callback: Callback<boolean>): void ```ts try { - accessibility.on('touchGuideStateChange', (err, data) => { - if (err) { - console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(err)); - return; - } - console.info('subscribe touch guide state change success'); + accessibility.on('touchGuideStateChange', (data) => { + console.info('subscribe touch guide state change, result: ' + JSON.stringify(data)); }); } catch (exception) { console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception)); @@ -660,7 +630,7 @@ off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 否 | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | @@ -669,15 +639,11 @@ off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void ```ts try { - accessibility.on('accessibilityStateChange', (err, data) => { - if (err) { - console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(err)); - return; - } - console.info('unSubscribe accessibility state change success'); + accessibility.off('accessibilityStateChange', (data) => { + console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(exception)); + console.error('failed to Unsubscribe accessibility state change, because ' + JSON.stringify(exception)); } ``` @@ -691,7 +657,7 @@ off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 否 | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | @@ -700,15 +666,11 @@ off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void ```ts try { - accessibility.on('touchGuideStateChange', (err, data) => { - if (err) { - console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(err)); - return; - } - console.info('unSubscribe touch guide state change success'); + accessibility.off('touchGuideStateChange', (data) => { + console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data)); }); } catch (exception) { - console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(exception)); + console.error('failed to Unsubscribe touch guide state change, because ' + JSON.stringify(exception)); } ``` @@ -746,7 +708,7 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | @@ -796,7 +758,7 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | @@ -827,7 +789,7 @@ sendEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | @@ -867,7 +829,7 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | @@ -899,7 +861,7 @@ sendAccessibilityEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | @@ -938,7 +900,7 @@ sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback<void>): v **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 9e2835b6930e7da7e569e7c8eda729baa5392d93..49b4ff2e97c184127eb2faeea6a0c3401a7a6c9e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -4691,10 +4691,16 @@ onResult: (code: number, result?: AuthResult) => void let appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthCallback(sessionId).then((callback) => { - var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", - [account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo", - [account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", - [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + var result = { + accountInfo: { + name: "Lisi", + owner: "com.example.accountjsdemo", + }, + tokenInfo: { + token: "xxxxxx", + authType: "getSocialData" + } + }; callback.onResult(account_appAccount.ResultCode.SUCCESS, result); }).catch((err) => { console.log("getAuthCallback err: " + JSON.stringify(err)); @@ -4727,9 +4733,16 @@ onRequestRedirected: (request: Want) => void } auth(name, authType, options, callback) { - var result = {[account_appAccount.Constants.KEY_NAME]: name, - [account_appAccount.Constants.KEY_AUTH_TYPE]: authType, - [account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; + var result = { + accountInfo: { + name: "Lisi", + owner: "com.example.accountjsdemo", + }, + tokenInfo: { + token: "xxxxxx", + authType: "getSocialData" + } + }; callback.onResult(account_appAccount.ResultCode.SUCCESS, result); } } diff --git a/zh-cn/application-dev/reference/apis/js-apis-appControl.md b/zh-cn/application-dev/reference/apis/js-apis-appControl.md index 71058a3a8c86c7c6c54067cd6f9ea7c2705de741..54bfbd04652fcaa8e3fe6cb81a7ac64dfec53d20 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appControl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appControl.md @@ -28,9 +28,9 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | -| appId | string | 是 | 需要设置处置状态的应用的appId。
appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | +| appId | string | 是 | 需要设置处置状态的应用的appId。
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | disposedWant | Want | 是 | 对应用的处置意图。 | **返回值:** @@ -41,32 +41,16 @@ setDisposedStatus(appId: string, disposedWant: Want): Promise\ **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取appId -var bundleName = 'com.example.myapplication'; -var appId; -try { - bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) - .then((data) => { - appId = data.signatureInfo.appId; - }, error => { - console.error("getBundleInfo failed " + error.message); - }); -} catch (error) { - console.error("getBundleInfo failed " + error.message); -} - +var appId = "com.example.myapplication_xxxxx"; var want = {bundleName: 'com.example.myapplication'}; try { @@ -95,49 +79,33 @@ setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback\ appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | +| appId | string | 是 | 需要设置处置的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | disposedWant | Want | 是 | 对应用的处置意图。 | | callback | AsyncCallback\ | 是 | 回调函数,当设置处置状态成功,err为undefined,否则为错误对象。 | **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取appId -var bundleName = 'com.example.myapplication'; -var appId; -try { - bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) - .then((data) => { - appId = data.signatureInfo.appId; - }, error => { - console.error("getBundleInfo failed " + error.message); - }); -} catch (error) { - console.error("getBundleInfo failed " + error.message); -} - +var appId = "com.example.myapplication_xxxxx"; var want = {bundleName: 'com.example.myapplication'}; try { - appControl.setDisposedStatus(appId, want, (err, data) => { - if (err) { + appControl.setDisposedStatus(appId, want, (error, data) => { + if (error) { console.error('setDisposedStatus failed ' + error.message); return; } - console.info('setDisposedStatus success'); + console.info('setDisposedStatus success'); }); } catch (error) { console.error('setDisposedStatus failed ' + error.message); @@ -158,9 +126,9 @@ getDisposedStatus(appId: string): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | -| appId | string | 是 | 要查询的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | +| appId | string | 是 | 要查询的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | **返回值:** @@ -170,31 +138,16 @@ getDisposedStatus(appId: string): Promise\; **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取appId -var bundleName = 'com.example.myapplication'; -var appId; -try { - bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) - .then((data) => { - appId = data.signatureInfo.appId; - }, error => { - console.error("getBundleInfo failed " + error.message); - }); -} catch (error) { - console.error("getBundleInfo failed " + error.message); -} +var appId = "com.example.myapplication_xxxxx"; try { appControl.getDisposedStatus(appId) @@ -222,42 +175,27 @@ getDisposedStatus(appId: string, callback: AsyncCallback\): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | -| appId | string | 是 | 要查询的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | +| appId | string | 是 | 要查询的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | callback | AsyncCallback\ | 是 | 回调函数。当获取应用的处置状态成功时,err为undefined,data为获取到的处置状态;否则为错误对象。 | **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取appId -var bundleName = 'com.example.myapplication'; -var appId; -try { - bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) - .then((data) => { - appId = data.signatureInfo.appId; - }, error => { - console.error("getBundleInfo failed " + error.message); - }); -} catch (error) { - console.error("getBundleInfo failed " + error.message); -} +var appId = "com.example.myapplication_xxxxx"; try { - appControl.getDisposedStatus(appId, (err, data) => { - if (err) { + appControl.getDisposedStatus(appId, (error, data) => { + if (error) { console.error('getDisposedStatus failed ' + error.message); return; } @@ -282,9 +220,9 @@ deleteDisposedStatus(appId: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | -| appId | string | 是 | 要删除处置状态的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | | +| appId | string | 是 | 要删除处置状态的应用的appId
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | **返回值:** @@ -294,31 +232,16 @@ deleteDisposedStatus(appId: string): Promise\ **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' -import bundleManager from '@ohos.bundle.bundleManager'; - -// 获取appId -var bundleName = 'com.example.myapplication'; -var appId; -try { - bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) - .then((data) => { - appId = data.signatureInfo.appId; - }, error => { - console.error("getBundleInfo failed " + error.message); - }); -} catch (error) { - console.error("getBundleInfo failed " + error.message); -} +var appId = "com.example.myapplication_xxxxx"; try { appControl.deleteDisposedStatus(appId) @@ -346,49 +269,56 @@ deleteDisposedStatus(appId: string, callback: AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | -| appId | string | 是 | 要查询的应用的appId。
appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过getBundleInfo接口获取。 | +| appId | string | 是 | 要查询的应用的appId。
appId是应用的唯一标识,由应用的包名和签名信息决定,获取方法参见[获取应用的appId](#获取应用的appid)。 | | callback | AsyncCallback\ | 是 | 回调函数,当设置处置状态成功时,err返回undefined。否则回调函数返回具体错误对象。 | **错误码** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码 | 错误信息 | +| 错误码ID | 错误信息 | | ------ | -------------------------------------- | | 17700005 | The specified appId was not found. | **示例:** ```ts -import appControl from '@ohos.bundle.appControl' +var appId = "com.example.myapplication_xxxxx"; +try { + appControl.deleteDisposedStatus(appId, (error, data) => { + if (error) { + console.error('deleteDisposedStatus failed ' + error.message); + return; + } + console.info('deleteDisposedStatus success'); + }); +} catch (error) { + console.error('deleteDisposedStatus failed ' + error.message); +} +``` + +## 获取应用的appId + +appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过[getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)接口获取。 + +**示例:** + +```ts import bundleManager from '@ohos.bundle.bundleManager'; -// 获取appId var bundleName = 'com.example.myapplication'; var appId; try { bundleManager.getBundleInfo(bundleName, bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) .then((data) => { appId = data.signatureInfo.appId; - }, error => { + console.info("appId is " + appId); + }).catch((error) => { console.error("getBundleInfo failed " + error.message); }); } catch (error) { console.error("getBundleInfo failed " + error.message); } - -try { - appControl.deleteDisposedStatus(appId, (err, data) => { - if (err) { - console.error('deleteDisposedStatus failed ' + error.message); - return; - } - console.info('deleteDisposedStatus success'); - }); -} catch (error) { - console.error('deleteDisposedStatus failed ' + error.message); -} -``` - +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md index 46efda388721bc8abf142aa6d021475cf3964dc9..ed1dd73836c31f85a2918e5bf1da6886d0618298 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-AccessibilityExtensionAbility.md @@ -18,7 +18,7 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens **系统能力:** SystemCapability.BarrierFree.Accessibility.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ------------------------- | | context | [AccessibilityExtensionContext](js-apis-accessibility-extension-context.md) | 是 | 否 | 表示辅助扩展能力上下文。 | @@ -30,9 +30,9 @@ import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtens ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ---------------------------------------- | ---- | ---- | ---------- | -| eventType | [EventType](js-apis-accessibility.md#EventType) \| [WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | 是 | 否 | 具体事件类型。 | +| eventType | [accessibility.EventType](js-apis-accessibility.md#EventType) \| [accessibility.WindowUpdateType](js-apis-accessibility.md#WindowUpdateType) \| [TouchGuideType](#touchguidetype) \| [GestureType](#gesturetype) \| [PageUpdateType](#pageupdatetype) | 是 | 否 | 具体事件类型。 | | target | AccessibilityElement | 是 | 否 | 发生事件的目标组件。 | | timeStamp | number | 是 | 否 | 事件时间戳。 | @@ -129,7 +129,7 @@ onAccessibilityEvent(event: AccessibilityEvent): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ---------------------------------------- | ---- | --------------- | | event | [AccessibilityEvent](#accessibilityevent) | 是 | 无障碍事件回调函数。无返回值。 | @@ -156,7 +156,7 @@ onKeyEvent(keyEvent: KeyEvent): boolean; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------------- | | keyEvent | [KeyEvent](js-apis-keyevent.md#KeyEvent) | 是 | 按键事件回调函数。返回true表示拦截此按键。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md index 9e24ac500b30adbc72259811495c1342e7579d8b..c4493e348a9a4cda5d3c1a6e70ab5aa39717fa9f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md @@ -21,7 +21,7 @@ import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbili **系统能力**:SystemCapability.DistributedDataManager.DataShare.Provider -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | context | [ExtensionContext](js-apis-extension-context.md) | 是 | 否 |表示数据共享扩展能力上下文。 | @@ -35,7 +35,7 @@ DataShare客户端连接DataShareExtensionAbility服务端时,服务端回调 **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | want | [Want](js-apis-application-Want.md#want) | 是 | Want类型信息,包括ability名称、bundle名称等。 | | callback | AsyncCallback<void> | 是 | 回调函数。无返回值。 | @@ -80,7 +80,7 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | uri |string | 是 | 指示要插入的数据的路径。 | | valueBucket |[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要插入的数据。 | @@ -124,7 +124,7 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示要更新的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | @@ -167,7 +167,7 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba **参数:** -| 名称 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ---------------------------------- | | uri | string | 是 | 指示要删除的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | @@ -209,7 +209,7 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns **参数:** -| 名称 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | uri | string | 是 | 指示要查询的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。 | @@ -255,7 +255,7 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy **参数:** -| 名称 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------- | | uri | string | 是 | 指示要批量插入的数据的路径。 | | valueBuckets | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 指示要批量插入的数据。 | @@ -301,7 +301,7 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ----------------------- | | uri | string | 是 | 指示用户传入的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。如果支持URI规范化,则返回规范化URI,否则返回空。 | @@ -328,7 +328,7 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | ----------------------- | | uri | string | 是 | 指示服务端使用的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。如果反规范化成功,则返回反规范化的URI;如果无需进行反规范化,则返回原始URI;若不支持则返回空。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md index 25f90a35aa58020b1bf586d7c182c798e1ef4ab3..b333f23ce25201bb343ae276a5b750dcddb11c49 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-EnvironmentCallback.md @@ -33,13 +33,13 @@ onConfigurationUpdated(config: Configuration): void; ```js -import AbilityStage from "@ohos.application.AbilityStage"; +import Ability from "@ohos.application.Ability"; var callbackId; -export default class MyAbilityStage extends AbilityStage { +export default class MyAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MyAbility onCreate") globalThis.applicationContext = this.context.getApplicationContext(); let EnvironmentCallback = { onConfigurationUpdated(config){ diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md index 62849134f98cf0adbd78b463bd543e4529bef6ed..c791e9c5264b9801b481a869699e783480dae451 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @@ -19,7 +19,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ------------------------- | | context | [ExtensionContext](js-apis-extension-context.md) | 是 | 否 | 上下文。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md index 5104b43533fe8b5646d27253d0e2b0b029e12ddb..14b7c0b1b88aeafcf0e180a7c114abff881790dc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md @@ -157,11 +157,11 @@ onAbilityContinue(ability: Ability): void; ```js - import AbilityStage from "@ohos.application.AbilityStage"; + import Ability from "@ohos.application.Ability"; - export default class MyAbilityStage extends AbilityStage { + export default class MyAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MyAbility onCreate") let AbilityLifecycleCallback = { onAbilityCreate(ability){ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); @@ -200,6 +200,12 @@ onAbilityContinue(ability: Ability): void; // 2.通过applicationContext注册监听应用内生命周期 let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid)); + }, + onDestroy() { + let applicationContext = this.context.getApplicationContext(); + applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => { + console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error)); + }); } } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md index 8724cdbd85a5f8c20b174dd46ab8b900073bb451..05ec3041cace1d337c20e239940bf573af73b871 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-applicationContext.md @@ -39,13 +39,13 @@ registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): **number** **示例:** ```js -import AbilityStage from "@ohos.application.AbilityStage"; +import Ability from "@ohos.application.Ability"; var lifecycleId; -export default class MyAbilityStage extends AbilityStage { +export default class MyAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MyAbility onCreate") let AbilityLifecycleCallback = { onAbilityCreate(ability){ console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability)); @@ -84,7 +84,7 @@ export default class MyAbilityStage extends AbilityStage { // 2.通过applicationContext注册监听应用内生命周期 lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback); console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId)); - } + }, onDestroy() { let applicationContext = this.context.getApplicationContext(); applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => { @@ -144,13 +144,13 @@ registerEnvironmentCallback(callback: EnvironmentCallback): **number**; **示例:** ```js -import AbilityStage from "@ohos.application.AbilityStage"; +import Ability from "@ohos.application.Ability"; var callbackId; -export default class MyAbilityStage extends AbilityStage { +export default class MyAbility extends Ability { onCreate() { - console.log("MyAbilityStage onCreate") + console.log("MyAbility onCreate") globalThis.applicationContext = this.context.getApplicationContext(); let EnvironmentCallback = { onConfigurationUpdated(config){ diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md new file mode 100644 index 0000000000000000000000000000000000000000..86a2559be56c47798384d2e958dc366afaf05ce5 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-application-configuration.md @@ -0,0 +1,34 @@ +# Configuration + +定义环境变化信息。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + + | 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| language8+ | string | 是 | 是 | 表示应用程序的当前语言。 | +| colorMode8+ | [ColorMode](js-apis-configurationconstant.md#configurationconstantcolormode) | 是 | 是 | 表示深浅色模式,取值范围:浅色模式(COLOR_MODE_LIGHT),深色模式(COLOR_MODE_DARK)。默认为浅色。 | +| direction9+ | Direction | 是 | 否 | 表示屏幕方向,取值范围:水平方向(DIRECTION_HORIZONTAL),垂直方向(DIRECTION_VERTICAL)。 | +| screenDensity9+ | ScreenDensity | 是 | 否 | 表示屏幕分辨率,取值范围:SCREEN_DENSITY_SDPI(120)、SCREEN_DENSITY_MDPI(160)、SCREEN_DENSITY_LDPI(240)、SCREEN_DENSITY_XLDPI(320)、SCREEN_DENSITY_XXLDPI(480)、SCREEN_DENSITY_XXXLDPI(640)。 | +| displayId9+ | number | 是 | 否 | 表示应用所在的物理屏幕Id。 | +| hasPointerDevice9+ | boolean | 是 | 否 | 指示指针类型设备是否已连接,如键鼠、触控板等。 | + +具体字段描述参考ohos.application.Configuration.d.ts文件 + +**示例:** + + ```ts + 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; + } + }; + var callbackId = applicationContext.registerEnvironmentCallback(envCallback); + ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-configurationConstant.md b/zh-cn/application-dev/reference/apis/js-apis-application-configurationConstant.md new file mode 100644 index 0000000000000000000000000000000000000000..52a2e191ea4c8095ab0479ed2f2bdefbbe1a172f --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-application-configurationConstant.md @@ -0,0 +1,55 @@ +# ConfigurationConstant + +ConfigurationConstant模块提供配置信息枚举值定义的能力。 + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```ts +import ConfigurationConstant from '@ohos.application.ConfigurationConstant'; +``` + +## ConfigurationConstant.ColorMode + +使用时通过ConfigurationConstant.ColorMode获取。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 值 | 说明 | +| -------- | -------- | -------- | +| COLOR_MODE_NOT_SET | -1 | 未设置颜色模式。 | +| COLOR_MODE_DARK | 0 | 深色模式。 | +| COLOR_MODE_LIGHT | 1 | 浅色模式。 | + + +## ConfigurationConstant.Direction9+ + +使用时通过ConfigurationConstant.Direction获取。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 值 | 说明 | +| -------- | -------- | -------- | +| DIRECTION_NOT_SET | -1 | 未设置方向。 | +| DIRECTION_VERTICAL | 0 | 垂直方向。 | +| DIRECTION_HORIZONTAL | 1 | 水平方向。 | + + +## ConfigurationConstant.ScreenDensity9+ + +使用时通过ConfigurationConstant.ScreenDensity获取。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase + +| 名称 | 值 | 说明 | +| -------- | -------- | -------- | +| SCREEN_DENSITY_NOT_SET | 0 | 未设置屏幕分辨率。 | +| SCREEN_DENSITY_SDPI | 120 | 屏幕分辨率为"sdpi"。 | +| SCREEN_DENSITY_MDPI | 160 | 屏幕分辨率为"mdpi"。 | +| SCREEN_DENSITY_LDPI | 240 | 屏幕分辨率为"ldpi"。 | +| SCREEN_DENSITY_XLDPI | 320 | 屏幕分辨率为"xldpi"。 | +| SCREEN_DENSITY_XXLDPI | 480 | 屏幕分辨率为"xxldpi"。 | +| SCREEN_DENSITY_XXXLDPI | 640 | 屏幕分辨率为"xxxldpi"。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 44d9ce297359623bc6c77ffc43fe33bfb8575d75..4512fcac0f3a9c9ee01f568540c68e9b04442860 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -26,7 +26,7 @@ import ArrayList from '@ohos.util.ArrayList'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | ArrayList的元素个数。 | @@ -43,7 +43,7 @@ ArrayList的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The ArrayList's constructor cannot be directly invoked. | @@ -83,7 +83,7 @@ add(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -99,7 +99,7 @@ add(element: T): boolean let result3 = arrayList.add(c); let result4 = arrayList.add(false); try { - arraylist.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.add.bind({}, "b")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -124,7 +124,7 @@ insert(element: T, index: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The insert method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -137,7 +137,7 @@ arrayList.insert("A", 0); arrayList.insert(0, 1); arrayList.insert(true, 2); try { - arraylist.insert.bind({}, 1, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.insert.bind({}, 1, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -177,7 +177,7 @@ has(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -189,7 +189,7 @@ let result = arrayList.has("squirrel"); arrayList.add("squirrel"); let result1 = arrayList.has("squirrel"); try { - arraylist.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.has.bind({}, "squirrel")(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -219,7 +219,7 @@ getIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOf method cannot be bound. | @@ -236,7 +236,7 @@ arrayList.add(2); arrayList.add(4); let result = arrayList.getIndexOf(2); try { - arraylist.getIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.getIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -266,7 +266,7 @@ getLastIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLastIndexOf method cannot be bound. | @@ -283,7 +283,7 @@ arrayList.add(2); arrayList.add(4); let result = arrayList.getLastIndexOf(2); try { - arraylist.getLastIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.getLastIndexOf.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -313,7 +313,7 @@ removeByIndex(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeByIndex method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -329,17 +329,17 @@ arrayList.add(2); arrayList.add(4); let result = arrayList.removeByIndex(2); try { - arraylist.removeByIndex.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.removeByIndex.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } try { - arraylist.removeByIndex("a"); // 测试类型异常 + arrayList.removeByIndex("a"); // 测试类型异常 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } try { - arraylist.removeByIndex(8); // 测试越界异常 + arrayList.removeByIndex(8); // 测试越界异常 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -369,7 +369,7 @@ remove(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -383,7 +383,7 @@ arrayList.add(5); arrayList.add(4); let result = arrayList.remove(2); try { - arraylist.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.remove.bind({}, 2)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -408,7 +408,7 @@ removeByRange(fromIndex: number, toIndex: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeByRange method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -423,12 +423,12 @@ arrayList.add(5); arrayList.add(4); arrayList.removeByRange(2, 4); try { - arraylist.removeByRange.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.removeByRange.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } try { - arraylist.removeByRange(8, 4); // 测试越界异常 + arrayList.removeByRange(8, 4); // 测试越界异常 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -462,7 +462,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The replaceAllElements method cannot be bound. | @@ -481,7 +481,7 @@ arrayList.replaceAllElements((value: number, index: number) => { return value = value - 2; }); try { - arraylist.replaceAllElements.bind({}, (value: number, index: number)=> { + arrayList.replaceAllElements.bind({}, (value: number, index: number)=> { return value = 2 * value; })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { @@ -517,7 +517,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -533,7 +533,7 @@ arrayList.forEach((value, index) => { console.log(`value:${value}`, index); }); try { - arraylist.forEach.bind({}, (value, index) => { + arrayList.forEach.bind({}, (value, index) => { console.log(`value:${value}`, index); })(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { @@ -566,7 +566,7 @@ comparator的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The sort method cannot be bound. | @@ -582,7 +582,7 @@ arrayList.sort((a: number, b: number) => a - b); arrayList.sort((a: number, b: number) => b - a); arrayList.sort(); try { - arraylist.sort.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.sort.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -613,7 +613,7 @@ subArrayList(fromIndex: number, toIndex: number): ArrayList<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The subArrayList method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -630,12 +630,12 @@ let result1 = arrayList.subArrayList(2, 4); let result2 = arrayList.subArrayList(4, 3); let result3 = arrayList.subArrayList(2, 6); try { - arraylist.subArrayList.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.subArrayList.bind({}, 2, 4)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } try { - arraylist.subArrayList(6, 4); + arrayList.subArrayList(6, 4); } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -653,7 +653,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -667,7 +667,7 @@ arrayList.add(5); arrayList.add(4); arrayList.clear(); try { - arraylist.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.clear.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -692,7 +692,7 @@ clone(): ArrayList<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clone method cannot be bound. | @@ -706,7 +706,7 @@ arrayList.add(5); arrayList.add(4); let result = arrayList.clone(); try { - arraylist.clone.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.clone.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -730,7 +730,7 @@ getCapacity(): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getCapacity method cannot be bound. | @@ -744,7 +744,7 @@ arrayList.add(5); arrayList.add(4); let result = arrayList.getCapacity(); try { - arraylist.getCapacity.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.getCapacity.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -768,7 +768,7 @@ convertToArray(): Array<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The convertToArray method cannot be bound. | @@ -782,7 +782,7 @@ arrayList.add(5); arrayList.add(4); let result = arrayList.convertToArray(); try { - arraylist.convertToArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.convertToArray.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -806,7 +806,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -820,7 +820,7 @@ arrayList.add(5); arrayList.add(4); let result = arrayList.isEmpty(); try { - arraylist.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.isEmpty.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -844,7 +844,7 @@ increaseCapacityTo(newCapacity: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The increaseCapacityTo method cannot be bound. | @@ -859,7 +859,7 @@ arrayList.add(4); arrayList.increaseCapacityTo(2); arrayList.increaseCapacityTo(8); try { - arraylist.increaseCapacityTo.bind({}, 5)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.increaseCapacityTo.bind({}, 5)(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -877,7 +877,7 @@ trimToCurrentLength(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The trimToCurrentLength method cannot be bound. | @@ -891,7 +891,7 @@ arrayList.add(5); arrayList.add(4); arrayList.trimToCurrentLength(); try { - arraylist.trimToCurrentLength.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList.trimToCurrentLength.bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -915,7 +915,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | @@ -941,7 +941,7 @@ while(temp != undefined) { temp = iter.next().value; } try { - arraylist[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 + arrayList[Symbol.iterator].bind({})(); // bind为JS标准内置对象Function的方法,用于改变this的指向,测试异常捕获 } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index fd8c5a68e0bbcb5bc50bd0dec63377c551e66f84..79c3758711f0d8c7ae1996d94e8e5022f76ebe11 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -24,7 +24,7 @@ import audio from '@ohos.multimedia.audio'; | --------------------------------------- | ----------| ---- | ---- | ------------------ | | LOCAL_NETWORK_ID9+ | string | 是 | 否 | 本地设备网络id。
此接口为系统接口。
**系统能力:** SystemCapability.Multimedia.Audio.Device | | DEFAULT_VOLUME_GROUP_ID9+ | number | 是 | 否 | 默认音量组id。
**系统能力:** SystemCapability.Multimedia.Audio.Volume | -| DEFAULT_INTERRUPT_GROUP_ID9+ | number | 是 | 否 | 默认音频中断组id。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt | +| DEFAULT_INTERRUPT_GROUP_ID9+ | number | 是 | 否 | 默认音频中断组id。
**系统能力:** SystemCapability.Multimedia.Audio.Interrupt | **示例:** @@ -73,7 +73,10 @@ createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\ **示例:** ```js +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; import audio from '@ohos.multimedia.audio'; let audioStreamInfo = { @@ -321,13 +326,14 @@ createTonePlayer(options: AudioRendererInfo): Promise<TonePlayer> ```js import audio from '@ohos.multimedia.audio'; -async function createTonePlayer(){ +let tonePlayer; +async function createTonePlayerBefore(){ let audioRendererInfo = { - "contentType": audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags": 0 + contentType : audio.ContentType.CONTENT_TYPE_MUSIC, + streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 } - let tonePlayer = await audio.createTonePlayer(audioRendererInfo); + tonePlayer = await audio.createTonePlayer(audioRendererInfo); } ``` @@ -337,7 +343,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------- | ------ | ---------- | | VOICE_CALL8+ | 0 | 语音电话。 | | RINGTONE | 2 | 铃声。 | @@ -353,7 +359,7 @@ async function createTonePlayer(){ **系统接口:** 该接口为系统接口 -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------- | ------ | ---------- | | INTERRUPT_REQUEST_GRANT | 0 | 请求音频中断成功。 | | INTERRUPT_REQUEST_REJECT | 1 | 请求音频中断失败,可能具有较高优先级类型。 | @@ -364,7 +370,7 @@ async function createTonePlayer(){ **系统能力:** SystemCapability.Multimedia.Audio.Interrupt -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------- | ------ | ---------- | | SHARE_MODE | 0 | 共享焦点模式。 | | INDEPENDENT_MODE | 1 | 独立焦点模式。 | @@ -375,7 +381,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------------------- | ------ | ------------------------------------------------- | | NONE_DEVICES_FLAG9+ | 0 | 无
此接口为系统接口。 | | OUTPUT_DEVICES_FLAG | 1 | 输出设备。 | @@ -391,7 +397,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------- | ------ | -------------- | | INPUT_DEVICE | 1 | 输入设备角色。 | | OUTPUT_DEVICE | 2 | 输出设备角色。 | @@ -402,7 +408,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------| ------ | --------------------------------------------------------- | | INVALID | 0 | 无效设备。 | | EARPIECE | 1 | 听筒。 | @@ -421,7 +427,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------- | ------ | -------------| | SPEAKER | 2 | 扬声器。 | @@ -431,7 +437,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------- | ------ | ---------- | | RINGER_MODE_SILENT | 0 | 静音模式。 | | RINGER_MODE_VIBRATE | 1 | 震动模式。 | @@ -443,7 +449,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------------- | ------ | -------------------------- | | SAMPLE_FORMAT_INVALID | -1 | 无效格式。 | | SAMPLE_FORMAT_U8 | 0 | 无符号8位整数。 | @@ -474,7 +480,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | --------- | -------- | -------- | | CHANNEL_1 | 0x1 << 0 | 单声道。 | | CHANNEL_2 | 0x1 << 1 | 双声道。 | @@ -485,7 +491,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ----------------- | ------ | --------------- | | SAMPLE_RATE_8000 | 8000 | 采样率为8000。 | | SAMPLE_RATE_11025 | 11025 | 采样率为11025。 | @@ -505,7 +511,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | --------------------- | ------ | --------- | | ENCODING_TYPE_INVALID | -1 | 无效。 | | ENCODING_TYPE_RAW | 0 | PCM编码。 | @@ -516,7 +522,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------------- | ------ | ---------- | | CONTENT_TYPE_UNKNOWN | 0 | 未知类型。 | | CONTENT_TYPE_SPEECH | 1 | 语音。 | @@ -531,7 +537,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------------------------------| ------ | ---------- | | STREAM_USAGE_UNKNOWN | 0 | 未知类型。 | | STREAM_USAGE_MEDIA | 1 | 音频。 | @@ -547,7 +553,7 @@ async function createTonePlayer(){ **系统能力:** SystemCapability.Multimedia.Audio.Interrupt -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------------- | ------ | ------------------------- | | INTERRUPT_REQUEST_TYPE_DEFAULT | 0 | 默认类型,可中断音频请求。 | @@ -557,7 +563,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | -------------- | ------ | ---------------- | | STATE_INVALID | -1 | 无效状态。 | | STATE_NEW | 0 | 创建新实例状态。 | @@ -573,7 +579,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------------ | ------ | ---------- | | RENDER_RATE_NORMAL | 0 | 正常速度。 | | RENDER_RATE_DOUBLE | 1 | 2倍速。 | @@ -585,7 +591,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | -------------------- | ------ | ---------------------- | | INTERRUPT_TYPE_BEGIN | 1 | 音频播放中断事件开始。 | | INTERRUPT_TYPE_END | 2 | 音频播放中断事件结束。 | @@ -596,7 +602,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | --------------- | ------ | ------------------------------------ | | INTERRUPT_FORCE | 0 | 由系统进行操作,强制打断音频播放。 | | INTERRUPT_SHARE | 1 | 由应用进行操作,可以选择打断或忽略。 | @@ -607,7 +613,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ---------------------------------- | ------ | -------------------------------------------- | | INTERRUPT_HINT_NONE8+ | 0 | 无提示。 | | INTERRUPT_HINT_RESUME | 1 | 提示音频恢复。 | @@ -635,7 +641,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------------- | --------------------------- | ---- | ---------------- | | content | [ContentType](#contenttype) | 是 | 媒体类型。 | | usage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 | @@ -660,7 +666,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------------ | ---------------------------------------- | ---- | ---------------- | | streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 | | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示渲染器信息。 | @@ -671,7 +677,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 类型 | 必填 | 说明 | +| 名称 | 类型 |必填 | 说明 | | --------- | ------------------------------------------ | ---- | ------------------------------------ | | eventType | [InterruptType](#interrupttype) | 是 | 中断事件类型,开始或是结束。 | | forceType | [InterruptForceType](#interruptforcetype9) | 是 | 操作是由系统执行或是由应用程序执行。 | @@ -685,7 +691,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume -| 名称 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | | volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | | volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | @@ -700,7 +706,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device | 名称 | 类型 | 必填 | 说明 | -| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| ---------- | ----------------------------------- | ---- | ---- | -------------------------------------------------------- | | mute | boolean | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | ## ConnectType9+ @@ -711,7 +717,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | :------------------------------ | :----- | :--------------------- | | CONNECT_TYPE_LOCAL | 1 | 本地设备。 | | CONNECT_TYPE_DISTRIBUTED | 2 | 分布式设备。 | @@ -737,7 +743,7 @@ async function createTonePlayer(){ | networkId9+ | string | 是 | 否 | 组网络id。 | | groupId9+ | number | 是 | 否 | 组设备组id。 | | mappingId9+ | number | 是 | 否 | 组映射id。 | -| groupName9+ | number | 是 | 否 | 组名。 | +| groupName9+ | string | 是 | 否 | 组名。 | | type9+ | [ConnectType](#connecttype9)| 是 | 否 | 连接设备类型。 | ## DeviceChangeAction @@ -757,7 +763,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | :--------- | :----- | :------------- | | CONNECT | 0 | 设备连接。 | | DISCONNECT | 1 | 断开设备连接。 | @@ -790,7 +796,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | :------------------------------------------- | :----- | :--------------------- | | SOURCE_TYPE_INVALID | -1 | 无效的音频源。 | | SOURCE_TYPE_MIC | 0 | Mic音频源。 | @@ -803,7 +809,7 @@ async function createTonePlayer(){ **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | :--------------------- | :----- | :-------------------------------------------- | | AUDIO_SCENE_DEFAULT | 0 | 默认音频场景。 | | AUDIO_SCENE_RINGING | 1 | 响铃模式。
此接口为系统接口。 | @@ -958,7 +964,6 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback\): void **示例:** ```js -let audioManager = audio.getAudioManager(); audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { if (err) { console.error(`Failed to set the audio scene mode.​ ${err}`); @@ -993,7 +998,6 @@ setAudioScene\(scene: AudioScene\): Promise **示例:** ```js -let audioManager = audio.getAudioManager(); audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { console.info('Promise returned to indicate a successful setting of the audio scene mode.'); }).catch ((err) => { @@ -1018,7 +1022,6 @@ getAudioScene\(callback: AsyncCallback\): void **示例:** ```js -let audioManager = audio.getAudioManager(); audioManager.getAudioScene((err, value) => { if (err) { console.error(`Failed to obtain the audio scene mode.​ ${err}`); @@ -1045,7 +1048,6 @@ getAudioScene\(\): Promise **示例:** ```js -let audioManager = audio.getAudioManager(); audioManager.getAudioScene().then((value) => { console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`); }).catch ((err) => { @@ -1171,7 +1173,7 @@ getVolumeGroupManager(groupId: number, callback: AsyncCallback ```js let groupid = audio.DEFAULT_VOLUME_GROUP_ID; -let audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid); -console.info('Callback invoked to indicate that the volume group infos list is obtained.'); +let audioVolumeGroupManager; +getVolumeGroupManager(); +async function getVolumeGroupManager(){ + audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupid); + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); +} + ``` ### on('volumeChange')9+ @@ -1236,7 +1243,7 @@ on(type: 'volumeChange', callback: Callback\): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -1750,7 +1757,7 @@ on(type: 'ringerModeChange', callback: Callback\): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -1889,7 +1896,7 @@ on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -2108,7 +2115,7 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -2157,7 +2164,7 @@ off(type: "audioRendererChange"): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -2181,6 +2188,14 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr | type | string | 是 | 事件类型,支持的事件`'audioCapturerChange'`:当音频采集器发生更改时触发。 | | callback | Callback<[AudioCapturerChangeInfoArray](#audiocapturerchangeinfoarray9)> | 是 | 回调函数。 | +**错误码:** + +以下错误码的详细介绍请参见[音频错误码](../errorcodes/errorcode-audio.md)。 + +| 错误码ID | 错误信息 | +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error | + **示例:** ```js @@ -2221,6 +2236,14 @@ off(type: "audioCapturerChange"): void; | -------- | -------- | --- | ------------------------------------------------------------- | | type | string |是 | 事件类型,支持的事件`'audioCapturerChange'`:音频采集器更改事件。 | +**错误码:** + +以下错误码的详细介绍请参见[音频错误码](../errorcodes/errorcode-audio.md)。 + +| 错误码ID | 错误信息 | +| ------- | --------------------------------------------| +| 6800101 | if input parameter value error | + **示例:** ```js @@ -2365,7 +2388,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** @@ -2429,10 +2452,10 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCall **示例:** ```js let inputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.INPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.INPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function selectInputDevice(){ audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => { @@ -2470,10 +2493,10 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void> ```js let inputAudioDeviceDescriptor =[{ - "deviceRole":audio.DeviceRole.INPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.INPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function getRoutingManager(){ audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => { @@ -2616,10 +2639,10 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa **示例:** ```js let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.OUTPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function selectOutputDevice(){ audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { if (err) { @@ -2656,10 +2679,10 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void& ```js let outputAudioDeviceDescriptor =[{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.OUTPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function selectOutputDevice(){ audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { @@ -2691,17 +2714,17 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi **示例:** ```js let outputAudioRendererFilter = { - "uid":20010041, - "rendererInfo": { - "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags":0 }, - "rendererId":0 }; + uid : 20010041, + rendererInfo : { + contentType : audio.ContentType.CONTENT_TYPE_MUSIC, + streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 }, + rendererId : 0 }; let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.OUTPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function selectOutputDeviceByFilter(){ audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { @@ -2740,17 +2763,17 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi ```js let outputAudioRendererFilter = { - "uid":20010041, - "rendererInfo": { - "contentType":audio.ContentType.CONTENT_TYPE_MUSIC, - "streamUsage":audio.StreamUsage.STREAM_USAGE_MEDIA, - "rendererFlags":0 }, - "rendererId":0 }; + uid : 20010041, + rendererInfo : { + contentType : audio.ContentType.CONTENT_TYPE_MUSIC, + streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 }, + rendererId : 0 }; let outputAudioDeviceDescriptor = [{ - "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, - "networkId":audio.LOCAL_NETWORK_ID, - "interruptGroupId":1, - "volumeGroupId":1 }]; + deviceRole : audio.DeviceRole.OUTPUT_DEVICE, + networkId : audio.LOCAL_NETWORK_ID, + interruptGroupId : 1, + volumeGroupId : 1 }]; async function selectOutputDeviceByFilter(){ audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { @@ -2783,11 +2806,8 @@ async function selectOutputDeviceByFilter(){ **示例:** ```js -import audio from '@ohos.multimedia.audio'; - let audioStreamManager; let resultFlag = false; -let audioManager = audio.getAudioManager(); audioManager.getStreamManager((err, data) => { if (err) { @@ -2843,7 +2863,7 @@ audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => | -------------------| ----------------------------------------- | ---- | ---- | ---------------------------- | | streamId | number | 是 | 否 | 音频流唯一id。 | | clientUid | number | 是 | 否 | 音频采集器客户端应用程序的Uid。
此接口为系统接口。 | -| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 | +| capturerInfo | [AudioCapturerInfo](#audiocapturerinfo8) | 是 | 否 | 音频采集器信息。 | | capturerState | [AudioState](#audiostate) | 是 | 否 | 音频状态。
此接口为系统接口。| **示例:** @@ -2944,7 +2964,7 @@ promise.then(function (value) { **系统接口:** 该接口为系统接口 -| 名称 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | -------------| ---------------------------------------- | ---- | -------------- | | uid | number | 是 | 表示应用ID。
**系统能力:** SystemCapability.Multimedia.Audio.Core| | rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。
**系统能力:** SystemCapability.Multimedia.Audio.Renderer| @@ -3804,56 +3824,60 @@ on(type: 'audioInterrupt', callback: Callback\): void | 错误码ID | 错误信息 | | ------- | --------------------------------------------| -| 6800101 | if input parameter value error. | +| 6800101 | if input parameter value error | **示例:** ```js let isPlay; let started; -audioRenderer.on('audioInterrupt', async(interruptEvent) => { - if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.info('Force paused. Stop writing'); - isPlay = false; - break; - case audio.InterruptHint.INTERRUPT_HINT_STOP: - console.info('Force stopped. Stop writing'); - isPlay = false; - break; - } - } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { - case audio.InterruptHint.INTERRUPT_HINT_RESUME: - console.info('Resume force paused renderer or ignore'); - await audioRenderer.start().then(async function () { - console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); - started = true; - }).catch((err) => { - console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`); - started = false; - }); - if (started) { - isPlay = true; - console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`); - } else { - console.error('AudioInterruptMusic Renderer start failed'); - } - break; - case audio.InterruptHint.INTERRUPT_HINT_PAUSE: - console.info('Choose to pause or ignore'); - if (isPlay == true) { - isPlay == false; - console.info('AudioInterruptMusic: Media PAUSE : TRUE'); - } else { - isPlay = true; - console.info('AudioInterruptMusic: Media PLAY : TRUE'); - } - break; - } - } -}); +onAudioInterrupt(); + +async function onAudioInterrupt(){ + audioRenderer.on('audioInterrupt', async(interruptEvent) => { + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('Force paused. Stop writing'); + isPlay = false; + break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.info('Force stopped. Stop writing'); + isPlay = false; + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + console.info('Resume force paused renderer or ignore'); + await audioRenderer.start().then(async function () { + console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); + started = true; + }).catch((err) => { + console.error(`AudioInterruptMusic: renderInstant start :ERROR : ${err}`); + started = false; + }); + if (started) { + isPlay = true; + console.info(`AudioInterruptMusic Renderer started : isPlay : ${isPlay}`); + } else { + console.error('AudioInterruptMusic Renderer start failed'); + } + break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.info('Choose to pause or ignore'); + if (isPlay == true) { + isPlay == false; + console.info('AudioInterruptMusic: Media PAUSE : TRUE'); + } else { + isPlay = true; + console.info('AudioInterruptMusic: Media PLAY : TRUE'); + } + break; + } + } + }); +} ``` ### on('markReach')8+ @@ -4627,7 +4651,7 @@ audioCapturer.on('stateChange', (state) => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Tone -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | :------------------------------------------------ | :----- | :----------------------------| | TONE_TYPE_DIAL_0 | 0 | 键0的DTMF音。 | | TONE_TYPE_DIAL_1 | 1 | 键1的DTMF音。 | @@ -4669,6 +4693,8 @@ load(type: ToneType, callback: AsyncCallback<void>): void 加载DTMF音调配置。使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **参数:** @@ -4697,6 +4723,8 @@ load(type: ToneType): Promise<void> 加载DTMF音调配置。使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **参数:** @@ -4727,6 +4755,8 @@ start(callback: AsyncCallback<void>): void 启动DTMF音调播放。使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **参数:** @@ -4754,6 +4784,8 @@ start(): Promise<void> 启动DTMF音调播放。使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **返回值:** @@ -4778,6 +4810,8 @@ stop(callback: AsyncCallback<void>): void 停止当前正在播放的音调。使用callback方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **参数:** @@ -4805,6 +4839,8 @@ stop(): Promise<void> 停止当前正在播放的音调。使用Promise方式异步返回结果。 +**系统接口:** 该接口为系统接口 + **系统能力:** SystemCapability.Multimedia.Audio.Tone **返回值:** @@ -4827,7 +4863,9 @@ tonePlayer.stop().then(() => { release(callback: AsyncCallback<void>): void -释放与此TonePlay对象关联的资源。使用callback方式异步返回结果。 +释放与此TonePlayer对象关联的资源。使用callback方式异步返回结果。 + +**系统接口:** 该接口为系统接口 **系统能力:** SystemCapability.Multimedia.Audio.Tone @@ -4854,7 +4892,9 @@ tonePlayer.release((err) => { release(): Promise<void> -释放与此TonePlay对象关联的资源。使用Promise方式异步返回结果。 +释放与此TonePlayer对象关联的资源。使用Promise方式异步返回结果。 + +**系统接口:** 该接口为系统接口 **系统能力:** SystemCapability.Multimedia.Audio.Tone @@ -4883,7 +4923,7 @@ tonePlayer.release().then(() => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | ------------- | ------ | ---------------------------------------------------- | | SPEAKER | 2 | 扬声器。 | | BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 | @@ -4897,7 +4937,7 @@ tonePlayer.release().then(() => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer -| 名称 | 默认值 | 描述 | +| 名称 | 值 | 说明 | | -------------- | ------ | ------------------ | | TYPE_ACTIVATED | 0 | 表示触发焦点事件。 | | TYPE_INTERRUPT | 1 | 表示音频打断事件。 | @@ -4912,10 +4952,10 @@ tonePlayer.release().then(() => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer | 名称 | 类型 | 必填 | 说明 | -| --------------- | --------------------------- | ---- | ------------------------------------------------------------ | -| streamUsage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 | -| contentType | [ContentType](#contenttype) | 是 | 音频打断媒体类型。 | -| pauseWhenDucked | boolean | 是 | 音频打断时是否可以暂停音频播放(true表示音频播放可以在音频打断期间暂停,false表示相反)。 | +| --------------- | --------------------------- | ----| ------------------------------------------------------------ | +| streamUsage | [StreamUsage](#streamusage) | 是 | 音频流使用类型。 | +| contentType | [ContentType](#contenttype) | 是 | 音频打断媒体类型。 | +| pauseWhenDucked | boolean | 是 | 音频打断时是否可以暂停音频播放(true表示音频播放可以在音频打断期间暂停,false表示相反)。 | ## InterruptAction(deprecated) @@ -4930,7 +4970,7 @@ tonePlayer.release().then(() => { | ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | | actionType | [InterruptActionType](#interruptactiontype) | 是 | 事件返回类型。TYPE_ACTIVATED为焦点触发事件,TYPE_INTERRUPT为音频打断事件。 | | type | [InterruptType](#interrupttype) | 否 | 打断事件类型。 | -| hint | [InterruptHint](#interrupthint) | 否 | 打断事件提示。 | +| hint | [InterruptHint](#interrupthint) | 否 | 打断事件提示。 | | activated | boolean | 否 | 获得/释放焦点。true表示焦点获取/释放成功,false表示焦点获得/释放失败。 | ### setVolume(deprecated) diff --git a/zh-cn/application-dev/reference/apis/js-apis-avsession.md b/zh-cn/application-dev/reference/apis/js-apis-avsession.md index 386f4d3a57c32465f09a6fd72b6efb0ac1e29aa3..15fd3d4d861a707b78633691221962be75215b65 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-avsession.md +++ b/zh-cn/application-dev/reference/apis/js-apis-avsession.md @@ -1,4 +1,4 @@ - # 媒体会话管理 +# 媒体会话管理 媒体会话管理提供媒体播控相关功能的接口,目的是让应用接入播控中心。 @@ -54,10 +54,9 @@ import featureAbility from '@ohos.ability.featureAbility'; let session; let tag = "createNewSession"; -let type = "audio"; let context = featureAbility.getContext(); -await avSession.createAVSession(context, tag, type).then((avSession) => { +await avSession.createAVSession(context, tag, "audio").then((avSession) => { session = avSession; console.info(`CreateAVSession : SUCCESS : sessionId = ${session.sessionId}`); }).catch((err) => { @@ -96,10 +95,9 @@ import featureAbility from '@ohos.ability.featureAbility'; let session; let tag = "createNewSession"; -let type = "audio"; let context = featureAbility.getContext(); -avSession.createAVSession(context, tag, type, function (err, avSession) { +avSession.createAVSession(context, tag, "audio", function (err, avSession) { if (err) { console.info(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`); } else { diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index fe38cfdda6ca2e31db35d5287607d23b327a388c..b363572eecbea607524e9ef94f5a5794df03f124 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -28,7 +28,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen 后台应用申请延迟挂起。 -延迟挂起时间一般情况下默认值为180000毫秒,低电量(依据系统低电量广播)时默认值为60000毫秒。 +延迟挂起时间一般情况下默认值为3分钟,低电量(依据系统低电量广播)时默认值为1分钟。 **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -452,14 +452,14 @@ export default class MainAbility extends Ability { **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| 参数名 | 参数值 | 描述 | -| ----------------------- | ---- | --------------------- | -| DATA_TRANSFER | 1 | 数据传输。 | -| AUDIO_PLAYBACK | 2 | 音频播放。 | -| AUDIO_RECORDING | 3 | 录音。 | -| LOCATION | 4 | 定位导航。 | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关。 | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联。 | -| WIFI_INTERACTION | 7 | WLAN相关
此接口为系统接口。 | -| VOIP | 8 | 音视频通话
此接口为系统接口。 | -| TASK_KEEPING | 9 | 计算任务(仅在特定设备生效)。 | \ No newline at end of file +| 参数名 | 描述 | +| ----------------------- | --------------------- | +| DATA_TRANSFER | 数据传输。 | +| AUDIO_PLAYBACK | 音频播放。 | +| AUDIO_RECORDING | 录音。 | +| LOCATION | 定位导航。 | +| BLUETOOTH_INTERACTION | 蓝牙相关。 | +| MULTI_DEVICE_CONNECTION | 多设备互联。 | +| WIFI_INTERACTION | WLAN相关(此接口为系统接口)。 | +| VOIP | 音视频通话(此接口为系统接口)。 | +| TASK_KEEPING | 计算任务(仅在特定设备生效)。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-buffer.md b/zh-cn/application-dev/reference/apis/js-apis-buffer.md index e96a0be8ea126341ca717dc3293c9919f4031415..f4086c7c60cff9de2a446944e2a4a7507796313e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-buffer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-buffer.md @@ -19,7 +19,7 @@ import buffer from '@ohos.buffer'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | buffer的字节长度。 | | buffer | ArrayBuffer | 是 | 否 | ArrayBuffer对象。 | @@ -29,7 +29,7 @@ import buffer from '@ohos.buffer'; 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200013 | Cannot set property ${propertyName} of Buffer which has only a getter. | @@ -271,7 +271,7 @@ concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "totalLength" is out of range. | @@ -359,7 +359,7 @@ from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[byteOffset/length]" is out of range. | @@ -371,6 +371,13 @@ import buffer from '@ohos.buffer'; let ab = new ArrayBuffer(10); let buf = buffer.from(ab, 0, 2); +let arrayBuffer = new ArrayBuffer(5); +let array = new Int8Array(arrayBuffer); +array[0] = '1'; +array[1] = '2'; +array[2] = '3'; +array[3] = '4'; +array[4] = '5'; try { const buf = buffer.from(arrayBuffer, 6, 1); } catch (err) { @@ -426,8 +433,8 @@ from(object: Object, offsetOrEncoding: number | string, length: number): Buffer | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | object | Object | 是 | 支持Symbol.toPrimitive或valueOf()的对象 | -| offsetOrEncoding | number \| string | 否 | 字节偏移量或编码。 | -| length | number | 否 | 字节长度。 | +| offsetOrEncoding | number \| string | 是 | 字节偏移量或编码。 | +| length | number | 是 | 字节长度。 | **返回值:** @@ -623,7 +630,7 @@ copy(target: Buffer| Uint8Array, targetStart?: number, sourceStart?: number, sou 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[targetStart/sourceStart/sourceEnd]" is out of range. | @@ -744,7 +751,7 @@ fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/end]" is out of range. | @@ -944,7 +951,7 @@ readBigInt64BE(offset?: number): bigint 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -990,7 +997,7 @@ readBigInt64LE(offset?: number): bigint 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1036,7 +1043,7 @@ readBigUInt64BE(offset?: number): bigint 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1082,7 +1089,7 @@ readBigUInt64LE(offset?: number): bigint 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1128,7 +1135,7 @@ readDoubleBE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1173,7 +1180,7 @@ readDoubleLE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1218,7 +1225,7 @@ readFloatBE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1263,7 +1270,7 @@ readFloatLE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1308,7 +1315,7 @@ readInt8(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1354,7 +1361,7 @@ readInt16BE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1399,7 +1406,7 @@ readInt16LE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1444,7 +1451,7 @@ readInt32BE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1489,7 +1496,7 @@ readInt32LE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1536,7 +1543,7 @@ readIntBE(offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/byteLength]" is out of range. | @@ -1585,7 +1592,7 @@ readIntLE(offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/byteLength]" is out of range. | @@ -1631,7 +1638,7 @@ readUInt8(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1644,10 +1651,10 @@ let buf = buffer.from([1, -2]); console.log(buf.readUInt8(0).toString()); console.log(buf.readUInt8(1).toString()); -let buf = buffer.allocUninitializedFromPool(4); -buf.writeUInt8(0x42); +let buf1 = buffer.allocUninitializedFromPool(4); +buf1.writeUInt8(0x42); try { - let ref = buf.readUInt8(4).toString(16); + let ref = buf1.readUInt8(4).toString(16); } catch (err) { console.log("readUInt8 exception: " + JSON.stringify(err)); } @@ -1678,7 +1685,7 @@ readUInt16BE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1725,7 +1732,7 @@ readUInt16LE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1772,7 +1779,7 @@ readUInt32BE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1818,7 +1825,7 @@ readUInt32LE(offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "offset" is out of range. | @@ -1865,7 +1872,7 @@ readUIntBE(offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/byteLength]" is out of range. | @@ -1912,7 +1919,7 @@ readUIntLE(offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/byteLength]" is out of range. | @@ -1988,7 +1995,7 @@ swap16(): Buffer 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200009 | Buffer size must be a multiple of 16-bits | @@ -2030,7 +2037,7 @@ swap32(): Buffer 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200009 | Buffer size must be a multiple of 32-bits | @@ -2072,7 +2079,7 @@ swap64(): Buffer 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200009 | Buffer size must be a multiple of 64-bits | @@ -2189,7 +2196,7 @@ for (let value of buf1.values()) { ### write -write(str: string, offset?: number, length?: number, encoding?: string): number +write(str: string, offset?: number, length?: number, encoding?: BufferEncoding): number 从buf的offset偏移写入指定编码的字符串str,写入的字节长度为length @@ -2215,7 +2222,7 @@ write(str: string, offset?: number, length?: number, encoding?: string): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[offset/length]" is out of range. | @@ -2280,7 +2287,7 @@ writeBigInt64BE(value: bigint, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2326,7 +2333,7 @@ writeBigInt64LE(value: bigint, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2372,7 +2379,7 @@ writeBigUInt64BE(value: bigint, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2418,7 +2425,7 @@ writeBigUInt64LE(value: bigint, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2430,9 +2437,9 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeBigUInt64LE(0xdecafafecacefaden, 0); -let buf = buffer.allocUninitializedFromPool(8); +let buf1 = buffer.allocUninitializedFromPool(8); try { - let ref = buf.writeBigUInt64LE(0xdecafafecacefaden, 1); + let ref = buf1.writeBigUInt64LE(0xdecafafecacefaden, 1); } catch (err) { console.log("writeBigUInt64LE exception: " + JSON.stringify(err)); } @@ -2464,7 +2471,7 @@ writeDoubleBE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2510,7 +2517,7 @@ writeDoubleLE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2522,9 +2529,9 @@ import buffer from '@ohos.buffer'; let buf = buffer.allocUninitializedFromPool(8); buf.writeDoubleLE(123.456, 0); -let buf = buffer.allocUninitializedFromPool(8); +let buf1 = buffer.allocUninitializedFromPool(8); try { - let ref = buf.writeDoubleLE(123.456, 1); + let ref = buf1.writeDoubleLE(123.456, 1); } catch (err) { console.log("writeDoubleLE exception: " + JSON.stringify(err)); } @@ -2556,7 +2563,7 @@ writeFloatBE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2603,7 +2610,7 @@ writeFloatLE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2649,7 +2656,7 @@ writeInt8(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2697,7 +2704,7 @@ writeInt16BE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2744,7 +2751,7 @@ writeInt16LE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2790,7 +2797,7 @@ writeInt32BE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2837,7 +2844,7 @@ writeInt32LE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -2884,7 +2891,7 @@ writeIntBE(value: number, offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset/byteLength]" is out of range. | @@ -2932,7 +2939,7 @@ writeIntLE(value: number, offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset/byteLength]" is out of range. | @@ -2978,7 +2985,7 @@ writeUInt8(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -3027,7 +3034,7 @@ writeUInt16BE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -3074,7 +3081,7 @@ writeUInt16LE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -3121,7 +3128,7 @@ writeUInt32BE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -3167,7 +3174,7 @@ writeUInt32LE(value: number, offset?: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset]" is out of range. | @@ -3214,7 +3221,7 @@ writeUIntBE(value: number, offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset/byteLength]" is out of range. | @@ -3261,7 +3268,7 @@ writeUIntLE(value: number, offset: number, byteLength: number): number 以下错误码的详细介绍请参见[buffer错误码](../errorcodes/errorcode-buffer.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200001 | The value of "[value/offset/byteLength]" is out of range. | @@ -3338,7 +3345,7 @@ try { **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | size | number | 是 | 否 | Blob实例的总字节大小。 | | type | string | 是 | 否 | Blob实例的内容类型。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md index 8a92eae11a38500e03159f86a522f28d0124c94f..785b892076bc1bd7226501b2372eadd05da25678 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-BundleInstaller.md @@ -91,11 +91,11 @@ SystemCapability.BundleManager.BundleFramework **系统API:** 此接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 说明 | -| ------------------------------ | ------------------------------ | ------------------ | -| userId | number | 指示用户id | -| installFlag | number | 指示安装标志 | -| isKeepData | boolean | 指示参数是否有数据 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------- | ---- | ---- | ------------------ | +| userId | number | 是 | 否 | 指示用户id | +| installFlag | number | 是 | 否 | 指示安装标志 | +| isKeepData | boolean | 是 | 否 | 指示参数是否有数据 | ## InstallStatus(deprecated) diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-CustomizeData.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-CustomizeData.md index f5063c17395b3ac8f8a0e0dd542b71b3ce356dcf..e297e63577d9efca95f61a3d1753991e525f5e77 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-CustomizeData.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-CustomizeData.md @@ -9,7 +9,9 @@ 自定义元数据 -## CustomizeData +## CustomizeData(deprecated) + +> 从API version 9开始不再维护,建议使用[Metadata](js-apis-bundleManager-metadata.md)替代。 **系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md index 2133578c207d3a0f7fbae3378179d3f5cb57d3bd..0950e990d6a7496d693f53277fbfa5845e28841c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ElementName.md @@ -7,7 +7,7 @@ ElementName信息,通过接口[Context.getElementName](js-apis-Context.md)获取。 -## ElementName(deprecated) +## ElementName(deprecated) > 从API version 9开始不再维护,建议使用[ElementName](js-apis-bundleManager-elementName.md)替代。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md index 9a76c507f1878ded89530ef32d94b7b5dc363d92..d99008d6cb2bb6858d8a98b3d1e3723a5c8701b8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md @@ -22,9 +22,9 @@ Ability信息,未做特殊说明的属性,均通过[GET_ABILITY_INFO_DEFAULT | iconId | number | 是 | 否 | Ability的图标资源id | | process | string | 是 | 否 | Ability的进程,如果不设置,默认为包的名称 | | isVisible | boolean | 是 | 否 | 判断Ability是否可以被其他应用调用 | -| type | AbilityType | 是 | 否 | Ability类型
此属性仅可在FA模型下使用 | -| orientation | DisplayOrientation | 是 | 否 | Ability的显示模式 | -| launchType | number | 是 | 否 | Ability的启动模式 | +| type | [AbilityType](js-apis-bundleManager.md#abilitytype) | 是 | 否 | Ability类型
此属性仅可在FA模型下使用 | +| orientation | [DisplayOrientation](js-apis-bundleManager.md#displayorientation) | 是 | 否 | Ability的显示模式 | +| launchType | [LaunchType](js-apis-bundleManager.md#launchtype) | 是 | 否 | Ability的启动模式 | | permissions | Array\ | 是 | 否 | 被其他应用Ability调用时需要申请的权限集合,通过传入GET_ABILITY_INFO_WITH_PERMISSION获取 | | readPermission | string | 是 | 否 | 读取Ability数据所需的权限
此属性仅可在FA模型下使用 | | writePermission | string | 是 | 否 | 向Ability写数据所需的权限
此属性仅可在FA模型下使用 | @@ -33,7 +33,7 @@ Ability信息,未做特殊说明的属性,均通过[GET_ABILITY_INFO_DEFAULT | applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | 应用程序的配置信息,通过传入GET_ABILITY_INFO_WITH_APPLICATION获取 | | metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | 是 | 否 | ability的元信息,通过传入GET_ABILITY_INFO_WITH_METADATA获取 | | enabled | boolean | 是 | 否 | ability是否可用 | -| supportWindowModes | Array\<[SupportWindowMode](js-apis-bundleManager.md)> | 是 | 否 | ability支持的窗口模式 | +| supportWindowModes | Array\<[SupportWindowMode](js-apis-bundleManager.md#supportwindowmode)> | 是 | 否 | ability支持的窗口模式 | | windowSize|[WindowSize](#windowsize) | 是 | 否 | 表示窗口尺寸| ## WindowSize diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md index 7df10c9c6138beebf7e3f9d65325c6b26c8cd4f6..cc60e34bf80cdf3c06948c48dc7dcc3733178c57 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-extensionAbilityInfo.md @@ -17,7 +17,7 @@ ExtensionAbility信息,未做特殊说明的属性,均通过[getBundleInfo]( | descriptionId | number | 是 | 否 | ExtensionAbility的描述资源id | | iconId | number | 是 | 否 | ExtensionAbility的图标资源id | | isVisible | boolean | 是 | 否 | 判断ExtensionAbility是否可以被其他应用调用 | -| extensionAbilityType | bundle.ExtensionAbilityType | 是 | 否 | ExtensionAbility类型 | +| extensionAbilityType | [ExtensionAbilityType](js-apis-bundleManager.md#extensionabilitytype) | 是 | 否 | ExtensionAbility类型 | | permissions | Array\ | 是 | 否 | 被其他应用ExtensionAbility调用时需要申请的权限集合 | | applicationInfo | [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | 是 | 否 | 应用程序的配置信息 | | metadata | Array\<[Metadata](js-apis-bundleManager-metadata.md)> | 是 | 否 | ExtensionAbility的元信息 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md index 9a71158f07bb069ff2f0a624a786a161e60fad5e..80414c55be4c5e1a89d12209cd25d71f64444476 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager-shortcutInfo.md @@ -15,7 +15,7 @@ | ------------------------- | ------ | ---- | ---- | -------------------- | | targetBundle | string | 是 | 否 | 快捷方式的目标bundleName | | targetModule | string | 是 | 否 | 快捷方式的目标moduleName | -| targetAbility | string | 是 | 否 | 快捷方式所需的目标abilityName | +| targetAbility | string | 是 | 否 | 快捷方式所需的目标abilityName | ## ShortcutInfo diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md index 099aef27744134e2adb0f69138f9b3a5caad5c44..8873a7941c95e0c7ba1cb48a56bba4cc29e751bf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleManager.md @@ -12,14 +12,14 @@ import bundleManager from '@ohos.bundle.bundleManager' ``` ## 权限列表 -| 权限 | 权限等级 | 描述 | +| 权限 | 权限等级 | 描述 | | ------------------------------------------ | ------------ | ------------------| | ohos.permission.GET_BUNDLE_INFO | normal | 查询指定应用信息 | | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 | | ohos.permission.REMOVE_CACHE_FILES | system_basic | 清理应用缓存 | |ohos.permission.CHANGE_ABILITY_ENABLED_STATE| system_basic | 设置禁用使能所需的权限 | -权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) +权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)。 ## 枚举 @@ -84,53 +84,53 @@ import bundleManager from '@ohos.bundle.bundleManager' **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 | 值 | -|:----------------:|:---:| -| FORM | 0 | -| WORK_SCHEDULER | 1 | -| INPUT_METHOD | 2 | -| SERVICE | 3 | -| ACCESSIBILITY | 4 | -| DATA_SHARE | 5 | -| FILE_SHARE | 6 | -| STATIC_SUBSCRIBER| 7 | -| WALLPAPER | 8 | -| BACKUP | 9 | -| WINDOW | 10 | -| ENTERPRISE_ADMIN | 11 | -| THUMBNAIL | 13 | -| PREVIEW | 14 | -| UNSPECIFIED | 255 | +| 名称 | 值 | 说明 | +|:----------------:|:---:|:---:| +| FORM | 0 | 卡片的extensionAbility | +| WORK_SCHEDULER | 1 | 延时任务的extensionAbility | +| INPUT_METHOD | 2 | 输入法的extensionAbility | +| SERVICE | 3 | 后台运行的service组件,只有系统应用才能使用 | +| ACCESSIBILITY | 4 | 辅助能力的extensionAbility | +| DATA_SHARE | 5 | 数据共享的extensionAbility,只有系统应用才能使用 | +| FILE_SHARE | 6 | 文件共享的extensionAbility | +| STATIC_SUBSCRIBER| 7 | 静态广播的extensionAbility | +| WALLPAPER | 8 | 壁纸的extensionAbility | +| BACKUP | 9 | 数据备份的extensionAbility | +| WINDOW | 10 | 这个extensionAbility会在启动过程中创建一个window,为开发者提供界面开发。开发者开发出来的界面将通过abilityComponent控件组合到其他应用的窗口中 | +| ENTERPRISE_ADMIN | 11 | 管理员用户的extensionAbility | +| THUMBNAIL | 13 | 获取文件缩略图的extensionAbility,开发者可以对自定义文件类型的文件提供缩略图 | +| PREVIEW | 14 | 这个extensionAbility会将文件解析后在一个窗口中显示,开发者可以通过将此窗口组合到其他应用窗口中 | +| UNSPECIFIED | 255 | 未指明用户的extensionAbility | ### PermissionGrantState **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 | 值 | -|:----------------:|:---:| -| PERMISSION_DENIED| -1 | -| PERMISSION_GRANTED | 0 | +| 名称 | 值 | 说明 | +|:----------------:|:---:|:---:| +| PERMISSION_DENIED| -1 | 拒绝授予权限 | +| PERMISSION_GRANTED | 0 | 授予权限 | ### SupportWindowMode **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 | 值 | -|:----------------:|:---:| -| FULL_SCREEN | 0 | -| SPLIT | 1 | -| FLOATING | 2 | +| 名称 | 值 | 说明 | +|:----------------:|:---:|:---:| +| FULL_SCREEN | 0 | 窗口支持全屏显示 | +| SPLIT | 1 | 窗口支持分屏显示 | +| FLOATING | 2 | 支持窗口化显示 | ### LaunchType **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 | 值 | -|:----------------:|:---:| -| SINGLETON | 0 | -| STANDARD | 1 | -| SPECIFIED | 2 | +| 名称 | 值 | 说明 | +|:----------------:|:---:|:---:| +| SINGLETON | 0 | ability的启动模式,表示单实例 | +| STANDARD | 1 | ability的启动模式,表示普通多实例 | +| SPECIFIED | 2 | ability的启动模式,表示该ability内部根据业务自己置顶多实例 | ### AbilityType @@ -138,31 +138,31 @@ import bundleManager from '@ohos.bundle.bundleManager' **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 | 值 | -|:----------------:|----| -| PAGE | 1 | -| SERVICE | 2 | -| DATA | 3 | +| 名称 | 值 | 说明 | +| :-----: | ---- | :--------------------------------------------------------: | +| PAGE | 1 | 表示基于Page模板开发的FA,用于提供与用户交互的能力 | +| SERVICE | 2 | 表示基于Service模板开发的PA,用于提供后台运行任务的能力 | +| DATA | 3 | 表示基于Data模板开发的PA,用于对外部提供统一的数据访问对象 | ### DisplayOrientation **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core。 -| 名称 |值 | -|:----------------------------------|---| -| UNSPECIFIED |0 | -| LANDSCAPE |1 | -| PORTRAIT |2 | -| FOLLOW_RECENT |3 | -| LANDSCAPE_INVERTED |4 | -| PORTRAIT_INVERTED |5 | -| AUTO_ROTATION |6 | -| AUTO_ROTATION_LANDSCAPE |7 | -| AUTO_ROTATION_PORTRAIT |8 | -| AUTO_ROTATION_RESTRICTED |9 | -| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10| -| AUTO_ROTATION_PORTRAIT_RESTRICTED |11| -| LOCKED |12| +| 名称 |值 |说明 | +|:----------------------------------|---|---| +| UNSPECIFIED |0 |表示未定义方向模式,由系统判定 | +| LANDSCAPE |1 |表示横屏显示模式 | +| PORTRAIT |2 |表示竖屏显示模式 | +| FOLLOW_RECENT |3 |表示跟随上一个显示模式 | +| LANDSCAPE_INVERTED |4 |表示反向横屏显示模式 | +| PORTRAIT_INVERTED |5 |表示反向竖屏显示模式 | +| AUTO_ROTATION |6 |表示传感器自动旋转模式 | +| AUTO_ROTATION_LANDSCAPE |7 |表示传感器自动横向旋转模式 | +| AUTO_ROTATION_PORTRAIT |8 |表示传感器自动竖向旋转模式 | +| AUTO_ROTATION_RESTRICTED |9 |表示受开关控制的自动旋转模式 | +| AUTO_ROTATION_LANDSCAPE_RESTRICTED |10|表述受开关控制的自动横向旋转模式| +| AUTO_ROTATION_PORTRAIT_RESTRICTED |11|表示受开关控制的自动竖向旋转模式| +| LOCKED |12|表示锁定模式| ## 方法 @@ -176,7 +176,7 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------- | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 | @@ -188,7 +188,7 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag)): Promise\<[BundleInfo]( **错误码:** -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 ```ts import bundleManager from '@ohos.bundle.bundleManager' @@ -214,14 +214,14 @@ getBundleInfoForSelf(bundleFlags: [number](#bundleflag), callback: AsyncCallback **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------- | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundleManager-bundleInfo.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的当前应用的BundleInfo;否则为错误对象 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 **示例:** @@ -256,7 +256,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息| @@ -265,9 +265,9 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -276,9 +276,30 @@ getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: **示例:** ```ts +// 额外获取AbilityInfo import bundleManager from '@ohos.bundle.bundleManager' let bundleName = 'com.example.myapplication'; -let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; +let userId = 100; + +try { + bundleManager.getBundleInfo(bundleName, bundleFlags, userId, (err, data) => { + if (err) { + console.error('getBundleInfo failed:' + err.message); + } else { + console.info('getBundleInfo successfully:' + JSON.stringify(data)); + } + }); +} catch (err) { + console.error('getBundleInfo failed:' + err.message); +} +``` + +``` +// 额外获取ApplicationInfo中的metadata +import bundleManager from '@ohos.bundle.bundleManager' +let bundleName = 'com.example.myapplication'; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA; let userId = 100; try { @@ -308,7 +329,7 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息| @@ -316,9 +337,9 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700026 | The specified bundle is disabled | @@ -326,9 +347,10 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< **示例:** ```ts +// 额外获取extensionAbility import bundleManager from '@ohos.bundle.bundleManager' let bundleName = 'com.example.myapplication'; -let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY; try { bundleManager.getBundleInfo(bundleName, bundleFlags, (err, data) => { @@ -357,7 +379,7 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 | @@ -371,8 +393,8 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 -| 错误码ID | 错误码信息 | +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -381,9 +403,10 @@ getBundleInfo(bundleName: string, bundleFlags: [number](#bundleflag), userId?: n **示例:** ```ts +// 额外获取ApplicationInfo和SignatureInfo import bundleManager from '@ohos.bundle.bundleManager' let bundleName = 'com.example.myapplication'; -let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT; +let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; let userId = 100; try { @@ -428,7 +451,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 | @@ -437,9 +460,9 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -480,7 +503,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 | @@ -488,9 +511,9 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700026 | The specified bundle is disabled | @@ -500,7 +523,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), cal ```ts import bundleManager from '@ohos.bundle.bundleManager' let bundleName = 'com.example.myapplication'; -let appsFlag = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; +let appFlags = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_WITH_PERMISSION; try { bundleManager.getApplicationInfo(bundleName, appFlags, (err, data) => { @@ -529,7 +552,7 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ---------------------------- | | bundleName | string | 是 | 表示要查询的应用程序包名称 | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 | @@ -543,9 +566,9 @@ getApplicationInfo(bundleName: string, appFlags: [number](#applicationflag), use **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -584,7 +607,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | -------------------------------------------------- | | bundleFlags | [number](#bundleflag) | 是 | 指定返回的BundleInfo所包含的信息 | | userId | number | 是 | 表示用户ID | @@ -592,9 +615,9 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId: number, callback: A **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------- | | 17700004 | The specified userId is not found | @@ -632,14 +655,14 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), callback: AsyncCallback> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\;否则为错误对象 | **错误码:** -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 **示例:** @@ -674,7 +697,7 @@ getAllBundleInfo(bundleFlags: [number](#bundleflag), userId?: number): Promise> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\;否则为错误对象 | **错误码:** -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 **示例:** @@ -814,7 +837,7 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---------------------------------------------------------- | | appFlags | [number](#applicationflag) | 是 | 指定返回的ApplicationInfo所包含的信息 | | userId | number | 否 | 表示用户ID | @@ -827,9 +850,9 @@ getAllApplicationInfo(appFlags: [number](#applicationflag), userId?: number): Pr **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------- | | 17700004 | The specified userId is not found | @@ -865,7 +888,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------ | ---- | ------------------------------------------------------- | | want | Want | 是 | 表示包含要查询的应用程序包名称的Want | | abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息 | @@ -874,9 +897,9 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId: numbe **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified ability is not found | @@ -922,7 +945,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------ | ---- | -------------------------------------------------------| | want | Want | 是 | 表示包含要查询的应用程序包名称的Want | | abilityFlags | [number](#abilityflag) | 是 | 指定返回的AbilityInfo所包含的信息 | @@ -930,9 +953,9 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), callback: Asy **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified ability is not found | @@ -976,7 +999,7 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------ | ---- | ------------------------------------------------------- | | want | Want | 是 | 表示包含要查询的应用程序包名称的Want | | abilityFlags | [number](#abilityflag) | 是 | 表示指定返回的AbilityInfo所包含的信息 | @@ -990,9 +1013,9 @@ queryAbilityInfo(want: Want, abilityFlags: [number](#abilityflag), userId?: numb **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified ability is not found | @@ -1055,7 +1078,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | want | Want | 是 | 表示包含要查询的应用程序包名称的Want | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 | @@ -1065,14 +1088,14 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | --------------------------------------| -| 17700001 | The specified bundleName is not found | -| 17700003 | The specified extensionAbility is not found | -| 17700004 | The specified userId is invalid | -| 17700026 | The specified bundle is disabled | +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700003 | The specified extensionAbility is not found | +| 17700004 | The specified userId is invalid | +| 17700026 | The specified bundle is disabled | **示例:** @@ -1113,7 +1136,7 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | want | Want | 是 | 表示包含要查询的应用程序包名称的Want | | extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 | @@ -1122,13 +1145,13 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | --------------------------------------| -| 17700001 | The specified bundleName is not found | -| 17700003 | The specified extensionAbility is not found| -| 17700026 | The specified bundle is disabled | +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------- | +| 17700001 | The specified bundleName is not found | +| 17700003 | The specified extensionAbility is not found | +| 17700026 | The specified bundle is disabled | **示例:** @@ -1168,12 +1191,12 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **参数:** -| 名称 | 类型 | 必填 | 描述 | -| --------------------- | -------------------- | ---- | ------------------------------------------------------ | -| want | Want | 是 | 表示包含要查询的应用程序包名称的Want | -| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 | +| 参数名 | 类型 | 必填 | 说明 | +| --------------------- | --------------------------------------------- | ---- | ------------------------------------------------------- | +| want | Want | 是 | 表示包含要查询的应用程序包名称的Want | +| extensionAbilityType | [ExtensionAbilityType](#extensionabilitytype) | 是 | 标识extensionAbility的类型 | | extensionAbilityFlags | [number](#extensionabilityflag) | 是 | 表示用于指定将返回的ExtensionInfo对象中包含的信息的标志 | -| userId | number | 否 | 表示用户ID | +| userId | number | 否 | 表示用户ID | **返回值:** @@ -1183,9 +1206,9 @@ queryExtensionAbilityInfo(want: Want, extensionAbilityType: [ExtensionAbilityTyp **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700003 | The specified extensionAbility is not found | @@ -1250,16 +1273,16 @@ getBundleNameByUid(uid: number, callback: AsyncCallback\): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | uid | number | 是 | 表示应用程序的UID | | callback | AsyncCallback\ | 是 | 回调函数,当获取成功时,err为null,data为获取到的BundleName;否则为错误对象 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------- | | 17700021 | The uid is not found | @@ -1295,7 +1318,7 @@ getBundleNameByUid(uid: number): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------ | | uid | number | 是 | 表示应用程序的UID | @@ -1307,9 +1330,9 @@ getBundleNameByUid(uid: number): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------| | 17700021 | The uid is not found | @@ -1343,7 +1366,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ----------------------------------------------------------- | | hapFilePath | string | 是 | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径 | | bundleFlags | [number](#bundleflag) | 是 | 表示用于指定要返回的BundleInfo对象中包含的信息的标志 | @@ -1351,9 +1374,9 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag), ca **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------- | | 17700022 | The hapFilePath is invalid | @@ -1391,7 +1414,7 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | hapFilePath | string | 是 | 表示存储HAP的路径,路径应该是当前应用程序数据目录的相对路径 | | bundleFlags | [number](#bundleflag) | 是 | 表示用于指定要返回的BundleInfo对象中包含的信息的标志 | @@ -1404,9 +1427,9 @@ getBundleArchiveInfo(hapFilePath: string, bundleFlags: [number](#bundleflag)): **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 17700022 | The hapFilePath is invalid | @@ -1442,18 +1465,18 @@ cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback\): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示要清理其缓存数据的应用程序的bundleName | | callback | AsyncCallback\ | 是 | 回调函数,当清理应用缓存目录数据成功,err为null,否则为错误对象 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | -| 17700001 | The specified bundleName is not found | +| 17700001 | The specified bundleName is not found | | 17700030 | The specified bundleName does not support cleaning cache files | **示例:** @@ -1489,8 +1512,8 @@ cleanBundleCacheFiles(bundleName: string): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ---------- | ------ | ---- | -------------------------------------------- | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------------ | | bundleName | string | 是 | 表示要清理其缓存数据的应用程序的bundleName | **返回值:** @@ -1501,11 +1524,11 @@ cleanBundleCacheFiles(bundleName: string): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | ------------------------------------------------------------ | -| 17700001 | The specified bundleName is not found | +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------------------------- | +| 17700001 | The specified bundleName is not found | | 17700030 | The specified bundle does not support cleaning cache files | **示例:** @@ -1539,7 +1562,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------- | ---- | ------------------------------------- | | bundleName | string | 是 | 指定应用的bundleName | | isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用 | @@ -1547,9 +1570,9 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCal **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | @@ -1586,7 +1609,7 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------- | ---- | ------------------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | isEnabled | boolean | 是 | 值为true表示使能,值为false表示禁用 | @@ -1599,9 +1622,9 @@ setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | @@ -1636,7 +1659,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------- | ---- | ------------------------------------- | | info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件 | | isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用 | @@ -1644,9 +1667,9 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------| | 17700001 | The specified bundleName is not found | | 17700003 | The specified abilityInfo is not found | @@ -1697,7 +1720,7 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------- | ---- | ------------------------------------- | | info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 需要被设置的组件 | | isEnabled| boolean | 是 | 值为true表示使能,值为false表示禁用 | @@ -1710,9 +1733,9 @@ setAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), isE **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified abilityInfo is not found | @@ -1759,16 +1782,16 @@ isApplicationEnabled(bundleName: string, callback: AsyncCallback\): voi **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | -------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | callback | AsyncCallback\ | 是 | 回调函数,返回true表示当前应用为使能状态,返回false表示应用为禁用状态 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | @@ -1803,7 +1826,7 @@ isApplicationEnabled(bundleName: string): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | -------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | @@ -1815,9 +1838,9 @@ isApplicationEnabled(bundleName: string): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | @@ -1850,16 +1873,16 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md), call **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ----------- | ---- | --------------------------- | | info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 表示关于检查ability的信息 | | callback | AsyncCallback\ | 是 | 回调函数,返回true表示当前应用组件为使能状态,返回false表示应用组件为禁用状态 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified abilityName is not found | @@ -1908,7 +1931,7 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---- | ----------- | ---- | --------------------------- | | info | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | 是 | 表示关于检查ability的信息 | @@ -1920,9 +1943,9 @@ isAbilityEnabled(info: [AbilityInfo](js-apis-bundleManager-abilityInfo.md)): Pro **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700003 | The specified abilityName is not found | @@ -1971,7 +1994,7 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName | | userId | number | 是 | 表示用户ID | @@ -1979,9 +2002,9 @@ getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallba **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -2021,16 +2044,16 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName | | callback | AsyncCallback\ | 是 | 回调函数,当获取成功时,err为null,data为获取到的Want;否则为错误对象 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700026 | The specified bundle is disabled | @@ -2068,7 +2091,7 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName | | userId | number | 否 | 表示用户ID| @@ -2081,9 +2104,9 @@ getLaunchWantForBundle(bundleName: string, userId?: number): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------| | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -2117,7 +2140,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | | moduleName | string | 是 | 表示应用程序的moduleName | | abilityName | string | 是 | 表示应用程序的abilityName | @@ -2126,9 +2149,9 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName: strin **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed | | 17700003 | The specified abilityName is not existed | @@ -2167,7 +2190,7 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------ | ---- | -------------------------- | | moduleName | string | 是 | 表示应用程序的moduleName | | abilityName | string | 是 | 表示应用程序的abilityName | @@ -2181,9 +2204,9 @@ getProfileByAbility(moduleName: string, abilityName: string, metadataName?: stri **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed | | 17700003 | The specified abilityName is not existed | @@ -2210,7 +2233,7 @@ try { } try { - bundleManager.getProfileByAbility(moduleName, abilityName,metadataName).then((data) => { + bundleManager.getProfileByAbility(moduleName, abilityName, metadataName).then((data) => { console.info('getProfileByAbility successfully. Data: ' + JSON.stringify(data)); }).catch(error => { console.error('getProfileByAbility failed. Cause: ' + error.message); @@ -2230,7 +2253,7 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------------------- | ----------------------------- | ---- | ------------------------------------------------------------ | | moduleName | string | 是 | 表示应用程序的moduleName | | extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName | @@ -2239,9 +2262,9 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed | | 17700003 | The specified extensionAbilityName is not existed | @@ -2279,8 +2302,8 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------------------- | ------ | ---- | -----------------------------------| +| 名称 | 类型 | 必填 | 说明 | +| -------------------- | ------ | ---- | ---------------------------------- | | moduleName | string | 是 | 表示应用程序的moduleName | | extensionAbilityName | string | 是 | 表示应用程序的extensionAbilityName | | metadataName | string | 否 | 表示应用程序的metadataName | @@ -2293,9 +2316,9 @@ getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, m **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17700002 | The specified moduleName is not existed | | 17700003 | The specified extensionAbilityName is not existed | @@ -2345,17 +2368,17 @@ getPermissionDef(permissionName: string, callback: AsyncCallback\<[PermissionDef **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | permissionName | string | 是 | 表示权限名称 | | callback | AsyncCallback\<[PermissionDef](js-apis-bundleManager-permissionDef.md)> | 是 | 回调函数,当获取成功时,err为null,data为获取到的Array\;否则为错误对象 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | --------------------------------------| +| 错误码ID | 错误信息 | +| -------- | ------------------------------------- | | 17700006 | The specified permission is not found | **示例:** @@ -2390,9 +2413,9 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------------- | ------ | ---- | -------------------- | -| permissionName | string | 是 | 表示权限名称 | +| 名称 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------- | +| permissionName | string | 是 | 表示权限参数名 | **返回值:** @@ -2402,10 +2425,10 @@ getPermissionDef(permissionName: string): Promise\<[PermissionDef](js-apis-bundl **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | --------------------------------------| +| 错误码ID | 错误信息 | +| -------- | ------------------------------------- | | 17700006 | The specified permission is not found | **示例:** @@ -2438,7 +2461,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName | | moduleName | string | 是 | 表示应用程序的moduleName | @@ -2447,10 +2470,10 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, cal **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | ---------------------------------------| +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700002 | The specified moduleName is not found | | 17700003 | The specified abilityName is not found | @@ -2492,7 +2515,7 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | moduleName | string | 是 | 表示应用程序的moduleName | @@ -2506,9 +2529,9 @@ getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Pr **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | --------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700002 | The specified moduleName is not found | @@ -2549,7 +2572,7 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 表示应用程序的bundleName | | moduleName | string | 是 | 表示应用程序的moduleName | @@ -2558,9 +2581,9 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, call **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700002 | The specified moduleName is not found | @@ -2603,7 +2626,7 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | moduleName | string | 是 | 表示应用程序的moduleName | @@ -2617,9 +2640,9 @@ getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Pro **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700002 | The specified moduleName is not found | @@ -2660,7 +2683,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ----------------------------------------------------------| | bundleName | string | 是 | 表示应用程序的bundleName | | applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息 | @@ -2674,9 +2697,9 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: num **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -2712,7 +2735,7 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | ----------------------------------------------------------| | bundleName | string | 是 | 表示应用程序的bundleName | | applicationFlags | [number](#applicationflag) | 是 | 表示用于指定将返回的ApplicationInfo对象中包含的信息 | @@ -2725,9 +2748,9 @@ getApplicationInfoSync(bundleName: string, applicationFlags: number) : [Applicat **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700026 | The specified bundle is disabled | @@ -2761,7 +2784,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | -------------------------------------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志 | @@ -2775,9 +2798,9 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700004 | The specified userId is not found | @@ -2813,7 +2836,7 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | -------------------------------------------------------- | | bundleName | string | 是 | 表示应用程序的bundleName | | bundleFlags | [number](#bundleflag) | 是 | 表示用于指定将返回的BundleInfo对象中包含的信息的标志 | @@ -2826,9 +2849,9 @@ getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [Bund **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------------- | | 17700001 | The specified bundleName is not found | | 17700026 | The specified bundle is disabled | @@ -2840,7 +2863,7 @@ import bundleManager from '@ohos.bundle.bundleManager' let bundleName = 'com.example.myapplication'; let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION; try { - let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags, userId); + let data = bundleManager.getBundleInfoSync(bundleName, bundleFlags); console.info("getBundleInfoSync successfully :" + JSON.stringify(data)); } catch (err) { console.error('getBundleInfoSync failed:' + err.message); diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md b/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md index f89f2c0a3bfd4647fa0771eaa9552fc5f689416e..a4fb1b82be2ba786390f5354fdcd47c7e72cb5b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundleMonitor.md @@ -24,7 +24,7 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor'; **系统能力:** SystemCapability.BundleManager.BundleFramework.Core -系统接口:为系统接口,三方应用不可调用 +**系统API:** 此接口为系统接口,三方应用不支持调用 | 名称 | 类型 | 可读 | 可写 | 说明 | | ---------- | ------ | ---- | ---- | -------------------------- | @@ -39,23 +39,23 @@ on(type: BundleChangedEvent, callback: Callback\): void; **需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE -**系统接口:**此接口为系统接口 +**系统API:** 此接口为系统接口,三方应用不支持调用 **系统能力:**SystemCapability.BundleManager.BundleFramework.Core **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------------------------- | -------- | ---- | ------------------ | | BundleChangedEvent | string | 是 | 注册监听的事件类型 | | Callback\ | callback | 是 | 注册监听的回调函数 | **相关错误码** -| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) | -| ------ | ---------------------------------------- | -| 201 | Permission denied. | -| 401 | The parameter check failed. | +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 201 | Permission denied. | +| 401 | The parameter check failed. | **示例:** @@ -79,23 +79,23 @@ off(type: BundleChangedEvent, callback?: Callback\): void; **需要权限:**ohos.permission.LISTEN_BUNDLE_CHANGE -**系统接口:**此接口为系统接口 +**系统API:** 此接口为系统接口,三方应用不支持调用 **系统能力:**SystemCapability.BundleManager.BundleFramework.Core **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------------------------- | -------- | ---- | ---------------------------------------------------------- | | BundleChangedEvent | string | 是 | 注销监听的事件类型 | | Callback\ | callback | 否 | 注销监听的回调函数,当为空时表示注销当前事件的所有callback | **相关错误码** -| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) | -| ------ | ---------------------------------------- | -| 201 | Permission denied. | -| 401 | The parameter check failed. | +| 错误码ID | 错误信息 | +| -------- | --------------------------- | +| 201 | Permission denied. | +| 401 | The parameter check failed. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index a53646225fcd2b3cf347b92e9dc42e78486e5d64..392fb9457b62af0d8e778ea47840b5e51daa9fba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -194,7 +194,7 @@ getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback { +cameraManager.getSupportedOutputCapability(cameradevice, (err, CameraOutputCapability) => { if (err) { console.error(`Failed to get the cameras. ${err.message}`); return; @@ -250,7 +250,7 @@ isCameraMuted(): boolean **示例:** ```js -let ismuted = await cameraManager.isCameraMuted(); +let ismuted = cameraManager.isCameraMuted(); ``` ### isCameraMuteSupported @@ -270,7 +270,7 @@ isCameraMuteSupported(): boolean **示例:** ```js -let ismutesuppotred = await cameraManager.isCameraMuteSupported(); +let ismutesuppotred = cameraManager.isCameraMuteSupported(); ``` ### muteCamera @@ -1092,7 +1092,7 @@ cameraInput.on('error', camera, (cameraInputError) => { | -------------------------- | ---- | ------------ | | FOCUS_MODE_MANUAL | 0 | 手动对焦。 | | FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动对焦。 | -| FOCUS_MODE_AUTO | 2 | 自动变焦。 | +| FOCUS_MODE_AUTO | 2 | 自动对焦。 | | FOCUS_MODE_LOCKED | 3 | 对焦锁定。 | ## FocusState @@ -2106,8 +2106,8 @@ getExposureBiasRange(): Promise\> **示例:** ```js -captureSession.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { - console.log(`Promise returned with exposure mode supported : ${isSupported}`); +captureSession.getExposureBiasRange().then((biasRangeArray) => { + console.log('Promise returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md index 52dca7d46205ca13abd2a6857474d6c14af8b035..f5a241b2dbf92f80d280f13ae4f363cf46a458fe 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cardEmulation.md @@ -30,8 +30,6 @@ isSupported(feature: number): boolean 是否支持某种类型的卡模拟。 -**需要权限**:ohos.permission.NFC_CARD_EMULATION - **系统能力**:SystemCapability.Communication.NFC.Core **参数:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md b/zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md index 8e1b9222850a83f8e9596a6314fbe1d6903ac51d..e6ff7755a77b867fe0b9ffa20c55e26497deb7a2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-colorSpaceManager.md @@ -33,7 +33,7 @@ import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; **系统能力:** SystemCapability.Graphic.Graphic2D.ColorManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------------------------- | -------- | ---- | ---- | ----------------------------------------------------- | | redX | number | 是 | 是 | 标准红色在色彩空间的x坐标值。 | | redY | number | 是 | 是 | 标准红色在色彩空间的y坐标值。 | @@ -166,7 +166,7 @@ getColorSpaceName(): ColorSpace ```js try { - let csType = colorSpace.getColorSpaceName(); + colorSpace.getColorSpaceName(); } catch (err) { console.log(`Fail to get colorSpace's name. Cause: ` + JSON.stringify(err)); } @@ -198,7 +198,7 @@ getWhitePoint(): Array\ ```js try { - let wp = colorSpace.getWhitePoint(); + colorSpace.getWhitePoint(); } catch (err) { console.log(`Failed to get white point. Cause: ` + JSON.stringify(err)); } @@ -230,9 +230,8 @@ getGamma(): number ```js try { - let gamma = colorSpace.getGamma(); + colorSpace.getGamma(); } catch (err) { console.log(`Failed to get gamma. Cause: ` + JSON.stringify(err)); } -``` - +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index 88e95d6c483b03279b6e3ceeb67f2007c11611e9..0769991e79375d027e80d2fe617592a966fa7729 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -1,10 +1,10 @@ # 公共事件模块 -本模块提供了公共事件的能力,包括公共事件的权限列表,发布公共事件,订阅或取消订阅公共事件,获取或修改公共事件结果代码、结果数据等。本模块将被commonEventManager模块取代,建议优先使用[commonEventManager](js-apis-commonEventManager.md)模块。 +本模块提供了公共事件的能力,包括公共事件的权限列表,发布公共事件,订阅或取消订阅公共事件,获取或修改公共事件结果代码、结果数据等。 > **说明:** -> -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 从API Version 9开始,该接口不再维护,推荐使用新接口[@ohos.commonEventManager](js-apis-commonEventManager.md)。 +> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -1263,7 +1263,7 @@ subscriber.finishCommonEvent().then(() => { | data | 是 | 否 | string | 表示公共事件的自定义结果数据。 | | subscriberPermissions | 是 | 否 | Array\ | 表示订阅者的权限。 | | isOrdered | 是 | 否 | boolean | 表示是否是有序事件。 | -| isSticky | 是 | 否 | boolean | 表示是否是粘性事件。 | +| isSticky | 是 | 否 | boolean | 表示是否是粘性事件。仅系统应用或系统服务允许发送粘性事件。 | | parameters | 是 | 否 | {[key: string]: any} | 表示公共事件的附加信息。 | ## CommonEventSubscribeInfo diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md index 94f5a3e6aeff0f6822182a0962dc11d7b1e3b8a0..75b1a37e514bcc67fea6278647e231fb6b7672a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md @@ -1,6 +1,6 @@ # 公共事件模块 -本模块提供了公共事件的能力,包括公共事件的权限列表,发布公共事件,订阅或取消订阅公共事件,获取或修改公共事件结果代码、结果数据等。本模块将会取代[commonEvent](js-apis-commonEvent.md)模块,建议优先使用本模块。 +本模块提供了公共事件的能力,包括公共事件的权限列表,发布公共事件,订阅或取消订阅公共事件,获取或修改公共事件结果代码、结果数据等。 > **说明:** > @@ -189,7 +189,7 @@ publish(event: string, callback: AsyncCallback\): void | callback | AsyncCallback\ | 是 | 表示被指定的回调方法。 | **错误码:** -以下错误码详细介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errcode-CommonEventService.md) +以下错误码详细介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) |错误码ID |错误信息 | |-----------|--------------------| @@ -1404,7 +1404,7 @@ subscriber.finishCommonEvent().then(() => { | data | 是 | 否 | string | 表示公共事件的自定义结果数据。 | | subscriberPermissions | 是 | 否 | Array\ | 表示订阅者的权限。 | | isOrdered | 是 | 否 | boolean | 表示是否是有序事件。 | -| isSticky | 是 | 否 | boolean | 表示是否是粘性事件。 | +| isSticky | 是 | 否 | boolean | 表示是否是粘性事件。仅系统应用或系统服务允许发送粘性事件。 | | parameters | 是 | 否 | {[key: string]: any} | 表示公共事件的附加信息。 | ## CommonEventSubscribeInfo diff --git a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md index 0e05d31270de26c1943eabbe95bdee8cfb036b64..239575f71050935bd1815d69cfc30b3d18e4f6e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-continuation-continuationManager.md @@ -2,7 +2,7 @@ continuationManager模块提供了流转/协同入口管理服务能力,包括连接/取消流转管理服务,注册/解注册设备连接变化监听,拉起设备选择模块,更新连接状态。 -本模块接口用于拉起系统中的设备选择模块,由于该模块功能暂不完备,因此**流转能力整体暂不支持用于应用开发**。 +本模块接口用于拉起系统中的设备选择模块,由于该模块功能暂不完备,因此流转能力整体暂不支持用于应用开发。 > **说明:** > @@ -20,7 +20,7 @@ register(callback: AsyncCallback\): void; 注册流转管理服务,并获取对应的注册token,无过滤条件,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 +> 从API version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -32,13 +32,13 @@ register(callback: AsyncCallback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360207 | The maximum number of registrations exceeded. | +| 29360207 | The number of registrations has reached the upper limit. | **示例:** @@ -60,7 +60,7 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\): vo 连接流转管理服务,并获取对应的注册token,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 +> 从API version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -73,13 +73,13 @@ register(options: ContinuationExtraParams, callback: AsyncCallback\): vo **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360207 | The maximum number of registrations exceeded. | +| 29360207 | The number of registrations has reached the upper limit. | | 29360216 | Invalid continuation mode. | **示例:** @@ -105,7 +105,7 @@ register(options?: ContinuationExtraParams): Promise\; 连接流转管理服务,并获取对应的注册token,使用Promise方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 +> 从API version 9开始不再维护,建议使用[registerContinuation](#continuationmanagerregistercontinuation9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -123,13 +123,13 @@ register(options?: ContinuationExtraParams): Promise\; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object | | 7 | The object is null. | -| 29360207 | The maximum number of registrations exceeded. | +| 29360207 | The number of registrations has reached the upper limit. | | 29360216 | Invalid continuation mode. | **示例:** @@ -167,12 +167,12 @@ registerContinuation(callback: AsyncCallback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | +| 16600001 | The system ability works abnormally. | | 16600003 | The number of token registration times has reached the upper limit. | **示例:** @@ -212,12 +212,12 @@ registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\< **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | +| 16600001 | The system ability works abnormally. | | 16600003 | The number of token registration times has reached the upper limit. | **示例:** @@ -265,12 +265,12 @@ registerContinuation(options?: ContinuationExtraParams): Promise\; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | +| 16600001 | The system ability works abnormally. | | 16600003 | The number of token registration times has reached the upper limit. | **示例:** @@ -301,7 +301,7 @@ on(type: "deviceConnect", callback: Callback\): void; 异步方法,监听设备连接状态,使用Callback形式返回连接的设备信息。 -> 从API Version 9开始不再维护,建议使用[on](#continuationmanagerondeviceselected9)替代。 +> 从API version 9开始不再维护,建议使用[on](#continuationmanagerondeviceselected9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -314,14 +314,14 @@ on(type: "deviceConnect", callback: Callback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object | | 7 | The object is null | 7 | -| 29360208 | The token has not registered. | -| 29360209 | Callback has been registered. | +| 29360208 | The token is not registered. | +| 29360209 | The callback has been registered. | | 29360214 | The type of callback is not supported. | **示例:** @@ -340,7 +340,7 @@ on(type: "deviceDisconnect", callback: Callback\): void; 异步方法,监听设备断开状态,使用Callback形式返回断开的设备信息。 -> 从API Version 9开始不再维护,建议使用[on](#continuationmanagerondeviceunselected9)替代。 +> 从API version 9开始不再维护,建议使用[on](#continuationmanagerondeviceunselected9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -353,14 +353,14 @@ on(type: "deviceDisconnect", callback: Callback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360209 | Callback has been registered. | +| 29360208 | The token is not registered. | +| 29360209 | The callback has been registered. | | 29360214 | The type of callback is not supported. | **示例:** @@ -377,7 +377,7 @@ off(type: "deviceConnect", callback?: Callback\): void; 异步方法,取消监听设备连接状态,使用Callback形式返回连接的设备信息。 -> 从API Version 9开始不再维护,建议使用[off](#continuationmanageroffdeviceselected9)替代。 +> 从API version 9开始不再维护,建议使用[off](#continuationmanageroffdeviceselected9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -390,14 +390,14 @@ off(type: "deviceConnect", callback?: Callback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | | 29360214 | The type of callback is not supported. | **示例:** @@ -416,7 +416,7 @@ off(type: "deviceDisconnect", callback?: Callback\): void; 异步方法,取消监听设备断开状态,使用Callback形式返回连接的设备信息。 -> 从API Version 9开始不再维护,建议使用[off](#continuationmanageroffdeviceunselected9)替代。 +> 从API version 9开始不再维护,建议使用[off](#continuationmanageroffdeviceunselected9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -429,14 +429,14 @@ off(type: "deviceDisconnect", callback?: Callback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | | 29360214 | The type of callback is not supported. | **示例:** @@ -467,13 +467,13 @@ on(type: "deviceSelected", token: number, callback: Callback\): void; 拉起设备选择模块,可显示组网内可选择设备列表信息,无过滤条件,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 +> 从API version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -639,15 +639,15 @@ startDeviceManager(token: number, callback: AsyncCallback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | -| 29360211 | Failed to connect ability. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | +| 29360211 | Failed to connect to the ability. | | 29360216 | Invalid continuation mode. | **示例:** @@ -669,7 +669,7 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As 拉起设备选择模块,可显示组网内可选择设备列表信息,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 +> 从API version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -683,15 +683,15 @@ startDeviceManager(token: number, options: ContinuationExtraParams, callback: As **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object | | 7 | The object is null | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | -| 29360211 | Failed to connect ability. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | +| 29360211 | Failed to connect to the ability. | | 29360216 | Invalid continuation mode. | **示例:** @@ -716,7 +716,7 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\ 从API Version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 +> 从API version 9开始不再维护,建议使用[startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -735,15 +735,15 @@ startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\): v **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -826,13 +826,13 @@ startContinuationDeviceManager(token: number, options: ContinuationExtraParams, **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -879,13 +879,13 @@ startContinuationDeviceManager(token: number, options?: ContinuationExtraParams) **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -913,7 +913,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, 通知设备选择模块,更新当前的连接状态,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 +> 从API version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -928,16 +928,16 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | -| 29360211 | Failed to connect ability. | -| 29360215 | Invalid connect state. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | +| 29360211 | Failed to connect to the ability. | +| 29360215 | Invalid connection state. | **示例:** @@ -959,7 +959,7 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) 通知设备选择模块,更新当前的连接状态,使用Promise方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 +> 从API version 9开始不再维护,建议使用[updateContinuationState](#continuationmanagerupdatecontinuationstate9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -979,16 +979,16 @@ updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState) **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | -| 29360210 | Callback has not registered. | -| 29360211 | Failed to connect ability. | -| 29360215 | Invalid connect state. | +| 29360208 | The token is not registered. | +| 29360210 | The callback is not registered. | +| 29360211 | Failed to connect to the ability. | +| 29360215 | Invalid connection state. | **示例:** @@ -1025,13 +1025,13 @@ updateContinuationState(token: number, deviceId: string, status: DeviceConnectSt **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -1077,13 +1077,13 @@ updateContinuationState(token: number, deviceId: string, status: DeviceConnectSt **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -1110,7 +1110,7 @@ unregister(token: number, callback: AsyncCallback\): void; 解注册流转管理服务,传入注册时获取的token进行解注册,使用AsyncCallback方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 +> 从API version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -1123,13 +1123,13 @@ unregister(token: number, callback: AsyncCallback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | +| 29360208 | The token is not registered. | **示例:** @@ -1150,7 +1150,7 @@ unregister(token: number): Promise\; 解注册流转管理服务,传入注册时获取的token进行解注册,使用Promise方式作为异步方法。 -> 从API Version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 +> 从API version 9开始不再维护,建议使用[unregisterContinuation](#continuationmanagerunregistercontinuation9)替代。 **系统能力**:SystemCapability.Ability.DistributedAbilityManager @@ -1168,13 +1168,13 @@ unregister(token: number): Promise\; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 3 | Failed to flatten the object. | | 7 | The object is null. | -| 29360208 | The token has not registered. | +| 29360208 | The token is not registered. | **示例:** @@ -1208,13 +1208,13 @@ unregisterContinuation(token: number, callback: AsyncCallback\): void; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** @@ -1257,13 +1257,13 @@ unregisterContinuation(token: number): Promise\; **错误码:** -以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errcode-DistributedSchedule.md)。 +以下错误码的详细介绍请参见[分布式调度错误码](../errorcodes/errorcode-DistributedSchedule.md)。 | 错误码ID | 错误信息 | | ------- | -------------------------------------------- | | 401 | The parameter check failed. | -| 16600001 | The system ability work abnormally. | -| 16600002 | The specified token or callback has not registered. | +| 16600001 | The system ability works abnormally. | +| 16600002 | The specified token or callback is not registered. | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md index 3e01d5ba83445c2915c3aca047a3d30fbfcd0920..f4101a76c1b6c0ec3a1c65af2415c37decb68189 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-cooperate.md +++ b/zh-cn/application-dev/reference/apis/js-apis-cooperate.md @@ -4,7 +4,9 @@ > **说明** > -> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> - 本模块接口均为系统接口。 ## 导入模块 @@ -18,7 +20,7 @@ enable(enable: boolean, callback: AsyncCallback<void>): void 开启、关闭键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -52,7 +54,7 @@ enable(enable: boolean): Promise<void> 开启、关闭键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -90,7 +92,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal 启动键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -102,7 +104,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal **错误码:** -以下错误码的详细介绍请参见[ohos.multimodalinput错误码](../errorcodes/errorcodes-multimodalinput.md)。 +以下错误码的详细介绍请参见[ohos.multimodalinput错误码](../errorcodes/errorcode-multimodalinput.md)。 | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | @@ -112,6 +114,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCal **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => { if (error) { @@ -131,7 +135,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ 启动键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**: SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -150,7 +154,7 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ **错误码:** -以下错误码的详细介绍请参见[ohos.multimodalinput错误码](../errorcodes/errorcodes-multimodalinput.md)。 +以下错误码的详细介绍请参见[ohos.multimodalinput错误码](../errorcodes/errorcode-multimodalinput.md)。 | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | @@ -160,6 +164,8 @@ start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\ **示例**: ```js +let sinkDeviceDescriptor = "descriptor"; +let srcInputDeviceId = 0; try { inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => { console.log(`Start Keyboard mouse crossing success.`); @@ -177,7 +183,7 @@ stop(callback: AsyncCallback\): void 停止键鼠穿越,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -209,13 +215,13 @@ stop(): Promise\ 停止键鼠穿越,使用Promise异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate -**参数**: +**返回值**: | 参数名 | 说明 | | -------- | ---------------------------- | -| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | +| Promise\ | Promise对象,异步返回停止键鼠穿越结果。 | **示例**: @@ -237,7 +243,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): 获取键鼠穿越开关的状态,使用AsyncCallback异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -249,6 +255,7 @@ getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor, (error, data) => { if (error) { @@ -268,7 +275,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }> 获取键鼠穿越开关的状态,使用Promise异步方式返回结果。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -289,6 +296,7 @@ getState(deviceDescriptor: string): Promise<{ state: boolean }> **示例**: ```js +let deviceDescriptor = "descriptor"; try { inputDeviceCooperate.getState(deviceDescriptor).then((data) => { console.log(`Get the status success, data: ${JSON.stringify(data)}`); @@ -306,7 +314,7 @@ on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, even 注册监听键鼠穿越状态。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: @@ -324,7 +332,7 @@ try { inputDeviceCooperate.on('cooperation', (data) => { console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`); }); -} catch (err) { +} catch (error) { console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -335,14 +343,14 @@ off(type: 'cooperation', callback?: AsyncCallback\): void 关闭监听键鼠穿越状态。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | ---- | ---------------------------- | | type | string | 是 | 注册类型,取值“cooperation”。 | -| callback | AsyncCallback | 否 | 需要取消注册的回调函数,若无此参数,则取消当前应用注册的所有回调函数。 | +| callback | AsyncCallback\ | 否 | 需要取消注册的回调函数,若无此参数,则取消当前应用注册的所有回调函数。 | @@ -350,25 +358,25 @@ off(type: 'cooperation', callback?: AsyncCallback\): void ```js // 取消注册单个回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; -}, +} try { - inputDeviceCooperate.on('cooperation', this.callback); - inputDeviceCooperate.off("cooperation", this.callback); + inputDeviceCooperate.on('cooperation', callback); + inputDeviceCooperate.off("cooperation", callback); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ```js // 取消注册所有回调函数 -callback: function(event) { +function callback(event) { console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`); return false; -}, +} try { - inputDeviceCooperate.on('cooperation', this.callback); + inputDeviceCooperate.on('cooperation', callback); inputDeviceCooperate.off("cooperation"); } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); @@ -379,9 +387,9 @@ try { 键鼠穿越事件。 -**系统能力**:SystemCapability.MultimodalInput.Input.InputDeviceCooperate +**系统能力**:SystemCapability.MultimodalInput.Input.Cooperate -| 参数名 | 值 | 说明 | +| 名称 | 值 | 说明 | | -------- | --------- | ----------------- | | MSG_COOPERATE_INFO_START | 200 | 键鼠穿越消息,表示键鼠穿越开始。 | | MSG_COOPERATE_INFO_SUCCESS | 201 | 键鼠穿越消息,表示键鼠穿越成功。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md index 4cee340f7927bd409d9fb1b093cb4cfe6a6a46ea..210f71874173df8a86ca48e9eba81b36af3af2a0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md @@ -28,7 +28,7 @@ createDataShareHelper(context: Context, uri: string, callback: AsyncCallback< **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------------- | ---- | ------------------------------------------------------------ | | context | [Context](js-apis-application-context.md#context) | 是 | 应用的上下文环境。 | | uri | string | 是 | 指示要连接的服务端应用的路径。 | @@ -73,7 +73,7 @@ createDataShareHelper(context: Context, uri: string): Promise<DataShareHelper **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------------------------- | ---- | ------------------------------ | | context | [Context](js-apis-application-context.md#context) | 是 | 应用的上下文环境。 | | uri | string | 是 | 指示要连接的服务端应用的路径。 | @@ -125,7 +125,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 订阅的事件/回调类型,支持的事件为'dataChange',当数据更改时,触发该事件。 | | uri | string | 是 | 表示指定的数据路径。 | @@ -152,7 +152,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | type | string | 是 | 取消订阅的事件/回调类型,支持的事件为'dataChange'。 | | uri | string | 是 | 表示指定的数据路径。 | @@ -179,7 +179,7 @@ insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要插入的数据。如果此参数为空,将插入一个空行。 | @@ -218,7 +218,7 @@ insert(uri: string, value: ValuesBucket): Promise<number> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ----- | --------------------------------------------------------- | ---- | -------------------------------------------------- | | uri | string | 是 | 指示要插入的数据的路径。 | | value | [ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket) | 是 | 指示要插入的数据。如果此参数为空,将插入一个空行。 | @@ -260,7 +260,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callbac **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要删除的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | @@ -298,7 +298,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promis **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要删除的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
delete接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB的删除目前仅支持inKeys谓词。 | @@ -339,7 +339,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | @@ -379,7 +379,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要查询的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
query接口所支持的谓词方法取决于服务端所选用的数据库,如KVDB目前仅支持inKeys和prefixKey。 | @@ -422,7 +422,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要更新的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | @@ -467,7 +467,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要更新的数据的路径。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件。
update接口是否支持谓词筛选条件取决于服务端所选用的数据库,如KVDB目前并不支持谓词筛选条件,仅RDB支持。 | @@ -515,7 +515,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallb **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 指示要插入的数据。 | @@ -552,7 +552,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number&g **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------------------ | | uri | string | 是 | 指示要插入的数据的路径。 | | values | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 指示要插入的数据。 | @@ -592,7 +592,7 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | -------------------------------------------------------- | | uri | string | 是 | 指示要规范化的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。当将给定的DataShare URI转换为规范化URI成功,err为undefined,data为获取到的规范化URI(如果支持URI规范化,则返回规范化URI,否则返回空);否则为错误对象。 | @@ -621,7 +621,7 @@ normalizeUri(uri: string): Promise<string> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------------------------------------- | | uri | string | 是 | 指示要规范化的[URI](js-apis-uri.md#uri)。 | @@ -653,7 +653,7 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | --------------------------------------------------- | | uri | string | 是 | 指示要反规范化的[URI](js-apis-uri.md#uri)。 | | callback | AsyncCallback<string> | 是 | 回调函数。当将指定的URI转换为非规范化URI,err为undefined,data为获取到的反规范化URI(如果反规范化成功,则返回反规范化的URI;如果无需进行反规范化,则返回原始URI;若不支持则返回空);否则为错误对象。 | @@ -682,7 +682,7 @@ denormalizeUri(uri: string): Promise<string> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ------------------------------------------- | | uri | string | 是 | 指示要反规范化的[URI](js-apis-uri.md#uri)。 | @@ -714,7 +714,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------ | | uri | string | 是 | 表示指定的数据路径。 | | callback | AsyncCallback<void> | 是 | 回调函数。当通知已注册的观察者指定URI对应的数据资源已发生变更成功,err为undefined;否则为错误对象。 | @@ -739,7 +739,7 @@ notifyChange(uri: string): Promise<void> **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 名称 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | -------------------- | | uri | string | 是 | 表示指定的数据路径。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md index 79c474b00aa1c9e77c25a6ea710df58815c0069a..24c88d945201aa455082234546aa91c66a29aa84 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-distributedobject.md @@ -131,7 +131,7 @@ setSessionId(sessionId: string, callback: AsyncCallback<void>): void **错误码:** - 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-data_object.md)。 + 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-dataObject.md)。 | 类型 | 说明 | | -------- | -------- | @@ -189,7 +189,7 @@ setSessionId(callback: AsyncCallback<void>): void **错误码:** - 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-data_object.md)。 + 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-dataObject.md)。 | 类型 | 说明 | | -------- | -------- | @@ -261,7 +261,7 @@ setSessionId(sessionId?: string): Promise<void> **错误码:** - 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-data_object.md)。 + 以下错误码的详细介绍参见[分布式数据对象错误码](../errorcodes/errorcode-distributed-dataObject.md)。 | 类型 | 说明 | | -------- | -------- | @@ -632,7 +632,7 @@ import distributedObject from '@ohos.data.distributedDataObject'; import featureAbility from '@ohos.ability.featureAbility'; // 获取context let context = featureAbility.getContext(); -let g_object = distributedObject.create({name:"Amy", age:18, isVis:false}); +let g_object = distributedObject.create(context,{name:"Amy", age:18, isVis:false}); g_object.setSessionId("123456"); g_object.save("local").then((result) => { console.log("save callback"); @@ -654,7 +654,7 @@ class MainAbility extends Ability{ context = this.context } } -let g_object = distributedObject.create({name:"Amy", age:18, isVis:false}); +let g_object = distributedObject.create(context,{name:"Amy", age:18, isVis:false}); g_object.setSessionId("123456"); g_object.save("local").then((result) => { console.log("save callback"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 49111b648c5c66fa8846e16561160dfe97fee3a6..a19a37efd9f244207dbdc75fa7abd60d684a450d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -475,7 +475,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): ```js try { - data_preferences.get('startup', 'default', function (err, val) { + preferences.get('startup', 'default', function (err, val) { if (err) { console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message); return; diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index 064669b6e3100d19ace8f95bb6656c96d598947d..1e3319ec529652898608f55dfc7d6b41ed5dea42 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -22,7 +22,7 @@ import data_storage from '@ohos.data.storage'; **系统能力:** 以下各项对应的系统能力均为SystemCapability.DistributedDataManager.Preferences.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------------- | -------- | ---- | ---- | ------------------------------------- | | MAX_KEY_LENGTH | number | 是 | 否 | key的最大长度限制,需小于80字节。 | | MAX_VALUE_LENGTH | number | 是 | 否 | value的最大长度限制,需小于8192字节。 | @@ -53,8 +53,8 @@ getStorageSync(path: string): Storage ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -86,8 +86,8 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -129,8 +129,8 @@ getStorage(path: string): Promise<Storage> ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -165,8 +165,8 @@ deleteStorageSync(path: string): void ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -195,8 +195,8 @@ deleteStorage(path: string, callback: AsyncCallback<void>): void ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -237,8 +237,8 @@ deleteStorage(path: string): Promise<void> ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -271,8 +271,8 @@ removeStorageFromCacheSync(path: string): void ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -302,8 +302,8 @@ removeStorageFromCache(path: string, callback: AsyncCallback<void>): void ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -344,8 +344,8 @@ removeStorageFromCache(path: string): Promise<void> ```js import featureAbility from '@ohos.ability.featureAbility'; -var path; -var context = featureAbility.getContext(); +let path; +let context = featureAbility.getContext(); context.getFilesDir().then((filePath) => { path = filePath; console.info("======================>getFilesDirPromise====================>"); @@ -864,15 +864,15 @@ on(type: 'change', callback: Callback<StorageObserver>): void **参数:** -| 参数名 | 类型 | 说明 | -| -------- | --------------------------------------------------- | ---------------------------------------- | -| type | string | 事件类型,固定值'change',表示数据变更。 | -| callback | Callback<[StorageObserver](#storageobserver)> | 回调对象实例。 | +| 参数名 | 类型 | 必填| 说明 | +| -------- | --------------------------------------------------- | ------ |---------------------------------------- | +| type | string |是| 事件类型,固定值'change',表示数据变更。 | +| callback | Callback<[StorageObserver](#storageobserver)> | 是|回调对象实例。 | **示例:** ```js -var observer = function (key) { +let observer = function (key) { console.info("The key of " + key + " changed."); } storage.on('change', observer); @@ -891,15 +891,15 @@ off(type: 'change', callback: Callback<StorageObserver>): void **参数:** -| 参数名 | 类型 | 说明 | -| -------- | --------------------------------------------------- | ---------------------------------------- | -| type | string | 事件类型,固定值'change',表示数据变更。 | -| callback | Callback<[StorageObserver](#storageobserver)> | 需要取消的回调对象实例。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ------ |---------------------------------------- | +| type | string |是| 事件类型,固定值'change',表示数据变更。 | +| callback | Callback<[StorageObserver](#storageobserver)> | 是|需要取消的回调对象实例。 | **示例:** ```js -var observer = function (key) { +let observer = function (key) { console.info("The key of " + key + " changed."); } storage.off('change', observer); @@ -910,7 +910,7 @@ storage.off('change', observer); **系统能力:** SystemCapability.DistributedDataManager.Preferences.Core -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---- | -------- | ---- | ---------------- | | key | string | 否 | 变更的数据内容。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md b/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md index 9cf076295258de43d1dafa6938320b885bad9c74..9c2722a2201949b7b1dbe11bc1eea6228844c542 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md @@ -15,9 +15,9 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager'; 应用类型 -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp -| 名称 | 类型 | 值 | 说明 | +| 参数名 | 类型 | 值 | 说明 | | -------- | -------- | -------------------------------------- | -------------------------------------- | | BROWSER | string | Web Browser | 默认浏览器。 | | IMAGE | string | Image Gallery | 默认图片查看器。 | @@ -34,11 +34,11 @@ isDefaultApplication(type: string): Promise\ 以异步方法根据系统已定义的应用类型判断当前应用是否是该应用类型的默认应用,使用Promise形式返回结果。 -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 | @@ -66,11 +66,11 @@ isDefaultApplication(type: string, callback: AsyncCallback\): void 以异步方法根据系统已定义的应用类型判断当前应用是否是该应用类型的默认应用,使用callback形式返回结果。 -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------- | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 | @@ -96,13 +96,13 @@ getDefaultApplication(type: string, userId?: number): Promise\ **需要权限:** ohos.permission.GET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户。 | @@ -115,7 +115,7 @@ getDefaultApplication(type: string, userId?: number): Promise\ **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ----------------------------------------- | | 17700004 | The specified user id is not found. | | 17700023 | The specified default app does not exist. | @@ -150,13 +150,13 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void **需要权限:** ohos.permission.GET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | callback | AsyncCallback\<[BundleInfo](js-apis-bundle-BundleInfo.md)> | 是 | 程序启动作为入参的回调函数,返回包信息。 | **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ----------------------------------------- | | 17700004 | The specified user id is not found. | | 17700023 | The specified default app does not exist. | @@ -253,13 +253,13 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要设置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 要设置为默认应用的组件信息。 | @@ -273,7 +273,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | @@ -323,13 +323,13 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要设置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 要设置为默认应用的组件信息。 | @@ -338,7 +338,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | @@ -382,13 +382,13 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要设置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | elementName | [ElementName](js-apis-bundle-ElementName.md) | 是 | 要设置为默认应用的组件信息。 | @@ -396,7 +396,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ---------------------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | @@ -439,20 +439,20 @@ resetDefaultApplication(type: string, userId?: number): Promise\ **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要重置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户。 | **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ----------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | @@ -487,13 +487,13 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void; **需要权限:** ohos.permission.SET_DEFAULT_APPLICATION -**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultAppManager +**系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp **系统API:** 此接口为系统接口,三方应用不支持调用 **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要重置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数。 | **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ----------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 4fb4fcdb83c8df3a3c661a2abf7d8fe97f84894a..482b3eb1faeaec10507cda27eb644931649a8abc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -26,7 +26,7 @@ import Deque from '@ohos.util.Deque'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | Deque的元素个数。 | @@ -42,7 +42,7 @@ Deque的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The Deque's constructor cannot be directly invoked. | @@ -75,7 +75,7 @@ insertFront(element: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The insertFront method cannot be bound. | @@ -115,7 +115,7 @@ insertEnd(element: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The insertEnd method cannot be bound. | @@ -161,7 +161,7 @@ has(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -197,7 +197,7 @@ popFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The popFirst method cannot be bound. | @@ -236,7 +236,7 @@ popLast(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The popLast method cannot be bound. | @@ -285,7 +285,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -327,7 +327,7 @@ getFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getFirst method cannot be bound. | @@ -365,7 +365,7 @@ getLast(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLast method cannot be bound. | @@ -403,7 +403,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md index 11ebc8aa8438efc8ec5681dbf6db58c221222267..facfc200a5d4cb84090fb641aecc3392461d4429 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dispatchInfo.md @@ -11,12 +11,12 @@ ## DispatchInfo -**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework +**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.FreeInstall **系统API:**此接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | ------ | ---- | ---- | ------------------------ | -| version | string | 是 | 否 | 包含dispatchInfo版本信息 | -| dispatchAPI | string | 是 | 否 | 包含免安装接口版本号 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------ | ------ | ---- | ---- | ------------------------ | +| version | string | 是 | 否 | 包含dispatchInfo版本信息 | +| dispatchAPIVersion | string | 是 | 否 | 包含免安装接口版本号 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-display.md b/zh-cn/application-dev/reference/apis/js-apis-display.md index 4e6680987322cb3d837833f821b1f973592e48c4..3541d6f2d145842797d0f052eee8a3e3fa9a009e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-display.md +++ b/zh-cn/application-dev/reference/apis/js-apis-display.md @@ -33,7 +33,7 @@ import display from '@ohos.display'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | ------------------ | | left | number | 是 | 是 | 矩形区域的左边界。 | | top | number | 是 | 是 | 矩形区域的上边界。 | @@ -46,7 +46,7 @@ import display from '@ohos.display'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------------- | ---- | ---- | ------------------ | | left | [Rect](#rect9) | 是 | 否 | 瀑布曲面区域的左侧矩形区域。 | | top | [Rect](#rect9) | 是 | 否 | 瀑布曲面区域的顶部矩形区域。 | @@ -59,7 +59,7 @@ import display from '@ohos.display'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------------------------- | ------------- | ---- | ---- | ------------------ | | boundingRects | Array\<[Rect](#rect9)> | 是 | 否 | 挖孔、刘海等区域的边界矩形。 | | waterfallDisplayAreaRects | [WaterfallDisplayAreaRects](#waterfalldisplayarearects9) | 是 | 否 | 瀑布屏曲面部分显示区域。 | @@ -94,7 +94,7 @@ try { displayClass = display.getDefaultDisplaySync(); } catch (exception) { console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); -}; +} ``` ## display.getAllDisplays9+ @@ -204,25 +204,24 @@ hasPrivateWindow(displayId: number): boolean let displayClass = null; try { displayClass = display.getDefaultDisplaySync(); -} catch (exception) { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); - return; -}; -let ret = undefined; -try { - ret = display.hasPrivateWindow(displayClass.id); + let ret = undefined; + try { + ret = display.hasPrivateWindow(displayClass.id); + } catch (exception) { + console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); + } + if (ret == undefined) { + console.log("Failed to check has privateWindow or not."); + } + if (ret) { + console.log("There has privateWindow."); + } else if (!ret) { + console.log("There has no privateWindow."); + } } catch (exception) { - console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); -}; -if (ret == undefined) { - console.log("Failed to check has privateWindow or not."); + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); } -if (ret) { - console.log("There has privateWindow."); -} else if (!ret) { - console.log("There has no privateWindow."); -}; ``` ## display.on('add'|'remove'|'change') @@ -250,7 +249,7 @@ try { display.on("add", callback); } catch (exception) { console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); -}; +} ``` ## display.off('add'|'remove'|'change') @@ -275,7 +274,7 @@ try { display.off("remove"); } catch (exception) { console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); -}; +} ``` ## display.getDefaultDisplay(deprecated) @@ -407,7 +406,7 @@ promise.then((data) => { **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | id | number | 是 | 否 | 显示设备的id号。| | name | string | 是 | 否 | 显示设备的名称。| @@ -450,17 +449,17 @@ getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void let displayClass = null; try { displayClass = display.getDefaultDisplaySync(); + + displayClass.getCutoutInfo((err, data) => { + if (err.code) { + console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); + }); } catch (exception) { console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); -}; - -displayClass.getCutoutInfo((err, data) => { - if (err.code) { - console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); -}); +} ``` ### getCutoutInfo9+ getCutoutInfo(): Promise<CutoutInfo> @@ -489,12 +488,14 @@ getCutoutInfo(): Promise<CutoutInfo> let displayClass = null; try { displayClass = display.getDefaultDisplaySync(); + + let promise = displayClass.getCutoutInfo(); + promise.then((data) => { + console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); + }).catch((err) => { + console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); + }); } catch (exception) { console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); -}; - -let promise = displayClass.getCutoutInfo(); -promise.then((data) => { - console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); -}); +} ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md index 7c2082ccad29c30e4f43ebc408e0d95ab0c3b015..8c59f4eed0ea39fb45737975ba5313bab53f411e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @@ -5,14 +5,12 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 - + ```js import account_distributedAccount from '@ohos.account.distributedAccount'; ``` - ## account_distributedAccount.getDistributedAccountAbility getDistributedAccountAbility(): DistributedAccountAbility diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md index 462caa2391b5942034954d8b5645d47260e6dd11..6501cbf3d71da90d07e6db905ff2c3738a7f1751 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-data.md @@ -35,7 +35,7 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | config | [KVManagerConfig](#kvmanagerconfig) | 是 | 提供KVManager实例的配置信息,包括调用方的包名和用户信息。 | | callback | AsyncCallback<[KVManager](#kvmanager)> | 是 | 回调函数。返回创建的KVManager对象实例。 | @@ -75,7 +75,7 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | config |[KVManagerConfig](#kvmanager) | 是 | 提供KVManager实例的配置信息,包括调用方的包名和用户信息。 | @@ -116,10 +116,10 @@ try { **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 参数名 | 参数类型 | 必填 | 说明 | -| ----- | ------ | ------ | ------ | -| userInfo | [UserInfo](#userinfo) | 是 | 调用方的用户信息。 | -| bundleName | string | 是 | 调用方的包名。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ------ | ------ | ------ | +| userInfo | [UserInfo](#userinfo) | 是 | 是 | 调用方的用户信息。 | +| bundleName | string | 是 | 是 | 调用方的包名。 | ## UserInfo @@ -127,10 +127,10 @@ try { **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 | 必填 | 说明 | -| ----- | ------ | ------ | ------ | -| userId | string | 是 | 指示要设置的用户ID。 | -| userType | [UserType](#usertype) | 是 | 指示要设置的用户类型。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ------ | ------ | ------ | +| userId | string | 是 | 是 | 指示要设置的用户ID。 | +| userType | [UserType](#usertype) | 是 | 是 | 指示要设置的用户类型。 | ## UserType @@ -158,7 +158,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options, callback: **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ------ | ------ | | storeId | string | 是 | 数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | options | [Options](#options) | 是 | 创建KVStore实例的配置信息。 | @@ -202,7 +202,7 @@ getKVStore<T extends KVStore>(storeId: string, options: Options): Promise& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ---------------------- | ---- | -------------------- | | storeId | string | 是 | 数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | options | [Options](#options) | 是 | 创建KVStore实例的配置信息。| @@ -250,7 +250,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------- | ---- | --------------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要关闭的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -295,7 +295,7 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要关闭的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -349,7 +349,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -392,7 +392,7 @@ deleteKVStore(appId: string, storeId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -446,7 +446,7 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | callback | AsyncCallback<string[]> | 是 |回调函数。返回所有创建的KvStore数据库的storeId。 | @@ -476,7 +476,7 @@ getAllKVStoreId(appId: string): Promise<string[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | appId | string | 是 | 所调用数据库方的包名。 | @@ -515,7 +515,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event | string | 是 | 订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | | deathCallback | Callback<void> | 是 | 回调函数。 | @@ -546,7 +546,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event | string | 是 | 取消订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | | deathCallback | Callback<void> | 否 | 回调函数。 | @@ -573,15 +573,15 @@ try { 用于提供创建数据库的配置信息。 -| 参数名 | 参数类型 | 必填 | 说明 | -| ----- | ------ | ---- | ----------------------- | -| createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| encrypt | boolean | 否 |设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| backup | boolean | 否 |设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | 否 |设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | -| kvStoreType | [KVStoreType](#kvstoretype) | 否 |设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| securityLevel | [SecurityLevel](#securitylevel) | 否 |设置数据库安全级别,默认不设置安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| schema8+ | [Schema](#schema8) | 否 | 设置定义存储在数据库中的值。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ------ | ------ | -------------------| +| createIfMissing | boolean | 是 | 是 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| encrypt | boolean | 是 | 是 |设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| backup | boolean | 是 | 是 |设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| autoSync | boolean | 是 | 是 |设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | +| kvStoreType | [KVStoreType](#kvstoretype) | 是 | 是 |设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| securityLevel | [SecurityLevel](#securitylevel) | 是 | 是 |设置数据库安全级别,默认不设置安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| schema8+ | [Schema](#schema8) | 是 | 是 | 设置定义存储在数据库中的值。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | ## KVStoreType @@ -631,12 +631,12 @@ KVStore常量。 **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore -| 名称 | 类型 | 说明 | -| --- | ---- | ----------------------- | -| root8+ | [FieldNode](#fieldnode8) | 表示json根对象。 | -| indexes8+ | Array\ | 表示json类型的字符串数组。 | -| mode8+ | number | 表示Schema的模式。 | -| skip8+ | number | Schema的跳跃大小。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --- | ---- | ---- | ---- | ----------------------- | +| root8+ | [FieldNode](#fieldnode8) | 是 | 是 | 表示json根对象。 | +| indexes8+ | Array\ | 是 | 是 | 表示json类型的字符串数组。 | +| mode8+ | number | 是 | 是 | 表示Schema的模式。 | +| skip8+ | number | 是 | 是 | Schema的跳跃大小。 | ### constructor8+ @@ -652,11 +652,11 @@ constructor() **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore -| 名称 | 类型 | 说明 | -| --- | ---- | ----------------------- | -| nullable8+ | boolean | 表示数据库字段是否可以为空。 | -| default8+ | string | 表示Fieldnode的默认值。 | -| type8+ | number | 表示指定节点对应数据类型的值。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --- | ---- | ---- | ---- | ----------------------- | +| nullable8+ | boolean | 是 | 是 | 表示数据库字段是否可以为空。 | +| default8+ | string | 是 | 是 | 表示Fieldnode的默认值。 | +| type8+ | number | 是 | 是 | 表示指定节点对应数据类型的值。 | ### constructor8+ @@ -668,7 +668,7 @@ constructor(name: string) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | --------------- | | name | string | 是 | FieldNode的值。 | @@ -682,7 +682,7 @@ appendChild(child: FieldNode): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | child | [FieldNode](#fieldnode8) | 是 | 要附加的域节点。 | @@ -935,7 +935,7 @@ move(offset: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | offset | number | 是 | 表示与当前位置的相对偏移量,负偏移表示向后移动,正偏移表示向前移动。 | @@ -975,7 +975,7 @@ moveToPosition(position: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | position | number | 是 |表示绝对位置。 | @@ -1230,7 +1230,7 @@ equalTo(field: string, value: number|string|boolean): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1265,7 +1265,7 @@ notEqualTo(field: string, value: number|string|boolean): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1300,7 +1300,7 @@ greaterThan(field: string, value: number|string|boolean): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1335,10 +1335,10 @@ lessThan(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | -| value | number\|string\|boolean | 是 | 表示指定的值。| +| value | number\|string | 是 | 表示指定的值。| **返回值:** @@ -1370,10 +1370,10 @@ greaterThanOrEqualTo(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | -| value | number\|string\|boolean | 是 | 表示指定的值。| +| value | number\|string | 是 | 表示指定的值。| **返回值:** @@ -1405,10 +1405,10 @@ lessThanOrEqualTo(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | -| value | number\|string\|boolean | 是 | 表示指定的值。| +| value | number\|string | 是 | 表示指定的值。| **返回值:** @@ -1440,7 +1440,7 @@ isNull(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | @@ -1475,7 +1475,7 @@ inNumber(field: string, valueList: number[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| @@ -1510,7 +1510,7 @@ inString(field: string, valueList: string[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| @@ -1545,7 +1545,7 @@ notInNumber(field: string, valueList: number[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。| @@ -1580,7 +1580,7 @@ notInString(field: string, valueList: string[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。| @@ -1615,7 +1615,7 @@ like(field: string, value: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | string | 是 | 表示指定的字符串值。| @@ -1650,7 +1650,7 @@ unlike(field: string, value: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | string | 是 | 表示指定的字符串值。| @@ -1745,7 +1745,7 @@ orderByAsc(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | @@ -1780,7 +1780,7 @@ orderByDesc(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | @@ -1815,7 +1815,7 @@ limit(total: number, offset: number): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | total | number | 是 |表示指定的结果数。 | | offset | number | 是 |表示起始位置。 | @@ -1853,7 +1853,7 @@ isNotNull(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | @@ -1947,7 +1947,7 @@ prefixKey(prefix: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | prefix | string | 是 |表示指定的键前缀。 | @@ -1982,7 +1982,7 @@ setSuggestIndex(index: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | index | string | 是 |指示要设置的索引。 | @@ -2017,7 +2017,7 @@ deviceId(deviceId:string):Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId | string | 是 |指示查询的设备ID。 | @@ -2084,7 +2084,7 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | @@ -2119,7 +2119,7 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | @@ -2157,7 +2157,7 @@ delete(key: string, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 |回调函数。 | @@ -2198,7 +2198,7 @@ delete(key: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -2240,7 +2240,7 @@ on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotific **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |订阅的事件名,固定为'dataChange',表示数据变更事件。 | | type |[SubscribeType](#subscribetype) | 是 |表示订阅的类型。 | @@ -2265,7 +2265,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 是 |回调函数。 | @@ -2289,7 +2289,7 @@ off(event:'dataChange', listener?: Callback<ChangeNotification>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |取消订阅的事件名,固定为'dataChange',表示数据变更事件。 | | listener |Callback<[ChangeNotification](#changenotification)> |否 |回调函数。 | @@ -2325,7 +2325,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | | callback |Asyncallback<void> |是 |回调函数。 | @@ -2372,7 +2372,7 @@ putBatch(entries: Entry[]): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | entries |[Entry](#entry)[] | 是 |表示要批量插入的键值对。 | @@ -2426,7 +2426,7 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keys |string[] | 是 |表示要批量删除的键值对。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -2473,7 +2473,7 @@ deleteBatch(keys: string[]): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keys |string[] | 是 |表示要批量删除的键值对。 | @@ -2529,7 +2529,7 @@ startTransaction(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -2616,7 +2616,7 @@ commit(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -2678,7 +2678,7 @@ rollback(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -2740,7 +2740,7 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | 是 |设定是否开启同步,true表示开启同步,false表示不启用同步。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -2773,7 +2773,7 @@ enableSync(enabled: boolean): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | enabled |boolean | 是 |设定是否开启同步,true表示开启同步,false表示不启用同步。 | @@ -2809,7 +2809,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | localLabels |string[] | 是 |表示本地设备的同步标签。 | | remoteSupportLabels |string[] | 是 |表示要同步数据的设备的同步标签。 | @@ -2841,7 +2841,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | localLabels |string[] | 是 |表示本地设备的同步标签。 | | remoteSupportLabels |string[] | 是 |表示要同步数据的设备的同步标签。 | @@ -2889,7 +2889,7 @@ try { **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 |可读 |可写 | 说明 | +| 名称 | 类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | | insertEntries | [Entry](#entry)[] | 是 | 是 |数据添加记录。 | | updateEntries | [Entry](#entry)[] | 是 | 是 |数据更新记录。 | @@ -2902,7 +2902,7 @@ try { **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 |可读 |可写 | 说明 | +| 名称 | 类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | | key | string | 是 | 是 |键值。 | | value | [Value](#value) | 是 | 是 |值对象。 | @@ -2914,7 +2914,7 @@ try { **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 |可读 |可写 | 说明 | +| 名称 | 类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | | type | [ValueType](#value) | 是 | 是 |值类型。 | | value | Uint8Array \| string \| number \| boolean| 是 | 是 |值。 | @@ -2952,7 +2952,7 @@ get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | numb **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | 是 |回调函数。返回获取查询的值。 | @@ -2990,7 +2990,7 @@ get(key: string): Promise<Uint8Array | string | boolean | number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -3033,7 +3033,7 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数。返回匹配指定前缀的键值对列表。 | @@ -3079,7 +3079,7 @@ getEntries(keyPrefix: string): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -3137,7 +3137,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数。返回与指定Query对象匹配的键值对列表。 | @@ -3188,7 +3188,7 @@ getEntries(query: Query): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -3246,7 +3246,7 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数。返回具有指定前缀的结果集。 | @@ -3295,7 +3295,7 @@ getResultSet(keyPrefix: string): Promise<KvStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -3355,7 +3355,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |Query | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)> | 是 |回调函数,获取与指定Query对象匹配的KvStoreResultSet对象。 | @@ -3403,7 +3403,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -3459,7 +3459,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的KvStoreResultSet对象。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -3493,7 +3493,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#kvstoreresultset8) | 是 |表示要关闭的KvStoreResultSet对象。 | @@ -3530,7 +3530,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数。返回与指定Query对象匹配的结果数。 | @@ -3576,7 +3576,7 @@ getResultSize(query: Query): Promise<number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -3631,7 +3631,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |表示要删除设备的名称。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -3673,7 +3673,7 @@ removeDeviceData(deviceId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |表示要删除设备的名称。 | @@ -3722,7 +3722,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 是 |回调函数。用于向调用方发送同步结果的回调。 | @@ -3758,7 +3758,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |取消订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback<Array<[string, number]>> | 否 |回调函数。用于向调用方发送同步结果的回调。 | @@ -3797,7 +3797,7 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceIds |string[] | 是 |同一组网环境下,需要同步的设备的deviceId列表。 | | mode |[SyncMode](#syncmode) | 是 |同步模式。 | @@ -3820,7 +3820,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -3850,7 +3850,7 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | defaultAllowedDelayMs |number | 是 |表示数据库同步允许的默认延迟,以毫秒为单位。 | @@ -3888,7 +3888,7 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | callback |AsyncCallback<[SecurityLevel](#securitylevel)> | 是 |回调函数。返回数据库的安全级别。 | @@ -3956,7 +3956,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | key |string | 是 |表示要查询key值的键。 | @@ -3991,7 +3991,7 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | key |string | 是 |表示要查询key值的键。 | @@ -4035,7 +4035,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -4083,7 +4083,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -4142,7 +4142,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[Entry](#entry)[]> | 是 |回调函数,返回与指定Query对象匹配的键值对列表。 | @@ -4194,7 +4194,7 @@ getEntries(query: Query): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4252,7 +4252,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |键值对所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4305,7 +4305,7 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |键值对所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4365,7 +4365,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvS **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -4400,7 +4400,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet&g **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | keyPrefix |string | 是 |表示要匹配的键前缀。 | @@ -4444,7 +4444,7 @@ getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): voi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultset8)[]> | 是 |回调函数,返回与指定Query对象匹配的KvStoreResultSet对象。 | @@ -4496,7 +4496,7 @@ getResultSet(query: Query): Promise<KvStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4560,7 +4560,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreR **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4612,7 +4612,7 @@ getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4678,7 +4678,7 @@ closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的KvStoreResultSet对象。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -4713,7 +4713,7 @@ closeResultSet(resultSet: KvStoreResultSet): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | resultSet |[KvStoreResultSet](#getresultset8) | 是 |指示要关闭的KvStoreResultSet对象。 | @@ -4751,7 +4751,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | | callback |AsyncCallback<number> | 是 |回调函数,返回与指定Query对象匹配的结果数。 | @@ -4798,7 +4798,7 @@ getResultSize(query: Query): Promise<number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4854,7 +4854,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4901,7 +4901,7 @@ getResultSize(deviceId: string, query: Query): Promise<number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |KvStoreResultSet对象所属的设备ID。 | | query |[Query](#query8) | 是 |表示查询对象。 | @@ -4957,7 +4957,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要删除其数据的设备。 | | callback |AsyncCallback<void> | 是 |回调函数。 | @@ -4999,7 +4999,7 @@ removeDeviceData(deviceId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要删除其数据的设备。 | @@ -5050,7 +5050,7 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceIds |string[] | 是 |需要同步DeviceKvStore数据库的设备ID列表。 | | mode |[SyncMode](#syncmode) | 是 |同步模式。 | @@ -5087,7 +5087,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback | 是 |回调函数。用于向调用方发送同步结果的回调。 | @@ -5123,7 +5123,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | event |string | 是 |取消订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback |Callback | 是 | 回调函数,操作成功返回err为null,data为RemoteAbilityInfo对象;否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -94,7 +94,7 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | -------------------------------------------- | ---- | ----------------------- | | elementName | [ElementName](js-apis-bundleManager-elementName.md) | 是 | ElementName信息。 | @@ -106,9 +106,9 @@ getRemoteAbilityInfo(elementName: ElementName): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -151,16 +151,16 @@ getRemoteAbilityInfo(elementNames: Array\, callback: AsyncCallback\ **参数:** -| 名称 | 类型 | 必填 | 描述 | -| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | -| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 | | callback | AsyncCallback\> | 是 | 回调函数,调用成功返回err为null,data为RemoteAbilityInfo数组对象;否则返回错误对象。 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -212,7 +212,7 @@ getRemoteAbilityInfo(elementNames: Array\): Promise\ | 是 | ElementName信息,最大数组长度为10。 | @@ -224,9 +224,9 @@ getRemoteAbilityInfo(elementNames: Array\): Promise\, locale: string, callback **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10 | | locale | string |是 | 语言地区 | @@ -397,9 +397,9 @@ getRemoteAbilityInfo(elementNames: Array\, locale: string, callback **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -451,7 +451,7 @@ getRemoteAbilityInfo(elementNames: Array\, locale: string): Promise **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | --------------------------------------------------- | ---- | ----------------------- | | elementNames | Array<[ElementName](js-apis-bundleManager-elementName.md)> | 是 | ElementName信息,最大数组长度为10。 | | locale | string |是 | 语言地区 | @@ -464,9 +464,9 @@ getRemoteAbilityInfo(elementNames: Array\, locale: string): Promise **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md index a1fd2b59fb7a2a13f0315cf9d46d567544158bfb..bec88516f18b34a540732e0226186a56a7dc4bb4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -26,10 +26,10 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 参数名 | 参数类型 | 必填 | 说明 | -| ---------- | --------------------- | ---- | ------------------------------------------------------------ | -| context | Context | 是 | 应用的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | -| bundleName | string | 是 | 调用方的包名。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------- | --------------------- | ---- | ---- | ------------------------------------------------------------ | +| context | Context | 是 | 是 |应用的上下文。
FA模型的应用Context定义见[Context](js-apis-Context.md)。
Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 | +| bundleName | string | 是 | 是 | 调用方的包名。 | ## Constants @@ -67,7 +67,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 |可读 |可写 | 说明 | +| 名称 | 类型 |可读 |可写 | 说明 | | ----- | ------- | -----| ------|------------------------ | | type | [ValueType](#valuetype) | 是 | 是 |值类型。 | | value | Uint8Array \| string \| number \| boolean| 是 | 是 |值。 | @@ -78,7 +78,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----- | --------------- | ---- | ---- | -------- | | key | string | 是 | 是 | 键值。 | | value | [Value](#value) | 是 | 是 | 值对象。 | @@ -89,7 +89,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------- | ----------------- | ---- | ---- | ------------------------ | | insertEntries | [Entry](#entry)[] | 是 | 是 | 数据添加记录。 | | updateEntries | [Entry](#entry)[] | 是 | 是 | 数据更新记录。 | @@ -146,15 +146,15 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; 用于提供创建数据库的配置信息。 -| 参数名 | 参数类型 | 必填 | 说明 | -| --------------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| createIfMissing | boolean | 否 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| encrypt | boolean | 否 | 设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| backup | boolean | 否 | 设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| autoSync | boolean | 否 | 设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | -| kvStoreType | [KVStoreType](#kvstoretype) | 否 | 设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| securityLevel | [SecurityLevel](#securitylevel) | 是 | 设置数据库安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | -| schema | [Schema](#schema) | 否 | 设置定义存储在数据库中的值,默认不使用Schema。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------- | ------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| createIfMissing | boolean | 是 | 是 | 当数据库文件不存在时是否创建数据库,默认创建。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| encrypt | boolean | 是 | 是 | 设置数据库文件是否加密,默认不加密。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| backup | boolean | 是 | 是 | 设置数据库文件是否备份,默认备份。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| autoSync | boolean | 是 | 是 | 设置数据库文件是否自动同步,默认不自动同步。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core
**需要权限**: ohos.permission.DISTRIBUTED_DATASYNC | +| kvStoreType | [KVStoreType](#kvstoretype) | 是 | 是 | 设置要创建的数据库类型,默认为多设备协同数据库。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| securityLevel | [SecurityLevel](#securitylevel) | 是 | 是 |设置数据库安全级别。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.Core | +| schema | [Schema](#schema) | 是 | 是 | 设置定义存储在数据库中的值,默认不使用Schema。
**系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | ## Schema @@ -162,12 +162,12 @@ import distributedKVStore from '@ohos.data.distributedKVStore'; **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore -| 名称 | 类型 | 说明 | -| ------- | ----------------------- | -------------------------- | -| root | [FieldNode](#fieldnode) | 表示json根对象。 | -| indexes | Array\ | 表示json类型的字符串数组。 | -| mode | number | 表示Schema的模式。 | -| skip | number | Schema的跳跃大小。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ----------------------- | ---- | ---- | -------------------------- | +| root | [FieldNode](#fieldnode) | 是 | 是 | 表示json根对象。 | +| indexes | Array\ | 是 | 是 | 表示json类型的字符串数组。 | +| mode | number | 是 | 是 | 表示Schema的模式。 | +| skip | number | 是 | 是 | Schema的跳跃大小。 | ### constructor @@ -183,11 +183,11 @@ constructor() **系统能力:** SystemCapability.DistributedDataManager.KVStore.DistributedKVStore -| 名称 | 类型 | 说明 | -| -------- | ------- | ------------------------------ | -| nullable | boolean | 表示数据库字段是否可以为空。 | -| default | string | 表示Fieldnode的默认值。 | -| type | number | 表示指定节点对应数据类型的值。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------- | ---- | ---- | ------------------------------ | +| nullable | boolean | 是 | 是 | 表示数据库字段是否可以为空。 | +| default | string | 是 | 是 | 表示Fieldnode的默认值。 | +| type | number | 是 | 是 | 表示指定节点对应数据类型的值。 | ### constructor @@ -199,7 +199,7 @@ constructor(name: string) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | --------------- | | name | string | 是 | FieldNode的值。 | @@ -213,7 +213,7 @@ appendChild(child: FieldNode): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------- | ---- | ---------------- | | child | [FieldNode](#fieldnode) | 是 | 要附加的域节点。 | @@ -256,7 +256,7 @@ createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ----------------------------------------------------------- | | config | [KVManagerConfig](#kvmanagerconfig) | 是 | 提供KVManager实例的配置信息,包括调用方的包名和应用上下文。 | | callback | AsyncCallback<[KVManager](#kvmanager)> | 是 | 回调函数。返回创建的KVManager对象实例。 | @@ -326,7 +326,7 @@ createKVManager(config: KVManagerConfig): Promise<KVManager> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------- | ---- | --------------------------------------------------------- | | config | [KVManagerConfig](#kvmanager) | 是 | 提供KVManager实例的配置信息,包括调用方的包名和用户信息。 | @@ -401,7 +401,7 @@ getKVStore<T >(storeId: string, options: Options, callback: AsyncCallback& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | storeId | string | 是 | 数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | options | [Options](#options) | 是 | 创建分布式键值实例的配置信息。 | @@ -453,7 +453,7 @@ getKVStore<T >(storeId: string, options: Options): Promise<T> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | storeId | string | 是 | 数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | | options | [Options](#options) | 是 | 创建分布式键值实例的配置信息。 | @@ -508,7 +508,7 @@ closeKVStore(appId: string, storeId: string, callback: AsyncCallback<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要关闭的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -541,7 +541,7 @@ try { }); }); } catch (e) { - console.error(`An unexpected error occurred.code is ${err.code},message is ${err.message}`); + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -555,7 +555,7 @@ closeKVStore(appId: string, storeId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | -------- | ---- | ------------------------------------------------------------ | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要关闭的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -607,7 +607,7 @@ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -666,7 +666,7 @@ deleteKVStore(appId: string, storeId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | -------- | ---- | ------------------------------------------------------------ | | appId | string | 是 | 所调用数据库方的包名。 | | storeId | string | 是 | 要删除的数据库唯一标识符,长度不大于[MAX_STORE_ID_LENGTH](#constants)。 | @@ -726,7 +726,7 @@ getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------- | ---- | --------------------------------------------------- | | appId | string | 是 | 所调用数据库方的包名。 | | callback | AsyncCallback<string[]> | 是 | 回调函数。返回所有创建的分布式键值数据库的storeId。 | @@ -738,7 +738,7 @@ let kvManager; try { kvManager.getAllKVStoreId('appId', function (err, data) { if (err != undefined) { - console.error(`Fail to get AllKVStoreId.code is ${e.code},message is ${e.message}`); + console.error(`Fail to get AllKVStoreId.code is ${err.code},message is ${err.message}`); return; } console.log('Succeeded in getting AllKVStoreId'); @@ -759,7 +759,7 @@ getAllKVStoreId(appId: string): Promise<string[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ---------------------- | | appId | string | 是 | 所调用数据库方的包名。 | @@ -796,7 +796,7 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): voi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------- | -------------------- | ---- | ------------------------------------------------------------ | | event | string | 是 | 订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | | deathCallback | Callback<void> | 是 | 回调函数。 | @@ -826,7 +826,7 @@ off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): v **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------- | -------------------- | ---- | ------------------------------------------------------------ | | event | string | 是 | 取消订阅的事件名,固定为'distributedDataServiceDie',即服务状态变更事件。 | | deathCallback | Callback<void> | 否 | 回调函数。 | @@ -1060,7 +1060,7 @@ move(offset: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | offset | number | 是 | 表示与当前位置的相对偏移量,负偏移表示向后移动,正偏移表示向前移动。 | @@ -1099,7 +1099,7 @@ moveToPosition(position: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | -------------- | | position | number | 是 | 表示绝对位置。 | @@ -1346,7 +1346,7 @@ equalTo(field: string, value: number|string|boolean): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1380,7 +1380,7 @@ notEqualTo(field: string, value: number|string|boolean): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1413,7 +1413,7 @@ greaterThan(field: string, value: number|string|boolean): Query **系统能力:** SystemCapability.DistributedDataManager.KVStore.Core **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string\|boolean | 是 | 表示指定的值。| @@ -1448,7 +1448,7 @@ lessThan(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string | 是 | 表示指定的值。| @@ -1483,7 +1483,7 @@ greaterThanOrEqualTo(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string | 是 | 表示指定的值。| @@ -1518,7 +1518,7 @@ lessThanOrEqualTo(field: string, value: number|string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | fieId | string | 是 |表示指定字段,不能包含' ^ '。 | | value | number\|string | 是 | 表示指定的值。| @@ -1552,7 +1552,7 @@ isNull(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | @@ -1585,7 +1585,7 @@ inNumber(field: string, valueList: number[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。 | @@ -1619,7 +1619,7 @@ inString(field: string, valueList: string[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。 | @@ -1653,7 +1653,7 @@ notInNumber(field: string, valueList: number[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | valueList | number[] | 是 | 表示指定的值列表。 | @@ -1687,7 +1687,7 @@ notInString(field: string, valueList: string[]): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | valueList | string[] | 是 | 表示指定的字符串值列表。 | @@ -1721,7 +1721,7 @@ like(field: string, value: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | value | string | 是 | 表示指定的字符串值。 | @@ -1755,7 +1755,7 @@ unlike(field: string, value: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | | value | string | 是 | 表示指定的字符串值。 | @@ -1847,7 +1847,7 @@ orderByAsc(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | @@ -1881,7 +1881,7 @@ orderByDesc(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | @@ -1915,7 +1915,7 @@ limit(total: number, offset: number): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------ | | total | number | 是 | 表示指定的结果数。 | | offset | number | 是 | 表示起始位置。 | @@ -1952,7 +1952,7 @@ isNotNull(field: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ----------------------------- | | fieId | string | 是 | 表示指定字段,不能包含' ^ '。 | @@ -2043,7 +2043,7 @@ prefixKey(prefix: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------ | | prefix | string | 是 | 表示指定的键前缀。 | @@ -2077,7 +2077,7 @@ setSuggestIndex(index: string): Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------ | | index | string | 是 | 指示要设置的索引。 | @@ -2111,7 +2111,7 @@ deviceId(deviceId:string):Query **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ------------------ | | deviceId | string | 是 | 指示查询的设备ID。 | @@ -2175,7 +2175,7 @@ put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncC **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | @@ -2219,7 +2219,7 @@ put(key: string, value: Uint8Array | string | number | boolean): Promise<void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key | string | 是 |要添加数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | value | Uint8Array \| string \| number \| boolean | 是 |要添加数据的value,支持Uint8Array、number 、 string 、boolean,Uint8Array、string 的长度不大于[MAX_VALUE_LENGTH](#constants)。 | @@ -2266,7 +2266,7 @@ putBatch(entries: Entry[], callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------ | ---- | ------------------------ | | entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。 | | callback | Asyncallback<void> | 是 | 回调函数。 | @@ -2328,7 +2328,7 @@ putBatch(entries: Entry[]): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ----------------- | ---- | ------------------------ | | entries | [Entry](#entry)[] | 是 | 表示要批量插入的键值对。 | @@ -2393,7 +2393,7 @@ putBatch(value: Array<ValuesBucket>, callback: AsyncCallback<void>): **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------ | | value | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 表示要插入的数据。 | | callback | Asyncallback<void> | 是 | 回调函数。 | @@ -2445,7 +2445,7 @@ putBatch(value: Array<ValuesBucket>): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------------------------------------------ | ---- | ------------------ | | value | Array<[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)> | 是 | 表示要插入的数据。 | @@ -2498,7 +2498,7 @@ delete(key: string, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | key | string | 是 | 要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -2535,7 +2535,7 @@ try { }); }); } catch (e) { - console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`; + console.error(`An unexpected error occurred.code is ${e.code},message is ${e.message}`); } ``` @@ -2549,7 +2549,7 @@ delete(key: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | key | string | 是 | 要删除数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -2603,7 +2603,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallb **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -2649,7 +2649,7 @@ delete(predicates: dataSharePredicates.DataSharePredicates): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | @@ -2704,7 +2704,7 @@ deleteBatch(keys: string[], callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------ | | keys | string[] | 是 | 表示要批量删除的键值对。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -2768,7 +2768,7 @@ deleteBatch(keys: string[]): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------ | | keys | string[] | 是 | 表示要批量删除的键值对。 | @@ -2833,7 +2833,7 @@ removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------- | | deviceId | string | 是 | 表示要删除设备的名称。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -2882,7 +2882,7 @@ removeDeviceData(deviceId: string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ---------------------- | | deviceId | string | 是 | 表示要删除设备的名称。 | @@ -2938,10 +2938,10 @@ get(key: string, callback: AsyncCallback) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | key |string | 是 |要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | -| callback |AsyncCallback<Uint8Array \| string \| boolean \| number>) | 是 |回调函数。返回获取查询的值。 | +| callback |AsyncCallback<boolean \| string \| number \| Uint8Array>) | 是 |回调函数。返回获取查询的值。 | **错误码:** @@ -2989,7 +2989,7 @@ get(key: string): Promise<boolean | string| number | Uint8Array> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | key | string | 是 | 要查询数据的key,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -3041,7 +3041,7 @@ getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------------------------------------- | ---- | ---------------------------------------- | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | | callback | AsyncCallback<[Entry](#entry)[]> | 是 | 回调函数。返回匹配指定前缀的键值对列表。 | @@ -3104,7 +3104,7 @@ getEntries(keyPrefix: string): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | -------------------- | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -3167,7 +3167,7 @@ getEntries(query: Query, callback: AsyncCallback<Entry[]>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ----------------------------------------------- | | query | [Query](query) | 是 | 表示要匹配的键前缀。 | | callback | AsyncCallback<[Entry](#entry)[]> | 是 | 回调函数。返回与指定Query对象匹配的键值对列表。 | @@ -3230,7 +3230,7 @@ getEntries(query: Query): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | -------------- | | query | [Query](query) | 是 | 表示查询对象。 | @@ -3297,7 +3297,7 @@ getResultSet(keyPrefix: string, callback: AsyncCallback<KVStoreResultSet>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ---------------------------------------------------------- | ---- | ------------------------------------ | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | | callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数。返回具有指定前缀的结果集。 | @@ -3366,7 +3366,7 @@ getResultSet(keyPrefix: string): Promise<KVStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | -------------------- | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -3434,7 +3434,7 @@ getResultSet(query: Query, callback: AsyncCallback<KVStoreResultSet>): voi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------------- | ---- | --------------------------------------------------------- | | query | Query | 是 | 表示查询对象。 | | callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数,获取与指定Query对象匹配的KVStoreResultSet对象。 | @@ -3497,7 +3497,7 @@ getResultSet(query: Query): Promise<KVStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | -------------- | | query | [Query](query) | 是 | 表示查询对象。 | @@ -3564,7 +3564,7 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: Asyn **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | | callback | AsyncCallback<[KVStoreResultSet](#kvstoreresultset)> | 是 | 回调函数,获取与指定Predicates对象匹配的KVStoreResultSet对象。 | @@ -3620,7 +3620,7 @@ getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise<KV **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | @@ -3675,7 +3675,7 @@ closeResultSet(resultSet: KVStoreResultSet, callback: AsyncCallback<void>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------------- | ---- | ---------------------------------- | | resultSet | [KVStoreResultSet](#kvstoreresultset) | 是 | 表示要关闭的KVStoreResultSet对象。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -3708,7 +3708,7 @@ closeResultSet(resultSet: KVStoreResultSet): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------------- | ---- | ---------------------------------- | | resultSet | [KVStoreResultSet](#kvstoreresultset) | 是 | 表示要关闭的KVStoreResultSet对象。 | @@ -3744,7 +3744,7 @@ getResultSize(query: Query, callback: AsyncCallback<number>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------------- | | query | [Query](query) | 是 | 表示查询对象。 | | callback | AsyncCallback<number> | 是 | 回调函数。返回与指定Query对象匹配的结果数。 | @@ -3802,7 +3802,7 @@ getResultSize(query: Query): Promise<number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------------- | ---- | -------------- | | query | [Query](query) | 是 | 表示查询对象。 | @@ -3865,7 +3865,7 @@ backup(file:string, callback: AsyncCallback<void>):void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | file | string | 是 | 备份数据库的指定名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 | 回调函数。当以指定名称备份数据库成功,err为undefined,否则为错误对象。 | @@ -3907,7 +3907,7 @@ backup(file:string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | file | string | 是 | 备份数据库的指定名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -3952,7 +3952,7 @@ restore(file:string, callback: AsyncCallback<void>):void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------------------------------ | | file | string | 是 | 指定的数据库文件名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<void> | 是 | 回调函数。当从指定的数据库文件恢复数据库成功,err为undefined,否则为错误对象。 | @@ -3994,7 +3994,7 @@ restore(file:string): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | file | string | 是 | 指定的数据库文件名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -4039,7 +4039,7 @@ deleteBackup(files:Array<string>, callback: AsyncCallback<Array<[str **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | | files | Array<string> | 是 | 删除备份文件所指定的名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | | callback | AsyncCallback<Array<[string, number]>> | 是 | 回调函数,返回删除备份的文件名及其处理结果。 | @@ -4072,7 +4072,7 @@ deleteBackup(files:Array<string>): Promise<Array<[string, number]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------- | ---- | ------------------------------------------------------------ | | files | Array<string> | 是 | 删除备份文件所指定的名称,不能为空且长度不大于[MAX_KEY_LENGTH](#constants)。 | @@ -4108,7 +4108,7 @@ startTransaction(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -4147,7 +4147,7 @@ try { }); kvStore.startTransaction(async function (err, data) { if (err != undefined) { - console.error(`Fail to start Transaction.code is ${e.code},message is ${e.message}`); + console.error(`Fail to start Transaction.code is ${err.code},message is ${err.message}`); return; } console.log('Succeeded in starting Transaction'); @@ -4155,7 +4155,7 @@ try { console.log(`entries: ${entries}`); kvStore.putBatch(entries, async function (err, data) { if (err != undefined) { - console.error(`Fail to put batch.code is ${e.code},message is ${e.message}`); + console.error(`Fail to put batch.code is ${err.code},message is ${err.message}`); return; } console.log('Succeeded in putting Batch'); @@ -4218,7 +4218,7 @@ commit(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -4294,7 +4294,7 @@ rollback(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -4370,7 +4370,7 @@ enableSync(enabled: boolean, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | --------------------------------------------------------- | | enabled | boolean | 是 | 设定是否开启同步,true表示开启同步,false表示不启用同步。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -4402,7 +4402,7 @@ enableSync(enabled: boolean): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | -------- | ---- | --------------------------------------------------------- | | enabled | boolean | 是 | 设定是否开启同步,true表示开启同步,false表示不启用同步。 | @@ -4437,7 +4437,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: Asy **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------------- | ------------------------- | ---- | -------------------------------- | | localLabels | string[] | 是 | 表示本地设备的同步标签。 | | remoteSupportLabels | string[] | 是 | 表示要同步数据的设备的同步标签。 | @@ -4472,7 +4472,7 @@ setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<v **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------------- | -------- | ---- | -------------------------------- | | localLabels | string[] | 是 | 表示本地设备的同步标签。 | | remoteSupportLabels | string[] | 是 | 表示要同步数据的设备的同步标签。 | @@ -4510,7 +4510,7 @@ setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------------------- | ------------------------- | ---- | -------------------------------------------- | | defaultAllowedDelayMs | number | 是 | 表示数据库同步允许的默认延迟,以毫秒为单位。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -4543,7 +4543,7 @@ setSyncParam(defaultAllowedDelayMs: number): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------------------- | -------- | ---- | -------------------------------------------- | | defaultAllowedDelayMs | number | 是 | 表示数据库同步允许的默认延迟,以毫秒为单位。 | @@ -4581,7 +4581,7 @@ sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------------------------- | | deviceIds | string[] | 是 | 同一组网环境下,需要同步的设备的deviceId列表。 | | mode | [SyncMode](#syncmode) | 是 | 同步模式。 | @@ -4619,7 +4619,7 @@ sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | --------------------- | ---- | ---------------------------------------------- | | deviceIds | string[] | 是 | 同一组网环境下,需要同步的设备的deviceId列表。 | | mode | [SyncMode](#syncmode) | 是 | 同步模式。 | @@ -4673,7 +4673,7 @@ on(event: 'dataChange', type: SubscribeType, listener: Callback<ChangeNotific **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ---------------------------------------------------- | | event | string | 是 | 订阅的事件名,固定为'dataChange',表示数据变更事件。 | | type | [SubscribeType](#subscribetype) | 是 | 表示订阅的类型。 | @@ -4711,7 +4711,7 @@ on(event: 'syncComplete', syncCallback: Callback<Array<[string, number]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | --------------------------------------------- | ---- | ------------------------------------------------------ | | event | string | 是 | 订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback | Callback<Array<[string, number]>> | 是 | 回调函数。用于向调用方发送同步结果的回调。 | @@ -4746,7 +4746,7 @@ off(event:'dataChange', listener?: Callback<ChangeNotification>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- | | event | string | 是 | 取消订阅的事件名,固定为'dataChange',表示数据变更事件。 | | listener | Callback<[ChangeNotification](#changenotification)> | 否 | 回调函数。 | @@ -4800,7 +4800,7 @@ off(event: 'syncComplete', syncCallback?: Callback<Array<[string, number]& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | --------------------------------------------- | ---- | ---------------------------------------------------------- | | event | string | 是 | 取消订阅的事件名,固定为'syncComplete',表示同步完成事件。 | | syncCallback | Callback<Array<[string, number]>> | 否 | 回调函数。用于向调用方发送同步结果的回调。 | @@ -4846,7 +4846,7 @@ getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------------------- | ---- | -------------------------------- | | callback | AsyncCallback<[SecurityLevel](#securitylevel)> | 是 | 回调函数。返回数据库的安全级别。 | @@ -4932,7 +4932,7 @@ get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|num **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------- | | deviceId |string | 是 |标识要查询其数据的设备。 | | key |string | 是 |表示要查询key值的键。 | @@ -4984,7 +4984,7 @@ get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | key | string | 是 | 表示要查询key值的键。 | @@ -5020,7 +5020,7 @@ try { console.error(`Fail to get.code is ${err.code},message is ${err.message}`); }); }).catch((error) => { - console.error(`Fail to put.code is ${err.code},message is ${err.message}`); + console.error(`Fail to put.code is ${error.code},message is ${error.message}`); }); } catch (e) { console.error(`Fail to get.code is ${e.code},message is ${e.message}`); @@ -5037,7 +5037,7 @@ getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------------------------------------- | ---- | ---------------------------------------------- | | deviceId | string | 是 | 标识要查询其数据的设备。 | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -5101,7 +5101,7 @@ getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -5168,7 +5168,7 @@ getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | ------------------------------------------------------- | | deviceId | string | 是 | 键值对所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | @@ -5238,7 +5238,7 @@ getEntries(deviceId: string, query: Query): Promise<Entry[]> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | -------------------- | | deviceId | string | 是 | 键值对所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | @@ -5293,7 +5293,7 @@ try { }); console.log('Succeeded in getting entries'); } catch (e) { - console.error(`Fail to get entries.code is ${err.code},message is ${err.message}`); + console.error(`Fail to get entries.code is ${e.code},message is ${e.message}`); } ``` @@ -5307,7 +5307,7 @@ getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KVS **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -5358,7 +5358,7 @@ getResultSet(deviceId: string, keyPrefix: string): Promise<KVStoreResultSet&g **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | --------- | -------- | ---- | ------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | keyPrefix | string | 是 | 表示要匹配的键前缀。 | @@ -5410,7 +5410,7 @@ getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KVStoreR **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | @@ -5482,7 +5482,7 @@ getResultSet(deviceId: string, query: Query): Promise<KVStoreResultSet> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------- | | deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | @@ -5558,7 +5558,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | deviceId | string | 是 | 标识要查询其数据的设备。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | @@ -5615,7 +5615,7 @@ getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicat **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | | deviceId | string | 是 | 标识要查询其数据的设备。 | | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | 是 | 指示筛选条件,当此参数为null时,应定义处理逻辑。 | @@ -5670,7 +5670,7 @@ getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number& **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------------------------------------------- | | deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | @@ -5734,7 +5734,7 @@ getResultSize(deviceId: string, query: Query): Promise<number> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------- | ---- | ---------------------------------- | | deviceId | string | 是 | KVStoreResultSet对象所属的设备ID。 | | query | [Query](query) | 是 | 表示查询对象。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md index 7231f0e6ed98c792dfdc695ae7fbad2bb86e07a4..37e09247632690faf9128bcbfc2cc558dd897427 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -43,7 +43,6 @@ createEffect(source: image.PixelMap): Filter import image from "@ohos.multimedia.image"; const color = new ArrayBuffer(96); -let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts).then((pixelMap) => { let headFilter = effectKit.createEffect(pixelMap); @@ -76,7 +75,6 @@ createColorPicker(source: image.PixelMap): Promise\ import image from "@ohos.multimedia.image"; const color = new ArrayBuffer(96); -let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts).then((pixelMap) => { effectKit.createColorPicker(pixelMap).then(colorPicker => { @@ -106,7 +104,6 @@ createColorPicker(source: image.PixelMap, callback: AsyncCallback\) import image from "@ohos.multimedia.image"; const color = new ArrayBuffer(96); -let bufferArr = new Uint8Array(color); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts).then((pixelMap) => { effectKit.createColorPicker(pixelMap, (error, colorPicker) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 6b86a4f7826a6b00b69b241a3ccfdb261488d7b6..c8ce2f7ab0ef05b63ab5739e411886bd7482acb9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -35,7 +35,7 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | --------------------------------------------------------------- | @@ -87,7 +87,7 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | --------------------------------------------------------------- | @@ -144,7 +144,7 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | --------------------------------------------------------------- | @@ -190,7 +190,7 @@ disableAdmin(admin: Want, callback: AsyncCallback\): void **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -234,7 +234,7 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\): void **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -283,7 +283,7 @@ disableAdmin(admin: Want, userId?: number): Promise\ **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -322,7 +322,7 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\): void **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -367,7 +367,7 @@ disableSuperAdmin(bundleName: String): Promise\ **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -401,7 +401,7 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\): void **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------------------- | @@ -573,7 +573,7 @@ getDeviceSettingsManager(callback: AsyncCallback<DeviceSettingsManager>): **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ---------------------------------------------------------------------------- | @@ -616,7 +616,7 @@ getDeviceSettingsManager(): Promise<DeviceSettingsManager> **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ---------------------------------------------------------------------------- | @@ -661,7 +661,7 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------- | @@ -714,7 +714,7 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\; **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------- | @@ -755,7 +755,7 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): v **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------- | @@ -802,7 +802,7 @@ getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ----------------------------------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md index e2629ee19d504edbfedc91525641bd4ec0487fcf..ef00fbbcea9afc1bd9223fe0900b271b61c7b303 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterpriseDeviceManager-DeviceSettingsManager.md @@ -44,7 +44,7 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\): void **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ---------------------------------------------------------------------------- | @@ -100,7 +100,7 @@ setDateTime(admin: Want, time: number): Promise\ **错误码**: -以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-EnterpriseDeviceManager.md) +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) | 类型 | 说明 | | ------- | ---------------------------------------------------------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md index 0f302eb0e6eccd14e73db49b92686113e443e290..8a844f7c141ed323a759a2db23212e7e8f016c5a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md +++ b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @@ -8,7 +8,6 @@ import faultLogger from '@ohos.faultLogger' ``` - ## FaultType 故障类型枚举。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md index da0b5ea904f03fd13c5a39a04654d2c03560cdc9..904e7d0854931644be98e6a66d2e5785e0a87485 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @@ -14,7 +14,7 @@ FeatureAbility模块的接口只能在Page类型的Ability调用 ## 导入模块 ``` -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; ``` ## featureAbility.startAbility @@ -35,8 +35,8 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\) **示例:** ```javascript -import featureAbility from '@ohos.ability.featureAbility' -import wantConstant from '@ohos.ability.wantConstant' +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.startAbility( { want: @@ -53,7 +53,7 @@ featureAbility.startAbility( }, }, (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) + console.info("startAbility err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); } ); ``` @@ -77,8 +77,8 @@ startAbility(parameter: StartAbilityParameter): Promise\ **示例:** ```javascript -import featureAbility from '@ohos.ability.featureAbility' -import wantConstant from '@ohos.ability.wantConstant' +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.startAbility( { want: @@ -86,7 +86,7 @@ featureAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.myapplication", /* FA模型中abilityName由package + Ability name组成 */ @@ -95,7 +95,7 @@ featureAbility.startAbility( }, } ).then((data) => { - console.info("==========================>startAbility=======================>"); + console.info("startAbility data: " + JSON.stringify(data)); }); ``` @@ -122,10 +122,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper **示例:** ```javascript -import featureAbility from '@ohos.ability.featureAbility' -featureAbility.acquireDataAbilityHelper( +import featureAbility from '@ohos.ability.featureAbility'; +var dataAbilityHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" -) +); ``` ## featureAbility.startAbilityForResult7+ @@ -147,7 +147,7 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; -import wantConstant from '@ohos.ability.wantConstant' +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.startAbilityForResult( { want: @@ -164,9 +164,9 @@ featureAbility.startAbilityForResult( }, }, (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) + console.info("startAbilityForResult err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); } -) +); ``` ## featureAbility.startAbilityForResult7+ @@ -193,7 +193,7 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; -import wantConstant from '@ohos.ability.wantConstant' +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.startAbilityForResult( { want: @@ -221,7 +221,7 @@ featureAbility.startAbilityForResult( }, }, ).then((data) => { - console.info("==========================>startAbilityForResult=======================>"); + console.info("startAbilityForResult data: " + JSON.stringify(data)); }); ``` @@ -243,8 +243,8 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\ **示例:** ```javascript -import featureAbility from '@ohos.ability.featureAbility' -import wantConstant from '@ohos.ability.wantConstant' +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.terminateSelfWithResult( { resultCode: 1, @@ -271,8 +271,8 @@ featureAbility.terminateSelfWithResult( } }, }, - (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) + (err) => { + console.info("err: " + JSON.stringify(err)) } ); ``` @@ -301,7 +301,7 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; -import wantConstant from '@ohos.ability.wantConstant' +import wantConstant from '@ohos.ability.wantConstant'; featureAbility.terminateSelfWithResult( { resultCode: 1, @@ -351,11 +351,9 @@ hasWindowFocus(callback: AsyncCallback\): void ```javascript import featureAbility from '@ohos.ability.featureAbility'; -featureAbility.hasWindowFocus( - (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) - } -) +featureAbility.hasWindowFocus((err, data) => { + console.info("hasWindowFocus err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## featureAbility.hasWindowFocus7+ @@ -377,7 +375,7 @@ hasWindowFocus(): Promise\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus().then((data) => { - console.info("==========================>hasWindowFocus=======================>"); + console.info("hasWindowFocus data: " + JSON.stringify(data)); }); ``` @@ -399,11 +397,9 @@ getWant(callback: AsyncCallback\): void ```javascript import featureAbility from '@ohos.ability.featureAbility'; -featureAbility.getWant( - (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) - } -) +featureAbility.getWant((err, data) => { + console.info("getWant err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## featureAbility.getWant @@ -425,7 +421,7 @@ getWant(): Promise\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant().then((data) => { - console.info("==========================>getWantCallBack=======================>"); + console.info("getWant data: " + JSON.stringify(data)); }); ``` @@ -448,7 +444,9 @@ getContext(): Context ```javascript import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext() -context.getBundleName() +context.getBundleName((err, data) => { + console.info("getBundleName err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)); +}); ``` ## featureAbility.terminateSelf7+ @@ -470,8 +468,8 @@ terminateSelf(callback: AsyncCallback\): void ```javascript import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf( - (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) + (err) => { + console.info("err: " + JSON.stringify(err)) } ) ``` @@ -495,7 +493,7 @@ terminateSelf(): Promise\ ```javascript import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf().then((data) => { - console.info("==========================>terminateSelfCallBack=======================>"); + console.info("==========================>terminateSelf=======================>"); }); ``` @@ -535,8 +533,8 @@ ConnectOptions类型说明 **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -546,7 +544,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { deviceId: "", bundleName: "com.ix.ServiceAbility", @@ -578,8 +576,8 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -589,7 +587,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", @@ -600,9 +598,9 @@ var connId = featureAbility.connectAbility( onFailed: onFailedCallback, }, ); -var result = featureAbility.disconnectAbility(connId, - (error, data) => { - console.log('featureAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code + " data: " + data) +var result = featureAbility.disconnectAbility(connectId, + (error) => { + console.log('featureAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code) }, ); ``` @@ -630,8 +628,8 @@ disconnectAbility(connection: number): Promise\ **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -641,7 +639,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", @@ -653,7 +651,7 @@ var connId = featureAbility.connectAbility( }, ); -featureAbility.disconnectAbility(connId).then((data) => { +featureAbility.disconnectAbility(connectId).then((data) => { console.log('data : ' + data); }).catch((error)=>{ console.log('featureAbilityTest result errCode : ' + error.code); @@ -678,11 +676,9 @@ getWindow(callback: AsyncCallback\): void **示例:** ```javascript -featureAbility.getWindow( - (err, data) => { - console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) - } -) +featureAbility.getWindow((err, data) => { + console.info("getWindow err: " + JSON.stringify(err) + "data: " + typeof(data)); +}); ``` ## featureAbility.getWindow7+ @@ -703,7 +699,7 @@ getWindow(): Promise\; ```javascript featureAbility.getWindow().then((data) => { - console.info("=============getWindowPromise========== " + JSON.stringify(data)); + console.info("getWindow data: " + typeof(data)); }); ``` @@ -725,8 +721,8 @@ onConnect(elementName: ElementName, remote: rpc.IRemoteObject): void; **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -736,7 +732,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { deviceId: "", bundleName: "com.ix.ServiceAbility", @@ -767,8 +763,8 @@ onDisconnect(elementName: ElementName): void; **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -778,7 +774,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { deviceId: "", bundleName: "com.ix.ServiceAbility", @@ -809,8 +805,8 @@ ConnectAbility调用失败时的回调函数。 **示例:** ```javascript -import rpc from '@ohos.rpc' -import featureAbility from '@ohos.ability.featureAbility' +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -820,7 +816,7 @@ function onDisconnectCallback(element){ function onFailedCallback(code){ console.log('featureAbilityTest ConnectAbility onFailed errCode : ' + code) } -var connId = featureAbility.connectAbility( +var connectId = featureAbility.connectAbility( { deviceId: "", bundleName: "com.ix.ServiceAbility", diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md b/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md index b0058cb086c97a3749b8497a91ce290d2f305ea3..fb94a1acb99a83a2f7f68f9febd7a1b64e287bed 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileExtensionInfo.md @@ -1,4 +1,4 @@ -# 公共文件访问与管理 +# 公共文件访问与管理属性信息 该模块提供公共文件访问和管理模块中RootInfo与FileInfo中部分属性值的定义。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md index 9ba948beaccf86693e6d13fe257ab5554212659b..4d5643fc7481e3a9f04d44e79b062fa851d635b6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md @@ -250,7 +250,7 @@ access(path: string, mode?: number): Promise<void> ## fileio.access -access(path: string, mode: number, callback: AsyncCallback<void>): void +access(path: string, mode?: number, callback: AsyncCallback<void>): void 检查当前进程是否可访问某文件,使用callback异步回调。 @@ -395,8 +395,8 @@ copyFile(src: string | number, dest: string | number, mode?: number): Promise< | 参数名 | 类型 | 必填 | 说明 | | ---- | -------------------------- | ---- | ---------------------------------------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | **返回值:** @@ -420,7 +420,7 @@ copyFile(src: string | number, dest: string | number, mode?: number): Promise< ## fileio.copyFile -copyFile(src: string | number, dest: string | number, mode: number, callback: AsyncCallback<void>): void +copyFile(src: string|number, dest: string|number, mode: number, callback: AsyncCallback<void>): void 复制文件,使用callback异步回调。 @@ -430,8 +430,8 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ---------------------------------------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | src | string\|number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string\|number | 是 | 目标文件路径或目标文件描述符。 | | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | | callback | AsyncCallback<void> | 是 | 异步复制文件之后的回调。 | @@ -448,7 +448,7 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As ## fileio.copyFileSync -copyFileSync(src: string | number, dest: string | number, mode?: number): void +copyFileSync(src: string|number, dest: string|number, mode?: number): void 以同步方法复制文件。 @@ -458,8 +458,8 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void | 参数名 | 类型 | 必填 | 说明 | | ---- | -------------------------- | ---- | ---------------------------------------- | - | src | string \| number | 是 | 待复制文件的路径或待复制文件的描述符。 | - | dest | string \| number | 是 | 目标文件路径或目标文件描述符。 | + | src | string\|number | 是 | 待复制文件的路径或待复制文件的描述符。 | + | dest | string\|number | 是 | 目标文件路径或目标文件描述符。 | | mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。
0:完全覆盖目标文件,未覆盖部分将被裁切掉。 | **示例:** @@ -602,7 +602,7 @@ open(path: string, flags: number, mode: number, callback: AsyncCallback<numbe | path | string | 是 | 待打开文件的应用沙箱路径。 | | flags | number | 否 | 打开文件的选项,必须指定如下选项中的一个,默认以只读方式打开:
- 0o0:只读打开。
- 0o1:只写打开。
- 0o2:读写打开。
同时,也可给定如下选项,以按位或的方式追加,默认不给定任何额外选项:
- 0o100:若文件不存在,则创建文件。使用该选项时必须指定第三个参数 mode。
- 0o200:如果追加了0o100选项,且文件已经存在,则出错。
- 0o1000:如果文件存在且以只写或读写的方式打开文件,则将其长度裁剪为零。
- 0o2000:以追加方式打开,后续写将追加到文件末尾。
- 0o4000:如果path指向FIFO、块特殊文件或字符特殊文件,则本次打开及后续 IO 进行非阻塞操作。
- 0o200000:如果path不指向目录,则出错。
- 0o400000:如果path指向符号链接,则出错。
- 0o4010000:以同步IO的方式打开文件。 | | mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。
- 0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | -| callback | AsyncCallback <void> | 是 | 异步打开文件之后的回调。 | +| callback | AsyncCallback<number> | 是 | 异步打开文件之后的回调。 | **示例:** @@ -950,7 +950,7 @@ write(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; len ## fileio.write -write(fd: number, buffer: ArrayBuffer | string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback<number>): void +write(fd: number, buffer: ArrayBuffer|string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback<number>): void 将数据写入文件,使用callback异步回调。 @@ -961,7 +961,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: { offset?: number; leng | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | | callback | AsyncCallback<number> | 是 | 异步将数据写入完成后执行的回调函数。 | @@ -980,7 +980,7 @@ write(fd: number, buffer: ArrayBuffer | string, options: { offset?: number; leng ## fileio.writeSync -writeSync(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number +writeSync(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): number 以同步方法将数据写入文件。 @@ -991,7 +991,7 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: { offset?: number; | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待写入文件的文件描述符。 | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | **返回值:** @@ -1525,7 +1525,7 @@ lstat(path: string): Promise<Stat> ```js let filePath = pathDir + "/test.txt"; fileio.lstat(filePath).then(function(stat){ - console.info("get link status succeed, " + the size of file is + stat.size); + console.info("get link status succeed, the size of file is" + stat.size); }).catch(function(err){ console.info("get link status failed with error:"+ err); }); @@ -1598,7 +1598,7 @@ rename(oldPath: string, newPath: string): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---------------------------- | | oldPath | string | 是 | 目标文件的当前应用沙箱路径。 | -| newPath | String | 是 | 目标文件的新应用沙箱路径。 | +| newPath | string | 是 | 目标文件的新应用沙箱路径。 | **返回值:** @@ -1632,8 +1632,8 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------------- | | oldPath | string | 是 | 目标文件的当前应用沙箱路径。 | -| newPath | String | 是 | 目标文件的新应用沙箱路径。 | -| Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | +| newPath | string | 是 | 目标文件的新应用沙箱路径。 | +| callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 | **示例:** @@ -1658,7 +1658,7 @@ renameSync(oldPath: string, newPath: string): void | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---------------------------- | | oldPath | string | 是 | 目标文件的当前应用沙箱路径。 | -| newPath | String | 是 | 目标文件的新应用沙箱路径。 | +| newPath | string | 是 | 目标文件的新应用沙箱路径。 | **示例:** @@ -1797,7 +1797,7 @@ fdatasync(fd: number, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ----------------- | | fd | number | 是 | 待同步文件的文件描述符。 | - | callback | AsyncCallback <void> | 是 | 异步将文件内容数据同步之后的回调。 | + | callback | AsyncCallback<void> | 是 | 异步将文件内容数据同步之后的回调。 | **示例:** @@ -2137,7 +2137,7 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void | -------- | ------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待改变文件的文件描述符。 | | mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。
- 0o700:所有者具有读、写及可执行权限。
- 0o400:所有者具有读权限。
- 0o200:所有者具有写权限。
- 0o100:所有者具有可执行权限。
- 0o070:所有用户组具有读、写及可执行权限。
- 0o040:所有用户组具有读权限。
- 0o020:所有用户组具有写权限。
- 0o010:所有用户组具有可执行权限。
- 0o007:其余用户具有读、写及可执行权限。
- 0o004:其余用户具有读权限。
- 0o002:其余用户具有写权限。
- 0o001:其余用户具有可执行权限。 | - | callback | AsyncCallback <void> | 是 | 异步改变文件权限之后的回调。 | + | callback | AsyncCallback<void> | 是 | 异步改变文件权限之后的回调。 | **示例:** @@ -2312,7 +2312,7 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | fd | number | 是 | 待打开文件的文件描述符。 | | mode | string | 是 | - r:打开只读文件,该文件必须存在。
- r+:打开可读写的文件,该文件必须存在。
- w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。
- a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。
- a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 | - | callback | AsyncCallback <[Stream](#stream)> | 是 | 异步打开文件流之后的回调。 | + | callback | AsyncCallback<[Stream](#stream)> | 是 | 异步打开文件流之后的回调。 | **示例:** @@ -2547,8 +2547,8 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------- | ---- | ------------------------------------------------------------ | | filePath | string | 是 | 待监视文件的应用沙箱路径。 | -| events | Number | 是 | - 1: 监听文件或者目录是否发生重命名。
- 2:监听文件或者目录内容的是否修改。
- 3:两者都有。 | -| callback | AsyncCallback<number > | 是 | 每发生变化一次,调用一次此函数。 | +| events | number | 是 | - 1: 监听文件或者目录是否发生重命名。
- 2:监听文件或者目录内容的是否修改。
- 3:两者都有。 | +| callback | AsyncCallback<number> | 是 | 每发生变化一次,调用一次此函数。 | **返回值:** @@ -2573,11 +2573,11 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe **系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.File.FileIO。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ---------- | ---- | ---- | ----------------- | | bytesRead | number | 是 | 是 | 实际读取长度。 | | offset | number | 是 | 是 | 读取数据相对于缓冲区首地址的偏移。 | -| buffer | ArrayBufer | 是 | 是 | 保存读取数据的缓冲区。 | +| buffer | ArrayBuffer | 是 | 是 | 保存读取数据的缓冲区。 | ## Stat @@ -2588,7 +2588,7 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ---- | ---- | ---------------------------------------- | | dev | number | 是 | 否 | 标识包含该文件的主设备号。 | | ino | number | 是 | 否 | 标识该文件。通常同设备上的不同文件的INO不同。 | @@ -2956,7 +2956,7 @@ flushSync(): void ### write7+ -write(buffer: ArrayBuffer | string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise<number> +write(buffer: ArrayBuffer|string, options?: { offset?: number; length?: number; position?: number; encoding?: string; }): Promise<number> 将数据写入流文件,使用Promise异步回调。 @@ -2966,7 +2966,7 @@ write(buffer: ArrayBuffer | string, options?: { offset?: number; length?: number | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | **返回值:** @@ -2990,7 +2990,7 @@ write(buffer: ArrayBuffer | string, options?: { offset?: number; length?: number ### write7+ -write(buffer: ArrayBuffer | string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback<number>): void +write(buffer: ArrayBuffer|string, options: { offset?: number; length?: number; position?: number; encoding?: string; }, callback: AsyncCallback<number>): void 将数据写入流文件,使用callback异步回调。 @@ -3000,7 +3000,7 @@ write(buffer: ArrayBuffer | string, options: { offset?: number; length?: number; | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer\|string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | | callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 | @@ -3030,7 +3030,7 @@ writeSync(buffer: ArrayBuffer | string, options?: { offset?: number; length?: nu | 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------------------- | ---- | ---------------------------------------- | - | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | + | buffer | ArrayBuffer \| string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 | | options | Object | 否 | 支持如下选项:
- offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。
- length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。
- position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。
- encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认 'utf-8'。仅支持 'utf-8'。
约束:offset+length<=buffer.size。 | **返回值:** @@ -3277,7 +3277,7 @@ closeSync(): void ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | ------ | ---- | ---- | ------- | | name | string | 是 | 否 | 目录项的名称。 | @@ -3443,7 +3443,7 @@ isSymbolicLink(): boolean 文件过滤器配置项。 -| 名称 | 参数类型 | 说明 | +| 名称 | 类型 | 说明 | | ----------- | --------------- | ------------------ | | suffix | Array<string> | 文件后缀名,各个关键词OR关系。 | | displayName | Array<string> | 文件名模糊匹配,各个关键词OR关系。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md index 571573a02743705f0d223670d74e4dc006124734..0e168f117f3ea9106c0ff095fbd9be636481f7c1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md +++ b/zh-cn/application-dev/reference/apis/js-apis-freeInstall.md @@ -21,8 +21,7 @@ import freeInstall from '@ohos.bundle.freeInstall'; | ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息 | | ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 | -权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) - +权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)。 ## UpgradeFlag **系统接口:** 此接口为系统接口。 @@ -62,7 +61,7 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------------------- | ---- | ---------------------------- | | bundleName | string | 是 | 应用程序包名称。 | | moduleName | string | 是 | 应用程序模块名称。 | @@ -71,9 +70,9 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -115,7 +114,7 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------------------- | ---- | ---------------------- | | bundleName | string | 是 | 应用程序包名称。 | | moduleName | string | 是 | 应用程序模块名称。 | @@ -129,9 +128,9 @@ setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: Upg **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -171,7 +170,7 @@ isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCall **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------- | ---- | --------------------------------------------- | | bundleName | string | 是 | 应用程序包名称。 | | moduleName | string | 是 | 应用程序模块名称。 | @@ -179,9 +178,9 @@ isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCall **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -222,7 +221,7 @@ isHapModuleRemovable(bundleName: string, moduleName: string): Promise\; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------------ | | bundleName | string | 是 | 应用程序包名称。 | | moduleName | string | 是 | 应用程序模块名称。 | @@ -235,9 +234,9 @@ isHapModuleRemovable(bundleName: string, moduleName: string): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -276,17 +275,17 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------- | -| bundleName | string | 是 | 应用程序包名称。 | -| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| bundleName | string | 是 | 应用程序包名称。 | +| bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 | | callback | AsyncCallback<[BundlePackInfo](js-apis-bundleManager-packInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的BundlePackInfo信息。否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -298,9 +297,9 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: ```js import freeInstall from '@ohos.bundle.freeInstall'; let bundleName = 'com.example.myapplication'; -let upgradeFlag = freeInstall.UpgradeFlag.GET_PACK_INFO_ALL; +let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL; try { - freeInstall.getBundlePackInfo(bundleName, upgradeFlag, (err, data) => { + freeInstall.getBundlePackInfo(bundleName, bundlePackFlag, (err, data) => { if (err) { console.error('Operation failed:' + JSON.stringify(err)); } else { @@ -325,9 +324,9 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------------- | ------------------------------------------------- | ---- | ---------------------- | -| bundleName | string | 是 | 应用程序包名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | --------------------------------- | ---- | ---------------------- | +| bundleName | string | 是 | 应用程序包名称。 | | bundlePackFlag | [BundlePackFlag](#bundlepackflag) | 是 | 指示要查询的应用包标志 | **返回值:** @@ -338,9 +337,9 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\ **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 401 | The parameter check failed. | @@ -352,9 +351,9 @@ getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise\ ```js import freeInstall from '@ohos.bundle.freeInstall'; let bundleName = 'com.example.myapplication'; -let upgradeFlag = freeInstall.UpgradeFlag.GET_PACK_INFO_ALL; +let bundlePackFlag = freeInstall.BundlePackFlag.GET_PACK_INFO_ALL; try { - freeInstall.getBundlePackInfo(bundleName, upgradeFlag).then(data => { + freeInstall.getBundlePackInfo(bundleName, bundlePackFlag).then(data => { console.info('Operation succeed:' + JSON.stringify(data)); }).catch(err => { console.error('Operation failed:' + JSON.stringify(err)); @@ -378,15 +377,15 @@ getDispatchInfo(callback: AsyncCallback\): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | -| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | callback | AsyncCallback<[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)> | 是 | 回调函数。当函数调用成功,err为null,data为获取到的[DispatchInfo](js-apis-bundleManager-dispatchInfo.md)信息。否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 801 | Capability not supported. | @@ -428,9 +427,9 @@ getDispatchInfo(): Promise\; **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误新息(此处仅提供错误抛出的关键信息) | +| 错误码ID | 错误信息 | |---------------|-------------------------| | 201 | Permission denied.| | 801 | Capability not supported. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md b/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md index b0e51a6b414bbdb2b3d6f23ffd3559eae266f144..66036d7616f66140e56437efd6e19223c37a8a75 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md @@ -63,7 +63,7 @@ off(type: 'countryCodeChange', callback?: Callback<CountryCode>): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“countryCodeChange”,表示取消订阅国家码信息变化事件。 | - | callback | Callback<[CountryCode](#countrycode)> | 是 | 接收国家码信息上报。 | + | callback | Callback<[CountryCode](#countrycode)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index 900cf2035959554d2a56935a802a3a627606ca8c..65d6de9a6f3f800065adbe2710544189b69d9c16 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -59,7 +59,7 @@ off(type: 'locationChange', callback?: Callback<Location>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationChange”,表示位置变化。 | - | callback | Callback<[Location](#location)> | 否 | 接收位置变化状态变化监听。 | + | callback | Callback<[Location](#location)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **示例** @@ -119,7 +119,7 @@ off(type: 'locationServiceState', callback?: Callback<boolean>): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“locationServiceState”,表示位置服务状态。 | - | callback | Callback<boolean> | 否 | 接收位置服务状态变化监听。 | + | callback | Callback<boolean> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **示例** @@ -180,7 +180,7 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“cachedGnssLocationsReporting”,表示GNSS缓存定位结果上报。 | - | callback | Callback<boolean> | 否 | 接收GNSS缓存位置上报。 | + | callback | Callback<boolean> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **示例** @@ -240,7 +240,7 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“gnssStatusChange”,表示订阅GNSS卫星状态信息上报。 | - | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | 否 | 接收GNSS卫星状态信息上报。 | + | callback | Callback<[SatelliteStatusInfo](#satellitestatusinfo)> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **示例** @@ -298,7 +298,7 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 设置事件类型。type为“nmeaMessageChange”,表示订阅GNSS NMEA信息上报。 | - | callback | Callback<string> | 否 | 接收GNSS NMEA信息上报。 | + | callback | Callback<string> | 否 | 需要取消订阅的回调函数。若无此参数,则取消当前类型的所有订阅。 | **示例** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index 5e58073b79314e40bef7036dd829b2a51a738bc2..dd8a05fc41bd7bbea1c8240542efd158cd62ef90 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -27,7 +27,7 @@ import HashMap from '@ohos.util.HashMap'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | HashMap的元素个数。 | @@ -44,7 +44,7 @@ HashMap的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The HashMap's constructor cannot be directly invoked. | @@ -78,7 +78,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -119,7 +119,7 @@ hasKey(key: K): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasKey method cannot be bound. | @@ -162,7 +162,7 @@ hasValue(value: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasValue method cannot be bound. | @@ -205,7 +205,7 @@ get(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -242,7 +242,7 @@ setAll(map: HashMap): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The setAll method cannot be bound. | @@ -287,7 +287,7 @@ set(key: K, value: V): Object 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The set method cannot be bound. | @@ -328,7 +328,7 @@ remove(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -359,7 +359,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -396,7 +396,7 @@ keys(): IterableIterator<K> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The keys method cannot be bound. | @@ -438,7 +438,7 @@ values(): IterableIterator<V> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The values method cannot be bound. | @@ -487,7 +487,7 @@ replace(key: K, newValue: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The replace method cannot be bound. | @@ -531,7 +531,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -572,7 +572,7 @@ entries(): IterableIterator<[K, V]> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The entries method cannot be bound. | @@ -615,7 +615,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index 5a270cec3dc83316db1eadfd6642c18dfd7695ea..239f9874427b4a093117c4d994f23c39637f5c59 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -24,7 +24,7 @@ import HashSet from '@ohos.util.HashSet'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | HashSet的元素个数。 | @@ -52,7 +52,7 @@ HashSet的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The HashSet's constructor cannot be directly invoked. | @@ -86,7 +86,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -127,7 +127,7 @@ has(value: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -170,7 +170,7 @@ add(value: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -211,7 +211,7 @@ remove(value: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -242,7 +242,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -279,7 +279,7 @@ values(): IterableIterator<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The values method cannot be bound. | @@ -329,7 +329,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -369,7 +369,7 @@ entries(): IterableIterator<[T, T]> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The entries method cannot be bound. | @@ -412,7 +412,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md index 390623519f0c1ce48914d21867c28effcbb67a07..43f00e1041a110133007d0d60d1506032eacb377 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md @@ -3,7 +3,7 @@ 本模块提供了应用事件打点能力,包括对打点数据的落盘,以及对打点功能的管理配置。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 本模块接口从API version 9开始废弃,建议使用新接口[@ohos.hiviewdfx.hiAppEvent](js-apis-hiviewdfx-hiappevent.md)替代。 +> - 本模块接口从API version 9开始废弃,建议使用新接口[`@ohos.hiviewdfx.hiAppEvent`](js-apis-hiviewdfx-hiappevent.md)替代。 > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hilog.md b/zh-cn/application-dev/reference/apis/js-apis-hilog.md index ed08c559fd4ae6dbf6e3799aaed3fdea5ce7e5b3..20c261f17b9702e2b14aeefbf8e5009fda475c00 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hilog.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hilog.md @@ -1,4 +1,4 @@ -# 日志打印 +# Hilog日志打印 hilog日志系统,使应用/服务可以按照指定级别、标识和格式字符串输出日志内容,帮助开发者了解应用/服务的运行状态,更好地调试程序。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-huks.md b/zh-cn/application-dev/reference/apis/js-apis-huks.md index 49c7126b86a04983f27ba36299d4c2ef5e3e5278..2180ff8d0017b1a7e027e60f78c88e57bad688f4 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-huks.md +++ b/zh-cn/application-dev/reference/apis/js-apis-huks.md @@ -1,12 +1,12 @@ # 通用密钥库系统 +向应用提供密钥库能力,包括密钥管理及密钥的密码学操作等功能。 +HUKS所管理的密钥可以由应用导入或者由应用调用HUKS接口生成。 + > **说明** > > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -向应用提供密钥库能力,包括密钥管理及密钥的密码学操作等功能。 -HUKS所管理的密钥可以由应用导入或者由应用调用HUKS接口生成。 - ## 导入模块 ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index c9a086de0f56f1923cc9b0eb6d22ead477d877a5..32940b1ac22869c454f4a181ae66003d0cb4f0db 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -1771,7 +1771,7 @@ createImageReceiver(width: number, height: number, format: number, capacity: num | -------- | ------ | ---- | ---------------------- | | width | number | 是 | 图像的默认宽度。 | | height | number | 是 | 图像的默认高度。 | -| format | number | 是 | 图像格式,取值为[ImageFormat](#imageformat9)常量(目前该参数为使用者和camera约定的值,以后可能还有其他应用场景,receiver的作用只是传递)。 | +| format | number | 是 | 图像格式,取值为[ImageFormat](#imageformat9)常量(目前该参数为使用者和camera约定的值,以后可能还有其他应用场景,receiver的作用只是传递,目前仅支持 ImageFormat:JPEG 格式)。 | | capacity | number | 是 | 同时访问的最大图像数。 | **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md index 7f9be5cf41f311e7f897d28c913dc166b7a2585f..11da53c811085c125ac82ce38a3c7726fa02379d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputconsumer.md @@ -27,7 +27,7 @@ on(type: "key", keyOptions: KeyOptions, callback: Callback<KeyOptions>): v **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------------- | ---- | ---------------------------------------- | | type | string | 是 | 事件类型,目前只支持”key“。 | | keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 | @@ -58,7 +58,7 @@ off(type: "key", keyOptions: KeyOptions, callback?: Callback<KeyOptions>): **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | -------------------------- | ---- | ------------------------------- | | type | string | 是 | 事件类型,当前只支持”key“。 | | keyOptions | [keyOptions](#keyoptions) | 是 | 组合键选项。 | @@ -106,9 +106,9 @@ try { **系统能力:** SystemCapability.MultimodalInput.Input.InputConsumer -| 参数 | 类型 | 必填 | 说明 | -| -------------------- | ------- | ---- | ------------------------ | -| preKeys | Array | 是 | 前置按键集合,数量范围[0, 4],前置按键无顺序要求。 | -| finalKey | Number | 是 | 最终按键,此项必填,最终按键触发上报回调函数。 | -| isFinalKeyDown | boolean | 是 | 最终按键状态。 | -| finalKeyDownDuration | Number | 是 | 最终按键保持按下持续时间,为0时立即触发回调函数,大于0时,当isFinalKeyDown为true,则最终按键按下超过此时长后触发回调函数,当isFinalKeyDown为false,则最终按键按下到抬起时间小于此时长时触发回调函数。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| preKeys | Array | 是 | 否 | 前置按键集合,数量范围[0, 4],前置按键无顺序要求。 | +| finalKey | Number | 是 | 否 | 最终按键,此项必填,最终按键触发上报回调函数。 | +| isFinalKeyDown | boolean | 是 | 否 | 最终按键状态。 | +| finalKeyDownDuration | Number | 是 | 否 | 最终按键保持按下持续时间,为0时立即触发回调函数,大于0时,当isFinalKeyDown为true,则最终按键按下超过此时长后触发回调函数,当isFinalKeyDown为false,则最终按键按下到抬起时间小于此时长时触发回调函数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md index ecd2d4b1968e32a6ab1c990538bc57c4e898e6f4..c10857c6d46f251994ed7a930eea161b1694254f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputdevice.md @@ -26,7 +26,7 @@ getDeviceList(callback: AsyncCallback<Array<number>>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | callback | AsyncCallback<Array<number>> | 是 | 回调函数,异步返回所有输入设备的id列表。 | @@ -82,7 +82,7 @@ getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------------- | ---- | --------------------------------------- | | deviceId | number | 是 | 输入设备id。 | | callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回输入设备信息。 | @@ -114,7 +114,7 @@ getDeviceInfo(deviceId: number): Promise<InputDeviceData> **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ---------------------- | | deviceId | number | 是 | 输入设备id。 | @@ -147,7 +147,7 @@ on(type: "change", listener: Callback<DeviceListener>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | 是 | 输入设备的事件类型。 | | listener | Callback<[DeviceListener](#devicelistener9)> | 是 | 回调函数,异步上报输入设备热插拔事件。 | @@ -186,7 +186,7 @@ off(type: "change", listener?: Callback<DeviceListener>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------- | | type | string | 是 | 输入设备的事件类型。 | | listener | Callback<[DeviceListener](#devicelistener9)> | 否 | 取消监听的回调函数。 | @@ -231,7 +231,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | callback | AsyncCallback<Array<number>> | 是 | 回调函数,异步返回所有输入设备的id列表。 | @@ -283,7 +283,7 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------------- | ---- | -------------------------------- | | deviceId | number | 是 | 输入设备id。 | | callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | 是 | 回调函数,异步返回输入设备信息。 | @@ -313,7 +313,7 @@ getDevice(deviceId: number): Promise<InputDeviceData> **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------ | | deviceId | number | 是 | 输入设备id。 | @@ -334,19 +334,19 @@ inputDevice.getDeviceInfo(1).then((deviceData) => { ## inputDevice.supportKeys9+ -supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void +supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback <Array<boolean>>): void -获取输入设备是否支持指定的键码值,使用Callback异步方式返回结果。 +获取输入设备是否支持指定的键码值,使用AsyncCallback异步方式返回结果。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice **参数**: -| 参数 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | -| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | -| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | -| callback | Callback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | +| keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | +| callback | AsyncCallback<Array<boolean>> | 是 | 回调函数,异步返回查询结果。 | **示例**: @@ -371,7 +371,7 @@ supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<b **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------- | ---- | ------------------------------------------------------ | | deviceId | number | 是 | 输入设备id,同一个物理设备反复插拔,设备id会发生变化。 | | keys | Array<KeyCode> | 是 | 需要查询的键码值,最多支持5个按键查询。 | @@ -405,7 +405,7 @@ getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | | callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | 是 | 回调函数,异步返回查询结果。 | @@ -437,7 +437,7 @@ getKeyboardType(deviceId: number): Promise<KeyboardType> **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | deviceId | number | 是 | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | @@ -466,10 +466,10 @@ try { **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| -------- | --------------------------- | ------------------------------------------------------------ | -| type | [ChangedType](#changedtype) | 输入设备插入或者移除。 | -| deviceId | number | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| type | [ChangedType](#changedtype) | 是 | 否 | 输入设备插入或者移除。| +| deviceId | number | 是 | 否 | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | ## InputDeviceData @@ -477,18 +477,18 @@ try { **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| -------------------- | -------------------------------------- | ------------------------------------------------------------ | -| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | -| name | string | 输入设备的名字。 | -| sources | Array<[SourceType](#sourcetype)> | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 | -| axisRanges | Array<[axisRanges](#axisrange)> | 输入设备的轴信息。 | -| bus9+ | number | 输入设备的总线类型。 | -| product9+ | number | 输入设备的产品信息。 | -| vendor9+ | number | 输入设备的厂商信息。 | -| version9+ | number | 输入设备的版本信息。 | -| phys9+ | string | 输入设备的物理地址。 | -| uniq9+ | string | 输入设备的唯一标识。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| id | number | 是 | 否 | 输入设备的唯一标识,同一个物理设备反复插拔,设备id会发生变化。 | +| name | string | 是 | 否 | 输入设备的名字。 | +| sources | Array<[SourceType](#sourcetype)> | 是 | 否 | 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 | +| axisRanges | Array<[axisRanges](#axisrange)> | 是 | 否 | 输入设备的轴信息。 | +| bus9+ | number | 是 | 否 | 输入设备的总线类型。 | +| product9+ | number | 是 | 否 | 输入设备的产品信息。 | +| vendor9+ | number | 是 | 否 | 输入设备的厂商信息。 | +| version9+ | number | 是 | 否 | 输入设备的版本信息。 | +| phys9+ | string | 是 | 否 | 输入设备的物理地址。 | +| uniq9+ | string | 是 | 否 | 输入设备的唯一标识。 | ## AxisType9+ @@ -496,17 +496,17 @@ try { **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| ----------- | ------ | --------------- | -| touchMajor | string | 表示touchMajor轴。 | -| touchMinor | string | 表示touchMinor轴。 | -| toolMinor | string | 表示toolMinor轴。 | -| toolMajor | string | 表示toolMajor轴。 | -| orientation | string | 表示orientation轴。 | -| pressure | string | 表示pressure轴。 | -| x | string | 表示x轴。 | -| y | string | 表示y轴。 | -| NULL | string | 无。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| touchMajor | string | 是 | 否 | 表示touchMajor轴。 | +| touchMinor | string | 是 | 否 | 表示touchMinor轴。 | +| toolMinor | string | 是 | 否 | 表示toolMinor轴。 | +| toolMajor | string | 是 | 否 | 表示toolMajor轴。 | +| orientation | string | 是 | 否 | 表示orientation轴。 | +| pressure | string | 是 | 否 | 表示pressure轴。 | +| x | string | 是 | 否 | 表示x轴。 | +| y | string | 是 | 否 | 表示y轴。 | +| NULL | string | 是 | 否 | 无。 | ## AxisRange @@ -514,41 +514,41 @@ try { **系统能力**: SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| ----------------------- | ------------------------- | -------- | -| source | [SourceType](#sourcetype) | 轴的输入源类型。 | -| axis | [AxisType](#axistype9) | 轴的类型。 | -| max | number | 轴的最大值。 | -| min | number | 轴的最小值。 | -| fuzz9+ | number | 轴的模糊值。 | -| flat9+ | number | 轴的基准值。 | -| resolution9+ | number | 轴的分辨率。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| source | [SourceType](#sourcetype) | 是 | 否 | 轴的输入源类型。 | +| axis | [AxisType](#axistype9) | 是 | 否 | 轴的类型。 | +| max | number | 是 | 否 | 轴的最大值。 | +| min | number | 是 | 否 | 轴的最小值。 | +| fuzz9+ | number | 是 | 否 | 轴的模糊值。 | +| flat9+ | number | 是 | 否 | 轴的基准值。 | +| resolution9+ | number | 是 | 否 | 轴的分辨率。 | -## SourceType +## SourceType9+ 轴的输入源类型。比如鼠标设备可上报x轴事件,则x轴的输入源就是鼠标。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| ----------- | ------ | ----------- | -| keyboard | string | 表示输入设备是键盘。 | -| touchscreen | string | 表示输入设备是触摸屏。 | -| mouse | string | 表示输入设备是鼠标。 | -| trackball | string | 表示输入设备是轨迹球。 | -| touchpad | string | 表示输入设备是触摸板。 | -| joystick | string | 表示输入设备是操纵杆。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| keyboard | string | 是 | 否 | 表示输入设备是键盘。 | +| touchscreen | string | 是 | 否 | 表示输入设备是触摸屏。 | +| mouse | string | 是 | 否 | 表示输入设备是鼠标。 | +| trackball | string | 是 | 否 | 表示输入设备是轨迹球。 | +| touchpad | string | 是 | 否 | 表示输入设备是触摸板。 | +| joystick | string | 是 | 否 | 表示输入设备是操纵杆。 | -## ChangedType +## ChangedType9+ 定义监听设备热插拔事件。 **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 说明 | -| ------ | ------ | --------- | -| add | string | 表示输入设备插入。 | -| remove | string | 表示输入设备移除。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| add | string | 是 | 否 | 表示输入设备插入。 | +| remove | string | 是 | 否 | 表示输入设备移除。 | ## KeyboardType9+ @@ -556,11 +556,11 @@ try { **系统能力**:SystemCapability.MultimodalInput.Input.InputDevice -| 名称 | 参数类型 | 值 | 说明 | -| ------------------- | ------ | ---- | --------- | -| NONE | number | 0 | 表示无按键设备。 | -| UNKNOWN | number | 1 | 表示未知按键设备。 | -| ALPHABETIC_KEYBOARD | number | 2 | 表示全键盘设备。 | -| DIGITAL_KEYBOARD | number | 3 | 表示小键盘设备。 | -| HANDWRITING_PEN | number | 4 | 表示手写笔设备。 | -| REMOTE_CONTROL | number | 5 | 表示遥控器设备。 | +| 名称 | 值 | 说明 | +| ------------------- | ---- | --------- | +| NONE | 0 | 表示无按键设备。 | +| UNKNOWN | 1 | 表示未知按键设备。 | +| ALPHABETIC_KEYBOARD | 2 | 表示全键盘设备。 | +| DIGITAL_KEYBOARD | 3 | 表示小键盘设备。 | +| HANDWRITING_PEN | 4 | 表示手写笔设备。 | +| REMOTE_CONTROL | 5 | 表示遥控器设备。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md index 1d964e6d0bab941d4127557c6da6f91cd1f65881..b5367dcf090ca6bd422caf60d30d66d2b3a289fb 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputevent.md @@ -15,7 +15,7 @@ import InputEvent from '@ohos.multimodalInput.inputEvent'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------- | ------ | ---- | ---- | -------------- | | id | number | 是 | 否 | 事件id | | deviceId | number | 是 | 否 | 上报输入事件的设备id | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md index 80d1a26688e276daea5ed1572764368ef93fb8ba..ece2f547946caf39c6f00a1135093b6c70d5a6c8 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md @@ -27,7 +27,7 @@ injectEvent({KeyEvent: KeyEvent}): void **参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------- | ---- | --------- | | KeyEvent | [KeyEvent](#keyevent) | 是 | 按键注入描述信息。 | @@ -41,7 +41,7 @@ try { keyDownDuration: 0, isIntercepted: false } - inputEventClient.injectKeyEvent({ KeyEvent: backKeyDown }); + inputEventClient.injectEvent({ KeyEvent: backKeyDown }); let backKeyUp = { isPressed: false, @@ -49,7 +49,7 @@ try { keyDownDuration: 0, isIntercepted: false }; - inputEventClient.injectKeyEvent({ KeyEvent: backKeyUp }); + inputEventClient.injectEvent({ KeyEvent: backKeyUp }); } catch (error) { console.log(`Failed to inject KeyEvent, error: ${JSON.stringify(error, [`code`, `message`])}`); } @@ -62,10 +62,10 @@ try { **系统能力:** SystemCapability.MultimodalInput.Input.InputSimulator -| 参数 | 类型 | 必填 | 说明 | -| --------------- | ------- | ---- | -------------------------- | -| isPressed | boolean | 是 | 按键是否按下。 | -| keyCode | number | 是 | 按键键值,当前只支持back键。 | -| keyDownDuration | number | 是 | 按键按下持续时间。 | -| isIntercepted | boolean | 是 | 按键是否可以被拦截。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------- | +| isPressed | boolean | 是 | 否 | 按键是否按下。 | +| keyCode | number | 是 | 否 | 按键键值,当前只支持back键。 | +| keyDownDuration | number | 是 | 否 | 按键按下持续时间。 | +| isIntercepted | boolean | 是 | 否 | 按键是否可以被拦截。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md index 6f381f501ab77c7b76e03734dd6311fe61801b7c..28b5c4a502ecd0348aab8a07507eda45a6ca4be9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod-extension-ability.md @@ -4,11 +4,11 @@ > **说明:** > ->本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 -``` +```js import InputMethodExtensionAbility from '@ohos.inputmethodextensionability'; ``` @@ -16,12 +16,11 @@ import InputMethodExtensionAbility from '@ohos.inputmethodextensionability'; **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | context | [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md) | 是 | 否 | InputMethodExtension的上下文环境,继承自ExtensionContext。 | - -## InputMethodExtensionAbility.onCreate() +## InputMethodExtensionAbility.onCreate onCreate(want: Want): void @@ -31,9 +30,9 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | ------------------------------- | +| want | [Want](js-apis-application-Want.md) | 是 | 当前Extension相关的Want类型信息,包括ability名称、bundle名称等。 | **示例:** @@ -45,8 +44,7 @@ class InputMethodExt extends InputMethodExtensionAbility { } ``` - -## InputMethodExtensionAbility.onDestroy() +## InputMethodExtensionAbility.onDestroy onDestroy(): void @@ -62,4 +60,4 @@ class InputMethodExt extends InputMethodExtensionAbility { console.log('onDestroy'); } } -``` +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md index aa285044a0905a546983a48e157baf82b2ea4858..eb51a3f69f6561557501f527ab8e3713dc9860b4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -19,7 +19,7 @@ import inputMethod from '@ohos.inputmethod'; **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 参数名 | 参数类型 | 常量值 | 说明 | +| 参数名 | 类型 | 常量值 | 说明 | | -------- | -------- | -------- | -------- | | MAX_TYPE_NUM | number | 128 | 可支持的最大输入法个数。 | @@ -29,7 +29,7 @@ import inputMethod from '@ohos.inputmethod'; **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | packageName(deprecated) | string | 是 | 否 | 输入法包名。
**说明:** 从API8开始支持,从API9开始废弃,建议使用name替代。 | | methodId(deprecated) | string | 是 | 否 | 输入法唯一标识。
**说明:** 从API8开始支持,从API9开始废弃,建议使用id替代。 | @@ -56,16 +56,16 @@ getController(): InputMethodController **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800006 | Input method controller error. | **示例:** ```js -let InputMethodController = inputMethod.getController(); +let inputMethodController = inputMethod.getController(); ``` ## inputMethod.getSetting9+ @@ -84,16 +84,16 @@ getSetting(): InputMethodSetting **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800007 | Input method settings extension error. | **示例:** ```js -let InputMethodSetting = inputMethod.getSetting(); +let inputMethodSetting = inputMethod.getSetting(); ``` ## inputMethod.switchInputMethod9+ @@ -115,9 +115,9 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -154,7 +154,7 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - |target | [InputmethodProperty](#inputmethodproperty8)| 是 | 传入要切换的目标输入法。 | + |target | [InputMethodProperty](#inputmethodproperty8)| 是 | 传入要切换的目标输入法。 | **返回值:** @@ -164,9 +164,9 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -201,7 +201,7 @@ getCurrentInputMethod(): InputMethodProperty | 类型 | 说明 | | -------------------------------------------- | ------------------------ | -| [InputmethodProperty](#inputmethodproperty8) | 返回当前输入法属性对象。 | +| [InputMethodProperty](#inputmethodproperty8) | 返回当前输入法属性对象。 | **示例:** @@ -228,9 +228,9 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -239,7 +239,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb ```js let inputMethodSubtype = { - id: "com.example.kikainput", + id: "com.example.kikakeyboard", label: "ServiceExtAbility", name: "", mode: "upper", @@ -290,9 +290,9 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean& **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -301,7 +301,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean& ```js let inputMethodSubtype = { - id: "com.example.kikainput", + id: "com.example.kikakeyboard", label: "ServiceExtAbility", name: "", mode: "upper", @@ -366,9 +366,9 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -382,7 +382,7 @@ let inputMethodProperty = { extra: {} } let inputMethodSubProperty = { - id: "com.example.kikainput", + id: "com.example.kikakeyboard", label: "ServiceExtAbility", name: "", mode: "upper", @@ -434,9 +434,9 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800005 | Configuration persisting error. | | 12800008 | Input method settings extension error. | @@ -445,19 +445,23 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp ```js let inputMethodProperty = { - name: "com.example.kikakeyboard", - id: "ServiceExtAbility" + packageName: "com.example.kikakeyboard", + methodId: "ServiceExtAbility", + extra: {} } let inputMethodSubProperty = { id: "com.example.kikakeyboard", - name: "", - locale: "", label: "ServiceExtAbility", - language: "", - extra : {} + name: "", + mode: "upper", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} } try { - inputMethod.switchCurrentInputMethodAndSubtype(property, subType).then((result) => { + inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((result) => { if (result) { console.info('Success to switchCurrentInputMethodAndSubtype.'); } else { @@ -492,7 +496,7 @@ getInputMethodController(): InputMethodController **示例:** ```js -let InputMethodController = inputMethod.getInputMethodController(); +let inputMethodController = inputMethod.getInputMethodController(); ``` ## inputMethod.getInputMethodSetting(deprecated) @@ -514,7 +518,7 @@ getInputMethodSetting(): InputMethodSetting **示例:** ```js -let InputMethodSetting = inputMethod.getInputMethodSetting(); +let inputMethodSetting = inputMethod.getInputMethodSetting(); ``` ## InputMethodController @@ -537,9 +541,9 @@ stopInputSession(callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -580,9 +584,9 @@ stopInputSession(): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -617,15 +621,15 @@ showSoftKeyboard(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -660,9 +664,9 @@ showSoftKeyboard(): Promise<void> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -689,15 +693,15 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -732,9 +736,9 @@ hideSoftKeyboard(): Promise<void> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -837,10 +841,8 @@ on(type: 'imeChange', callback: (inputMethodProperty: InputMethodProperty, input **示例:** ```js -let InputMethodSetting = inputMethod.getSetting(); -InputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => { - InputMethodProperty = inputMethodProperty; - InputMethodSubtype = inputMethodSubtype; +inputMethodSetting.on('imeChange', (inputMethodProperty, inputMethodSubtype) => { + console.info('Succeeded in subscribing imeChange: inputMethodProperty: ' + JSON.stringify(inputMethodProperty) + " , inputMethodSubtype: " + JSON.stringify(inputMethodSubtype)); }); ``` @@ -862,8 +864,7 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp **示例:** ```js -let InputMethodSetting = inputMethod.getSetting(); -InputMethodSetting.off('imeChange'); +inputMethodSetting.off('imeChange'); ``` ### listInputMethodSubtype9+ @@ -879,13 +880,13 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | | inputMethodProperty | InputMethodProperty| 是 | 指定获取子类型所属的输入法应用。 | -| callback | Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)> | 是 | 回调函数,返回指定输入法应用的所有子类型。 | +| callback | AsyncCallback<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | 是 | 回调函数,返回指定输入法应用的所有子类型。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -899,7 +900,7 @@ let inputMethodProperty = { extra:{} } try { - InputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { + inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err,data) => { if (err) { console.error('listInputMethodSubtype failed: ' + JSON.stringify(err)); return; @@ -933,9 +934,9 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -949,7 +950,7 @@ let inputMethodProperty = { extra:{} } try { - InputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { + inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { console.info('listInputMethodSubtype success'); }).catch((err) => { console.error('listInputMethodSubtype err: ' + JSON.stringify(err)); @@ -971,13 +972,13 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | -| callback | Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)> | 是 | 回调函数,返回当前输入法应用的所有子类型。 | +| callback | AsyncCallback<Array<[InputMethodSubtype](./js-apis-inputmethod-subtype.md#inputmethodsubtype)>> | 是 | 回调函数,返回当前输入法应用的所有子类型。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -986,7 +987,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback<Array<InputMethodSub ```js try { - InputMethodSetting.listCurrentInputMethodSubtype((err, data) => { + inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { if (err) { console.error('listCurrentInputMethodSubtype failed: ' + JSON.stringify(err)); return; @@ -1014,9 +1015,9 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -1025,7 +1026,7 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>> ```js try { - InputMethodSetting.listCurrentInputMethodSubtype().then((data) => { + inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { console.info('listCurrentInputMethodSubtype success'); }).catch((err) => { console.error('listCurrentInputMethodSubtype err: ' + err); @@ -1048,13 +1049,13 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------- | ---- | ----------------------------- | | enable | boolean | 是 | 指定返回已激活/未激活。 | -| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是 | 回调函数,返回已激活/未激活输入法列表。 | +| callback | AsyncCallback<Array<[InputMethodProperty](#inputmethodproperty8)>> | 是 | 回调函数,返回已激活/未激活输入法列表。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -1063,7 +1064,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback<Array<InputMethod ```js try { - InputMethodSetting.getInputMethods(true, (err,data) => { + inputMethodSetting.getInputMethods(true, (err,data) => { if (err) { console.error('getInputMethods failed: ' + JSON.stringify(err)); return; @@ -1091,9 +1092,9 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800001 | Package manager error. | | 12800008 | Input method settings extension error. | @@ -1108,7 +1109,7 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>> ```js try { - InputMethodSetting.getInputMethods(true).then((data) => { + inputMethodSetting.getInputMethods(true).then((data) => { console.info('getInputMethods success'); }).catch((err) => { console.error('getInputMethods err: ' + JSON.stringify(err)); @@ -1136,9 +1137,9 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800008 | Input method settings extension error. | @@ -1146,7 +1147,7 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void ```js try { - InputMethodSetting.showOptionalInputMethods((err, data) => { + inputMethodSetting.showOptionalInputMethods((err, data) => { if (err) { console.error('showOptionalInputMethods failed: ' + JSON.stringify(err)); return; @@ -1176,16 +1177,16 @@ showOptionalInputMethods(): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800008 | Input method settings extension error. | **示例:** ```js -InputMethodSetting.showOptionalInputMethods().then((data) => { +inputMethodSetting.showOptionalInputMethods().then((data) => { console.info('displayOptionalInputMethod success.'); }).catch((err) => { console.error('displayOptionalInputMethod err: ' + err); @@ -1208,12 +1209,12 @@ listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>) | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------------- | ---- | ---------------------- | -| callback | Array<[InputMethodProperty](#inputmethodproperty8)> | 是 | 回调函数,返回已安装的输入法列表。 | +| callback | AsyncCallback<Array<[InputMethodProperty](#inputmethodproperty8)>> | 是 | 回调函数,返回已安装的输入法列表。 | **示例:** ```js -InputMethodSetting.listInputMethod((err,data) => { +inputMethodSetting.listInputMethod((err,data) => { if (err) { console.error('listInputMethod failed because: ' + JSON.stringify(err)); return; @@ -1243,7 +1244,7 @@ listInputMethod(): Promise<Array<InputMethodProperty>> **示例:** ```js -InputMethodSetting.listInputMethod().then((data) => { +inputMethodSetting.listInputMethod().then((data) => { console.info('listInputMethod success'); }).catch((err) => { console.error('listInputMethod err: ' + JSON.stringify(err)); @@ -1271,7 +1272,7 @@ displayOptionalInputMethod(callback: AsyncCallback<void>): void **示例:** ```js -InputMethodSetting.displayOptionalInputMethod((err) => { +inputMethodSetting.displayOptionalInputMethod((err) => { if (err) { console.error('displayOptionalInputMethod failed because: ' + JSON.stringify(err)); return; @@ -1301,7 +1302,7 @@ displayOptionalInputMethod(): Promise<void> **示例:** ```js -InputMethodSetting.displayOptionalInputMethod().then(() => { +inputMethodSetting.displayOptionalInputMethod().then(() => { console.info('displayOptionalInputMethod success'); }).catch((err) => { console.error('displayOptionalInputMethod err: ' + err); diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md index d441dc68018c365df774f93d1bb3c582b5dab978..ceb131a45c167ddd38c0748944ee0c640ad07a78 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -18,7 +18,7 @@ import inputMethodEngine from '@ohos.inputmethodengine'; **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 值 | 说明 | +| 名称 | 类型 | 值 | 说明 | | -------- | -------- | -------- | -------- | | ENTER_KEY_TYPE_UNSPECIFIED | number | 0 | 无功能键。 | | ENTER_KEY_TYPE_GO | number | 2 | “前往”功能键。 | @@ -204,7 +204,7 @@ on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | void | 否 | 回调函数。 | +| callback | void | 是 | 回调函数。 | **示例:** @@ -463,7 +463,7 @@ inputMethodEngine.getInputMethodAbility().on('setSubtype', (inputMethodSubtype) ### off('setSubtype')9+ -off(ype: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void +off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void 取消订阅输入法子类型事件。使用callback异步回调。 @@ -474,7 +474,7 @@ off(ype: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => vo | 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | ------------------------------------------------------------ | | type | string | 是 | 设置监听类型。
- type为'setSubtype',表示取消订阅输入法子类型设置。
- type为'keyboardHide',表示订阅输入法隐藏。 | -| callback | InputMethodSubtype | 是 | 回调函数,返回调用方的输入法子类型。 | +| callback | InputMethodSubtype | 否 | 回调函数,返回调用方的输入法子类型。 | **示例:** @@ -708,13 +708,13 @@ hide(callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | -------- | -| callback | AsyncCallback<void> | 否 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象。 | **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -746,9 +746,9 @@ hide(): Promise<void> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -778,7 +778,7 @@ hideKeyboard(callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | -------- | -| callback | AsyncCallback<void> | 否 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当输入法隐藏成功,err为undefined,否则为错误对象。 | **示例:** @@ -841,9 +841,9 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -889,9 +889,9 @@ sendKeyFunction(action:number): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -930,9 +930,9 @@ getForward(length:number, callback: AsyncCallback<string>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -976,9 +976,9 @@ getForward(length:number): Promise<string> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1015,9 +1015,9 @@ getBackward(length:number, callback: AsyncCallback<string>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1061,9 +1061,9 @@ getBackward(length:number): Promise<string> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1100,9 +1100,9 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1150,9 +1150,9 @@ deleteForward(length:number): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1193,9 +1193,9 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1243,9 +1243,9 @@ deleteBackward(length:number): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1282,9 +1282,9 @@ insertText(text:string, callback: AsyncCallback<boolean>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1327,9 +1327,9 @@ insertText(text:string): Promise<boolean> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1368,9 +1368,9 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1403,9 +1403,9 @@ getEditorAttribute(): Promise<EditorAttribute> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1437,9 +1437,9 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1481,9 +1481,9 @@ moveCursor(direction: number): Promise<void> **错误码:** -以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)。 +以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1507,7 +1507,7 @@ try { **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------ | -------- | ---- | ---- | ------------------ | | enterKeyType | number | 是 | 否 | 编辑框的功能属性。 | | inputPattern | number | 是 | 否 | 编辑框的文本属性。 | @@ -1518,7 +1518,7 @@ try { **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ------------ | | keyCode | number | 是 | 否 | 按键的键值。 | | keyAction | number | 是 | 否 | 按键的状态。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md index 242b63a32ab5337185af44603502d634ae068b2b..d4ecfb44e1cb7da6e78cf86e0228ee9bfea5557f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -1,6 +1,7 @@ # 输入监听 输入监听模块,提供了监听输入设备事件(当前支持触摸屏和鼠标)的能力。 + > **说明:** > > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -26,13 +27,14 @@ on(type: "touch", receiver: TouchEventReceiver): void **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - **参数:** -| 参数 | 类型 | 必填 | 说明 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------- | | type | string | 是 | 输入设备事件类型,取值“touch”。 | | receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 回调函数,异步上报触摸屏输入事件。 | - **示例:** +**示例:** ```js try { @@ -45,6 +47,7 @@ try { } ``` +## inputMonitor.on9+ on(type: "mouse", receiver: Callback<MouseEvent>): void @@ -54,9 +57,9 @@ on(type: "mouse", receiver: Callback<MouseEvent>): void **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - **参数:** +**参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ------------------- | | type | string | 是 | 输入设备事件类型,取值“mouse”。 | | receiver | Callback<MouseEvent> | 是 | 回调函数,异步上报鼠标输入事件。 | @@ -86,13 +89,14 @@ off(type: "touch", receiver?: TouchEventReceiver): void **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - **参数:** -| 参数 | 类型 | 必填 | 说明 | +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------- | | type | string | 是 | 输入设备事件类型,取值“touch”。 | | receiver | [TouchEventReceiver](#toucheventreceiver) | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 | - **示例:** +**示例:** ```js // 取消监听单个回调函数 @@ -124,6 +128,8 @@ try { } ``` +## inputMonitor.off9+ + off(type: "mouse", receiver?: Callback<MouseEvent>): void 停止监听全局鼠标事件。 @@ -132,9 +138,9 @@ off(type: "mouse", receiver?: Callback<MouseEvent>): void **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - **参数:** +**参数:** -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------- | ---- | ------------------- | | type | string | 是 | 输入设备事件类型,取值“mouse”。 | | receiver | Callback<MouseEvent> | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 | @@ -179,22 +185,24 @@ try { **系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor - **参数:** +**参数:** + | 参数 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ---------------------------------------- | | touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | 是 | 触摸输入事件。 | - **返回值:** +**返回值:** + | 类型 | 说明 | | ------- | ---------------------------------------- | | Boolean | 若返回true,本次触摸后续产生的事件不再分发到窗口;若返回false,本次触摸后续产生的事件还会分发到窗口。 | - **示例:** +**示例:** ```js try { inputMonitor.on("touch", touchEvent => { - if (touchEvent.touches.size() == 3) { // 当前有三个手指按下 + if (touchEvent.touches.length == 3) { // 当前有三个手指按下 return true; } else { return false; diff --git a/zh-cn/application-dev/reference/apis/js-apis-installer.md b/zh-cn/application-dev/reference/apis/js-apis-installer.md index 9dcb496371bb59a6fcafc7e8f9554cf05f6bef97..47b19faffb278c0a6588e06707a93a3c89660e27 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-installer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-installer.md @@ -13,9 +13,9 @@ import installer from '@ohos.bundle.installer'; ## 权限列表 -| 权限 | 权限等级 | 描述 | -| ------------------------------------------ | ------------ | ------------------ | -| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 | +| 权限 | 权限等级 | 描述 | +| ------------------------------ | ----------- | ---------------- | +| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用 | 权限等级参考[权限等级说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/accesstoken-overview.md#%E6%9D%83%E9%99%90%E7%AD%89%E7%BA%A7%E8%AF%B4%E6%98%8E) @@ -31,13 +31,13 @@ getBundleInstaller(callback: AsyncCallback\): void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | callback | AsyncCallback\<[BundleInstaller](js-apis-installer.md#BundleInstaller)> | 是 | 回调函数,获取BundleInstaller对象,err为undefined,data为获取到的BundleInstaller对象;否则为错误对象 | **错误码:** -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 **示例:** @@ -74,7 +74,7 @@ getBundleInstaller(): Promise\; **错误码:** -错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 **示例:** @@ -105,7 +105,7 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback: **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | | hapFilePaths | Array<string> | 是 | 存储应用程序包的路径。路径应该是当前应用程序中存放HAP包的数据目录。当传入的路径是一个目录时, 该目录下只能放同一个应用的HAP包,且这些HAP包的签名需要保持一致 | | installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 | @@ -113,19 +113,19 @@ install(hapFilePaths: Array<string>, installParam: InstallParam, callback: **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | ---------------------------------------------------------------| -| 17700004 | The specified userId is not existed | -| 17700010 | To parse file of config.json or module.json failed | -| 17700011 | To verify signature failed | -| 17700012 | Invalid hap file path or too large file size | -| 17700015 | Multiple haps have inconsistent configured information | -| 17700016 | No disk space left for installation | -| 17700017 | Downgrade installation is prohibited | -| 17700101 | The system service is excepted | -| 17700103 | I/O operation is failed | +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------ | +| 17700004 | The specified userId is not existed | +| 17700010 | To parse file of config.json or module.json failed | +| 17700011 | To verify signature failed | +| 17700012 | Invalid hap file path or too large file size | +| 17700015 | Multiple haps have inconsistent configured information | +| 17700016 | No disk space left for installation | +| 17700017 | Downgrade installation is prohibited | +| 17700101 | The system service is excepted | +| 17700103 | I/O operation is failed | **示例:** @@ -169,7 +169,7 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | 是 | 包名 | | installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 | @@ -177,13 +177,13 @@ uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallbac **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | ---------------------------------------------------------------------------| -| 17700004 | The specified userId is not existed | -| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled | -| 17700101 | The system service is excepted | +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 17700004 | The specified userId is not existed | +| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled | +| 17700101 | The system service is excepted | **示例:** @@ -227,7 +227,7 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | | bundleName | string | 是 | 包名 | | installParam | [InstallParam](#installparam) | 是 | 指定安装所需的其他参数 | @@ -235,11 +235,11 @@ recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback& **错误码:** -以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errcode-bundle.md)。 +以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)。 -| 错误码ID | 错误码信息 | -| -------- | ---------------------------------------------------------------------------| -| 17700004 | The specified userId is not existed | +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 17700004 | The specified userId is not existed | **示例:** @@ -277,7 +277,7 @@ try { **系统接口:** 此接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 说明 | +| 参数名 | 类型 | 说明 | | ---------- | ------ | ---------------- | | moduleName | string | 应用程序模块名称 | | hashValue | string | 哈希值 | @@ -290,7 +290,7 @@ try { **系统接口:** 此接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 说明 | +| 参数名 | 类型 | 说明 | | ------------------------------ | ------------------------------ | ------------------ | | userId | number | 指示用户id,可使用[queryOsAccountLocalIdFromProcess](js-apis-osAccount.md#queryosaccountlocalidfromprocess9)获取当前进程所在用户 | | installFlag | number | 指示安装标志,枚举值:0:应用初次安装,1:应用覆盖安装 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keycode.md b/zh-cn/application-dev/reference/apis/js-apis-keycode.md index 150356c791aee490a2aa04facc354b2c10a51674..817111a4877788bf4e983a202a002e3bc1cb6221 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keycode.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keycode.md @@ -15,7 +15,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------------------------------- | ------ | ---- | ---- | --------------------------- | | KEYCODE_FN | number | 是 | 否 | 功能(Fn)键 | | KEYCODE_UNKNOWN | number | 是 | 否 | 未知按键 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md index d1ac98a67ae88626552bb6c8c02252bb5e351ace..b1bf555396839b7ab0570ab059cf1b255be796f2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-keyevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-keyevent.md @@ -16,7 +16,7 @@ import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | -------- | | CANCEL | number | 是 | 否 | 按键取消 | | DOWN | number | 是 | 否 | 按键按下 | @@ -26,7 +26,7 @@ import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | -------- | ---- | ---- | -------------- | | code | KeyCode | 是 | 否 | 按键码 | | pressedTime | number | 是 | 否 | 按键按下时间 | @@ -36,7 +36,7 @@ import {Action, Key, KeyEvent} from '@ohos.multimodalInput.keyEvent'; **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | -------- | ---- | ---- | ------------------------------ | | action | Action | 是 | 否 | 按键动作 | | key | Key | 是 | 否 | 当前上报的按键 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md new file mode 100644 index 0000000000000000000000000000000000000000..a3a0ace1ea6a67cdc9f0f9f650940eb592c6c59d --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-launcherBundleManager.md @@ -0,0 +1,267 @@ +# Bundle.launcherBundleManager模块 + +本模块支持launcher应用所需的查询能力,支持[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)、[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md)信息的查询。 + +> **说明:** +> +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; +``` + + +## launcherBundlemanager.**getLauncherAbilityInfo9+** + +getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallback>) : void; + +查询指定bundleName及用户的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用程序包名称。 | +| userId | number | 是 | 被查询的用户id。| + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------- | --------------------------------------------------- | +| AsyncCallback\> | callback形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息 | + +**相关错误码** + +| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700004 | The specified user id is not found. | + +**示例:** + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100, (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.Stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +getLauncherAbilityInfo(bundleName: string, userId: number) : Promise>; + +查询指定bundleName及用户的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)。 + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用程序包名称 。| +| userId | number | 是 | 被查询的用户id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | -------------------------------------------------- | +| Promise\> | Promise形式返回bundle包含的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md)信息 | + +**相关错误码** + +| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) | +| -------- | ---------------------------------------- | +| 17700001 | The specified bundle name is not found. | +| 17700004 | The specified user id is not found. | + +**示例:** + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100).then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getAllLauncherAbilityInfo9+ + +getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback>) : void; + +查询指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------ | ------ | ---- | -------------- | +| userId | number | 是 | 被查询的用户id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------- | ------------------------------------------------------- | +| AsyncCallback\> | callback形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) | + +**相关错误码** + +| 错误码 | 错误信息(此处仅提供错误抛出的关键信息) | +| -------- | ---------------------------------------- | +| 17700004 | The specified user id is not found. | + +示例: + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getAllLauncherAbilityInfo(100, (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +getAllLauncherAbilityInfo(userId: number) : Promise>; + +查询指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +**参数:** + +| 参数名 | 类型 | 必填 | 描述 | +| ------ | ------ | ---- | -------------- | +| userId | number | 是 | 被查询的用户id。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------- | ------------------------------------------------------ | +| Promise\> | Promise形式返回指定用户下所有应用的[LauncherAbilityInfo](js-apis-bundleManager-launcherAbilityInfo.md) | + +示例: + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getAllLauncherAbilityInfo(100).then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +## launcherBundlemanager.getShortcutInfo9+ + +getShortcutInfo(bundleName :string, callback: AsyncCallback>) : void; + +查询当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +| 参数名 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用程序包名称。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| AsyncCallback\> | callback形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) | + +示例: + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getShortcutInfo("com.example.demo", (errData, data) => { + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + } + console.log("data is " + JSON.stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` + +getShortcutInfo(bundleName : string) : Promise>; + +**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + +**系统接口:** 此接口为系统接口 + +**系统能力:** SystemCapability.BundleManager.BundleFramework.Launcher + +| 参数名 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | -------------- | +| bundleName | string | 是 | 应用程序包名称。 | + +**返回值:** + +| 类型 | 说明 | +| ---------------------- | ----------------------------------------------- | +| Promise\> | Promise形式返回当前用户下指定应用的[ShortcutInfo](js-apis-bundleManager-shortcutInfo.md) | + +示例: + +```typescript +import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; + +try { + launcherBundleManager.getShortcutInfo("com.example.demo").then(data => { + console.log("data is " + JSON.stringify(data)); + }).catch (errData => { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md index 2514ed13d36f220d75e6f70f757d50fd436152b6..52f81a6da39e6b4797058d00dfec9adf34f637de 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @@ -29,7 +29,7 @@ import LightWeightMap from '@ohos.util.LightWeightMap'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | LightWeightMap的元素个数。 | @@ -47,7 +47,7 @@ LightWeightMap的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The LightWeightMap's constructor cannot be directly invoked. | @@ -81,7 +81,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -122,7 +122,7 @@ hasAll(map: LightWeightMap): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasAll method cannot be bound. | @@ -167,7 +167,7 @@ hasKey(key: K): boolean; 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasKey method cannot be bound. | @@ -211,7 +211,7 @@ hasValue(value: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasValue method cannot be bound. | @@ -242,7 +242,7 @@ increaseCapacityTo(minimumCapacity: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The increaseCapacityTo method cannot be bound. | @@ -289,7 +289,7 @@ get(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -332,7 +332,7 @@ getIndexOfKey(key: K): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOfKey method cannot be bound. | @@ -375,7 +375,7 @@ getIndexOfValue(value: V): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOfValue method cannot be bound. | @@ -418,7 +418,7 @@ getKeyAt(index: number): K 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getKeyAt method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -461,7 +461,7 @@ setAll(map: LightWeightMap): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The setAll method cannot be bound. | @@ -505,7 +505,7 @@ set(key: K, value: V): Object 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The set method cannot be bound. | @@ -546,7 +546,7 @@ remove(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -589,7 +589,7 @@ removeAt(index: number): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeAt method cannot be bound. | @@ -633,7 +633,7 @@ setValueAt(index: number, newValue: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The setValueAt method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -682,7 +682,7 @@ getValueAt(index: number): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getValueAt method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -719,7 +719,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -756,7 +756,7 @@ keys(): IterableIterator<K> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The keys method cannot be bound. | @@ -798,7 +798,7 @@ values(): IterableIterator<V> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The values method cannot be bound. | @@ -848,7 +848,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -889,7 +889,7 @@ entries(): IterableIterator<[K, V]> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The entries method cannot be bound. | @@ -931,7 +931,7 @@ toString(): String 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The toString method cannot be bound. | @@ -967,7 +967,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index 64dcd50b28ddc85b09c099134cd3b5a5f6b35fca..fe447467d4044fb94b8a107af81d6813d54168af 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -30,7 +30,7 @@ import LightWeightSet from '@ohos.util.LightWeightSet'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | LightWeightSet的元素个数。 | @@ -47,7 +47,7 @@ LightWeightSet的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The LightWeightSet's constructor cannot be directly invoked. | @@ -81,7 +81,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -121,7 +121,7 @@ add(obj: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -156,7 +156,7 @@ addAll(set: LightWeightSet<T>): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The addAll method cannot be bound. | @@ -201,7 +201,7 @@ hasAll(set: LightWeightSet<T>): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasAll method cannot be bound. | @@ -246,7 +246,7 @@ has(key: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -289,7 +289,7 @@ equal(obj: Object): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The equal method cannot be bound. | @@ -327,7 +327,7 @@ increaseCapacityTo(minimumCapacity: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The increaseCapacityTo method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -374,7 +374,7 @@ getIndexOf(key: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOf method cannot be bound. | @@ -417,7 +417,7 @@ remove(key: T): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -460,7 +460,7 @@ removeAt(index: number): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeAt method cannot be bound. | @@ -503,7 +503,7 @@ getValueAt(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getValueAt method cannot be bound. | @@ -534,7 +534,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -571,7 +571,7 @@ toString(): String 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The toString method cannot be bound. | @@ -608,7 +608,7 @@ toArray(): Array<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The toArray method cannot be bound. | @@ -645,7 +645,7 @@ values(): IterableIterator<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The values method cannot be bound. | @@ -695,7 +695,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -736,7 +736,7 @@ entries(): IterableIterator<[T, T]> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The entries method cannot be bound. | @@ -778,7 +778,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 46efb533394a4cbe1f7fdede32914192ef93cd52..471698ed66ea72bf336fd0f49bb3e71829d3bb1f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -29,7 +29,7 @@ import LinkedList from '@ohos.util.LinkedList'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | LinkedList的元素个数。 | @@ -46,7 +46,7 @@ LinkedList的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The LinkedList's constructor cannot be directly invoked. | @@ -87,7 +87,7 @@ add(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -127,7 +127,7 @@ addFirst(element: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The addFirst method cannot be bound. | @@ -168,7 +168,7 @@ insert(index: number, element: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The insert method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -216,7 +216,7 @@ has(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -258,7 +258,7 @@ get(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -305,7 +305,7 @@ getLastIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLastIndexOf method cannot be bound. | @@ -352,7 +352,7 @@ getIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOf method cannot be bound. | @@ -399,7 +399,7 @@ removeByIndex(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeByIndex method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -444,7 +444,7 @@ removeFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeFirst method cannot be bound. | | 10200010 | Container is empty. | @@ -489,7 +489,7 @@ removeLast(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeLast method cannot be bound. | | 10200010 | Container is empty. | @@ -540,7 +540,7 @@ remove(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -584,7 +584,7 @@ removeFirstFound(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeFirstFound method cannot be bound. | | 10200010 | Container is empty. | @@ -594,7 +594,7 @@ removeFirstFound(element: T): boolean ```ts let linkedList = new LinkedList(); try { - linkedList.removeFirstFound(); + linkedList.removeFirstFound(4); } catch(err) { console.log(`${err.code} - ${err.name} - ${err.message}`); } @@ -634,7 +634,7 @@ removeLastFound(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeLastFound method cannot be bound. | | 10200010 | Container is empty. | @@ -678,7 +678,7 @@ clone(): LinkedList<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clone method cannot be bound. | @@ -726,7 +726,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -762,7 +762,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -807,7 +807,7 @@ set(index: number, element: T): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The set method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -851,7 +851,7 @@ convertToArray(): Array<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The convertToArray method cannot be bound. | @@ -888,7 +888,7 @@ getFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getFirst method cannot be bound. | @@ -926,7 +926,7 @@ getLast(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLast method cannot be bound. | @@ -964,7 +964,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index 0d2eb8595d2791af97b275ad20daf413258c4193..dd72faa764685356fb33f1e76615ae67a877293f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -25,7 +25,7 @@ import List from '@ohos.util.List'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | List的元素个数。 | @@ -42,7 +42,7 @@ List的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The List's constructor cannot be directly invoked. | @@ -82,7 +82,7 @@ add(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -123,7 +123,7 @@ insert(element: T, index: number): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The insert method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -171,7 +171,7 @@ has(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -213,7 +213,7 @@ get(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -260,7 +260,7 @@ getLastIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLastIndexOf method cannot be bound. | @@ -307,7 +307,7 @@ getIndexOf(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOf method cannot be bound. | @@ -355,7 +355,7 @@ equal(obj: Object): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The equal method cannot be bound. | @@ -405,7 +405,7 @@ removeByIndex(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeByIndex method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -456,7 +456,7 @@ remove(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -504,7 +504,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The replaceAllElements method cannot be bound. | @@ -559,7 +559,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -609,7 +609,7 @@ comparator的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The sort method cannot be bound. | @@ -655,7 +655,7 @@ getSubList(fromIndex: number, toIndex: number): List<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getSubList method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -695,7 +695,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -740,7 +740,7 @@ set(index: number, element: T): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The set method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -784,7 +784,7 @@ convertToArray(): Array<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The convertToArray method cannot be bound. | @@ -822,7 +822,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -860,7 +860,7 @@ getFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getFirst method cannot be bound. | @@ -898,7 +898,7 @@ getLast(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLast method cannot be bound. | @@ -936,7 +936,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 32319b0f5e36631db7f00257255834b220947330..94e38c88cfe4f0b51cc613bea4293c5d85829b67 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -1080,7 +1080,7 @@ seek(timeMs: number, mode?:SeekMode): Promise\ | 类型 | 说明 | | -------------- | ------------------------------------------- | -| Promise\ | 跳转到指定播放位置的Promise返回值,单位ms。 | +| Promise\ | 跳转到指定播放位置的Promise返回值,单位ms。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md index e576e6611ddd5adce1afe4c1a16c478309bf90f8..9df3148c907354854aed3c1b606b9d24b18441a0 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-mouseevent.md @@ -15,7 +15,7 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | -------- | ---- | ---- | -------------------- | | CANCEL | number | 是 | 否 | 取消 | | MOVE | number | 是 | 否 | 鼠标移动 | @@ -30,7 +30,7 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------- | ------ | ---- | ---- | ----- | | LEFT | number | 是 | 否 | 鼠标左键 | | MIDDLE | number | 是 | 否 | 鼠标中键 | @@ -45,7 +45,7 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------------- | ------ | ---- | ---- | ----- | | SCROLL_VERTICAL | number | 是 | 否 | 垂直滚动轴 | | SCROLL_HORIZONTAL | number | 是 | 否 | 水平滚动轴 | @@ -56,7 +56,7 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----- | ------ | ---- | ---- | ---- | | axis | Axis | 是 | 否 | 轴类型 | | value | number | 是 | 否 | 轴的值 | @@ -66,7 +66,7 @@ import {Action,Button,Axis,AxisValue,MouseEvent} from '@ohos.multimodalInput.mou **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------------- | ----------- | ---- | ---- | ---------------------------------------- | | action | Action | 是 | 否 | 鼠标事件动作 | | screenX | number | 是 | 否 | 鼠标光标在屏幕中的横坐标 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index 71a0bee5b2b0e60b8ee2984768de9fa1c4891da5..e2aa810f1382baeea9df6845f028ef2cbec3d9e2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -315,12 +315,272 @@ getTagInfo(want: [Want](js-apis-application-Want.md#Want)): [TagInfo](#taginfo) | ------------------ | --------------------------| | [TagInfo](#taginfo) | TagInfo对象,用于获取不同技术类型的Tag对象。 | + +## tag.ndef.makeUriRecord9+ + +makeUriRecord(uri: string): [NdefRecord](#ndefrecord9); + +根据输入的URI,构建NDEF标签的Record数据对象。 + +**系统能力**:SystemCapability.Communication.NFC.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| uri | string | 是 | 写入到NDEF Record里面的数据内容。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +try { + let uri = "https://gitee.com/openharmony"; // change it to be correct. + let ndefRecord = tag.ndef.makeUriRecord(uri); + if (ndefRecord != undefined) { + console.log("ndefMessage makeUriRecord rtdType: " + ndefRecord.rtdType); + console.log("ndefMessage makeUriRecord payload: " + ndefRecord.payload); + } else { + console.log("ndefMessage makeUriRecord ndefRecord: " + ndefRecord); + } +} catch (busiError) { + console.log("ndefMessage makeUriRecord catched busiError: " + busiError); +} +``` + +## tag.ndef.makeTextRecord9+ + +makeTextRecord(text: string, locale: string): [NdefRecord](#ndefrecord9); + +根据输入的文本数据和编码类型,构建NDEF标签的Record。 + +**系统能力**:SystemCapability.Communication.NFC.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| text | string | 是 | 写入到NDEF Record里面的文本数据内容。 | +| locale | string | 是 | 文本数据内容的编码方式。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +try { + let text = "Hello World"; // change it to be correct. + let locale = "en"; // change it to be correct. + let ndefRecord = tag.ndef.makeTextRecord(text, locale); + if (ndefRecord != undefined) { + console.log("ndefMessage makeTextRecord rtdType: " + ndefRecord.rtdType); + console.log("ndefMessage makeTextRecord payload: " + ndefRecord.payload); + } else { + console.log("ndefMessage makeTextRecord ndefRecord: " + ndefRecord); + } +} catch (busiError) { + console.log("ndefMessage makeTextRecord catched busiError: " + busiError); +} +``` + + +## tag.ndef.makeMimeRecord9+ + +makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](#ndefrecord9); + +根据输入的MIME数据和类型,构建NDEF标签的Record。 + +**系统能力**:SystemCapability.Communication.NFC + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| mimeType | string | 是 | 符合RFC规则的MIME类型,比如"text/plain"或"image/jpeg"。 | +| mimeData | number[] | 是 | MIME数据内容,每个number十六进制表示,范围是0x00~0xFF。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +try { + let mimeType = "text/plain"; // change it to be correct. + let mimeData = [0x01, 0x02, 0x03, 0x04, ...]; // change it to be correct. + let ndefRecord = tag.ndef.makeMimeRecord(mimeType, mimeData); + if (ndefRecord != undefined) { + console.log("ndefMessage makeMimeRecord rtdType: " + ndefRecord.rtdType); + console.log("ndefMessage makeMimeRecord payload: " + ndefRecord.payload); + } else { + console.log("ndefMessage makeMimeRecord ndefRecord: " + ndefRecord); + } +} catch (busiError) { + console.log("ndefMessage makeMimeRecord catched busiError: " + busiError); +} +``` +## tag.ndef.makeExternalRecord9+ + +makeExternalRecord(domainName: string, type: string, externalData: number[]): [NdefRecord](#ndefrecord9); + +根据应用程序特定的外部数据,构建NDEF标签的Record。 + +**系统能力**:SystemCapability.Communication.NFC + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| domainName | string | 是 | 外部数据发布组织的域名,一般是应用程序的包名。 | +| type | string | 是 | 外部数据的指定类型。 | +| externalData | number[] | 是 | 外部数据内容,每个number十六进制表示,范围是0x00~0xFF。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +try { + let domainName = "ohos.nfc.application"; // change it to be correct. + let type = "test"; // change it to be correct. + let externalData = [0x01, 0x02, 0x03, 0x04, ...]; // change it to be correct. + let ndefRecord = tag.ndef.makeExternalRecord(domainName, type, externalData); + if (ndefRecord != undefined) { + console.log("ndefMessage makeExternalRecord rtdType: " + ndefRecord.rtdType); + console.log("ndefMessage makeExternalRecord payload: " + ndefRecord.payload); + } else { + console.log("ndefMessage makeExternalRecord ndefRecord: " + ndefRecord); + } +} catch (busiError) { + console.log("ndefMessage makeExternalRecord catched busiError: " + busiError); +} +``` + +## tag.ndef.messageToBytes9+ + +messageToBytes(ndefMessage: [NdefMessage](js-apis-nfctech.md#ndefmessage9)): number[]; + +把输入的NDEF消息数据对象,转换为字节格式的数据。 + +**系统能力**:SystemCapability.Communication.NFC + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | 是 | NDEF消息数据对象。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| number[] | NDEF消息数据对象,所转换成的字节格式的数据。每个number十六进制表示,范围是0x00~0xFF。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +let rawData = [0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]; // MUST can be parsed as NDEF Record. +let ndefMessage; +try { + ndefMessage = tag.ndef.createNdefMessage(rawData); + console.log("ndef createNdefMessage, ndefMessage: " + ndefMessage); +} catch (busiError) { + console.log("ndef createNdefMessage busiError: " + busiError); +} + +try { + let rawData2 = tag.ndef.messageToBytes(ndefMessage); + console.log("ndefMessage messageToBytes rawData2: " + rawData2); +} catch (busiError) { + console.log("ndefMessage messageToBytes catched busiError: " + busiError); +} +``` +## tag.ndef.createNdefMessage9+ + +createNdefMessage(data: number[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9) + +使用原始字节数据创建NDEF标签的Message。该数据必须符合NDEF Record数据格式,如果不符合格式,则返回的NdeMessage数据对象,所包含的NDE Record列表会为空。 + +**系统能力**:SystemCapability.Communication.NFC + +**参数:** +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| data | number[] | 是 | 原始字节,每个number十六进制表示,范围是0x00~0xFF。要求必须满足NDEF Record的格式。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +let rawData = [0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]; // MUST can be parsed as NDEF Record. +let ndefMessage; +try { + ndefMessage = tag.ndef.createNdefMessage(rawData); + console.log("ndef createNdefMessage, ndefMessage: " + ndefMessage); +} catch (busiError) { + console.log("ndef createNdefMessage busiError: " + busiError); +} +``` + +## tag.ndef.createNdefMessage9+ + +createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9) + +使用NDEF Records列表,创建NDEF Message。 + +**系统能力**:SystemCapability.Communication.NFC.Core + +**参数:** +| **参数名** | **类型** | **必填** | **说明** | +| -------- | -------- | -------- | -------- | +| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | 是 | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | + +**返回值:** +| **类型** | **说明** | +| ------------------ | --------------------------| +| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。| + +**示例:** +```js +import tag from '@ohos.nfc.tag'; + +let uriRecord = tag.ndef.makeUriRecord("https://gitee.com/openharmony"); +let textRecord = tag.ndef.makeTextRecord("Hello World", "en"); +let ndefRecords = [uriRecord, textRecord]; +let ndefMessage; +try { + ndefMessage = tag.ndef.createNdefMessage(ndefRecords); + console.log("ndef createNdefMessage ndefMessage: " + ndefMessage); +} catch (busiError) { + console.log("ndef createNdefMessage busiError: " + busiError); +} +``` + ## TagInfo NFC服务在读取到标签时给出的对象,通过改对象属性,应用知道该标签支持哪些技术类型,并使用匹配的技术类型来调用相关接口。 **系统能力**:SystemCapability.Communication.NFC.Core +**需要权限**:ohos.permission.NFC_TAG + | **参数名** | **类型** | **说明** | | -------- | -------- | -------- | | uid9+ | number[] | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。 | @@ -331,6 +591,7 @@ NFC服务在读取到标签时给出的对象,通过改对象属性,应用 NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **类型** | **说明** | | -------- | -------- | -------- | | tnf | number | NDEF Record的TNF(Type Name Field)。 | @@ -342,22 +603,24 @@ NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDE NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | -| NFC_A | 1 | NFC-A(ISO 14443-3A)技术。| -| NFC_B | 2 | NFC-A(ISO 14443-3B)技术。| -| ISO_DEP | 3 | ISO-DEP(ISO 14443-4)技术。| -| NFC_F | 4 | NFC-F(JIS 6319-4)技术。| -| NFC_V | 5 | NFC-V(ISO 15693)技术。| +| NFC_A | 1 | NFC-A (ISO 14443-3A)技术。| +| NFC_B | 2 | NFC-A (ISO 14443-3B)技术。| +| ISO_DEP | 3 | ISO-DEP (ISO 14443-4)技术。| +| NFC_F | 4 | NFC-F (JIS 6319-4)技术。| +| NFC_V | 5 | NFC-V (ISO 15693)技术。| | NDEF | 6 | NDEF技术。| +| NDEF_FORMATABLE9+ | 7 | 可以格式化的NDEF技术。| | MIFARE_CLASSIC | 8 | MIFARE Classic技术。| | MIFARE_ULTRALIGHT | 9 | MIFARE Utralight技术。| -| NDEF_FORMATABLE9+ | 10 | 可以格式化的NDEF技术。| ## TnfType9+ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | | TNF_EMPTY | 0x0 | Empty。| @@ -372,6 +635,7 @@ NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFC NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | | RTD_TEXT9+ | [0x54] | 文本类型的NDEF Record。| @@ -381,6 +645,7 @@ NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规 NFC Forum标准里面Tag类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | | NFC_FORUM_TYPE_1 | 1 | NFC论坛类型1。 | @@ -393,9 +658,10 @@ NFC Forum标准里面Tag类型的定义。 MIFARE Classic标签类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | -| TYPE_UNKNOWN | 0 | 未知MIFARE类型。 | +| TYPE_UNKNOWN | 0 | 未知的MIFARE类型。 | | TYPE_CLASSIC | 1 | MIFARE Classic类型。| | TYPE_PLUS | 2 | MIFARE Plus类型。| | TYPE_PRO | 3 | MIFARE Pro类型。 | @@ -404,6 +670,7 @@ MIFARE Classic标签类型的定义。 MIFARE Classic标签存储大小的定义。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | | MC_SIZE_MINI | 320 | 每个标签5个扇区,每个扇区4个块。 | @@ -415,6 +682,7 @@ MIFARE Classic标签存储大小的定义。 MIFARE Ultralight标签类型的定义。 **系统能力**:SystemCapability.Communication.NFC.Core + | **参数名** | **常量值** | **说明** | | -------- | -------- | -------- | | TYPE_UNKOWN | 0 | 未知的 MIFARE 类型。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md index f198cca93ffad384df83c41be315cc0a0c252b7c..159daa8d2819971d08ec506ae7465167f400835a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfctech.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfctech.md @@ -173,7 +173,7 @@ getPmm(): number[] **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -207,7 +207,7 @@ getResponseFlags(): number **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -233,7 +233,7 @@ getDsfId(): number **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** @@ -265,7 +265,7 @@ getHistoricalBytes(): number[] 获取标签的历史字节,针对基于NfcA通信技术的IsoDep卡片。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -287,7 +287,7 @@ getHiLayerResponse(): number[] 获取标签的更高层响应字节,针对基于NfcB通信技术的IsoDep卡片。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -311,7 +311,7 @@ isExtendedApduSupported(): Promise<boolean> **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -358,7 +358,7 @@ isExtendedApduSupported(callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -405,7 +405,7 @@ getNdefRecords(): [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] 获取NDEF消息中的所有记录。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -416,213 +416,14 @@ getNdefRecords(): [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] ```js import tag from '@ohos.nfc.tag'; -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. -// var ndefMessage = ndefTag.createNdefMessage(...); +// Obtains ndefMessage from tag.ndef.createNdefMessage or ndefTag.getNdefMessage. +// var ndefMessage = tag.ndef.createNdefMessage(...); // var ndefMessage = ndefTag.getNdefMessage(); let ndefRecords = ndefMessage.getNdefRecords(); console.log("ndef ndefRecords number: " + ndefRecords.length); ``` -### NdefMessage.makeUriRecord9+ - -makeUriRecord(uri: string): [NdefRecord](js-apis-nfcTag.md#ndefrecord9); - -根据输入的URI,构建NDEF标签的Record数据对象。 - -**系统能力**:SystemCapability.Communication.NFC -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| uri | string | 是 | 写入到NDEF Record里面的数据内容。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefRecord](js-apis-nfcTag.md#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. Such as: -// var ndefMessage = ndefTag.createNdefMessage(...); -// var ndefMessage = ndefTag.getNdefMessage(); - -try { - let uri = "https://gitee.com/openharmony"; // change it to be correct. - let ndefRecord = ndefMessage.makeUriRecord(uri); - if (ndefRecord != undefined) { - console.log("ndefMessage makeUriRecord rtdType: " + ndefRecord.rtdType); - console.log("ndefMessage makeUriRecord payload: " + ndefRecord.payload); - } else { - console.log("ndefMessage makeUriRecord ndefRecord: " + ndefRecord); - } -} catch (busiError) { - console.log("ndefMessage makeUriRecord catched busiError: " + busiError); -} -``` - -### NdefMessage.makeTextRecord9+ - -makeTextRecord(text: string, locale: string): [NdefRecord](js-apis-nfcTag.md#ndefrecord9); - -根据输入的文本数据和编码类型,构建NDEF标签的Record。 - -**系统能力**:SystemCapability.Communication.NFC -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| text | string | 是 | 写入到NDEF Record里面的文本数据内容。 | -| locale | string | 是 | 文本数据内容的编码方式。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefRecord](js-apis-nfcTag.md#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. Such as: -// var ndefMessage = ndefTag.createNdefMessage(...); -// var ndefMessage = ndefTag.getNdefMessage(); - -try { - let text = "Hello World"; // change it to be correct. - let locale = "utf8"; // change it to be correct. - let ndefRecord = ndefMessage.makeTextRecord(text, locale); - if (ndefRecord != undefined) { - console.log("ndefMessage makeTextRecord rtdType: " + ndefRecord.rtdType); - console.log("ndefMessage makeTextRecord payload: " + ndefRecord.payload); - } else { - console.log("ndefMessage makeTextRecord ndefRecord: " + ndefRecord); - } -} catch (busiError) { - console.log("ndefMessage makeTextRecord catched busiError: " + busiError); -} -``` - - -### NdefMessage.makeMimeRecord9+ - -makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](js-apis-nfcTag.md#ndefrecord9); - -根据输入的MIME数据和类型,构建NDEF标签的Record。 - -**系统能力**:SystemCapability.Communication.NFC -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| mimeType | string | 是 | MIME数据的类型。 | -| mimeData | number[] | 是 | MIME数据内容。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefRecord](js-apis-nfcTag.md#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. Such as: -// var ndefMessage = ndefTag.createNdefMessage(...); -// var ndefMessage = ndefTag.getNdefMessage(); - -try { - let mimeType = "media"; // change it to be correct. - let mimeData = [0x01, 0x02, 0x03, 0x04]; // change it to be correct. - let ndefRecord = ndefMessage.makeMimeRecord(mimeType, mimeData); - if (ndefRecord != undefined) { - console.log("ndefMessage makeMimeRecord rtdType: " + ndefRecord.rtdType); - console.log("ndefMessage makeMimeRecord payload: " + ndefRecord.payload); - } else { - console.log("ndefMessage makeMimeRecord ndefRecord: " + ndefRecord); - } -} catch (busiError) { - console.log("ndefMessage makeMimeRecord catched busiError: " + busiError); -} -``` -### NdefMessage.makeExternalRecord9+ - -makeExternalRecord(domainName: string, serviceName: string, externalData: number[]): [NdefRecord](js-apis-nfcTag.md#ndefrecord9); - -根据应用程序特定的外部数据,构建NDEF标签的Record。 - -**系统能力**:SystemCapability.Communication.NFC -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| domainName | string | 是 | 外部数据发布组织的域名,一般是应用程序的包名。 | -| serviceName | string | 是 | 外部数据的指定类型。 | -| externalData | number[] | 是 | 外部数据内容。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefRecord](js-apis-nfcTag.md#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. Such as: -// var ndefMessage = ndefTag.createNdefMessage(...); -// var ndefMessage = ndefTag.getNdefMessage(); - -try { - let domainName = "ohos.nfc.application"; // change it to be correct. - let type = "nfc"; // change it to be correct. - let externalData = [0x01, 0x02, 0x03, 0x04]; // change it to be correct. - let ndefRecord = ndefMessage.makeExternalRecord(domainName, type, externalData); - if (ndefRecord != undefined) { - console.log("ndefMessage makeExternalRecord rtdType: " + ndefRecord.rtdType); - console.log("ndefMessage makeExternalRecord payload: " + ndefRecord.payload); - } else { - console.log("ndefMessage makeExternalRecord ndefRecord: " + ndefRecord); - } -} catch (busiError) { - console.log("ndefMessage makeExternalRecord catched busiError: " + busiError); -} -``` - -### NdefMessage.messageToBytes9+ - -messageToBytes(ndefMessage: [NdefMessage](#ndefmessage9)): number[]; - -把输入的NDEF消息数据对象,转换为字节格式的数据。 - -**系统能力**:SystemCapability.Communication.NFC -**参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------- | ---- | -------------------------------------- | -| ndefMessage | [NdefMessage](#ndefmessage9) | 是 | NDEF消息数据对象。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| number[] | NDEF消息数据对象,所转换成的字节格式的数据。每个number十六进制表示,范围是0x00~0xFF。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see NdefTag, obtains ndefMessage from ndefTag.createNdefMessage or ndefTag.getNdefMessage. Such as: -// var ndefMessage = ndefTag.createNdefMessage(...); -// var ndefMessage = ndefTag.getNdefMessage(); - -try { - // the parameter 'ndefMessage' can be different from the instance object. - let rawData = ndefMessage.messageToBytes(ndefMessage); - console.log("ndefMessage messageToBytes rawData: " + rawData); -} catch (busiError) { - console.log("ndefMessage messageToBytes catched busiError: " + busiError); -} -``` - ## NdefTag9+ 提供对已格式化为NDEF的NFC标签的数据和操作的访问,继承自TagSession。 @@ -631,88 +432,13 @@ TagSession是所有NFC Tag技术类型的基类, 提供建立连接和发送 以下是NdefTag的独有接口。 -### NdefTag.createNdefMessage9+ - -createNdefMessage(data: number[]): [NdefMessage](#ndefmessage9) - -使用原始字节数据创建NDEF标签的Message。该数据必须符合NDEF Record数据格式,如果不符合格式,则返回的NdeMessage数据对象,所包含的NDE Record列表会为空。 - -**系统能力**:SystemCapability.Communication.NFC - -**参数:** -| **参数名** | **类型** | **必填** | **说明** | -| -------- | -------- | -------- | -------- | -| data | number[] | 是 | 原始字节,每个number十六进制表示,范围是0x00~0xFF。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefMessage](#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly. -let rawData = [0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]; // change the raw data bytes to be correct. -let ndefMessage; -try { - ndefMessage = ndefTag.createNdefMessage(rawData); - console.log("ndef createNdefMessage, ndefMessage: " + ndefMessage); -} catch (busiError) { - console.log("ndef createNdefMessage busiError: " + busiError); -} -``` - -### NdefTag.createNdefMessage9+ - -createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](#ndefmessage9) - -使用NDEF Records列表,创建NDEF Message。 - -**系统能力**:SystemCapability.Communication.NFC - -**参数:** -| **参数名** | **类型** | **必填** | **说明** | -| -------- | -------- | -------- | -------- | -| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | 是 | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 | - -**返回值:** -| **类型** | **说明** | -| ------------------ | --------------------------| -| [NdefMessage](#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。| - -**示例:** -```js -import tag from '@ohos.nfc.tag'; - -// see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly. -let ndefRecords = [ - // record format: tnf, rtdType, id, payload - // 1st record: - {tnf: 0x01, rtdType: [0x54], id: [0x01, 0x02, ...], payload: [0x00, 0xa4, 0x04, ...]}, - - // 2nd record: - {tnf: 0x02, rtdType: [0x55], id: [0x03, 0x04, ...], payload: [0x00, 0xa4, 0x04, ...]}, - - // other record if has one ... -]; -let ndefMessage; -try { - ndefMessage = ndefTag.createNdefMessage(ndefRecords); - console.log("ndef createNdefMessage ndefMessage: " + ndefMessage); -} catch (busiError) { - console.log("ndef createNdefMessage busiError: " + busiError); -} -``` - ### NdefTag.getNdefTagType9+ getNdefTagType(): NfcForumType 获取NDEF标签的类型。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -734,7 +460,7 @@ getNdefMessage(): NdefMessage 获取发现NDEF标签时,从标签读取的Message。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -756,7 +482,7 @@ isNdefWritable(): boolean; 检查NDEF标签是否可写。在调用写数据接口前,需要先判断是否支持写操作。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -780,7 +506,7 @@ readNdef(): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -826,7 +552,7 @@ readNdef(callback: AsyncCallback\<[NdefMessage](#ndefmessage9)>): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -874,7 +600,7 @@ writeNdef(msg: NdefMessage): Promise\; **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -893,8 +619,8 @@ import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly. // ndefMessage created from raw data, such as: -let ndefMessage = ndefTag.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // change the raw data to be correct. -// or ndefMessage created from ndefTag.createNdefMessage(ndefRecords: NdefRecord[]) +let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record. +// or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[]) // connect the tag at first if not connected. if (!ndefTag.isTagConnected()) { @@ -923,7 +649,7 @@ writeNdef(msg: NdefMessage, callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -943,8 +669,8 @@ import tag from '@ohos.nfc.tag'; // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly. // ndefMessage created from raw data, such as: -let ndefMessage = ndefTag.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // change the raw data to be correct. -// or ndefMessage created from ndefTag.createNdefMessage(ndefRecords: NdefRecord[]) +let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record. +// or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[]) // connect the tag at first if not connected. if (!ndefTag.isTagConnected()) { @@ -975,7 +701,7 @@ canSetReadOnly(): boolean **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -1005,7 +731,7 @@ setReadOnly(): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **错误码:** 以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)。 @@ -1046,7 +772,7 @@ setReadOnly(callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1092,7 +818,7 @@ getNdefTagTypeString(type: [NfcForumType](js-apis-nfcTag.md#nfcforumtype9)): str 将NFC论坛类型,转换为NFC论坛中定义的字符串描述。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1134,7 +860,7 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1184,7 +910,7 @@ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1237,7 +963,7 @@ readSingleBlock(blockIndex: number): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1289,7 +1015,7 @@ readSingleBlock(blockIndex: number, callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1339,7 +1065,7 @@ writeSingleBlock(blockIndex: number, data: number[]): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1388,7 +1114,7 @@ writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1489,7 +1215,7 @@ incrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1541,7 +1267,7 @@ decrementBlock(blockIndex: number, value: number): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1590,7 +1316,7 @@ decrementBlock(blockIndex: number, value: number, callback: AsyncCallback\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1642,7 +1368,7 @@ transferToBlock(blockIndex: number): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1689,7 +1415,7 @@ transferToBlock(blockIndex: number, callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1739,7 +1465,7 @@ restoreFromBlock(blockIndex: number): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1786,7 +1512,7 @@ restoreFromBlock(blockIndex: number, callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1834,7 +1560,7 @@ getSectorCount(): number 获取MIFARE Classic标签中的扇区数。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -1856,7 +1582,7 @@ getBlockCountInSector(sectorIndex: number): number 获取指定扇区中的块数。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1889,7 +1615,7 @@ getType(): [MifareClassicType](js-apis-nfcTag.md#mifareclassictype9) 获取MIFARE Classic标签的类型。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -1911,7 +1637,7 @@ getTagSize(): number 获取标签的存储空间大小,具体请参见[MifareClassicSize](js-apis-nfcTag.md#mifareclassicsize9)。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -1933,7 +1659,7 @@ isEmulatedTag(): boolean 检查标签是不是被模拟的。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **返回值:** | **类型** | **说明** | @@ -1955,7 +1681,7 @@ getBlockIndex(sectorIndex: number): number 获取特定扇区的第一个块的序号。 -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1990,7 +1716,7 @@ getSectorIndex(blockIndex: number): number **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2033,7 +1759,7 @@ readMultiplePages(pageIndex: number): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** @@ -2087,7 +1813,7 @@ readMultiplePages(pageIndex: number, callback: AsyncCallback\): void **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2137,7 +1863,7 @@ writeSinglePage(pageIndex: number, data: number[]): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2186,7 +1912,7 @@ writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2298,8 +2024,8 @@ if (!ndefFormatable.isTagConnected()) { try { // ndefMessage created from raw data, such as: - let ndefMessage = ndefTag.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // change the raw data to be correct. - // or ndefMessage created from ndefTag.createNdefMessage(ndefRecords: NdefRecord[]) + let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record. + // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[]) ndefFormatable.format(ndefMessage).then(() => { console.log("ndefFormatable format Promise success."); @@ -2319,7 +2045,7 @@ format(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\): v **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2348,8 +2074,8 @@ if (!ndefFormatable.isTagConnected()) { try { // ndefMessage created from raw data, such as: - let ndefMessage = ndefTag.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // change the raw data to be correct. - // or ndefMessage created from ndefTag.createNdefMessage(ndefRecords: NdefRecord[]) + let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record. + // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[]) ndefFormatable.format(ndefMessage, (err)=> { if (err) { @@ -2371,7 +2097,7 @@ formatReadOnly(message: [NdefMessage](#ndefmessage9)): Promise\ **需要权限**:ohos.permission.NFC_TAG -**系统能力**:SystemCapability.Communication.NFC +**系统能力**:SystemCapability.Communication.NFC.Core **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2400,8 +2126,8 @@ if (!ndefFormatable.isTagConnected()) { try { // ndefMessage created from raw data, such as: - let ndefMessage = ndefTag.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // change the raw data to be correct. - // or ndefMessage created from ndefTag.createNdefMessage(ndefRecords: NdefRecord[]) + let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record. + // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[]) ndefFormatable.formatReadOnly(ndefMessage).then(() => { console.log("ndefFormatable formatReadOnly Promise success."); @@ -2421,7 +2147,7 @@ formatReadOnly(message: [NdefMessage](#ndefmessage9), callback: AsyncCallback\ { if (err) { diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index c3633af4282dafbbaddee308d58eb327dc505ff0..212c3514f0f15998814642c9c0c1ed6866b162ab 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -3967,10 +3967,10 @@ Notification.subscribe(subscriber, subscribeCallback); | deliveryTime | 是 | 是 | number | 通知发送时间。 | | tapDismissed | 是 | 是 | boolean | 通知是否自动清除。 | | autoDeletedTime | 是 | 是 | number | 自动清除的时间。 | -| wantAgent | 是 | 是 | WantAgent | 点击跳转的WantAgent。 | +| wantAgent | 是 | 是 | WantAgent | WantAgent封装了应用的行为意图,点击通知时触发该行为。 | | extraInfo | 是 | 是 | {[key: string]: any} | 扩展参数。 | -| color | 是 | 是 | number | 通知背景颜色。 | -| colorEnabled | 是 | 是 | boolean | 通知背景颜色是否使能。 | +| color | 是 | 是 | number | 通知背景颜色。暂不支持。 | +| colorEnabled | 是 | 是 | boolean | 通知背景颜色是否使能。暂不支持。 | | isAlertOnce | 是 | 是 | boolean | 设置是否仅有一次此通知警报。 | | isStopwatch | 是 | 是 | boolean | 是否显示已用时间。 | | isCountDown | 是 | 是 | boolean | 是否显示倒计时时间。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index 3baf08fd65d5c60b7ae4950bbb4622c3a553465e..498e1af03c1f98e5092062269b446e22047f8862 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -415,7 +415,7 @@ connectAbility(request: Want, options:ConnectOptions): number function onFailedCallback(code){ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) } - var connId = particleAbility.connectAbility( + var connectId = particleAbility.connectAbility( { bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", @@ -427,7 +427,7 @@ connectAbility(request: Want, options:ConnectOptions): number }, ); - particleAbility.disconnectAbility(connId).then((data)=>{ + particleAbility.disconnectAbility(connectId).then((data)=>{ console.log( " data: " + data); }).catch((error)=>{ console.log('particleAbilityTest result errCode : ' + error.code ) @@ -464,7 +464,7 @@ import rpc from '@ohos.rpc' function onFailedCallback(code){ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) } - var connId = particleAbility.connectAbility( + var connectId = particleAbility.connectAbility( { bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", @@ -475,7 +475,7 @@ import rpc from '@ohos.rpc' onFailed: onFailedCallback, }, ); - var result = particleAbility.disconnectAbility(connId).then((data)=>{ + var result = particleAbility.disconnectAbility(connectId).then((data)=>{ console.log( " data: " + data); }).catch((error)=>{ console.log('particleAbilityTest result errCode : ' + error.code ) @@ -511,7 +511,7 @@ function onConnectCallback(element, remote){ function onFailedCallback(code){ console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) } - var connId = particleAbility.connectAbility( + var connectId = particleAbility.connectAbility( { bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", @@ -523,7 +523,7 @@ function onConnectCallback(element, remote){ }, ); - particleAbility.disconnectAbility(connId).then((data)=>{ + particleAbility.disconnectAbility(connectId).then((data)=>{ console.log( " data: " + data); }).catch((error)=>{ console.log('particleAbilityTest result errCode : ' + error.code ) diff --git a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md index 78f0bec7ffa1aa3efa02af6f4051f53d5c13bc2a..4aff2d3116e50b96dd6f4f4678b28cf3e67a0b94 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -16,7 +16,7 @@ import pasteboard from '@ohos.pasteboard'; **系统能力:** SystemCapability.MiscServices.Pasteboard -| 名称 | 参数类型 | 值 | 说明 | +| 名称 | 类型 | 值 | 说明 | | -------- | -------- | -------- | -------- | | MAX_RECORD_NUM7+ | number | 512 | 单个PasteData中所能包含的最大条目数。 | | MIMETYPE_TEXT_HTML7+ | string | 'text/html' | HTML内容的MIME类型定义。 | @@ -374,7 +374,7 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio **系统能力:** SystemCapability.MiscServices.Pasteboard -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | additions7+ | {[key:string]:object} | 是 | 是 | 设置的其他附加属性数据。 | | mimeTypes7+ | Array<string> | 是 | 否 | 剪贴板内容条目的数据类型,非重复的类型列表。 | @@ -391,7 +391,7 @@ let record = pasteboard.createUriRecord('dataability:///com.example.myapplicatio **系统能力:** SystemCapability.MiscServices.Pasteboard -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | htmlText7+ | string | 是 | 否 | HTML内容。 | | want7+ | [Want](js-apis-application-Want.md) | 是 | 否 | Want内容。 | @@ -636,8 +636,8 @@ let opt = { scaleMode: 1 }; image.createPixelMap(buffer, opt).then((pixelMap) => { - let pasteData = pasteboard.createPixelMapData(pixelMap); - let pixelMap = pasteData.getPrimaryPixelMap(); + let pasteData = pasteboard.createData('app/xml',pixelMap); + let PixelMap = pasteData.getPrimaryPixelMap(); }); ``` @@ -687,6 +687,7 @@ addRecord(mimeType: string, value: ValueType): void **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900002 | The number of record exceeds the maximum limit. | @@ -808,6 +809,7 @@ getRecord(index: number): PasteDataRecord **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900001 | The index is out of range. | @@ -905,6 +907,7 @@ removeRecord(index: number): void **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900001 | The index is out of range. | @@ -934,6 +937,7 @@ replaceRecord(index: number, record: PasteDataRecord): void **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900001 | The index is out of range. | @@ -1226,6 +1230,7 @@ off(type: 'update', callback?: () =>void ): void **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); let listener = () => { console.info('The system pasteboard has changed.'); }; @@ -1249,6 +1254,7 @@ clearData(callback: AsyncCallback<void>): void **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.clearData((err, data) => { if (err) { console.error(`Failed to clear the pasteboard. Cause: ${err.message}`); @@ -1275,6 +1281,7 @@ clearData(): Promise<void> **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.clearData().then((data) => { console.info('Succeeded in clearing the pasteboard.'); }).catch((err) => { @@ -1300,6 +1307,7 @@ setData(data: PasteData, callback: AsyncCallback<void>): void **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900003 | Another copy or paste is in progress. | @@ -1342,6 +1350,7 @@ setData(data: PasteData): Promise<void> **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900003 | Another copy or paste is in progress. | @@ -1376,6 +1385,7 @@ getData( callback: AsyncCallback<PasteData>): void **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900003 | Another copy or paste is in progress. | @@ -1410,6 +1420,7 @@ getData(): Promise<PasteData> **错误码:** 以下错误码的详细介绍请参见[剪贴板错误码](../errorcodes/errorcode-pasteboard.md)。 + | 错误码ID | 错误信息 | | -------- | -------- | | 12900003 | Another copy or paste is in progress. | @@ -1442,6 +1453,7 @@ hasData(callback: AsyncCallback<boolean>): void **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.hasData((err, data) => { if (err) { console.error(`Failed to check the PasteData. Cause: ${err.message}`); @@ -1468,6 +1480,7 @@ hasData(): Promise<boolean> **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.hasData().then((data) => { console.info(`Succeeded in checking the PasteData. Data: ${data}`); }).catch((err) => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 27b1bfc3f827854304bb83ebe8cd7e643491d11e..16bc3164750617cddfec79af1ba731b37beca6c6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -28,7 +28,7 @@ import PlainArray from '@ohos.util.PlainArray'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | PlainArray的元素个数。 | @@ -45,7 +45,7 @@ PlainArray的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The PlainArray's constructor cannot be directly invoked. | @@ -79,7 +79,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -120,7 +120,7 @@ has(key: number): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The has method cannot be bound. | @@ -163,7 +163,7 @@ get(key: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -206,7 +206,7 @@ getIndexOfKey(key: number): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOfKey method cannot be bound. | @@ -249,7 +249,7 @@ getIndexOfValue(value: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getIndexOfValue method cannot be bound. | @@ -292,7 +292,7 @@ getKeyAt(index: number): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getKeyAt method cannot be bound. | @@ -334,7 +334,7 @@ getValueAt(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getValueAt method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -376,7 +376,7 @@ clone(): PlainArray<T> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clone method cannot be bound. | @@ -414,7 +414,7 @@ add(key: number, value: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -455,7 +455,7 @@ remove(key: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -498,7 +498,7 @@ removeAt(index: number): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeAt method cannot be bound. | @@ -542,7 +542,7 @@ removeRangeFrom(index: number, size: number): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The removeRangeFrom method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -586,7 +586,7 @@ setValueAt(index: number, value: T): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The setValueAt method cannot be bound. | | 10200001 | The value of parameters are out of range. | @@ -629,7 +629,7 @@ toString(): String 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The toString method cannot be bound. | @@ -660,7 +660,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -705,7 +705,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -746,7 +746,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-pointer.md b/zh-cn/application-dev/reference/apis/js-apis-pointer.md index ca40808f6481390185bfb8882b3a447e6ed4cc61..a967cea7ebf4540aeff5827020673fac0a5aca0d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-pointer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pointer.md @@ -22,7 +22,7 @@ setPointerVisible(visible: boolean, callback: AsyncCallback<void>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------------------------------------- | | visible | boolean | 是 | 鼠标指针是否显示。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -53,7 +53,7 @@ setPointerVisible(visible: boolean): Promise<void> **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | ---------------------------------------- | | visible | boolean | 是 | 鼠标指针是否显示。 | @@ -85,7 +85,7 @@ isPointerVisible(callback: AsyncCallback<boolean>): void **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------- | ---- | -------------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,异步返回鼠标指针显示或隐藏状态。 | @@ -135,9 +135,11 @@ setPointerSpeed(speed: number, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.MultimodalInput.Input.Pointer +**系统API**: 此接口为系统接口。 + **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ------------------------------------- | | speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 | | callback | AysncCallback<void> | 是 | 回调函数。 | @@ -166,9 +168,11 @@ setPointerSpeed(speed: number): Promise<void> **系统能力**:SystemCapability.MultimodalInput.Input.Pointer +**系统API**: 此接口为系统接口。 + **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----------------------------------- | | speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 | @@ -198,9 +202,11 @@ getPointerSpeed(callback: AsyncCallback<number>): void **系统能力**:SystemCapability.MultimodalInput.Input.Pointer +**系统API**: 此接口为系统接口。 + **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | -------------- | | callback | AsyncCallback<number> | 是 | 回调函数,异步返回鼠标移动速度。 | @@ -228,6 +234,8 @@ getPointerSpeed(): Promise<number> **系统能力**:SystemCapability.MultimodalInput.Input.Pointer +**系统API**: 此接口为系统接口。 + **返回值**: | 参数 | 说明 | @@ -256,7 +264,7 @@ getPointerStyle(windowId: number, callback: AsyncCallback<PointerStyle>): **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------- | | windowId | number | 是 | 窗口id。 | | callback | AsyncCallback<[PointerStyle](#pointerstyle9)> | 是 | 回调函数,异步返回鼠标样式类型。 | @@ -294,7 +302,7 @@ getPointerStyle(windowId: number): Promise<PointerStyle> **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------ | ---- | -------- | | windowId | number | 是 | 窗口id。 | @@ -337,7 +345,7 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCal **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------ | ------------------------------ | ---- | ----------------------------------- | | windowId | number | 是 | 窗口id。 | | pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 | @@ -375,7 +383,7 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise<void&g **参数**: -| 参数 | 类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ------------------- | ------------------------------ | ---- | ---------------- | | windowId | number | 是 | 窗口id。 | | pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index e6d713fce36bd5c91e0dd42e087f292a37392890..cbbd9bd227454911ec84f88023ddf833eb93e968 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -25,7 +25,7 @@ import Queue from '@ohos.util.Queue'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | Queue的元素个数。 | @@ -42,7 +42,7 @@ Queue的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The Queue's constructor cannot be directly invoked. | @@ -82,7 +82,7 @@ add(element: T): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The add method cannot be bound. | @@ -121,7 +121,7 @@ pop(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The pop method cannot be bound. | @@ -160,7 +160,7 @@ getFirst(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getFirst method cannot be bound. | @@ -208,7 +208,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -250,7 +250,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md b/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md index 4aa51affe53c246dcfb3eaf8795247633c50bb01..60e03b6967b89bafdccd0b1cde63a34462353bad 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -35,11 +35,11 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number& **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700001 | Notification does not enable. | +| 1700001 | Notification is not enabled. | | 1700002 | The number of reminders exceeds the limit. | **示例**: @@ -84,11 +84,11 @@ publishReminder(reminderReq: ReminderRequest): Promise<number> **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700001 | Notification does not enable. | +| 1700001 | Notification is not enabled. | | 1700002 | The number of reminders exceeds the limit. | **示例**: @@ -126,12 +126,12 @@ cancelReminder(reminderId: number, callback: AsyncCallback<void>): void **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | | 1700003 | The reminder does not exist. | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -172,12 +172,12 @@ cancelReminder(reminderId: number): Promise<void> **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | | 1700003 | The reminder does not exist. | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -210,11 +210,11 @@ getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -270,11 +270,11 @@ getValidReminders(): Promise<Array<ReminderRequest>> **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -328,11 +328,11 @@ cancelAllReminders(callback: AsyncCallback<void>): void **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -367,11 +367,11 @@ cancelAllReminders(): Promise<void> **错误码:** -以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errcode-reminderAgentManager.md)错误码。 +以下错误码的详细介绍请参见[@ohos.reminderAgentManager (后台代理提醒)](../errorcodes/errorcode-reminderAgentManager.md)错误码。 | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-request.md b/zh-cn/application-dev/reference/apis/js-apis-request.md index 7a2a4623d5e4aab2f9f49985e87d25e2d00c09ab..fb3b971d29373fdadac3722b130b6a73c3b00945 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -187,8 +187,8 @@ upload(context: BaseContext, config: UploadConfig): Promise<UploadTask> url: 'https://patch', header: { key1: "value1", key2: "value2" }, method: "POST", - files: { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }, - data: { name: "name123", value: "123" }, + files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], + data: [{ name: "name123", value: "123" }], }; request.upload(globalThis.abilityContext, uploadConfig).then((data) => { uploadTask = data; @@ -264,7 +264,7 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask> | Promise<[UploadTask](#uploadtask)> | 返回上传任务。 | **错误码:** -以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcodes-request.md)。 +以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 | 错误码ID | 错误码信息 | | -------- | -------- | @@ -278,8 +278,8 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask> url: 'https://patch', header: { key1: "value1", key2: "value2" }, method: "POST", - files: { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }, - data: { name: "name123", value: "123" }, + files: [{ filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }], + data: [{ name: "name123", value: "123" }], }; request.uploadFile(globalThis.abilityContext, uploadConfig).then((data) => { uploadTask = data; @@ -308,7 +308,7 @@ uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback&l | callback | AsyncCallback<[UploadTask](#uploadtask)> | 否 | 回调函数,异步返回UploadTask对象。 | **错误码:** -以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcodes-request.md)。 +以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 | 错误码ID | 错误码信息 | | -------- | -------- | @@ -910,7 +910,7 @@ downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadT | Promise<[DownloadTask](#downloadtask)> | 返回下载任务。 | **错误码:** -以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcodes-request.md)。 +以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 | 错误码ID | 错误码信息 | | -------- | -------- | @@ -949,7 +949,7 @@ downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallba | callback | AsyncCallback<[DownloadTask](#downloadtask)> | 否 | 下载接口的回调函数。 | **错误码:** -以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcodes-request.md)。 +以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 | 错误码ID | 错误码信息 | | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index 1bf99a5114ee2ff91fdf710eedb6aae38c0442fe..6e4cb79de19f291f726377d612f73ba1e2d232ce 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -39,6 +39,7 @@ getResourceManager(callback: AsyncCallback<ResourceManager>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------------------- | | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | 是 | callback方式返回ResourceManager对象 | @@ -72,6 +73,7 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ----------------------------- | | bundleName | string | 是 | 指定应用的Bundle名称 | @@ -126,6 +128,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------- | | bundleName | string | 是 | 指定应用的Bundle名称 | @@ -149,7 +152,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------------------- | ---- | ---- | | DIRECTION_VERTICAL | 0 | 竖屏 | | DIRECTION_HORIZONTAL | 1 | 横屏 | @@ -161,7 +164,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------------------- | ---- | ---- | | DEVICE_TYPE_PHONE | 0x00 | 手机 | | DEVICE_TYPE_TABLET | 0x01 | 平板 | @@ -177,7 +180,7 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------------- | ---- | ---------- | | SCREEN_SDPI | 120 | 小规模的屏幕密度 | | SCREEN_MDPI | 160 | 中规模的屏幕密度 | @@ -193,8 +196,9 @@ getResourceManager(bundleName: string): Promise<ResourceManager> **系统能力**:SystemCapability.Global.ResourceManager +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | ----------------------- | ---- | ---- | -------- | | direction | [Direction](#direction) | 是 | 否 | 当前设备屏幕方向 | | locale | string | 是 | 否 | 当前系统语言 | @@ -216,8 +220,9 @@ resourceManager.getResourceManager((error, mgr) => { **系统能力**:SystemCapability.Global.ResourceManager +**参数:** -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------- | ------------------------------- | ---- | ---- | -------- | | screenDensity | [ScreenDensity](#screendensity) | 是 | 否 | 当前设备屏幕密度 | | deviceType | [DeviceType](#devicetype) | 是 | 否 | 当前设备类型 | @@ -239,11 +244,13 @@ resourceManager.getResourceManager((error, mgr) => { **系统能力:** SystemCapability.Global.ResourceManager -| 名称 | 类型 | 说明 | -| ------ | ------ | ------------------ | -| fd | number | rawfile的descriptor | -| offset | number | rawfile的起始偏移量 | -| length | number | rawfile的文件长度 | +**参数:** + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ------------------ | +| fd | number | 是 | 否 | rawfile的descriptor | +| offset | number | 是 | 否 | rawfile的起始偏移量 | +| length | number | 是 | 否 | rawfile的文件长度 | ## Resource9+ @@ -251,11 +258,13 @@ resourceManager.getResourceManager((error, mgr) => { **系统能力:** 以下各项对应的系统能力均为SystemCapability.Global.ResourceManager -| 名称 | 类型 | 说明 | -| ---------- | ------ | ----------- | -| bundleName | string | 应用的bundle名称 | -| moduleName | string | 应用的module名称 | -| id | number | 资源的id值 | +**参数:** + +| 名称 | 类型 | 可读 | 可写 |说明 | +| ---------- | ------ | ----- | ---- | ---------------| +| bundleName | string | 是 | 否 | 应用的bundle名称 | +| moduleName | string | 是 | 否 | 应用的module名称 | +| id | number | 是 | 否 | 资源的id值 | ## ResourceManager @@ -277,6 +286,7 @@ getStringValue(resId: number, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------- | | resId | number | 是 | 资源ID值 | @@ -288,9 +298,9 @@ getStringValue(resId: number, callback: AsyncCallback<string>): void | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the module resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例Stage:** ```ts @@ -317,6 +327,7 @@ getStringValue(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -328,11 +339,13 @@ getStringValue(resId: number): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -357,6 +370,7 @@ getStringValue(resource: Resource, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -364,11 +378,13 @@ getStringValue(resource: Resource, callback: AsyncCallback<string>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -377,7 +393,7 @@ getStringValue(resource: Resource, callback: AsyncCallback<string>): void moduleName: "entry", id: $r('app.string.test').id }; - tyr { + try { this.context.resourceManager.getStringValue(resource, (error, value) => { if (error != null) { console.log("error is " + error); @@ -400,23 +416,26 @@ getStringValue(resource: Resource): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager -**参数:** +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | -**返回值:** +**返回值:** | 类型 | 说明 | | --------------------- | ---------------- | | Promise<string> | resource对象对应的字符串 | 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -446,6 +465,7 @@ getStringArrayValue(resId: number, callback: AsyncCallback<Array<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | resId | number | 是 | 资源ID值 | @@ -453,11 +473,13 @@ getStringArrayValue(resId: number, callback: AsyncCallback<Array<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -484,6 +506,7 @@ getStringArrayValue(resId: number): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -495,11 +518,13 @@ getStringArrayValue(resId: number): Promise<Array<string>> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -523,6 +548,7 @@ getStringArrayValue(resource: Resource, callback: AsyncCallback<Array<stri **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -530,11 +556,13 @@ getStringArrayValue(resource: Resource, callback: AsyncCallback<Array<stri 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -565,6 +593,7 @@ getStringArrayValue(resource: Resource): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -576,11 +605,13 @@ getStringArrayValue(resource: Resource): Promise<Array<string>> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -601,7 +632,7 @@ getStringArrayValue(resource: Resource): Promise<Array<string>> ``` -### getMediaContent +### getMediaContent9+ getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void @@ -610,6 +641,7 @@ getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------ | | resId | number | 是 | 资源ID值 | @@ -617,10 +649,12 @@ getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts @@ -638,7 +672,7 @@ getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void ``` -### getMediaContent +### getMediaContent9+ getMediaContent(resId: number): Promise<Uint8Array> @@ -647,6 +681,7 @@ getMediaContent(resId: number): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -658,15 +693,17 @@ getMediaContent(resId: number): Promise<Uint8Array> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts try { - mgr.getMediaContent($r('app.media.test').id).then(value => { + this.context.resourceManager.getMediaContent($r('app.media.test').id).then(value => { let media = value; }).catch(error => { console.log("getMediaContent promise error is " + error); @@ -685,6 +722,7 @@ getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>): **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------ | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -692,10 +730,12 @@ getMediaContent(resource: Resource, callback: AsyncCallback<Uint8Array>): 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts @@ -726,6 +766,7 @@ getMediaContent(resource: Resource): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -737,10 +778,12 @@ getMediaContent(resource: Resource): Promise<Uint8Array> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts @@ -761,7 +804,7 @@ getMediaContent(resource: Resource): Promise<Uint8Array> ``` -### getMediaContentBase64 +### getMediaContentBase649+ getMediaContentBase64(resId: number, callback: AsyncCallback<string>): void @@ -770,6 +813,7 @@ getMediaContentBase64(resId: number, callback: AsyncCallback<string>): voi **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------ | | resId | number | 是 | 资源ID值 | @@ -777,15 +821,17 @@ getMediaContentBase64(resId: number, callback: AsyncCallback<string>): voi 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts try { - mgr.getMediaContentBase64($r('app.media.test').id, (error, value) => { + this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, (error, value) => { if (error != null) { console.log("error is " + error); } else { @@ -798,7 +844,7 @@ getMediaContentBase64(resId: number, callback: AsyncCallback<string>): voi ``` -### getMediaContentBase64 +### getMediaContentBase649+ getMediaContentBase64(resId: number): Promise<string> @@ -807,6 +853,7 @@ getMediaContentBase64(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -818,15 +865,17 @@ getMediaContentBase64(resId: number): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts try { - mgr.getMediaContentBase64($r('app.media.test').id).then(value => { + this.context.resourceManager.getMediaContentBase64($r('app.media.test').id).then(value => { let media = value; }).catch(error => { console.log("getMediaContentBase64 promise error is " + error); @@ -844,7 +893,8 @@ getMediaContentBase64(resource: Resource, callback: AsyncCallback<string>) **系统能力**:SystemCapability.Global.ResourceManager -**参数:** +**参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------ | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -852,10 +902,12 @@ getMediaContentBase64(resource: Resource, callback: AsyncCallback<string>) 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts @@ -886,6 +938,7 @@ getMediaContentBase64(resource: Resource): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -897,10 +950,12 @@ getMediaContentBase64(resource: Resource): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | **示例:** ```ts @@ -930,6 +985,7 @@ getConfiguration(callback: AsyncCallback<Configuration>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------- | | callback | AsyncCallback<[Configuration](#configuration)> | 是 | 异步回调,用于返回设备的Configuration | @@ -984,6 +1040,7 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------- | | callback | AsyncCallback<[DeviceCapability](#devicecapability)> | 是 | 异步回调,用于返回设备的DeviceCapability | @@ -1029,7 +1086,7 @@ getDeviceCapability(): Promise<DeviceCapability> ``` -### getPluralStringValue +### getPluralStringValue9+ getPluralStringValue(resId: number, num: number, callback: AsyncCallback<string>): void @@ -1038,6 +1095,7 @@ getPluralStringValue(resId: number, num: number, callback: AsyncCallback<stri **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------- | | resId | number | 是 | 资源ID值 | @@ -1046,11 +1104,13 @@ getPluralStringValue(resId: number, num: number, callback: AsyncCallback<stri 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1068,7 +1128,7 @@ getPluralStringValue(resId: number, num: number, callback: AsyncCallback<stri ``` -### getPluralStringValue +### getPluralStringValue9+ getPluralStringValue(resId: number, num: number): Promise<string> @@ -1077,6 +1137,7 @@ getPluralStringValue(resId: number, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -1089,11 +1150,13 @@ getPluralStringValue(resId: number, num: number): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1117,6 +1180,7 @@ getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback< **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------------ | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -1125,11 +1189,13 @@ getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback< 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1161,6 +1227,7 @@ getPluralString(resource: Resource, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -1173,11 +1240,13 @@ getPluralString(resource: Resource, num: number): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1207,6 +1276,7 @@ getRawFileContent(path: string, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ----------------------- | | path | string | 是 | rawfile文件路径 | @@ -1214,9 +1284,11 @@ getRawFileContent(path: string, callback: AsyncCallback<Uint8Array>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001005 | The resource not found by path. | +| 9001005 | If the resource not found by path. | **示例:** ```ts @@ -1243,6 +1315,7 @@ getRawFileContent(path: string): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1254,9 +1327,11 @@ getRawFileContent(path: string): Promise<Uint8Array> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001005 | The resource not found by path. | +| 9001005 | If the resource not found by path. | **示例:** ```ts @@ -1281,6 +1356,7 @@ getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------------------------- | | path | string | 是 | rawfile文件路径 | @@ -1288,9 +1364,11 @@ getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001005 | The resource not found by path. | +| 9001005 | If the resource not found by path. | **示例:** ```ts @@ -1303,9 +1381,8 @@ getRawFd(path: string, callback: AsyncCallback<RawFileDescriptor>): void let offset = value.offset; let length = value.length; } - }); - } catch(error => { - console.log("getRawFd callback error is " + error); + }).catch(error => { + console.log("getRawFd callback error is " + error); }); ``` @@ -1318,6 +1395,7 @@ getRawFd(path: string): Promise<RawFileDescriptor> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1329,9 +1407,11 @@ getRawFd(path: string): Promise<RawFileDescriptor> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001005 | The resource not found by path. | +| 9001005 | If the resource not found by path. | **示例:** ```ts @@ -1357,6 +1437,7 @@ closeRawFileDescriptor(path: string, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1382,6 +1463,7 @@ closeRawFileDescriptor(path: string): Promise<void> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1412,6 +1494,7 @@ closeRawFd(path: string, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1419,6 +1502,8 @@ closeRawFd(path: string, callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | | 9001005 | The resource not found by path. | @@ -1426,7 +1511,7 @@ closeRawFd(path: string, callback: AsyncCallback<void>): void **示例:** ```ts try { - mgr.closeRawFd("test.xml", (error, value) => { + this.context.resourceManager.closeRawFd("test.xml", (error, value) => { if (error != null) { console.log("error is " + error); } @@ -1446,6 +1531,7 @@ closeRawFd(path: string): Promise<void> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -1457,14 +1543,16 @@ closeRawFd(path: string): Promise<void> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001005 | The resource not found by path. | +| 9001005 | If the resource not found by path. | **示例:** ```ts try { - mgr.closeRawFd("test.xml").then(value => { + this.context.resourceManager.closeRawFd("test.xml").then(value => { let result = value; }).catch(error => { console.log("closeRawFd promise error is " + error); @@ -1498,6 +1586,7 @@ getStringByName(resName: string, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------- | | resName | string | 是 | 资源名称 | @@ -1505,11 +1594,13 @@ getStringByName(resName: string, callback: AsyncCallback<string>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1536,6 +1627,7 @@ getStringByName(resName: string): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1547,11 +1639,13 @@ getStringByName(resName: string): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1575,6 +1669,7 @@ getStringArrayByName(resName: string, callback: AsyncCallback<Array<string **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | resName | string | 是 | 资源名称 | @@ -1582,11 +1677,13 @@ getStringArrayByName(resName: string, callback: AsyncCallback<Array<string 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1612,6 +1709,7 @@ getStringArrayByName(resName: string): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1623,11 +1721,13 @@ getStringArrayByName(resName: string): Promise<Array<string>> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1651,6 +1751,7 @@ getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------ | | resName | string | 是 | 资源名称 | @@ -1658,11 +1759,13 @@ getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1688,6 +1791,7 @@ getMediaByName(resName: string): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1699,11 +1803,13 @@ getMediaByName(resName: string): Promise<Uint8Array> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1727,6 +1833,7 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): vo **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------ | | resName | string | 是 | 资源名称 | @@ -1734,11 +1841,13 @@ getMediaBase64ByName(resName: string, callback: AsyncCallback<string>): vo 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1764,6 +1873,7 @@ getMediaBase64ByName(resName: string): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1775,11 +1885,13 @@ getMediaBase64ByName(resName: string): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1803,6 +1915,7 @@ getPluralStringByName(resName: string, num: number, callback: AsyncCallback<s **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ----------------------------- | | resName | string | 是 | 资源名称 | @@ -1811,11 +1924,13 @@ getPluralStringByName(resName: string, num: number, callback: AsyncCallback<s 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1842,6 +1957,7 @@ getPluralStringByName(resName: string, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1854,11 +1970,13 @@ getPluralStringByName(resName: string, num: number): Promise<string> 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1882,6 +2000,7 @@ getStringSync(resId: number): string **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -1891,6 +2010,16 @@ getStringSync(resId: number): string | ------ | ----------- | | string | 资源ID值对应的字符串 | +以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 + +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | ---------------------------------------- | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | + **示例:** ```ts try { @@ -1909,6 +2038,7 @@ getStringSync(resource: Resource): string **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -1920,11 +2050,13 @@ getStringSync(resource: Resource): string 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1949,6 +2081,7 @@ getStringByNameSync(resName: string): string **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -1960,11 +2093,13 @@ getStringByNameSync(resName: string): string 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -1984,6 +2119,7 @@ getBoolean(resId: number): boolean **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -1995,11 +2131,13 @@ getBoolean(resId: number): boolean 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2018,6 +2156,7 @@ getBoolean(resource: Resource): boolean **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -2029,11 +2168,13 @@ getBoolean(resource: Resource): boolean 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2058,6 +2199,7 @@ getBooleanByName(resName: string): boolean **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -2069,11 +2211,13 @@ getBooleanByName(resName: string): boolean 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2093,6 +2237,7 @@ getNumber(resId: number): number **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2104,11 +2249,13 @@ getNumber(resId: number): number 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2134,6 +2281,7 @@ getNumber(resource: Resource): number **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------- | ---- | ---- | | resource | [Resource](#resource9) | 是 | 资源信息 | @@ -2145,11 +2293,13 @@ getNumber(resource: Resource): number 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001001 | The resId invalid. | -| 9001002 | The resource not found by resId. | -| 9001006 | The resource re-ref too much. | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2174,6 +2324,7 @@ getNumberByName(resName: string): number **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ------- | ------ | ---- | ---- | | resName | string | 是 | 资源名称 | @@ -2185,11 +2336,13 @@ getNumberByName(resName: string): number 以下错误码的详细介绍请参见[资源管理错误码](../errorcodes/errorcode-resource-manager.md)。 +**错误码:** + | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | -| 9001003 | The resName invalid. | -| 9001004 | The resource not found by resName. | -| 9001006 | The resource re-ref too much. | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | **示例:** ```ts @@ -2218,6 +2371,7 @@ getString(resId: number, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | --------------- | | resId | number | 是 | 资源ID值 | @@ -2248,6 +2402,7 @@ getString(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2280,6 +2435,7 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ----------------- | | resId | number | 是 | 资源ID值 | @@ -2310,6 +2466,7 @@ getStringArray(resId: number): Promise<Array<string>> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2342,6 +2499,7 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ------------------ | | resId | number | 是 | 资源ID值 | @@ -2372,6 +2530,7 @@ getMedia(resId: number): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2404,6 +2563,7 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------ | | resId | number | 是 | 资源ID值 | @@ -2434,6 +2594,7 @@ getMediaBase64(resId: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2466,6 +2627,7 @@ getPluralString(resId: number, num: number): Promise<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ----- | ------ | ---- | ----- | | resId | number | 是 | 资源ID值 | @@ -2499,6 +2661,7 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | ------------------------------- | | resId | number | 是 | 资源ID值 | @@ -2530,6 +2693,7 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------- | ---- | ----------------------- | | path | string | 是 | rawfile文件路径 | @@ -2560,6 +2724,7 @@ getRawFile(path: string): Promise<Uint8Array> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | @@ -2592,6 +2757,7 @@ getRawFileDescriptor(path: string, callback: AsyncCallback<RawFileDescriptor& **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | -------------------------------- | | path | string | 是 | rawfile文件路径 | @@ -2623,6 +2789,7 @@ getRawFileDescriptor(path: string): Promise<RawFileDescriptor> **系统能力**:SystemCapability.Global.ResourceManager **参数:** + | 参数名 | 类型 | 必填 | 说明 | | ---- | ------ | ---- | ----------- | | path | string | 是 | rawfile文件路径 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md index 6d0e97241064cd8dd8ef07c78a0738f3371b083b..f51e494b71d44995bf8bb64da53243c936519deb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-backgroundTaskManager.md @@ -26,7 +26,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen 后台应用申请延迟挂起。 -延迟挂起时间一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 +延迟挂起时间一般情况下默认值为3分钟,低电量(依据系统低电量广播)时默认值为1分钟。 **系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask @@ -255,8 +255,8 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **示例**: ```js +import Ability from '@ohos.application.Ability' import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import featureAbility from '@ohos.ability.featureAbility'; import wantAgent from '@ohos.wantAgent'; function callback(error, data) { @@ -267,27 +267,30 @@ function callback(error, data) { } } -let wantAgentInfo = { - wants: [ - { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility" - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -}; - -wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { - try { - backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), - backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj, callback) - } catch (error) { - console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + 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}`); + } + }); } -}); - +}; ``` ## backgroundTaskManager.startBackgroundRunning:promise @@ -331,35 +334,38 @@ startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: Want **示例**: ```js -import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import featureAbility from '@ohos.ability.featureAbility'; +import Ability from '@ohos.application.Ability' +import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; import wantAgent from '@ohos.wantAgent'; -let wantAgentInfo = { - wants: [ - { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility" - } - ], - operationType: wantAgent.OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] -}; - -wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { - try { - backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(), - backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => { - console.info("Operation startBackgroundRunning succeeded"); - }).catch((error) => { - console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + 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) => { + 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}`); } -}); - +}; ``` ## backgroundTaskManager.stopBackgroundRunning:callback @@ -394,8 +400,8 @@ stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): vo **示例**: ```js +import Ability from '@ohos.application.Ability' import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import featureAbility from '@ohos.ability.featureAbility'; function callback(error, data) { if (error) { @@ -405,12 +411,15 @@ function callback(error, data) { } } -try { - backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callback); -} catch (error) { - console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); -} - +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + try { + backgroundTaskManager.stopBackgroundRunning(this.context, callback); + } catch (error) { + console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + } + } +}; ``` ## backgroundTaskManager.stopBackgroundRunning:promise @@ -452,19 +461,22 @@ stopBackgroundRunning(context: Context): Promise<void> **示例**: ```js +import Ability from '@ohos.application.Ability' import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; -import featureAbility from '@ohos.ability.featureAbility'; - -try { - backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { - console.info("Operation stopBackgroundRunning succeeded"); - }).catch((err) => { - console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); - }); -} catch (error) { - console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); -} +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + try { + backgroundTaskManager.stopBackgroundRunning(this.context).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((err) => { + console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + }); + } catch (error) { + console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + } + } +}; ``` ## backgroundTaskManager.applyEfficiencyResources @@ -546,7 +558,7 @@ resetAllEfficiencyResources(): void import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; try { - backgroundTaskManager.backgroundTaskManager.resetAllEfficiencyResources(); + backgroundTaskManager.resetAllEfficiencyResources(); } catch (error) { console.error(`resetAllEfficiencyResources failed. code is ${error.code} message is ${error.message}`); } @@ -576,8 +588,8 @@ try { | LOCATION | 4 | 定位导航。 | | BLUETOOTH_INTERACTION | 5 | 蓝牙相关。 | | MULTI_DEVICE_CONNECTION | 6 | 多设备互联。 | -| WIFI_INTERACTION | 7 | WLAN相关
此接口为系统接口。 | -| VOIP | 8 | 音视频通话
此接口为系统接口。 | +| WIFI_INTERACTION | 7 | WLAN相关(此接口为系统接口)。 | +| VOIP | 8 | 音视频通话(此接口为系统接口)。 | | TASK_KEEPING | 9 | 计算任务(仅在特定设备生效)。 | ## EfficiencyResourcesRequest @@ -605,13 +617,13 @@ try { **系统API**: 此接口为系统接口。 -| 参数名 | 参数值 | 描述 | -| ----------------------- | ---- | --------------------- | -| CPU | 1 | CPU资源,申请后不被挂起。 | -| COMMON_EVENT | 2 | 公共事件,申请后挂起状态下不被代理掉。 | -| TIMER | 4 | 计时器,申请后挂起状态下不被代理掉。 | -| WORK_SCHEDULER | 8 | 延迟任务,申请后有更长的执行时间。 | -| BLUETOOTH | 16 | 蓝牙相关,申请后挂起状态下不被代理掉。 | -| GPS | 32 | GPS相关,申请后挂起状态下不被代理掉。 | -| AUDIO | 64 | 音频资源,申请后挂起状态下不被代理掉。 | +| 参数名 | 描述 | +| ----------------------- | --------------------- | +| CPU | CPU资源,申请后不被挂起。 | +| COMMON_EVENT | 公共事件,申请后挂起状态下不被代理掉。 | +| TIMER | 计时器,申请后挂起状态下不被代理掉。 | +| WORK_SCHEDULER | 延迟任务,申请后有更长的执行时间。 | +| BLUETOOTH | 蓝牙相关,申请后挂起状态下不被代理掉。 | +| GPS | GPS相关,申请后挂起状态下不被代理掉。 | +| AUDIO | 音频资源,申请后挂起状态下不被代理掉。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md index 3b9a1ebbe44a3efd2051ae690f88ac7c7a7bb50b..b6bc46eae0e8acd671ce83cfab9859ba07f29e92 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md @@ -46,7 +46,7 @@ isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -93,7 +93,7 @@ isIdleState(bundleName: string): Promise<boolean> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -133,7 +133,7 @@ queryAppGroup(): Promise<number> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -175,7 +175,7 @@ queryAppGroup(callback: AsyncCallback<number>): void **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -225,7 +225,7 @@ queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback<Bun **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -285,7 +285,7 @@ queryBundleStatsInfos(begin: number, end: number): Promise<BundleStatsMap> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -339,7 +339,7 @@ queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: num **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -398,7 +398,7 @@ queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: num **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -449,7 +449,7 @@ queryBundleEvents(begin: number, end: number, callback: AsyncCallback<Array&l **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -507,7 +507,7 @@ queryBundleEvents(begin: number, end: number): Promise<Array<BundleEvents& **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -554,7 +554,7 @@ queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback< **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -608,7 +608,7 @@ queryCurrentBundleEvents(begin: number, end: number): Promise<Array<Bundle **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -657,7 +657,7 @@ queryModuleUsageRecords(): Promise<Array<HapModuleInfo>> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -707,7 +707,7 @@ queryModuleUsageRecords(callback: AsyncCallback<Array<HapModuleInfo>> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -764,7 +764,7 @@ queryModuleUsageRecords(maxNum: number): Promise<Array<HapModuleInfo>&g **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -814,7 +814,7 @@ queryModuleUsageRecords(maxNum: number, callback: AsyncCallback<Array<HapM **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -871,7 +871,7 @@ queryAppGroup(bundleName : string): Promise<number> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -920,7 +920,7 @@ queryAppGroup(bundleName : string, callback: AsyncCallback<number>): void **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -947,7 +947,6 @@ queryAppGroup(bundleName : string, callback: AsyncCallback<number>): void } catch (error) { console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message); } -}); ``` ## usageStatistics.setAppGroup @@ -971,7 +970,7 @@ setAppGroup(bundleName: string, newGroup: GroupType): Promise<void> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -992,7 +991,7 @@ setAppGroup(bundleName: string, newGroup: GroupType): Promise<void> ```javascript let bundleName = "com.example.deviceUsageStatistics"; - let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; + let newGroup = usageStatistics.GroupType.DAILY_GROUP; try{ usageStatistics.setAppGroup(bundleName, newGroup).then( () => { @@ -1027,7 +1026,7 @@ setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback< **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1042,7 +1041,7 @@ setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback< ```javascript let bundleName = "com.example.deviceUsageStatistics"; - let newGroup = bundleState.GroupType.ACTIVE_GROUP_DAILY; + let newGroup = usageStatistics.GroupType.DAILY_GROUP; try{ usageStatistics.setAppGroup(bundleName, newGroup, (err) => { @@ -1077,7 +1076,7 @@ registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>): P **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1136,7 +1135,7 @@ registerAppGroupCallBack(groupCallback: Callback<AppGroupCallbackInfo>, ca **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1193,7 +1192,7 @@ unregisterAppGroupCallBack(): Promise<void> **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1237,7 +1236,7 @@ unregisterAppGroupCallBack(callback: AsyncCallback<void>): void; **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1290,7 +1289,7 @@ queryDeviceEventStats(begin: number, end: number): Promise<Array<DeviceEve **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1338,7 +1337,7 @@ queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback<Arr **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1393,7 +1392,7 @@ queryNotificationEventStats(begin: number, end: number): Promise<Array<Dev **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | @@ -1441,7 +1440,7 @@ queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback& **错误码**: -以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errcode-DeviceUsageStatistics.md)。 +以下错误码的详细介绍请参见[设备信息使用统计错误码](../errorcodes/errorcode-DeviceUsageStatistics.md)。 | 错误码ID | 错误信息 | | ---------- | ---------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md index f796d0fde9d0e8d20bc425c0b7b93b9ff47d544b..1e5fabba4a1dd5769ef741a52c9718d5ce3775e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-workScheduler.md @@ -353,7 +353,7 @@ isLastWorkTimeOut(workId: number, callback : AsyncCallback\): boolean try{ workScheduler.isLastWorkTimeOut(500, (error, res) =>{ if (error) { - onsole.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); + console.error(`workschedulerLog isLastWorkTimeOut failed. code is ${error.code} message is ${error.message}`); } else { console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`); } @@ -437,45 +437,45 @@ isLastWorkTimeOut(workId: number): Promise\ **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 默认值 | 说明 | -| ---------------------- | ---- | ----------------------- | -| NETWORK_TYPE_ANY | 0 | 表示这个触发条件是任何类型的网络连接。 | -| NETWORK_TYPE_MOBILE | 1 | 表示这个触发条件是Mobile网络连接。 | -| NETWORK_TYPE_WIFI | 2 | 表示这个触发条件是Wifi类型的网络连接。 | -| NETWORK_TYPE_BLUETOOTH | 3 | 表示这个触发条件是Bluetooth网络连接。 | -| NETWORK_TYPE_WIFI_P2P | 4 | 表示这个触发条件是Wifi P2P网络连接。 | -| NETWORK_TYPE_ETHERNET | 5 | 表示这个触发条件是有线网络连接。 | +| 名称 | 说明 | +| ---------------------- | ----------------------- | +| NETWORK_TYPE_ANY | 表示这个触发条件是任何类型的网络连接。 | +| NETWORK_TYPE_MOBILE | 表示这个触发条件是Mobile网络连接。 | +| NETWORK_TYPE_WIFI | 表示这个触发条件是Wifi类型的网络连接。 | +| NETWORK_TYPE_BLUETOOTH | 表示这个触发条件是Bluetooth网络连接。 | +| NETWORK_TYPE_WIFI_P2P | 表示这个触发条件是Wifi P2P网络连接。 | +| NETWORK_TYPE_ETHERNET | 表示这个触发条件是有线网络连接。 | ## ChargingType 触发工作的充电类型。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 默认值 | 说明 | -| ------------------------- | ---- | -------------------- | -| CHARGING_PLUGGED_ANY | 0 | 表示这个触发条件是任何类型的充电器连接。 | -| CHARGING_PLUGGED_AC | 1 | 表示这个触发条件是直流充电器连接。 | -| CHARGING_PLUGGED_USB | 2 | 表示这个触发条件是USB充连接。 | -| CHARGING_PLUGGED_WIRELESS | 3 | 表示这个触发条件是无线充电器连接。 | +| 名称 | 说明 | +| ------------------------- | -------------------- | +| CHARGING_PLUGGED_ANY | 表示这个触发条件是任何类型的充电器连接。 | +| CHARGING_PLUGGED_AC | 表示这个触发条件是直流充电器连接。 | +| CHARGING_PLUGGED_USB | 表示这个触发条件是USB充连接。 | +| CHARGING_PLUGGED_WIRELESS | 表示这个触发条件是无线充电器连接。 | ## BatteryStatus 触发工作的电池状态。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 默认值 | 说明 | -| -------------------------- | ---- | -------------------------- | -| BATTERY_STATUS_LOW | 0 | 表示这个触发条件是低电告警。 | -| BATTERY_STATUS_OKAY | 1 | 表示这个触发条件是从低电恢复到正常电量。 | -| BATTERY_STATUS_LOW_OR_OKAY | 2 | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | +| 名称 | 说明 | +| -------------------------- | -------------------------- | +| BATTERY_STATUS_LOW | 表示这个触发条件是低电告警。 | +| BATTERY_STATUS_OKAY | 表示这个触发条件是从低电恢复到正常电量。 | +| BATTERY_STATUS_LOW_OR_OKAY | 表示这个触发条件是从低电恢复到正常电量或者低电告警。 | ## StorageRequest 触发工作的存储状态。 **系统能力**:SystemCapability.ResourceSchedule.WorkScheduler -| 名称 | 默认值 | 说明 | -| ------------------------- | ---- | ------------------------------ | -| STORAGE_LEVEL_LOW | 0 | 表示这个触发条件是存储空间不足。 | -| STORAGE_LEVEL_OKAY | 1 | 表示这个触发条件是从存储空间不足恢复到正常。 | -| STORAGE_LEVEL_LOW_OR_OKAY | 2 | 表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 | \ No newline at end of file +| 名称 | 说明 | +| ------------------------- | ------------------------------ | +| STORAGE_LEVEL_LOW | 表示这个触发条件是存储空间不足。 | +| STORAGE_LEVEL_OKAY | 表示这个触发条件是从存储空间不足恢复到正常。 | +| STORAGE_LEVEL_LOW_OR_OKAY | 表示这个触发条件是从存储空间不足恢复到正常或者存储空间不足。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md index 17f1f4702f2feedf93d98c3690484a9d527137b9..4f674091308c1d77fc23dc6edc7229930653bf86 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen-lock.md @@ -1,387 +1,369 @@ # 锁屏管理 -锁屏管理服务是OpenHarmony中系统服务,为锁屏应用提供注册亮屏、灭屏、开启屏幕、结束休眠、退出动画、请求解锁结果监听,并提供回调结果给锁屏应用。锁屏管理服务向三方应用提供请求解锁、查询锁屏状态、查询是否设置锁屏密码的能力。 +锁屏管理服务是OpenHarmony中的系统服务,为锁屏应用提供注册亮屏、灭屏、开启屏幕、结束休眠、退出动画、请求解锁结果监听,并提供回调结果给锁屏应用。锁屏管理服务向三方应用提供请求解锁、查询锁屏状态、查询是否设置锁屏密码的能力。 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> **说明:** +> > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - ## 导入模块 - ```js import screenlock from '@ohos.screenLock'; ``` - ## screenlock.isScreenLocked isScreenLocked(callback: AsyncCallback<boolean>): void -判断屏幕是否锁屏,使用callback作为异步方法。 +判断屏幕是否锁屏,使用callback异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 -> -> 从 API version 7开始支持。 +> +>从 API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数,返回true表示屏幕已锁屏,返回false表示屏幕未锁屏。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ----------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数,返回true表示屏幕已锁屏,返回false表示屏幕未锁屏。 | **示例:** - - ```js - screenlock.isScreenLocked((err, data)=>{ - if (err) { - console.error('isScreenLocked callback error -> ${JSON.stringify(err)}'); - return; - } - console.info('isScreenLocked callback success data -> ${JSON.stringify(data)}'); - }); - ``` +```js +screenlock.isScreenLocked((err, data)=>{ + if (err) { + console.error('isScreenLocked callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('isScreenLocked callback success data -> ${JSON.stringify(data)}'); +}); +``` ## screenlock.isScreenLocked isScreenLocked(): Promise<boolean> -判断屏幕是否锁屏,使用Promise作为异步方法。 +判断屏幕是否锁屏,使用Promise异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 -> -> 从 API version 7开始支持。 +> +> 从API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.isLocked9+](#screenlockislocked9)代替。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**返回值**: - - | 类型 | 说明 | - | -------- | -------- | - | Promise<boolean> | 以Promise形式返回结果。 | +**返回值:** -**示例**: +| 类型 | 说明 | +| ---------------------- | ------------------------------------------- | +| Promise<boolean> | Promise对象,返回判断结果。返回true表示屏幕已锁屏,返回false表示屏幕未锁屏。 | - ```js - screenlock.isScreenLocked().then((data) => { - console.log('isScreenLocked success: data -> ${JSON.stringify(data)}'); - }).catch((err) => { - console.error('isScreenLocked fail, promise: err -> ${JSON.stringify(err)}'); - }); - ``` +**示例:** +```js +screenlock.isScreenLocked().then((data) => { + console.log('isScreenLocked success: data -> ${JSON.stringify(data)}'); +}).catch((err) => { + console.error('isScreenLocked fail, promise: err -> ${JSON.stringify(err)}'); +}); +``` ## screenlock.isLocked9+ -isLocked(): boolean; +isLocked(): boolean 判断屏幕是否锁屏,使用同步方法。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**返回值**: - - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示当前屏幕已锁定,返回false表示当前屏幕未锁定。 | +**返回值:** -**示例**: +| 类型 | 说明 | +| ------- | ------------------------------------------------- | +| boolean | 返回true表示屏幕已锁屏,返回false表示屏幕未锁屏。 | - ```js - var isLocked = screenlock.isLocked(); - ``` +**示例:** +```js +let isLocked = screenlock.isLocked(); +``` ## screenlock.isSecureMode isSecureMode(callback: AsyncCallback<boolean>): void -判断设备是否处于安全模式下,使用callback作为异步方法。 +判断设备是否处于安全模式下,使用callback异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 -> -> 从 API version 7开始支持。 +> +> 从 API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------------ | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | -**示例**: - - ```js - screenlock.isSecureMode((err, data)=>{ - if (err) { - console.error('isSecureMode callback error -> ${JSON.stringify(err)}'); - return; - } - console.info('isSecureMode callback success data -> ${JSON.stringify(err)}'); - }); - ``` +**示例:** +```js +screenlock.isSecureMode((err, data)=>{ + if (err) { + console.error('isSecureMode callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('isSecureMode callback success data -> ${JSON.stringify(err)}'); +}); +``` ## screenlock.isSecureMode isSecureMode(): Promise<boolean> -判断设备是否处于安全模式下,使用Promise作为异步方法。 +判断设备是否处于安全模式下,使用Promise异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 -> -> 从 API version 7开始支持。 - -**系统能力**: SystemCapability.MiscServices.ScreenLock +> +> 从 API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.isSecure9+](#screenlockissecure9)代替。 -**返回值**: +**系统能力:** SystemCapability.MiscServices.ScreenLock - | 类型 | 说明 | - | -------- | -------- | - | Promise<boolean> | 以Promise形式返回结果。 | +**返回值:** -**示例**: +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | - ```js - screenlock.isSecureMode().then((data) => { - console.log('isSecureMode success: data->${JSON.stringify(data)}'); - }).catch((err) => { - console.error('isSecureMode fail, promise: err->${JSON.stringify(err)}'); - }); - ``` +**示例:** +```js +screenlock.isSecureMode().then((data) => { + console.log('isSecureMode success: data->${JSON.stringify(data)}'); +}).catch((err) => { + console.error('isSecureMode fail, promise: err->${JSON.stringify(err)}'); +}); +``` ## screenlock.isSecure9+ -isSecure(): boolean; - -判断设备是否处于安全模式下,使用同步方法。 +isSecure(): boolean -**系统能力**: SystemCapability.MiscServices.ScreenLock +判断设备是否处于安全模式下。 -**返回值**: +**系统能力:** SystemCapability.MiscServices.ScreenLock - | 类型 | 说明 | - | -------- | -------- | - | boolean | 返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | +**返回值:** -**示例**: +| 类型 | 说明 | +| ------- | ------------------------------------------------------------ | +| boolean | 返回true表示屏幕处于安全模式下,返回false表示屏幕当前不在安全模式下。 | - ```js - var isSecure = screenlock.isSecure(); - ``` +**示例:** +```js +let isSecure = screenlock.isSecure(); +``` ## screenlock.unlockScreen unlockScreen(callback: AsyncCallback<void>): void -解锁屏幕,使用callback作为异步方法。 +解锁屏幕,使用callback异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 -> -> 从 API version 7开始支持。 +> +> 从 API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数,失败时返回错误信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | --------------- | +| callback | AsyncCallback<void> | 是 | 回调函数,失败时返回错误信息。 | -**示例**: - - ```js - screenlock.unlockScreen((err) => { - if (err) { - console.error('unlockScreen callback error -> ${JSON.stringify(err)}'); - return; - } - console.info('unlockScreen callback success'); - }); - ``` +**示例:** +```js +screenlock.unlockScreen((err) => { + if (err) { + console.error('unlockScreen callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('unlockScreen callback success'); +}); +``` ## screenlock.unlockScreen unlockScreen(): Promise<void> -解锁屏幕,使用Promise作为异步方法。 +解锁屏幕,使用Promise异步回调。 > **说明:** -> 从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 -> -> 从 API version 7开始支持。 +> +> 从 API version 7开始支持,从API version 9开始废弃。建议使用[screenlock.unlock9+](#screenlockunlock9)代替。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**返回值**: +**返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 以Promise形式返回结果。 | +| 类型 | 说明 | +| ------------------- | ------------------------- | +| Promise<void> | 无返回结果的Promise对象。 | -**示例**: - - ```js - screenlock.unlockScreen().then(() => { - console.log('unlockScreen success'); - }).catch((err) => { - console.error('unlockScreen fail, promise: err->${JSON.stringify(err)}'); - }); - ``` +**示例:** +```js +screenlock.unlockScreen().then(() => { + console.log('unlockScreen success'); +}).catch((err) => { + console.error('unlockScreen fail, promise: err->${JSON.stringify(err)}'); +}); +``` ## screenlock.unlock9+ unlock(callback: AsyncCallback<boolean>): void -解锁屏幕,使用callback作为异步方法。 +解锁屏幕,使用callback异步回调。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。返回true表示屏幕解锁成功,返回false表示屏幕解锁失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------------- | +| callback | AsyncCallback<void> | 是 | 回调函数。返回true表示屏幕解锁成功,返回false表示屏幕解锁失败。 | -**示例**: - - ```js - screenlock.unlock((err,data) => { - if (err) { - console.error('unlock error -> ${JSON.stringify(err)}'); - return; - } - console.info('unlock success data -> ${JSON.stringify(data)}'); - }); - ``` +**示例:** +```js +screenlock.unlock((err,data) => { + if (err) { + console.error('unlock error -> ${JSON.stringify(err)}'); + return; + } + console.info('unlock success data -> ${JSON.stringify(data)}'); +}); +``` ## screenlock.unlock9+ unlock(): Promise<boolean> -解锁屏幕,使用Promise作为异步方法。 +解锁屏幕,使用Promise异步回调。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**返回值**: +**返回值:** - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 以Promise形式返回结果。 | +| 类型 | 说明 | +| ------------------- | ------------------------------------------------------------ | +| Promise<void> | Promise对象。返回true表示屏幕解锁成功,返回false表示屏幕解锁失败。 | -**示例**: - - ```js - screenlock.unlock().then((data) => { - console.log('unlock success'); - }).catch((err) => { - console.error('unlock fail, : err->${JSON.stringify(err)}'); - }); - ``` +**示例:** +```js +screenlock.unlock().then((data) => { + console.log('unlock success'); +}).catch((err) => { + console.error('unlock fail, : err->${JSON.stringify(err)}'); +}); +``` ## screenlock.lock9+ lock(callback: AsyncCallback<boolean>): void -锁定屏幕,使用callback作为异步方法。 +锁定屏幕,使用callback异步回调。 + +**系统能力:** SystemCapability.MiscServices.ScreenLock -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统接口**:此接口为系统接口。 -**系统接口**:此接口为系统接口,三方应用不支持调用。 +**参数:** -**参数**: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------- | +| callback | AsyncCallback<boolean> | 是 | 回调函数。返回true表示屏幕锁定成功,返回false表示屏幕锁定失败。 | - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | 是 | 回调函数。返回true表示屏幕锁定成功,返回false表示屏幕锁定失败。 | +**示例:** -**示例**: - - ```js - screenlock.lock((err) => { - if (err) { - console.error('lock callback error -> ${JSON.stringify(err)}'); - return; - } - console.info('lock callback success'); - }); - ``` +```js +screenlock.lock((err,data) => { + if (err) { + console.error('lock callback error -> ${JSON.stringify(err)}'); + return; + } + console.info('lock callback success'); +}); +``` ## screenlock.lock9+ lock(): Promise<boolean> -锁定屏幕,使用Promise作为异步方法。 +锁定屏幕,使用Promise异步回调。 + +**系统能力:** SystemCapability.MiscServices.ScreenLock -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统接口**:此接口为系统接口。 -**系统接口**:此接口为系统接口,三方应用不支持调用。 +**返回值:** -**返回值**: +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | +| Promise<boolean> | Promise对象。返回true表示屏幕锁定成功,返回false表示屏幕锁定失败。 | - | 类型 | 说明 | - | -------- | -------- | - | Promise<void> | 以Promise形式返回结果。 | +**示例:** -**示例**: - - ```js - screenlock.lock().then(() => { - console.log('lock success'); - }).catch((err) => { - console.error('lock fail, promise: err->${JSON.stringify(err)}'); - }); - ``` +```js +screenlock.lock().then((data) => { + console.log('lock success'); +}).catch((err) => { + console.error('lock fail, promise: err->${JSON.stringify(err)}'); +}); +``` ## EventType 定义系统事件类型。 -**系统能力**: SystemCapability.MiscServices.ScreenLock - - | 名称 | 说明 | - | -------- | -------- | - | beginWakeUp | 表示事件开始时开始唤醒。 | - | endWakeUp | 表示事件结束时结束唤醒。 | - | beginScreenOn | 表示事件开始时开始亮屏。 | - | endScreenOn | 表示事件结束时结束亮屏。 | - | beginScreenOff | 表示事件开始时开始灭屏。 | - | endScreenOff | 表示事件结束时结束灭屏。 | - | unlockScreen | 表示请求解锁屏幕。 | - | lockScreen | 表示请求锁定屏幕。 | - | beginExitAnimation | 表示动画开始退场。 | - | beginSleep | 表示开始休眠。 | - | endSleep | 表示结束休眠。 | - | changeUser | 表示切换用户。 | - | screenlockEnabled | 表示锁屏是否启用。 | - | serviceRestart | 表示锁屏服务进行重启。 | +**系统能力:** SystemCapability.MiscServices.ScreenLock + +| 名称 | 说明 | +| ------------------ | ------------------------ | +| beginWakeUp | 表示事件开始时开始唤醒。 | +| endWakeUp | 表示事件结束时结束唤醒。 | +| beginScreenOn | 表示事件开始时开始亮屏。 | +| endScreenOn | 表示事件结束时结束亮屏。 | +| beginScreenOff | 表示事件开始时开始灭屏。 | +| endScreenOff | 表示事件结束时结束灭屏。 | +| unlockScreen | 表示请求解锁屏幕。 | +| lockScreen | 表示请求锁定屏幕。 | +| beginExitAnimation | 表示动画开始退场。 | +| beginSleep | 表示开始休眠。 | +| endSleep | 表示结束休眠。 | +| changeUser | 表示切换用户。 | +| screenlockEnabled | 表示锁屏是否启用。 | +| serviceRestart | 表示锁屏服务进行重启。 | ## SystemEvent 定义系统事件回调参数结构。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock - | 名称 | 说明 | - | -------- | -------- | - | eventType | 系统事件类型。 | - | params | 系统事件的事件参数。 | +| 名称 | 说明 | +| --------- | -------------------- | +| eventType | 系统事件类型。 | +| params | 系统事件的事件参数。 | ## screenlock.onSystemEvent9+ @@ -389,89 +371,86 @@ onSystemEvent(callback: Callback\): boolean 注册锁屏相关的系统事件。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**系统接口**:此接口为系统接口,三方应用不支持调用。 +**系统接口**:此接口为系统接口。 -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | callback | Callback\ | 是 | 锁屏相关的系统事件回调函数 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ---------------------------- | +| callback | Callback\<[SystemEvent](#systemevent)> | 是 | 锁屏相关的系统事件回调函数。 | **返回值:** - | 类型 | 说明 | - | ------- | -------------------------------------------- | - | boolean | 返回true表示锁屏系统事件注册成功,否则返回false| - -**示例**: - - ```js - let isSuccess = screenlock.onSystemEvent((err, event)=>{ - console.log(`onSystemEvent:callback:${event.eventType}`) - if (err) { - console.log(`onSystemEvent callback error -> ${JSON.stringify(err)}`); - } - }); - if (!isSuccess) { - console.log(`onSystemEvent result is false`) - } - ``` +| 类型 | 说明 | +| ------- | ------------------------------------------------- | +| boolean | 返回true表示锁屏系统事件注册成功,否则返回false。 | + +**示例:** + +```js +let isSuccess = screenlock.onSystemEvent((event)=>{ + console.log(`onSystemEvent:callback:${event.eventType}`) +}); +if (!isSuccess) { + console.log(`onSystemEvent result is false`) +} +``` ## screenlock.sendScreenLockEvent9+ -sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\): void +sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback\): void -应用发送事件到锁屏服务,异步方法。 +应用发送事件到锁屏服务,使用callback异步回调。 -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统能力:** SystemCapability.MiscServices.ScreenLock -**系统接口**:此接口为系统接口,三方应用不支持调用。 +**系统接口**:此接口为系统接口。 -**参数**: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "screenDrawDone",表示屏幕绘制完成。 | - | parameter | number | 是 | 解锁状态。
- parameter为0,表示解锁成功。
- parameter为1,表示解锁失败。
- parameter为2,表示解锁取消。 | - | callback | AsyncCallback\ | 是 | 表示执行结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------ | ---- | -------------------- | +| event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "screenDrawDone",表示屏幕绘制完成。 | +| parameter | number | 是 | 解锁状态。
- parameter为0,表示解锁成功。
- parameter为1,表示解锁失败。
- parameter为2,表示解锁取消。 | +| callback | AsyncCallback\ | 是 | 回调函数,返回执行的结果。true表示执行成功,false表示执行失败。 | -**示例**: - - ```js - screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { - console.log('sending result:' + result); - }); - ``` +**示例:** + +```js +screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { + console.log('sending result:' + result); +}); +``` ## screenlock.sendScreenLockEvent9+ -sendScreenLockEvent(event: String, parameter: number): Promise\ +sendScreenLockEvent(event: String, parameter: number): Promise\ + +应用发送事件到锁屏服务,使用Promise异步回调。 -应用发送事件到锁屏服务,异步方法。 +**系统能力:** SystemCapability.MiscServices.ScreenLock -**系统能力**: SystemCapability.MiscServices.ScreenLock +**系统接口**:此接口为系统接口。 -**系统接口**:此接口为系统接口,三方应用不支持调用。 +**参数:** -**参数**: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | --------------------------------------- | +| event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "screenDrawDone",表示屏幕绘制完成。 | +| parameter | number | 是 | 解锁状态。
- parameter为0,表示解锁成功。
- parameter为1,表示解锁失败。
- parameter为2,表示解锁取消。 | - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | event | String | 是 | 事件类型,支持如下取值:
- "unlockScreenResult",表示解锁结果。
- "screenDrawDone",表示屏幕绘制完成。 | - | parameter | number | 是 | 解锁状态。
- parameter为0,表示解锁成功。
- parameter为1,表示解锁失败。
- parameter为2,表示解锁取消。 | +**返回值:** -**返回值**: +| 类型 | 说明 | +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise对象,返回执行的结果。true表示执行成功,false表示执行失败。 | - | 类型 | 说明 | - | -------- | -------- | - | Promise\ | 以Promise形式返回执行结果。 | +**示例:** -**示例**: - - ```js - screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { - console.log('sending result:' + result); - }); - ``` +```js +screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => { + console.log('sending result:' + result); +}); +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-screen.md b/zh-cn/application-dev/reference/apis/js-apis-screen.md index 23be691d792e46a5e86e562fbea267aa06ec25f1..70b136d4edd3883a8b52a913ce6b9fa4bf65c56d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screen.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screen.md @@ -154,7 +154,7 @@ makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number& | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------ | ---- | -------------------------------- | | options | Array<[ExpandOption](#expandoption)> | 是 | 设置扩展屏幕的参数集合。 | -| callback | Callback<number> | 是 | 回调函数。返回扩展屏幕的群组id。 | +| callback | AsyncCallback<number> | 是 | 回调函数。返回扩展屏幕的群组id。 | **错误码:** @@ -709,7 +709,7 @@ try { **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | ---- | ---- | ------------------- | | screenId | number | 是 | 是 | 屏幕的id。 | | startX | number | 是 | 是 | 屏幕的起始X轴坐标。 | @@ -721,7 +721,7 @@ try { **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------- | -------- | ---- | ---- | ------------------------- | | name | string | 是 | 是 | 指定虚拟屏幕的名称。 | | width | number | 是 | 是 | 指定虚拟屏幕的宽度。 | @@ -737,7 +737,7 @@ try { **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------------- | ---------------------------------------------- | ---- | ---- | ---------------------- | | id | number | 是 | 否 | 屏幕的id。 | | parent | number | 是 | 否 | 屏幕所属群组的id。 | @@ -1003,7 +1003,7 @@ try { **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | -------- | ---- | ---- | -------------------------------------------------- | | id | number | 是 | 是 | 模式id,所支持的模式由具体设备分辨率和刷新率决定。 | | width | number | 是 | 是 | 屏幕的宽度。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md index 86d42135ec5e3a9d9926cb753d4f80f57d12e24b..85dc24395f65aa8a73e1a7a365393337e9fe454a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-screenshot.md +++ b/zh-cn/application-dev/reference/apis/js-apis-screenshot.md @@ -20,7 +20,7 @@ import screenshot from '@ohos.screenshot'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------------------- | ------------- | ---- | ------------------------------------------------------------ | | screenRect | [Rect](#rect) | 否 | 表示截取图像的区域,不传值默认为全屏。 | | imageSize | [Size](#size) | 否 | 表示截取图像的大小,不传值默认为全屏。 | @@ -34,7 +34,7 @@ import screenshot from '@ohos.screenshot'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | | left | number | 是 | 表示截取图像区域的左边界。| | top | number | 是 | 表示截取图像区域的上边界。| @@ -48,7 +48,7 @@ import screenshot from '@ohos.screenshot'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | | width | number | 是 | 表示截取图像的宽度。| | height | number | 是 | 表示截取图像的高度。| diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index c95391469e678dfb6822b15a12d4242c426d358f..6be2c9cd36e49db2dcddc5f5bf61eff3a359c597 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -26,11 +26,11 @@ on(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AccelerometerResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -68,9 +68,9 @@ on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<Acceleromete | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AccelerometerUncalibratedResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -107,11 +107,11 @@ on(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>, option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- | +| type | [SensorId](#sensorid9).AMBIENT_LIGHT | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | | callback | Callback<[LightResponse](#lightresponse)> | 是 | 回调函数,异步上报的传感器数据固定为LightResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -145,9 +145,9 @@ on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatureR | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | +| type | [SensorId](#sensorid9).AMBIENT_TEMPERATURE | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AmbientTemperatureResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -179,11 +179,11 @@ on(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>, option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).BAROMETER | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为BarometerResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -215,11 +215,11 @@ on(type: SensorId.GRAVITY, callback: Callback<GravityResponse>,options?: O **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------------- | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------- | +| type | [SensorId](#sensorid9).GRAVITY | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为GravityResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -255,11 +255,11 @@ on(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>,options **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).GYROSCOPE | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 回调函数,异步上报的传感器数据固定为GyroscopeResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -298,9 +298,9 @@ on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncalib | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为GyroscopeUncalibratedResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -337,11 +337,11 @@ on(type: SensorId.HALL, callback: Callback<HallResponse>, options?: Option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HALL。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | -------------------------------------------------- | +| type | [SensorId](#sensorid9).HALL | 是 | 传感器类型,该值固定为SensorId.HALL。 | | callback | Callback<[HallResponse](#hallresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HallResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -375,11 +375,11 @@ on(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>,option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).HEART_RATE | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HeartRateResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -411,11 +411,11 @@ on(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>,options?: **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------ | +| type | [SensorId](#sensorid9).HUMIDITY | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HumidityResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -452,9 +452,9 @@ on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAcceleromete | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELEROMETER。 | +| type | [SensorId](#sensorid9).LINEAR_ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELEROMETER。 | | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为LinearAccelerometerResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -488,11 +488,11 @@ on(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 回调函数,异步上报的传感器数据固定为MagneticFieldResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -528,9 +528,9 @@ on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticFie | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为MagneticFieldUncalibratedResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -575,11 +575,11 @@ on(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>,opt **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------------------- | +| type | [SensorId](#sensorid9).ORIENTATION | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | | callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 回调函数,异步上报的传感器数据固定为OrientationResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **示例:** @@ -615,11 +615,11 @@ on(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>, option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).PEDOMETER | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | | callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为PedometerResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **示例:** @@ -648,9 +648,9 @@ on(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectionR | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | +| type | [SensorId](#sensorid9).PEDOMETER_DETECTION | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为PedometerDetectionResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -682,11 +682,11 @@ on(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>, option **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).PROXIMITY | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为ProximityResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -721,9 +721,9 @@ on(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorResponse& | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | +| type | [SensorId](#sensorid9).ROTATION_VECTOR | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 回调函数,异步上报的传感器数据固定为RotationVectorResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -761,9 +761,9 @@ on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionRes | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | +| type | [SensorId](#sensorid9).SIGNIFICANT_MOTION | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为SignificantMotionResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -796,11 +796,11 @@ on(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).WEAR_DETECTION | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为WearDetectionResponse。 | -| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | +| options | [Options](#options) | 否 | 设置上报频率,默认值为200000000ns。 | **错误码**: @@ -836,9 +836,9 @@ once(type: SensorId.ACCELEROMETER, callback: Callback<AccelerometerResponse&g **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AccelerometerResponse。 | **错误码**: @@ -877,7 +877,7 @@ once(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback: Callback<Accelerome | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AccelerometerUncalibratedResponse。 | **错误码**: @@ -915,9 +915,9 @@ once(type: SensorId.AMBIENT_LIGHT, callback: Callback<LightResponse>): voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | --------------------------------------------------- | +| type | [SensorId](#sensorid9).AMBIENT_LIGHT | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | | callback | Callback<[LightResponse](#lightresponse)> | 是 | 回调函数,异步上报的传感器数据固定为LightResponse。 | **错误码**: @@ -952,7 +952,7 @@ once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback<AmbientTemperatur | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | +| type | [SensorId](#sensorid9).AMBIENT_TEMPERATURE | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | | callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 回调函数,异步上报的传感器数据固定为AmbientTemperatureResponse。 | **错误码**: @@ -985,9 +985,9 @@ once(type: SensorId.BAROMETER, callback: Callback<BarometerResponse>): voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).BAROMETER | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | | callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为BarometerResponse。 | **错误码**: @@ -1020,9 +1020,9 @@ once(type: SensorId.GRAVITY, callback: Callback<GravityResponse>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------- | +| type | [SensorId](#sensorid9).GRAVITY | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | | callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为GravityResponse。 | **错误码**: @@ -1059,9 +1059,9 @@ once(type: SensorId.GYROSCOPE, callback: Callback<GyroscopeResponse>): voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).GYROSCOPE | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | | callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 回调函数,异步上报的传感器数据固定为GyroscopeResponse。 | **错误码**: @@ -1100,7 +1100,7 @@ once(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback<GyroscopeUncal | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | | callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为GyroscopeUncalibratedResponse。 | **错误码**: @@ -1138,9 +1138,9 @@ once(type: SensorId.HALL, callback: Callback<HallResponse>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HALL。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | -------------------------------------------------- | +| type | [SensorId](#sensorid9).HALL | 是 | 传感器类型,该值固定为SensorId.HALL。 | | callback | Callback<[HallResponse](#hallresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HallResponse。 | **错误码**: @@ -1175,9 +1175,9 @@ once(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>): vo **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).HEART_RATE | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HeartRateResponse。 | **错误码**: @@ -1192,7 +1192,7 @@ once(type: SensorId.HEART_RATE, callback: Callback<HeartRateResponse>): vo ```js try { - sensor.once(sensor.SensorId.HEART_BEAT_RATE, function (data) { + sensor.once(sensor.SensorId.HEART_RATE, function (data) { console.info('Heart rate: ' + data.heartRate); }); } catch (err) { @@ -1210,9 +1210,9 @@ once(type: SensorId.HUMIDITY, callback: Callback<HumidityResponse>): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------ | +| type | [SensorId](#sensorid9).HUMIDITY | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | | callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为HumidityResponse。 | **错误码**: @@ -1249,7 +1249,7 @@ once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback<LinearAccelerome | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELEROMETER。 | +| type | [SensorId](#sensorid9).LINEAR_ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELEROMETER。 | | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为LinearAccelerometerResponse。 | **错误码**: @@ -1284,9 +1284,9 @@ once(type: SensorId.MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse& **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | | callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 回调函数,异步上报的传感器数据固定为MagneticFieldResponse。 | **错误码**: @@ -1323,7 +1323,7 @@ once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback: Callback<MagneticF | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | | callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 回调函数,异步上报的传感器数据固定为MagneticFieldUncalibratedResponse。 | **错误码**: @@ -1361,9 +1361,9 @@ once(type: SensorId.ORIENTATION, callback: Callback<OrientationResponse>): **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------------------- | +| type | [SensorId](#sensorid9).ORIENTATION | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | | callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 回调函数,异步上报的传感器数据固定为OrientationResponse。 | **错误码**: @@ -1400,9 +1400,9 @@ once(type: SensorId.PEDOMETER, callback: Callback<PedometerResponse>): voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).PEDOMETER | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | | callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 回调函数,异步上报的传感器数据固定为PedometerResponse。 | **错误码**: @@ -1438,7 +1438,7 @@ once(type: SensorId.PEDOMETER_DETECTION, callback: Callback<PedometerDetectio | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | +| type | [SensorId](#sensorid9).PEDOMETER_DETECTION | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | | callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为PedometerDetectionResponse。 | **错误码**: @@ -1471,9 +1471,9 @@ once(type: SensorId.PROXIMITY, callback: Callback<ProximityResponse>): voi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------- | +| type | [SensorId](#sensorid9).PROXIMITY | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | | callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 回调函数,异步上报的传感器数据固定为ProximityResponse。 | **错误码**: @@ -1508,7 +1508,7 @@ once(type: SensorId.ROTATION_VECTOR, callback: Callback<RotationVectorRespons | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | +| type | [SensorId](#sensorid9).ROTATION_VECTOR | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | | callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 回调函数,异步上报的传感器数据固定为RotationVectorResponse。 | **错误码**: @@ -1546,7 +1546,7 @@ once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback<SignificantMotionR | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | +| type | [SensorId](#sensorid9).SIGNIFICANT_MOTION | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | | callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为SignificantMotionResponse。 | **错误码**: @@ -1579,9 +1579,9 @@ once(type: SensorId.WEAR_DETECTION, callback: Callback<WearDetectionResponse& **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorId](#sensorid9).WEAR_DETECTION | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | | callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 回调函数,异步上报的传感器数据固定为WearDetectionResponse。 | **错误码**: @@ -1620,7 +1620,7 @@ off(type: SensorId.ACCELEROMETER, callback?: Callback<AccelerometerResponse&g | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | +| type | [SensorId](#sensorid9).ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER。 | | callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1658,7 +1658,7 @@ off(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback?: Callback<Accelerome | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | +| type | [SensorId](#sensorid9).ACCELEROMETER_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.ACCELEROMETER_UNCALIBRATED。 | | callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1694,8 +1694,8 @@ off(type: SensorId.AMBIENT_LIGHT, callback?: Callback<LightResponse>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).AMBIENT_LIGHT | 是 | 传感器类型,该值固定为SensorId.AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1715,7 +1715,7 @@ try { sensor.off(sensor.SensorId.AMBIENT_LIGHT); } catch (err) { console.error('Off fail, errCode: ' + err.code + ' ,msg: ' + err.message); -}V +} ``` ### AMBIENT_TEMPERATURE9+ @@ -1730,8 +1730,8 @@ off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatur | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).AMBIENT_TEMPERATURE | 是 | 传感器类型,该值固定为SensorId.AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1766,8 +1766,8 @@ off(type: SensorId.BAROMETER, callback?: Callback<BarometerResponse>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).BAROMETER | 是 | 传感器类型,该值固定为SensorId.BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1802,8 +1802,8 @@ off(type: SensorId.GRAVITY, callback?: Callback<GravityResponse>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).GRAVITY | 是 | 传感器类型,该值固定为SensorId.GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1840,8 +1840,8 @@ off(type: SensorId.GYROSCOPE, callback?: Callback<GyroscopeResponse>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).GYROSCOPE | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1878,8 +1878,8 @@ off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncal | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).GYROSCOPE_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1914,8 +1914,8 @@ off(type: SensorId.HALL, callback?: Callback<HallResponse>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).HALL | 是 | 传感器类型,该值固定为SensorId.HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1952,8 +1952,8 @@ off(type: SensorId.HEART_RATE, callback?: Callback<HeartRateResponse>): vo | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).HEART_RATE | 是 | 传感器类型,该值固定为SensorId.HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -1988,8 +1988,8 @@ off(type: SensorId.HUMIDITY, callback?: Callback<HumidityResponse>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).HUMIDITY | 是 | 传感器类型,该值固定为SensorId.HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2026,8 +2026,8 @@ off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback<LinearAccelerome | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).LINEAR_ACCELEROMETER | 是 | 传感器类型,该值固定为SensorId.LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2062,8 +2062,8 @@ off(type: SensorId.MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse& | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | -| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2098,8 +2098,8 @@ off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticF | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).MAGNETIC_FIELD_UNCALIBRATED | 是 | 传感器类型,该值固定为SensorId.MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2134,8 +2134,8 @@ off(type: SensorId.ORIENTATION, callback?: Callback<OrientationResponse>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).ORIENTATION | 是 | 传感器类型,该值固定为SensorId.ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2172,8 +2172,8 @@ off(type: SensorId.PEDOMETER, callback?: Callback<PedometerResponse>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).PEDOMETER | 是 | 传感器类型,该值固定为SensorId.PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2210,8 +2210,8 @@ off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback<PedometerDetectio | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).PEDOMETER_DETECTION | 是 | 传感器类型,该值固定为SensorId.PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2246,8 +2246,8 @@ off(type: SensorId.PROXIMITY, callback?: Callback<ProximityResponse>): voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).PROXIMITY | 是 | 传感器类型,该值固定为SensorId.PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2282,8 +2282,8 @@ off(type: SensorId.ROTATION_VECTOR, callback?: Callback<RotationVectorRespons | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).ROTATION_VECTOR | 是 | 传感器类型,该值固定为SensorId.ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2318,8 +2318,8 @@ off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionR | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).SIGNIFICANT_MOTION | 是 | 传感器类型,该值固定为SensorId.SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -2354,8 +2354,8 @@ off(type: SensorId.WEAR_DETECTION, callback?: Callback<WearDetectionResponse& | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| type | [SensorId](#sensorid9) | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | +| type | [SensorId](#sensorid9).WEAR_DETECTION | 是 | 传感器类型,该值固定为SensorId.WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 否 | 需要取消订阅的回调函数,若无此参数,则取消订阅当前类型的所有回调函数。 | **示例:** @@ -3340,7 +3340,7 @@ getSingleSensor(type: SensorId, callback: AsyncCallback<Sensor>): void ```js try { - sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER, (err, data) => { + sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER, (err, data) => { if (err) { console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); return; @@ -3384,7 +3384,7 @@ try { ```js try { - sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER).then((data) => { + sensor.getSingleSensor(sensor.SensorId.ACCELEROMETER).then((data) => { console.info('Sensor: ' + JSON.stringify(data)); }, (err) => { console.error('Get singleSensor failed. Error code: ' + err.code + '; message: ' + err.message); @@ -3400,29 +3400,29 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 默认值 | 说明 | -| --------------------------- | ------ | ---------------------- | -| ACCELEROMETER | 1 | 加速度传感器。 | -| GYROSCOPE | 2 | 陀螺仪传感器。 | -| AMBIENT_LIGHT | 5 | 环境光传感器。 | -| MAGNETIC_FIELD | 6 | 磁场传感器。 | -| BAROMETER | 8 | 气压计传感器。 | -| HALL | 10 | 霍尔传感器。 | -| PROXIMITY | 12 | 接近光传感器。 | -| HUMIDITY | 13 | 湿度传感器。 | -| ORIENTATION | 256 | 方向传感器。 | -| GRAVITY | 257 | 重力传感器。 | -| LINEAR_ACCELEROMETER | 258 | 线性加速度传感器。 | -| ROTATION_VECTOR | 259 | 旋转矢量传感器。 | -| AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | -| MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | -| GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | -| SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | -| PEDOMETER_DETECTION | 265 | 计步检测传感器。 | -| PEDOMETER | 266 | 计步传感器。 | -| HEART_RATE | 278 | 心率传感器。 | -| WEAR_DETECTION | 280 | 佩戴检测传感器。 | -| ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | +| 名称 | 值 | 说明 | +| --------------------------- | ---- | ---------------------- | +| ACCELEROMETER | 1 | 加速度传感器。 | +| GYROSCOPE | 2 | 陀螺仪传感器。 | +| AMBIENT_LIGHT | 5 | 环境光传感器。 | +| MAGNETIC_FIELD | 6 | 磁场传感器。 | +| BAROMETER | 8 | 气压计传感器。 | +| HALL | 10 | 霍尔传感器。 | +| PROXIMITY | 12 | 接近光传感器。 | +| HUMIDITY | 13 | 湿度传感器。 | +| ORIENTATION | 256 | 方向传感器。 | +| GRAVITY | 257 | 重力传感器。 | +| LINEAR_ACCELEROMETER | 258 | 线性加速度传感器。 | +| ROTATION_VECTOR | 259 | 旋转矢量传感器。 | +| AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | +| MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | +| GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | +| SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | +| PEDOMETER_DETECTION | 265 | 计步检测传感器。 | +| PEDOMETER | 266 | 计步传感器。 | +| HEART_RATE | 278 | 心率传感器。 | +| WEAR_DETECTION | 280 | 佩戴检测传感器。 | +| ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | ## SensorType(deprecated) @@ -3431,29 +3431,29 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 默认值 | 说明 | -| ------------------------------------------ | ------ | ---------------------- | -| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | -| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | -| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | -| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | -| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | -| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | -| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | -| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | -| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | 线性加速度传感器。 | -| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | -| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | -| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | -| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | -| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | -| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | -| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | -| SENSOR_TYPE_ID_HEART_RATE | 278 | 心率传感器。 | -| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | -| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | +| 名称 | 值 | 说明 | +| ------------------------------------------ | ---- | ---------------------- | +| SENSOR_TYPE_ID_ACCELEROMETER | 1 | 加速度传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE | 2 | 陀螺仪传感器。 | +| SENSOR_TYPE_ID_AMBIENT_LIGHT | 5 | 环境光传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD | 6 | 磁场传感器。 | +| SENSOR_TYPE_ID_BAROMETER | 8 | 气压计传感器。 | +| SENSOR_TYPE_ID_HALL | 10 | 霍尔传感器。 | +| SENSOR_TYPE_ID_PROXIMITY | 12 | 接近光传感器。 | +| SENSOR_TYPE_ID_HUMIDITY | 13 | 湿度传感器。 | +| SENSOR_TYPE_ID_ORIENTATION | 256 | 方向传感器。 | +| SENSOR_TYPE_ID_GRAVITY | 257 | 重力传感器。 | +| SENSOR_TYPE_ID_LINEAR_ACCELERATION | 258 | 线性加速度传感器。 | +| SENSOR_TYPE_ID_ROTATION_VECTOR | 259 | 旋转矢量传感器。 | +| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 260 | 环境温度传感器。 | +| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 261 | 未校准磁场传感器。 | +| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 263 | 未校准陀螺仪传感器。 | +| SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 264 | 有效运动传感器。 | +| SENSOR_TYPE_ID_PEDOMETER_DETECTION | 265 | 计步检测传感器。 | +| SENSOR_TYPE_ID_PEDOMETER | 266 | 计步传感器。 | +| SENSOR_TYPE_ID_HEART_RATE | 278 | 心率传感器。 | +| SENSOR_TYPE_ID_WEAR_DETECTION | 280 | 佩戴检测传感器。 | +| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281 | 未校准加速度计传感器。 | ## Response @@ -3462,9 +3462,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | ------------------------ | -| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ------------------------ | +| timestamp | number | 是 | 是 | 传感器数据上报的时间戳。 | ## Sensor9+ @@ -3472,18 +3472,18 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 说明 | -| --------------- | -------- | ---------------------- | -| sensorName | string | 传感器名称。 | -| venderName | string | 传感器供应商。 | -| firmwareVersion | string | 传感器固件版本。 | -| hardwareVersion | string | 传感器硬件版本。 | -| sensorId | number | 传感器类型id。 | -| maxRange | number | 传感器测量范围的最大值。 | -| minSamplePeriod | number | 允许的最小采样周期。 | -| maxSamplePeriod | number | 允许的最大采样周期。 | -| precision | number | 传感器精度。 | -| power | number | 传感器功率。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------- | -------- | ---------------------- | ---------------------- | ---------------------- | +| sensorName | string | 是 | 是 | 传感器名称。 | +| venderName | string | 是 | 是 | 传感器供应商。 | +| firmwareVersion | string | 是 | 是 | 传感器固件版本。 | +| hardwareVersion | string | 是 | 是 | 传感器硬件版本。 | +| sensorId | number | 是 | 是 | 传感器类型id。 | +| maxRange | number | 是 | 是 | 传感器测量范围的最大值。 | +| minSamplePeriod | number | 是 | 是 | 允许的最小采样周期。 | +| maxSamplePeriod | number | 是 | 是 | 允许的最大采样周期。 | +| precision | number | 是 | 是 | 传感器精度。 | +| power | number | 是 | 是 | 传感器功率。 | ## AccelerometerResponse @@ -3492,11 +3492,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ------------------------------------ | -| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ------------------------------------ | +| x | number | 是 | 是 | 施加在设备x轴的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的加速度,单位 : m/s2。 | ## LinearAccelerometerResponse @@ -3506,11 +3506,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ---------------------------------------- | -| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| x | number | 是 | 是 | 施加在设备x轴的线性加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的线性加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的线性加速度,单位 : m/s2。 | ## AccelerometerUncalibratedResponse @@ -3520,14 +3520,14 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | ------------------------------------------------ | -| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | -| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | -| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | -| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------------------------------ | +| x | number | 是 | 是 | 施加在设备x轴未校准的加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴未校准的加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴未校准的加速度,单位 : m/s2。 | +| biasX | number | 是 | 是 | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。 | +| biasY | number | 是 | 是 | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 | +| biasZ | number | 是 | 是 | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。 | ## GravityResponse @@ -3537,11 +3537,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ---------------------------------------- | -| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | -| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | -| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ---------------------------------------- | +| x | number | 是 | 是 | 施加在设备x轴的重力加速度,单位 : m/s2。 | +| y | number | 是 | 是 | 施加在设备y轴的重力加速度,单位 : m/s2。 | +| z | number | 是 | 是 | 施加在设备z轴的重力加速度,单位 : m/s2。 | ## OrientationResponse @@ -3551,11 +3551,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | --------------------------------- | -| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | -| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | -| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | --------------------------------- | +| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | +| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | +| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | ## RotationVectorResponse @@ -3565,12 +3565,12 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ----------------- | -| x | number | 是 | 是 | 旋转矢量x轴分量。 | -| y | number | 是 | 是 | 旋转矢量y轴分量。 | -| z | number | 是 | 是 | 旋转矢量z轴分量。 | -| w | number | 是 | 是 | 标量。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ----------------- | +| x | number | 是 | 是 | 旋转矢量x轴分量。 | +| y | number | 是 | 是 | 旋转矢量y轴分量。 | +| z | number | 是 | 是 | 旋转矢量z轴分量。 | +| w | number | 是 | 是 | 标量。 | ## GyroscopeResponse @@ -3580,11 +3580,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | -------------------------------- | -| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | -------------------------------- | +| x | number | 是 | 是 | 设备x轴的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴的旋转角速度,单位rad/s。 | ## GyroscopeUncalibratedResponse @@ -3594,14 +3594,14 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | ------------------------------------------ | -| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | -| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | -| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | -| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | -| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | -| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------------------------ | +| x | number | 是 | 是 | 设备x轴未校准的旋转角速度,单位rad/s。 | +| y | number | 是 | 是 | 设备y轴未校准的旋转角速度,单位rad/s。 | +| z | number | 是 | 是 | 设备z轴未校准的旋转角速度,单位rad/s。 | +| biasX | number | 是 | 是 | 设备x轴未校准的旋转角速度偏量,单位rad/s。 | +| biasY | number | 是 | 是 | 设备y轴未校准的旋转角速度偏量,单位rad/s。 | +| biasZ | number | 是 | 是 | 设备z轴未校准的旋转角速度偏量,单位rad/s。 | ## SignificantMotionResponse @@ -3611,9 +3611,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ------------------------------------------------------------ | +| scalar | number | 是 | 是 | 表示剧烈运动程度。测量三个物理轴(x、y 和 z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 | ## ProximityResponse @@ -3623,9 +3623,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | ---- | ---- | ------------------------------------------------------ | -| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------------------------------------------------------ | +| distance | number | 是 | 是 | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 | ## LightResponse @@ -3635,9 +3635,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | ---------------------- | -| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ---------------------- | +| intensity | number | 是 | 是 | 光强(单位:勒克斯)。 | ## HallResponse @@ -3647,9 +3647,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ------------------------------------------------------------ | +| status | number | 是 | 是 | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有。 | ## MagneticFieldResponse @@ -3659,11 +3659,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ---------------------------- | -| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ---------------------------- | +| x | number | 是 | 是 | x轴环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴环境磁场强度,单位 : μT。 | ## MagneticFieldUncalibratedResponse @@ -3673,14 +3673,14 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | -------------------------------------- | -| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | -| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | -| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | -| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | -| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | -| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | -------------------------------------- | +| x | number | 是 | 是 | x轴未校准环境磁场强度,单位 : μT。 | +| y | number | 是 | 是 | y轴未校准环境磁场强度,单位 : μT。 | +| z | number | 是 | 是 | z轴未校准环境磁场强度,单位 : μT。 | +| biasX | number | 是 | 是 | x轴未校准环境磁场强度偏量,单位 : μT。 | +| biasY | number | 是 | 是 | y轴未校准环境磁场强度偏量,单位 : μT。 | +| biasZ | number | 是 | 是 | z轴未校准环境磁场强度偏量,单位 : μT。 | ## PedometerResponse @@ -3690,9 +3690,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | ---------------- | -| steps | number | 是 | 是 | 用户的行走步数。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ---------------- | +| steps | number | 是 | 是 | 用户的行走步数。 | ## HumidityResponse @@ -3702,9 +3702,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | ---- | ---- | --------------------------------------------------------- | -| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | --------------------------------------------------------- | +| humidity | number | 是 | 是 | 湿度值。测量环境的相对湿度,以百分比 (%) 表示。 | ## PedometerDetectionResponse @@ -3714,9 +3714,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ------------------------------------------------------------ | +| scalar | number | 是 | 是 | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 | ## AmbientTemperatureResponse @@ -3726,9 +3726,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----------- | -------- | ---- | ---- | -------------------------- | -| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------ | ---- | ---- | -------------------------- | +| temperature | number | 是 | 是 | 环境温度(单位:摄氏度)。 | ## BarometerResponse @@ -3738,9 +3738,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| -------- | -------- | ---- | ---- | ------------------------ | -| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------------------------ | +| pressure | number | 是 | 是 | 压力值(单位:帕斯卡)。 | ## HeartRateResponse @@ -3750,9 +3750,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | --------------------------------------- | -| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | --------------------------------------- | +| heartRate | number | 是 | 是 | 心率值。测量用户的心率数值,单位:bpm。 | ## WearDetectionResponse @@ -3762,9 +3762,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ----- | -------- | ---- | ---- | ------------------------------------------------ | -| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ------ | ---- | ---- | ------------------------------------------------ | +| value | number | 是 | 是 | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 | ## Options @@ -3773,9 +3773,9 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 说明 | -| -------- | -------- | ------------------------------------------- | -| interval | number | 表示传感器的上报频率,默认值为200000000ns。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | ------ | ---- | ---- | ------------------------------------------- | +| interval | number | 是 | 是 | 表示传感器的上报频率,默认值为200000000ns。 | ## RotationMatrixResponse @@ -3783,7 +3783,7 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------------------- | ---- | ---- | ---------- | | rotation | Array<number> | 是 | 是 | 旋转矩阵。 | | inclination | Array<number> | 是 | 是 | 倾斜矩阵。 | @@ -3795,10 +3795,10 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---- | -------- | ---- | ---- | ----------- | -| x | number | 是 | 是 | x坐标方向。 | -| y | number | 是 | 是 | y坐标方向。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---- | ------ | ---- | ---- | ----------- | +| x | number | 是 | 是 | x坐标方向。 | +| y | number | 是 | 是 | y坐标方向。 | ## GeomagneticResponse @@ -3807,15 +3807,15 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------------- | -------- | ---- | ---- | -------------------------------------------------- | -| x | number | 是 | 是 | 地磁场的北分量。 | -| y | number | 是 | 是 | 地磁场的东分量。 | -| z | number | 是 | 是 | 地磁场的垂直分量。 | -| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | -| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | -| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | -| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------------- | ------ | ---- | ---- | -------------------------------------------------- | +| x | number | 是 | 是 | 地磁场的北分量。 | +| y | number | 是 | 是 | 地磁场的东分量。 | +| z | number | 是 | 是 | 地磁场的垂直分量。 | +| geomagneticDip | number | 是 | 是 | 地磁倾角,即地球磁场线与水平面的夹角。 | +| deflectionAngle | number | 是 | 是 | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 | +| levelIntensity | number | 是 | 是 | 地磁场的水平强度。 | +| totalIntensity | number | 是 | 是 | 地磁场的总强度。 | ## LocationOptions @@ -3823,11 +3823,11 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| --------- | -------- | ---- | ---- | ---------- | -| latitude | number | 是 | 是 | 纬度。 | -| longitude | number | 是 | 是 | 经度。 | -| altitude | number | 是 | 是 | 海拔高度。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ---- | ---------- | +| latitude | number | 是 | 是 | 纬度。 | +| longitude | number | 是 | 是 | 经度。 | +| altitude | number | 是 | 是 | 海拔高度。 | ## sensor.on(deprecated) @@ -3845,11 +3845,11 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Acceler **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER | 是 | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -3877,11 +3877,11 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Line **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | 是 | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | ### ACCELEROMETER_UNCALIBRATED(deprecated) @@ -3897,11 +3897,11 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 是 | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -3929,11 +3929,11 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityRespons **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------------- | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY | 是 | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -3960,11 +3960,11 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE | 是 | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -3991,11 +3991,11 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<G **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 是 | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | **示例:** ```js @@ -4023,11 +4023,11 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<Sig **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 是 | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4052,11 +4052,11 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<Pe **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | 是 | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4081,11 +4081,11 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | --------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER | 是 | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4108,11 +4108,11 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<Ambi **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 是 | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -4136,11 +4136,11 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<Magneti **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD | 是 | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -4166,11 +4166,11 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 是 | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4198,11 +4198,11 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY | 是 | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4225,11 +4225,11 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityRespo **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | -------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY | 是 | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -4253,11 +4253,11 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER | 是 | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -4281,11 +4281,11 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | 是 | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4308,11 +4308,11 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ----------------------------------------------------------- | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | 是 | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** @@ -4336,11 +4336,11 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<Orientatio **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION | 是 | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4369,7 +4369,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateRe | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | ### ROTATION_VECTOR(deprecated) @@ -4384,11 +4384,11 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<Rotatio **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR | 是 | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4414,11 +4414,11 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDet **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | -| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION | 是 | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | **示例:** ```js @@ -4445,10 +4445,10 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<Accele **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER | 是 | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | **示例:** ```js @@ -4474,10 +4474,10 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Li **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | ### ACCELEROMETER_UNCALIBRATED(deprecated) @@ -4493,10 +4493,10 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callba **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 是 | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | **示例:** ``` @@ -4523,10 +4523,10 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityRespo **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | --------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY | 是 | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | **示例:** ```js @@ -4552,10 +4552,10 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE | 是 | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | **示例:** ```js @@ -4581,10 +4581,10 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 是 | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | **示例:** ```js @@ -4611,10 +4611,10 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<Si **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 是 | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | **示例:** ```js @@ -4638,10 +4638,10 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<P **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | 是 | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | **示例:** ```js @@ -4665,10 +4665,10 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER | 是 | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | **示例:** ```js @@ -4690,10 +4690,10 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<A **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 是 | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | **示例:** ```js @@ -4715,10 +4715,10 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<Magne **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD | 是 | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | **示例:** ```js @@ -4742,10 +4742,10 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 是 | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | **示例:** ```js @@ -4772,10 +4772,10 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY | 是 | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | **示例:** ```js @@ -4797,10 +4797,10 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY | 是 | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | **示例:** ```js @@ -4822,10 +4822,10 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER | 是 | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | **示例:** ```js @@ -4847,10 +4847,10 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | 是 | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | **示例:** ```js @@ -4872,10 +4872,10 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | -------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | 是 | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | **示例:** @@ -4898,10 +4898,10 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<Orientat **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION | 是 | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。 | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | **示例:** ```js @@ -4925,10 +4925,10 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<Rota **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR | 是 | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | **示例:** ```js @@ -4955,10 +4955,10 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRate **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | ### WEAR_DETECTION(deprecated) @@ -4972,10 +4972,10 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearD **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION | 是 | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | **示例:** ```js @@ -5001,10 +5001,10 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<Accele **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | -| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER | 是 | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 | +| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 否 | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | **示例:** @@ -5031,10 +5031,10 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | -| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 是 | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 | +| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 否 | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 | **示例:** @@ -5062,10 +5062,10 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | -| callback | Callback<[LightResponse](#lightresponse)> | 是 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_LIGHT | 是 | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 | +| callback | Callback<[LightResponse](#lightresponse)> | 否 | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 | **示例:** @@ -5088,10 +5088,10 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback< **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | -| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_AMBIENT_TEMPERATURE | 是 | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 | +| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 否 | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | **示例:** @@ -5114,10 +5114,10 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | -| callback | Callback<[BarometerResponse](#barometerresponse)> | 是 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_BAROMETER | 是 | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 | +| callback | Callback<[BarometerResponse](#barometerresponse)> | 否 | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | **示例:** @@ -5140,10 +5140,10 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityRespo **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | -| callback | Callback<[GravityResponse](#gravityresponse)> | 是 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GRAVITY | 是 | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。 | +| callback | Callback<[GravityResponse](#gravityresponse)> | 否 | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 | **示例:** @@ -5170,10 +5170,10 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | -| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE | 是 | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 | +| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 否 | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | **示例:** @@ -5200,10 +5200,10 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | -| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED | 是 | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 | +| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 否 | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | **示例:** @@ -5228,10 +5228,10 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | -| callback | Callback<[HallResponse](#hallresponse)> | 是 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HALL | 是 | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。 | +| callback | Callback<[HallResponse](#hallresponse)> | 否 | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 | **示例:** @@ -5258,8 +5258,8 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRate | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HEART_RATE | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 否 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | ### HUMIDITY(deprecated) @@ -5273,10 +5273,10 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityRes **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | -| callback | Callback<[HumidityResponse](#humidityresponse)> | 是 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_HUMIDITY | 是 | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。 | +| callback | Callback<[HumidityResponse](#humidityresponse)> | 否 | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | **示例:** @@ -5301,10 +5301,10 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback< **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | -| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_LINEAR_ACCELERATION | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | +| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 否 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | ### MAGNETIC_FIELD(deprecated) @@ -5318,10 +5318,10 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback< **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | -| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD | 是 | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 | +| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 否 | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | **示例:** @@ -5346,10 +5346,10 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | -| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED | 是 | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 | +| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 否 | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | **示例:** @@ -5377,10 +5377,10 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | -| callback | Callback<[OrientationResponse](#orientationresponse)> | 是 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ORIENTATION | 是 | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION | +| callback | Callback<[OrientationResponse](#orientationresponse)> | 否 | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 | **示例:** @@ -5407,10 +5407,10 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | -| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER | 是 | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。 | +| callback | Callback<[PedometerResponse](#pedometerresponse)> | 否 | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 | **示例:** @@ -5435,10 +5435,10 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback< **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | -| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PEDOMETER_DETECTION | 是 | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 | +| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 否 | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | **示例:** @@ -5461,10 +5461,10 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityR **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | -| callback | Callback<[ProximityResponse](#proximityresponse)> | 是 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_PROXIMITY | 是 | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 | +| callback | Callback<[ProximityResponse](#proximityresponse)> | 否 | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | **示例:** @@ -5487,10 +5487,10 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<Rota **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | -| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_ROTATION_VECTOR | 是 | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 | +| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 否 | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | **示例:** @@ -5516,10 +5516,10 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<S **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | -| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_SIGNIFICANT_MOTION | 是 | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 | +| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 否 | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | **示例:** @@ -5542,10 +5542,10 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearD **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | -| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype).SENSOR_TYPE_ID_WEAR_DETECTION | 是 | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 | +| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 否 | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index 3abca73aad6110eb4d9f13e40eb2e444515c4f87..2a43f80c5a865a1be7fd045f1159ecec73b9d3c9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -27,7 +27,7 @@ import Stack from '@ohos.util.Stack'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | Stack的元素个数。 | @@ -44,7 +44,7 @@ Stack的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The Stack's constructor cannot be directly invoked. | @@ -84,7 +84,7 @@ push(item: T): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The push method cannot be bound. | @@ -123,7 +123,7 @@ pop(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The pop method cannot be bound. | @@ -162,7 +162,7 @@ peek(): T 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The peek method cannot be bound. | @@ -206,7 +206,7 @@ locate(element: T): number 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The locate method cannot be bound. | @@ -254,7 +254,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -296,7 +296,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -334,7 +334,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index b0a44d376ac347c3e25825aee28ae22815f26968..2733e096e3392f350851a026fbe8f5051c4854ef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -4,8 +4,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -69,7 +68,7 @@ getTotalSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | | volumeUuid | string | 是 | 卷id | - | callback | callback: AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 | + | callback | AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 | **示例:** @@ -138,7 +137,7 @@ getFreeSizeOfVolume(volumeUuid: string, callback: AsyncCallback<number>): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | ---------------------------- | | volumeUuid | string | 是 | 卷id | - | callback | callback: AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 | + | callback | AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 | **示例:** @@ -174,7 +173,7 @@ getBundleStats(packageName: string): Promise<BundleStats> | 类型 | 说明 | | ------------------------------------------ | -------------------------- | - | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储数据 | + | Promise<[Bundlestats](#bundlestats9)> | 返回指定卷上的应用存储数据 | **示例:** @@ -206,7 +205,7 @@ getBundleStats(packageName: string, callback: AsyncCallback<BundleStats>) | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | | packageName | string | 是 | 应用包名 | - | callback | callback: AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储数据之后的回调 | + | callback | AsyncCallback<[Bundlestats](#bundlestats9)> | 是 | 获取指定卷上的应用存储数据之后的回调 | **示例:** @@ -230,7 +229,7 @@ getCurrentBundleStats(): Promise<BundleStats> | 类型 | 说明 | | ------------------------------------------ | -------------------------- | - | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 | + | Promise<[Bundlestats](#bundlestats9)> | 返回指定卷上的应用存储状态 | **示例:** @@ -251,7 +250,7 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback: AsyncCallback<[BundleStats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + | callback | AsyncCallback<[BundleStats](#bundlestats9)> | 是 | 获取指定卷上的应用存储状态之后的回调 | **示例:** @@ -271,11 +270,11 @@ getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void 该接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 说明 | -| --------- | ------ | -------------- | -| appSize | number | app数据大小 | -| cacheSize | number | 缓存数据大小 | -| dataSize | number | 应用总数据大小 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | --- | ---- | -------------- | +| appSize | number | 是 | 否 | app数据大小 | +| cacheSize | number | 是 | 否 | 缓存数据大小 | +| dataSize | number | 是 | 否 | 应用总数据大小 | ## storageStatistics.getTotalSize9+ @@ -323,7 +322,7 @@ getTotalSize(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | ------------------------ | - | callback | callback: AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 | + | callback | AsyncCallback<number> | 是 | 获取内卡的总空间大小之后的回调 | **示例:** @@ -381,7 +380,7 @@ getFreeSize(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------ | ---- | ------------------------- | - | callback | callback: AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 | + | callback | AsyncCallback<number> | 是 | 获取内卡的可用空间大小之后的回调 | **示例:** @@ -440,7 +439,7 @@ getSystemSize(callback: AsyncCallback<number>): void | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | - | callback | callback: AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 | + | callback | AsyncCallback<number> | 是 | 获取系统空间大小之后的回调 | **示例:** @@ -475,7 +474,7 @@ getUserStorageStats(userId? : number): Promise<StorageStats> | 类型 | 说明 | | --------------------- | ---------------- | - | Promise<[StorageStats](#storagestats)> | 返回各类别数据大小 | + | Promise<[StorageStats](#storagestats9)> | 返回各类别数据大小 | **示例:** @@ -507,7 +506,7 @@ getUserStorageStats(userId: number, callback: AsyncCallback<StorageStats>) | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------ | ---- | -------------------------- | | userId | number | 否 | 用户id
确认当前用户:
- 有值:表示指定用户。
- 无值:表示当前用户。 | - | callback | callback: AsyncCallback<[StorageStats](#storagestats)> | 是 | 返回各类别数据大小之后的回调 | + | callback | AsyncCallback<[StorageStats](#storagestats9)> | 是 | 返回各类别数据大小之后的回调 | **示例:** @@ -529,11 +528,11 @@ getUserStorageStats(userId: number, callback: AsyncCallback<StorageStats>) 该接口为系统接口,三方应用不支持调用 -| 名称 | 类型 | 说明 | -| --------- | ------ | -------------- | -| total | number | 内卡总空间大小 | -| audio | number | 音频数据大小 | -| video | number | 视频数据大小 | -| image | number | 图像数据大小 | -| file | number | 文件数据大小 | -| app | number | 应用数据大小 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| --------- | ------ | ---- | ----- | -------------- | +| total | number | 是 | 否 | 内卡总空间大小 | +| audio | number |是 | 否 | 音频数据大小 | +| video | number | 是 | 否 | 视频数据大小 | +| image | number | 是 | 否 | 图像数据大小 | +| file | number | 是 | 否 | 文件数据大小 | +| app | number | 是 | 否 | 应用数据大小 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-package.md b/zh-cn/application-dev/reference/apis/js-apis-system-package.md index b8138d9d985f899aa02592ae330f9e195e7008cd..b9eac4c952ba2a7bed4624d84ea439e7cafa785c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-package.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-package.md @@ -3,7 +3,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> - 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.bundle`](js-apis-Bundle.md)。 +> - 从API version 9开始不再维护,推荐使用该模块[`@ohos.bundle.bundleManager`](js-apis-bundleManager.md)。 > > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -16,7 +16,8 @@ import pkg from '@system.package'; ``` -## package.hasInstalled +## package.hasInstalled(deprecated) +> 从API version 9开始不再维护,推荐使用该模块[`@ohos.bundle.bundleManager`](js-apis-bundleManager.md)。 hasInstalled(Object): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md index 241022c81a30abe2eea560476816be44fde47a80..f7c9679d6a4b8cd6d845663edd48a1b64cab4c8f 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-parameter.md @@ -5,7 +5,7 @@ [系统参数](../../../device-dev/subsystems/subsys-boot-init-sysparam.md)。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 本模块接口从API version 9开始不再维护,建议使用新接口[@ohos.systemParameterV9](js-apis-system-parameterV9.md)替代。 +> - 本模块接口从API version 9开始不再维护,建议使用新接口[`@ohos.systemParameterV9`](js-apis-system-parameterV9.md)替代。 > - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块接口为系统接口。 > - 由于系统参数都是各个系统服务的内部信息和控制参数,每个系统参数都有各自不同的DAC和MAC访问控制权限,三方应用不能使用此类接口。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md index a8428fefc5956cce3dc06397b5a76f17ae6d0d30..24339605a5fb26ccb92e1be2e363dc27483fa0c1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-timer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-timer.md @@ -14,7 +14,7 @@ import systemTimer from '@ohos.systemTimer'; ``` -## systemTime.createTimer +## systemTimer.createTimer createTimer(options: TimerOptions, callback: AsyncCallback<number>): void @@ -55,7 +55,7 @@ export default { ``` -## systemTime.createTimer +## systemTimer.createTimer createTimer(options: TimerOptions): Promise<number> @@ -94,7 +94,7 @@ export default { ``` -## systemTime.startTimer +## systemTimer.startTimer startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void>): void @@ -106,7 +106,7 @@ startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void&g | 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------------------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| timer | number | 是 | 定时器的ID。 | | triggerTime | number | 是 | 定时器的触发时间,单位:毫秒。 | @@ -114,12 +114,12 @@ startTimer(timer: number, triggerTime: number, callback: AsyncCallback<void&g ```js export default { - systemTimer () { + async systemTimer () { var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime, (error, data) => { @@ -132,8 +132,8 @@ export default { } } ``` - -## systemTime.startTimer + +## systemTimer.startTimer startTimer(timer: number, triggerTime: number): Promise<void> @@ -153,12 +153,12 @@ startTimer(timer: number, triggerTime: number): Promise<void> ```js export default { - systemTimer (){ + async systemTimer (){ var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime).then((data) => { @@ -171,7 +171,7 @@ export default { ``` -## systemTime.stopTimer +## systemTimer.stopTimer stopTimer(timer: number, callback: AsyncCallback<void>): void @@ -189,16 +189,16 @@ stopTimer(timer: number, callback: AsyncCallback<void>): void ```js export default { - systemTimer () { + async systemTimer () { var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) - systemTimer.stoptTimer(timerId, (error, data) => { + systemTimer.stopTimer(timerId, (error, data) => { if (error) { console.error(`failed to systemTime.startTimer ` + JSON.stringify(error)); return; @@ -210,7 +210,7 @@ export default { ``` -## systemTime.stopTimer +## systemTimer.stopTimer stopTimer(timer: number): Promise<void> @@ -222,22 +222,22 @@ stopTimer(timer: number): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------- | ---- | ------------------------------------------------------------ | -| timer | number | 是 | 定时器的ID。 | +| timer | number | 是 | 定时器的ID。 | **示例:** ```js export default { - systemTimer (){ + async systemTimer (){ var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) - systemTimer.stoptTimer(timerId).then((data) => { + systemTimer.stopTimer(timerId).then((data) => { console.log(`systemTime.startTimer success data : ` + JSON.stringify(data)); }).catch((error) => { console.error(`failed to systemTime.startTimer because ` + JSON.stringify(error)); @@ -247,7 +247,7 @@ export default { ``` -## systemTime.destroyTimer +## systemTimer.destroyTimer destroyTimer(timer: number, callback: AsyncCallback<void>): void @@ -265,12 +265,12 @@ destroyTimer(timer: number, callback: AsyncCallback<void>): void ```js export default { - systemTimer () { + async systemTimer () { var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) @@ -287,7 +287,7 @@ export default { ``` -## systemTime.destroyTimer +## systemTimer.destroyTimer destroyTimer(timer: number): Promise<void> @@ -305,12 +305,12 @@ destroyTimer(timer: number): Promise<void> ```js export default { - systemTimer (){ + async systemTimer (){ var options = { type: systemTimer.TIMER_TYPE_REALTIME, repeat:false } - let timerId = systemTimer.createTimer(options) + let timerId = await systemTimer.createTimer(options) let triggerTime = new Date().getTime() triggerTime += 3000 systemTimer.startTimer(timerId, triggerTime) @@ -323,7 +323,7 @@ export default { } } ``` - + ## TimerOptions createTimer的初始化选项。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md index 59f8191cdf9522b993ee139a046456ff8dec2f88..403cf5e7cecd370115bcca1b707e2722a05fac38 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-touchevent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-touchevent.md @@ -16,7 +16,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ---- | ---- | ---- | | CANCEL | number | 是 | 否 | 触摸取消 | | DOWN | number | 是 | 否 | 触摸按下 | @@ -27,7 +27,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | ------ | ---- | ---- | ---- | | FINGER | number | 是 | 否 | 手指 | | PEN | number | 是 | 否 | 笔 | @@ -42,7 +42,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------ | ------ | ---- | ---- | ---- | | TOUCH_SCREEN | number | 是 | 否 | 触摸屏 | | PEN | number | 是 | 否 | 手写笔 | @@ -52,7 +52,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------ | ---- | ---- | ----------------------------------- | | id | number | 是 | 否 | 触摸事件标识 | | pressedTime | number | 是 | 否 | 按下时间戳 | @@ -77,7 +77,7 @@ import {Action,ToolType,SourceType,Touch,TouchEvent} from '@ohos.multimodalInput **系统能力**:SystemCapability.MultimodalInput.Input.Core -| 名称 | 参数类型 | 可读 | 可写 | 描述 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------- | ---------- | ---- | ---- | --------- | | action | Action | 是 | 否 | 触摸动作 | | touch | Touch | 是 | 否 | 当前触摸点 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index 2362b3a1e8b2048c9012f922350c88ced020ba0a..572b16437e8f0fdb6f8160e4b924b9b82cf1b4d0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -27,7 +27,7 @@ import TreeMap from '@ohos.util.TreeMap'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | TreeMap的元素个数。 | @@ -50,7 +50,7 @@ TreeMap的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The TreeMap's constructor cannot be directly invoked. | @@ -84,7 +84,7 @@ isEmpty(): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The isEmpty method cannot be bound. | @@ -125,7 +125,7 @@ hasKey(key: K): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasKey method cannot be bound. | @@ -168,7 +168,7 @@ hasValue(value: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The hasValue method cannot be bound. | @@ -211,7 +211,7 @@ get(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The get method cannot be bound. | @@ -248,7 +248,7 @@ getFirstKey(): K 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getFirstKey method cannot be bound. | @@ -285,7 +285,7 @@ getLastKey(): K 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLastKey method cannot be bound. | @@ -322,7 +322,7 @@ setAll(map: TreeMap): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The setAll method cannot be bound. | @@ -367,7 +367,7 @@ set(key: K, value: V): Object 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The set method cannot be bound. | @@ -408,7 +408,7 @@ remove(key: K): V 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The remove method cannot be bound. | @@ -451,7 +451,7 @@ getLowerKey(key: K): K 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getLowerKey method cannot be bound. | @@ -495,7 +495,7 @@ getHigherKey(key: K): K 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The getHigherKey method cannot be bound. | @@ -539,7 +539,7 @@ replace(key: K, newValue: V): boolean 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The replace method cannot be bound. | @@ -569,7 +569,7 @@ clear(): void 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The clear method cannot be bound. | @@ -606,7 +606,7 @@ keys(): IterableIterator<K> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The keys method cannot be bound. | @@ -648,7 +648,7 @@ values(): IterableIterator<V> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The values method cannot be bound. | @@ -698,7 +698,7 @@ callbackfn的参数说明: 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The forEach method cannot be bound. | @@ -739,7 +739,7 @@ entries(): IterableIterator<[K, V]> 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The entries method cannot be bound. | @@ -781,7 +781,7 @@ try { 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200011 | The Symbol.iterator method cannot be bound. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index 02102890f016d30d0f3a1712396683e4ebbb65a7..27ed062edd7d0d632e091a807cca2bb5cec59c5f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -24,7 +24,7 @@ import TreeSet from '@ohos.util.TreeSet'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | TreeSet的元素个数。 | @@ -47,7 +47,7 @@ TreeSet的构造函数。 以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------- | | 10200012 | The TreeSet's constructor cannot be directly invoked. | @@ -77,6 +77,14 @@ isEmpty(): boolean | -------- | -------- | | boolean | 为空返回true,不为空返回false。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The isEmpty method cannot be bound. | + **示例:** ```ts @@ -110,6 +118,14 @@ has(value: T): boolean | -------- | -------- | | boolean | 包含指定元素返回true,否则返回false。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The has method cannot be bound. | + **示例:** ```ts @@ -139,6 +155,14 @@ getFirstValue(): T | -------- | -------- | | T | 返回排序第一的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The getFirstValue method cannot be bound. | + **示例:** ```ts @@ -168,6 +192,14 @@ getLastValue(): T | -------- | -------- | | T | 返回排序最后的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The getLastValue method cannot be bound. | + **示例:** ```ts @@ -203,6 +235,14 @@ add(value: T): boolean | -------- | -------- | | boolean | 成功添加新数据至容器返回true,否则返回false。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The add method cannot be bound. | + **示例:** ```ts @@ -236,6 +276,14 @@ remove(value: T): boolean | -------- | -------- | | boolean | 成功删除元素返回true,否则返回false。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The remove method cannot be bound. | + **示例:** ```ts @@ -271,6 +319,14 @@ getLowerValue(key: T): T | -------- | -------- | | T | 返回排序中对比元素前一位的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The getLowerValue method cannot be bound. | + **示例:** ```ts @@ -307,6 +363,14 @@ getHigherValue(key: T): T | -------- | -------- | | T | 返回排序中传入元素后一位的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The getHigherValue method cannot be bound. | + **示例:** ```ts @@ -337,6 +401,14 @@ popFirst(): T | -------- | -------- | | T | 返回删除的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The popFirst method cannot be bound. | + **示例:** ```ts @@ -366,6 +438,14 @@ popLast(): T | -------- | -------- | | T | 返回删除的数据。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The popLast method cannot be bound. | + **示例:** ```ts @@ -389,6 +469,14 @@ clear(): void **系统能力:** SystemCapability.Utils.Lang +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The clear method cannot be bound. | + **示例:** ```ts @@ -418,6 +506,14 @@ values(): IterableIterator<T> | -------- | -------- | | IterableIterator<T> | 返回一个迭代器。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The values method cannot be bound. | + **示例:** ```ts @@ -460,6 +556,14 @@ callbackfn的参数说明: | key | T | 否 | 当前遍历到的元素(和value相同)。 | | set | TreeSet<T> | 否 | 当前调用forEach方法的实例对象。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The forEach method cannot be bound. | + **示例:** ```ts @@ -493,6 +597,14 @@ entries(): IterableIterator<[T, T]> | -------- | -------- | | IterableIterator<[T, T]> | 返回一个迭代器。 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The entries method cannot be bound. | + **示例:** ```ts @@ -528,6 +640,14 @@ try { | -------- | -------- | | IterableIterator<T> | 返回一个迭代器 | +**错误码:** + +以下错误码的详细介绍请参见[containers错误码](../errorcodes/errorcode-containers.md)。 + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 10200011 | The Symbol.iterator method cannot be bound. | + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-uitest.md b/zh-cn/application-dev/reference/apis/js-apis-uitest.md index 212701eefaa6fa62c51f94eb98907f158f93a9c7..0876c020eb9f4aa92054c5fe2e78993b68e3f2d6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uitest.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uitest.md @@ -8,9 +8,9 @@ UiTest提供模拟UI操作的能力,供开发者在测试场景使用,主要 - [Component9+](#component9):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。 - [Driver9+](#driver9):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能力。 - [UiWindow9+](#uiwindow9):入口类,提供窗口属性获取,窗口拖动、调整窗口大小等能力。 -- [By(deprecated)](#bydeprecated):提供控件特征描述能力,用于控件筛选匹配查找。从API version9开始不再维护,建议使用[On9+](#on9)。 -- [UiComponent(deprecated)](#uicomponentdeprecated):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。从API version9开始不再维护,建议使用[Component9+](#component9)。 -- [UiDriver(deprecated)](#uidriverdeprecated):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能力。从API version9开始不再维护,建议使用[Driver9+](#driver9)。 +- [By(deprecated)](#bydeprecated):提供控件特征描述能力,用于控件筛选匹配查找。从API version 9开始不再维护,建议使用[On9+](#on9)。 +- [UiComponent(deprecated)](#uicomponentdeprecated):代表UI界面上的指定控件,提供控件属性获取,控件点击,滑动查找,文本注入等能力。从API version 9开始不再维护,建议使用[Component9+](#component9)。 +- [UiDriver(deprecated)](#uidriverdeprecated):入口类,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等能力。从API version 9开始不再维护,建议使用[Driver9+](#driver9)。 >**说明:** > @@ -118,7 +118,7 @@ import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern ## On9+ -UiTest框架在API9中,通过On类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。
+UiTest框架在API 9中,通过On类提供了丰富的控件特征描述API,用于进行控件筛选来匹配/查找出目标控件。
On提供的API能力具有以下几个特点:
1、支持单属性匹配和多属性组合匹配,例如同时指定目标控件text和id。
2、控件属性支持多种匹配模式。
3、支持控件绝对定位,相对定位,可通过[ON.isBefore](#isbefore)和[ON.isAfter](#isafter)等API限定邻近控件特征进行辅助定位。
On类提供的所有API均为同步接口,建议使用者通过静态构造器ON来链式创建On对象。 ```js @@ -821,7 +821,7 @@ isChecked(): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('Checkbox')); + let checkBox = await driver.findComponent(ON.type('Checkbox')); if(await checkBox.isChecked) { console.info('This checkBox is checked'); } else { @@ -858,7 +858,7 @@ isCheckable(): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('Checkbox')); + let checkBox = await driver.findComponent(ON.type('Checkbox')); if(await checkBox.isCheckable) { console.info('This checkBox is checkable'); } else { @@ -895,7 +895,7 @@ isScrollable(): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.scrollable(true)); + let scrollBar = await driver.findComponent(ON.scrollable(true)); if(await scrollBar.isScrollable()) { console.info('This scrollBar can be operated'); } else { @@ -1045,7 +1045,7 @@ inputText(text: string): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.text('hello world')); + let text = await driver.findComponent(ON.text('hello world')); await text.inputText('123'); } ``` @@ -1070,7 +1070,7 @@ clearText(): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.text('hello world')); + let text = await driver.findComponent(ON.text('hello world')); await text.clearText(); } ``` @@ -1142,7 +1142,7 @@ scrollToTop(speed?: number): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('Scroll')); + let scrollBar = await driver.findComponent(ON.type('Scroll')); await scrollBar.scrollToTop(); } ``` @@ -1175,7 +1175,7 @@ scrollToBottom(speed?: number): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('Scroll')); + let scrollBar = await driver.findComponent(ON.type('Scroll')); await scrollBar.scrollToBottom(); } ``` @@ -1242,7 +1242,7 @@ pinchOut(scale: number): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('image')); + let image = await driver.findComponent(ON.type('image')); await image.pinchOut(1.5); } ``` @@ -1275,7 +1275,7 @@ pinchIn(scale: number): Promise\ ```js async function demo() { let driver = Driver.create(); - let button = await driver.findComponent(ON.type('image')); + let image = await driver.findComponent(ON.type('image')); await image.pinchIn(0.5); } ``` @@ -2130,6 +2130,7 @@ injectMultiPointerAction(pointers: PointerMatrix, speed?: number): Promise\ By提供的API能力具有以下几个特点:
1、支持单属性匹配和多属性组合匹配,例如同时指定目标控件text和id。
2、控件属性支持多种匹配模式。
3、支持控件绝对定位,相对定位,可通过[By.isBefore(deprecated)](#isbeforedeprecated)和[By.isAfter(deprecated)](#isafterdeprecated)等API限定邻近控件特征进行辅助定位。
By类提供的所有API均为同步接口,建议使用者通过静态构造器BY来链式创建By对象。 -从API version9开始不再维护,建议使用[On9+](#on9)。 +从API version 9开始不再维护,建议使用[On9+](#on9)。 ```js BY.text('123').type('button'); @@ -2662,7 +2663,7 @@ text(txt: string, pattern?: MatchPattern): By 指定目标控件文本属性,支持多种匹配模式,返回By对象自身。 -从API version9开始不再维护,建议使用[text9+](#text9)。 +从API version 9开始不再维护,建议使用[text9+](#text9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2692,7 +2693,7 @@ key(key: string): By 指定目标控件key值属性,返回By对象自身。 -从API version9开始不再维护,建议使用[id9+](#id9)。 +从API version 9开始不再维护,建议使用[id9+](#id9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2721,7 +2722,7 @@ id(id: number): By 指定目标控件id属性,返回By对象自身。 -从API version9开始废弃。 +从API version 9开始废弃。 **系统能力**:SystemCapability.Test.UiTest @@ -2750,7 +2751,7 @@ type(tp: string): By 指定目标控件的控件类型属性,返回By对象自身。 -从API version9开始不再维护,建议使用[type9+](#type9)。 +从API version 9开始不再维护,建议使用[type9+](#type9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2779,7 +2780,7 @@ clickable(b?: boolean): By 指定目标控件的可点击状态属性,返回By对象自身。 -从API version9开始不再维护,建议使用[clickable9+](#clickable9)。 +从API version 9开始不再维护,建议使用[clickable9+](#clickable9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2808,7 +2809,7 @@ scrollable(b?: boolean): By 指定目标控件的可滑动状态属性,返回By对象自身。 -从API version9开始不再维护,建议使用[scrollable9+](#scrollable9)。 +从API version 9开始不再维护,建议使用[scrollable9+](#scrollable9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2836,7 +2837,7 @@ enabled(b?: boolean): By 指定目标控件的使能状态属性,返回By对象自身。 -从API version9开始不再维护,建议使用[enabled9+](#enabled9)。 +从API version 9开始不再维护,建议使用[enabled9+](#enabled9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2864,7 +2865,7 @@ focused(b?: boolean): By 指定目标控件的获焦状态属性,返回By对象自身。 -从API version9开始不再维护,建议使用[focused9+](#focused9)。 +从API version 9开始不再维护,建议使用[focused9+](#focused9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2892,7 +2893,7 @@ selected(b?: boolean): By 指定目标控件的被选中状态属性,返回By对象自身。 -从API version9开始不再维护,建议使用[selected9+](#selected9)。 +从API version 9开始不再维护,建议使用[selected9+](#selected9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2920,7 +2921,7 @@ isBefore(by: By): By 指定目标控件位于给出的特征属性控件之前,返回By对象自身。 -从API version9开始不再维护,建议使用[isBefore9+](#isbefore9)。 +从API version 9开始不再维护,建议使用[isBefore9+](#isbefore9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2948,7 +2949,7 @@ isAfter(by: By): By 指定目标控件位于给出的特征属性控件之后,返回By对象自身。 -从API version9开始不再维护,建议使用[isAfter9+](#isafter9)。 +从API version 9开始不再维护,建议使用[isAfter9+](#isafter9)。 **系统能力**:SystemCapability.Test.UiTest @@ -2975,7 +2976,7 @@ let by = BY.isAfter(BY.text('123')); // 使用静态构造器BY创建by对象, UiTest中,UiComponent类代表了UI界面上的一个控件,提供控件属性获取,控件点击,滑动查找,文本注入等API。 该类提供的所有方法都使用Promise方式作为异步方法,需使用await调用。 -从API version9开始不再维护,建议使用[Component9+](#component9)。 +从API version 9开始不再维护,建议使用[Component9+](#component9)。 ### click(deprecated) @@ -2983,7 +2984,7 @@ click(): Promise\ 控件对象进行点击操作。 -从API version9开始不再维护,建议使用[click9+](#click9)。 +从API version 9开始不再维护,建议使用[click9+](#click9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3003,7 +3004,7 @@ doubleClick(): Promise\ 控件对象进行双击操作。 -从API version9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 +从API version 9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3023,7 +3024,7 @@ longClick(): Promise\ 控件对象进行长按操作。 -从API version9开始不再维护,建议使用[longClick9+](#longclick9)。 +从API version 9开始不再维护,建议使用[longClick9+](#longclick9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3043,7 +3044,7 @@ getId(): Promise\ 获取控件对象的id值。 -从API version9开始不再维护,被废弃。 +从API version 9开始不再维护,被废弃。 **系统能力**:SystemCapability.Test.UiTest @@ -3069,7 +3070,7 @@ getKey(): Promise\ 获取控件对象的key值。 -从API version9开始不再维护,建议使用[getId9+](#getid9) +从API version 9开始不再维护,建议使用[getId9+](#getid9) **系统能力**:SystemCapability.Test.UiTest @@ -3095,7 +3096,7 @@ getText(): Promise\ 获取控件对象的文本信息。 -从API version9开始不再维护,建议使用[getText9+](#gettext9)。 +从API version 9开始不再维护,建议使用[getText9+](#gettext9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3121,7 +3122,7 @@ getType(): Promise\ 获取控件对象的控件类型。 -从API version9开始不再维护,建议使用[getType9+](#gettype9)。 +从API version 9开始不再维护,建议使用[getType9+](#gettype9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3147,7 +3148,7 @@ isClickable(): Promise\ 获取控件对象可点击状态。 -从API version9开始不再维护,建议使用[isClickable9+](#isclickable9)。 +从API version 9开始不再维护,建议使用[isClickable9+](#isclickable9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3177,7 +3178,7 @@ isScrollable(): Promise\ 获取控件对象可滑动状态。 -从API version9开始不再维护,建议使用[isScrollable9+](#isscrollable9)。 +从API version 9开始不再维护,建议使用[isScrollable9+](#isscrollable9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3208,7 +3209,7 @@ isEnabled(): Promise\ 获取控件使能状态。 -从API version9开始不再维护,建议使用[isEnabled9+](#isenabled9)。 +从API version 9开始不再维护,建议使用[isEnabled9+](#isenabled9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3239,7 +3240,7 @@ isFocused(): Promise\ 判断控件对象是否获焦。 -从API version9开始不再维护,建议使用[isFocused9+](#isfocused9)。 +从API version 9开始不再维护,建议使用[isFocused9+](#isfocused9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3269,7 +3270,7 @@ isSelected(): Promise\ 获取控件对象被选中状态。 -从API version9开始不再维护,建议使用[isSelected9+](#isselected9)。 +从API version 9开始不再维护,建议使用[isSelected9+](#isselected9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3299,7 +3300,7 @@ inputText(text: string): Promise\ 向控件中输入文本(适用于文本框控件)。 -从API version9开始不再维护,建议使用[inputText9+](#inputtext9)。 +从API version 9开始不再维护,建议使用[inputText9+](#inputtext9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3325,7 +3326,7 @@ scrollSearch(by: By): Promise\ 在控件上滑动查找目标控件(适用于List等支持滑动的控件)。 -从API version9开始不再维护,建议使用[scrollSearch9+](#scrollsearch9)。 +从API version 9开始不再维护,建议使用[scrollSearch9+](#scrollsearch9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3356,7 +3357,7 @@ async function demo() { UiDriver类为uitest测试框架的总入口,提供控件匹配/查找,按键注入,坐标点击/滑动,截图等API。 该类提供的方法除UiDriver.create()以外的所有方法都使用Promise方式作为异步方法,需使用await调用。 -从API version9开始不再维护,建议使用[Driver9+](#driver9)。 +从API version 9开始不再维护,建议使用[Driver9+](#driver9)。 ### create(deprecated) @@ -3364,7 +3365,7 @@ static create(): UiDriver 静态方法,构造一个UiDriver对象,并返回该对象。 -从API version9开始不再维护,建议使用[create9+](#create9)。 +从API version 9开始不再维护,建议使用[create9+](#create9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3388,7 +3389,7 @@ delayMs(duration: number): Promise\ UiDriver对象在给定的时间内延时。 -从API version9开始不再维护,建议使用[delayMs9+](#delayms9)。 +从API version 9开始不再维护,建议使用[delayMs9+](#delayms9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3413,7 +3414,7 @@ findComponent(by: By): Promise\ 在UiDriver对象中,根据给出的目标控件属性要求查找目标控件。 -从API version9开始不再维护,建议使用[findComponent9+](#findcomponent9)。 +从API version 9开始不再维护,建议使用[findComponent9+](#findcomponent9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3444,7 +3445,7 @@ findComponents(by: By): Promise\> 在UiDriver对象中,根据给出的目标控件属性要求查找出所有匹配控件,以列表保存。 -从API version9开始不再维护,建议使用[findComponents9+](#findcomponents9)。 +从API version 9开始不再维护,建议使用[findComponents9+](#findcomponents9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3475,7 +3476,7 @@ assertComponentExist(by: By): Promise\ 断言API,用于断言当前界面存在满足给出的目标控件属性的控件; 如果控件不存在,该API将抛出JS异常,使当前测试用例失败。 -从API version9开始不再维护,建议使用[assertComponentExist9+](#assertcomponentexist9)。 +从API version 9开始不再维护,建议使用[assertComponentExist9+](#assertcomponentexist9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3500,7 +3501,7 @@ pressBack(): Promise\ UiDriver对象进行点击BACK键的操作。 -从API version9开始不再维护,建议使用[pressBack9+](#pressback9)。 +从API version 9开始不再维护,建议使用[pressBack9+](#pressback9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3519,7 +3520,7 @@ triggerKey(keyCode: number): Promise\ UiDriver对象采取如下操作:通过key值找到对应键并点击。 -从API version9开始不再维护,建议使用[triggerKey9+](#triggerkey9)。 +从API version 9开始不再维护,建议使用[triggerKey9+](#triggerkey9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3545,7 +3546,7 @@ click(x: number, y: number): Promise\ UiDriver对象采取如下操作:在目标坐标点单击。 -从API version9开始不再维护,建议使用[click9+](#click9)。 +从API version 9开始不再维护,建议使用[click9+](#click9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3571,7 +3572,7 @@ doubleClick(x: number, y: number): Promise\ UiDriver对象采取如下操作:在目标坐标点双击。 -从API version9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 +从API version 9开始不再维护,建议使用[doubleClick9+](#doubleclick9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3597,7 +3598,7 @@ longClick(x: number, y: number): Promise\ UiDriver对象采取如下操作:在目标坐标点长按下鼠标左键。 -从API version9开始不再维护,建议使用[longClick9+](#longclick9)。 +从API version 9开始不再维护,建议使用[longClick9+](#longclick9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3623,7 +3624,7 @@ swipe(startx: number, starty: number, endx: number, endy: number): Promise\9+
](#swipe9)。 +从API version 9开始不再维护,建议使用[swipe9+](#swipe9)。 **系统能力**:SystemCapability.Test.UiTest @@ -3651,7 +3652,7 @@ screenCap(savePath: string): Promise\ UiDriver对象采取如下操作:捕获当前屏幕,并保存为PNG格式的图片至给出的保存路径中。 -从API version9开始不再维护,建议使用[screenCap9+](#screencap9)。 +从API version 9开始不再维护,建议使用[screenCap9+](#screencap9)。 **系统能力**:SystemCapability.Test.UiTest diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index f6b29aa4c3a4b51193c7fcc15abcef1829e44d1f..e630fc5fcbd76430dd4e2dd940f0cb155ea6e982 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -39,6 +39,14 @@ getOnlineUpdater(upgradeInfo: UpgradeInfo): Updater | ------------------- | ---- | | [Updater](#updater) | 升级对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -71,6 +79,14 @@ getRestorer(): Restorer | --------------------- | ------ | | [Restorer](#restorer) | 恢复出厂对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -95,6 +111,14 @@ getLocalUpdater(): LocalUpdater | ----------------------------- | ------ | | [LocalUpdater](#localupdater) | 本地升级对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -102,7 +126,7 @@ try { let localUpdater = update.getLocalUpdater(); } catch(error) { console.error(`Fail to get localUpdater error: ${error}`); -} +}; ``` ## Updater @@ -123,6 +147,14 @@ checkNewVersion(callback: AsyncCallback\): void | -------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback\<[CheckResult](#checkresult)> | 是 | 回调函数,返回搜包结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -147,6 +179,14 @@ checkNewVersion(): Promise\ | ------------------------------------- | ------------------- | | Promise\<[CheckResult](#checkresult)> | Promise对象,返回搜包结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -175,6 +215,14 @@ getNewVersionInfo(callback: AsyncCallback\): void | -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | 是 | 回调函数,返回新版本信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -200,6 +248,14 @@ getNewVersionInfo(): Promise\ | ---------------------------------------- | -------------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise对象,返回新版本信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -229,6 +285,14 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption | descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | 描述文件选项。 | | callback | AsyncCallback\>) | 是 | 回调函数,返回新版本描述文件。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -272,6 +336,14 @@ getNewVersionDescription(versionDigestInfo: VersionDigestInfo, descriptionOption | ---------------------------------------- | ------------------- | | Promise\> | Promise对象,返回新版本描述文件。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -309,6 +381,14 @@ getCurrentVersionInfo(callback: AsyncCallback\): void | -------- | ---------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[CurrentVersionInfo](#currentversioninfo)> | 是 | 回调函数,返回当前版本信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -335,6 +415,14 @@ getCurrentVersionInfo(): Promise\ | ---------------------------------------- | ------------------- | | Promise\<[CurrentVersionInfo](#currentversioninfo)> | Promise对象,返回当前版本对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -364,6 +452,14 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions, callback: A | descriptionOptions | [DescriptionOptions](#descriptionoptions) | 是 | 描述文件选项。 | | callback | AsyncCallback\>) | 是 | 回调函数,返回当前版本描述文件。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -401,6 +497,14 @@ getCurrentVersionDescription(descriptionOptions: DescriptionOptions): Promise\
> | Promise对象,返回当前版本描述文件。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -433,6 +537,14 @@ getTaskInfo(callback: AsyncCallback\): void | -------- | ------------------------------------- | ---- | ---------------- | | callback | AsyncCallback\<[TaskInfo](#taskinfo)> | 是 | 回调函数,返回升级任务信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -457,6 +569,14 @@ getTaskInfo(): Promise\ | ------------------------------- | ------------------- | | Promise\<[TaskInfo](#taskinfo)> | Promise对象,返回任务信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -485,6 +605,14 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions, | downloadOptions | [DownloadOptions](#downloadoptions) | 是 | 下载选项。 | | callback | AsyncCallback\ | 是 | 回调函数。当下载成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -526,6 +654,14 @@ download(versionDigestInfo: VersionDigestInfo, downloadOptions: DownloadOptions) | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -564,6 +700,14 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu | resumeDownloadOptions | [ResumeDownloadOptions](#resumedownloadoptions) | 是 | 恢复下载选项。 | | callback | AsyncCallback\ | 是 | 回调函数。当恢复下载成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -604,6 +748,14 @@ resumeDownload(versionDigestInfo: VersionDigestInfo, resumeDownloadOptions: Resu | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -641,6 +793,14 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD | pauseDownloadOptions | [PauseDownloadOptions](#pausedownloadoptions) | 是 | 暂停下载选项。 | | callback | AsyncCallback\ | 是 | 回调函数。当暂停下载成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -681,6 +841,14 @@ pauseDownload(versionDigestInfo: VersionDigestInfo, pauseDownloadOptions: PauseD | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -718,6 +886,14 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions, ca | upgradeOptions | [UpgradeOptions](#upgradeoptions) | 是 | 更新选项。 | | callback | AsyncCallback\ | 是 | 回调函数。当升级执行成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -758,6 +934,14 @@ upgrade(versionDigestInfo: VersionDigestInfo, upgradeOptions: UpgradeOptions): P | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -795,6 +979,14 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions, cal | clearOptions | [ClearOptions](#clearoptions) | 是 | 清除选项。 | | callback | AsyncCallback\ | 是 | 回调函数。当清除异常成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -835,6 +1027,14 @@ clearError(versionDigestInfo: VersionDigestInfo, clearOptions: ClearOptions): Pr | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -844,7 +1044,7 @@ const versionDigestInfo = { }; // 清除选项 -lconstet clearOptions = { +const clearOptions = { status: update.UpgradeStatus.UPGRADE_FAIL, }; updater.clearError(versionDigestInfo, clearOptions).then(() => { @@ -870,6 +1070,14 @@ getUpgradePolicy(callback: AsyncCallback\): void | -------- | ---------------------------------------- | ---- | --------------- | | callback | AsyncCallback\<[UpgradePolicy](#upgradepolicy)> | 是 | 回调函数,返回升级策略信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -895,6 +1103,14 @@ getUpgradePolicy(): Promise\ | ---------------------------------------- | --------------------- | | Promise\<[UpgradePolicy](#upgradepolicy)> | Promise对象,返回升级策略信息对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -923,6 +1139,14 @@ setUpgradePolicy(policy: UpgradePolicy, callback: AsyncCallback\): void | policy | [UpgradePolicy](#upgradepolicy) | 是 | 升级策略。 | | callback | AsyncCallback\ | 是 | 回调函数,返回设置结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -958,6 +1182,14 @@ setUpgradePolicy(policy: UpgradePolicy): Promise\ | -------------- | ------------------- | | Promise\ | Promise对象,返回设置结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -989,6 +1221,14 @@ terminateUpgrade(callback: AsyncCallback\): void | -------- | -------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\ | 是 | 回调函数。当清除升级缓存成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1013,6 +1253,14 @@ terminateUpgrade(): Promise\ | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1038,6 +1286,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi | eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | 事件信息。 | | taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1065,6 +1321,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v | eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | 事件信息。 | | taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 否 | 事件回调。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1096,6 +1360,14 @@ factoryReset(callback: AsyncCallback\): void | -------- | -------------------- | ---- | -------------------------------------- | | callback | AsyncCallback\ | 是 | 回调函数。当恢复出厂执行成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1120,6 +1392,14 @@ factoryReset(): Promise\ | -------------- | -------------------------- | | Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1150,6 +1430,14 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string, callback: Asyn | certsFile | string | 是 | 证书文件路径。 | | callback | AsyncCallback\ | 是 | 回调函数,返回升级包校验结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1186,6 +1474,14 @@ verifyUpgradePackage(upgradeFile: UpgradeFile, certsFile: string): Promise\ | Promise对象,返回升级包校验结果对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1216,6 +1512,14 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>, callback: Asyn | upgradeFile | Array<[UpgradeFile](#upgradefile)> | 是 | 升级文件。 | | callback | AsyncCallback\ | 是 | 回调函数。当安装升级包执行成功时,err为undefined,否则为错误对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1245,10 +1549,18 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts -localUpdater upgradeFiles = [{ +const upgradeFiles = [{ fileType: update.ComponentType.OTA, // OTA包 filePath: "path" // 本地升级包路径 }]; @@ -1273,6 +1585,14 @@ on(eventClassifyInfo: EventClassifyInfo, taskCallback: UpgradeTaskCallback): voi | eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | 事件信息。 | | taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -1302,6 +1622,14 @@ off(eventClassifyInfo: EventClassifyInfo, taskCallback?: UpgradeTaskCallback): v | eventClassifyInfo | [EventClassifyInfo](#eventclassifyinfo) | 是 | 事件信息。 | | taskCallback | [UpgradeTaskCallback](#upgradetaskcallback) | 是 | 事件回调。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index ffa8e471f0e279279714c637cc16ecdd0f4a96f7..2780155db9df46c9eaeabed1696644f4c01128a2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -107,7 +107,7 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe> **错误码:** -以下错误码的详细介绍参见[USB错误码](../errorcodes/errcode-usb.md)。 +以下错误码的详细介绍参见[USB错误码](../errorcodes/errorcode-usb.md)。 | 错误码ID | 错误信息 | | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md index a11bb6703146cf44e669709e0db46d28e5073894..5922f80b2d90d9ee2384292c82529fef8d671474 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md @@ -3,8 +3,8 @@ 该模块提供用户数据管理能力,包括访问、修改用户等用户公共媒体数据信息等常用功能。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该模块从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -> 本模块下的接口均为系统接口 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块接口为系统接口。 ## 导入模块 @@ -26,7 +26,7 @@ getUserFileMgr(context: Context): UserFileManager | 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | -------------------------- | -| context | [Context](#../apis/js-apis-Context.md) | 是 | 传入Ability实例的Context。 | +| context | [Context](js-apis-Context.md) | 是 | 传入Ability实例的Context。 | **返回值:** @@ -38,7 +38,7 @@ getUserFileMgr(context: Context): UserFileManager ```ts const context = getContext(this); -let mgr = userfilemanager.getUserFileMgr(context); +let mgr = userFileManager.getUserFileMgr(context); ``` ## userFileManager.getUserFileMgr @@ -62,7 +62,7 @@ getUserFileMgr(): UserFileManager **示例:** ```ts -let mgr = userfilemanager.getUserFileMgr(); +let mgr = userFileManager.getUserFileMgr(); ``` ## UserFileManager @@ -90,6 +90,8 @@ getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult< **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPhotoAssets'); let predicates = new dataSharePredicates.DataSharePredicates(); @@ -138,6 +140,8 @@ getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>&g **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPhotoAssets'); let predicates = new dataSharePredicates.DataSharePredicates(); @@ -180,6 +184,8 @@ createPhotoAsset(displayName: string, albumUri: string, callback: AsyncCallback& **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('createPhotoAssetDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -291,6 +297,8 @@ getPhotoAlbums(options: AlbumFetchOptions, callback: AsyncCallback<FetchResul **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPhotoAlbumsDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -340,6 +348,8 @@ getPhotoAlbums(options: AlbumFetchOptions): Promise<FetchResult<Album>& **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPhotoAlbumsDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -450,6 +460,8 @@ getAudioAssets(options: FetchOptions, callback: AsyncCallback<FetchResult< **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getAudioAssets'); let predicates = new dataSharePredicates.DataSharePredicates(); @@ -498,6 +510,8 @@ getAudioAssets(options: FetchOptions): Promise<FetchResult<FileAsset>&g **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getAudioAssets'); let predicates = new dataSharePredicates.DataSharePredicates(); @@ -540,6 +554,8 @@ delete(uri: string, callback: AsyncCallback<void>): void; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('deleteAssetDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -592,6 +608,8 @@ delete(uri: string): Promise<void>; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('deleteDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -934,7 +952,10 @@ get(member: string): MemberType; | member | string | 是 | 成员参数名称例如:ImageVideoKey.URI | **示例:** + ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('fileAssetGetDemo') try { @@ -970,7 +991,10 @@ set(member: string, value: string): void; | value | string | 是 | 设置成员参数名称,只能修改ImageVideoKey.TITLE的值 | **示例:** + ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('fileAssetSetDemo') try { @@ -1008,6 +1032,8 @@ commitModify(callback: AsyncCallback<void>): void **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('commitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1051,6 +1077,8 @@ commitModify(): Promise<void> **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('commitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1173,6 +1201,8 @@ close(fd: number, callback: AsyncCallback<void>): void **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('closeDemo') try { @@ -1221,6 +1251,8 @@ close(fd: number): Promise<void> **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('closeDemo') try { @@ -1255,11 +1287,13 @@ getThumbnail(callback: AsyncCallback<image.PixelMap>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ---------------- | -| callback | AsyncCallback<[image.PixelMap](#../apis/js-apis-image.md#pixelmap7)> | 是 | 回调返回缩略图的PixelMap | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调返回缩略图的PixelMap | **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getThumbnailDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1295,11 +1329,13 @@ getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ---------------- | | size | Size | 是 | 缩略图尺寸 | -| callback | AsyncCallback<[image.PixelMap](#../apis/js-apis-image.md#pixelmap7)> | 是 | 回调返回缩略图的PixelMap | +| callback | AsyncCallback<[image.PixelMap](js-apis-image.md#pixelmap7)> | 是 | 回调返回缩略图的PixelMap | **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getThumbnailDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1341,11 +1377,13 @@ getThumbnail(size?: Size): Promise<image.PixelMap> | 类型 | 说明 | | ----------------------------- | --------------------- | -| Promise<[image.PixelMap](#../apis/js-apis-image.md#pixelmap7)> | Promise返回缩略图的PixelMap | +| Promise<[image.PixelMap](js-apis-image.md#pixelmap7)> | Promise返回缩略图的PixelMap | **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getThumbnailDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1385,6 +1423,8 @@ favorite(isFavorite: boolean, callback: AsyncCallback<void>): void **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('favoriteDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1429,6 +1469,8 @@ favorite(isFavorite: boolean): Promise<void> **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('favoriteDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1467,6 +1509,8 @@ getCount(): number **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getCountDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1497,6 +1541,8 @@ isAfterLast(): boolean **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { let predicates = new dataSharePredicates.DataSharePredicates(); let fetchOption = { @@ -1526,6 +1572,8 @@ close(): void **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('fetchResultCloseDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1556,6 +1604,8 @@ getFirstObject(callback: AsyncCallback<T>): void **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getFirstObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1591,6 +1641,8 @@ getFirstObject(): Promise<T> **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getFirstObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1621,6 +1673,8 @@ async function example() { **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getNextObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1659,6 +1713,8 @@ async function example() { **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getNextObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1692,6 +1748,8 @@ getLastObject(callback: AsyncCallback<T>): void **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getLastObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1727,6 +1785,8 @@ getLastObject(): Promise<T> **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getLastObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1758,6 +1818,8 @@ getPositionObject(index: number, callback: AsyncCallback<T>): void **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPositionObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1799,6 +1861,8 @@ getPositionObject(index: number): Promise<T> **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getPositionObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1848,6 +1912,8 @@ getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult< **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumGetFileAssetsDemoCallback') @@ -1890,6 +1956,8 @@ getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>&g **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumGetFileAssetsDemoPromise') @@ -1930,6 +1998,8 @@ commitModify(callback: AsyncCallback<void>): void; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumCommitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1968,6 +2038,8 @@ commitModify(): Promise<void>; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumCommitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -2024,6 +2096,8 @@ getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult< **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumGetFileAssetsDemoCallback') let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2069,6 +2143,8 @@ getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>&g **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumGetFileAssetsDemoPromise') let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2103,6 +2179,8 @@ delete(uri: string, callback: AsyncCallback<void>): void; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumDeleteCallback'); let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2149,6 +2227,8 @@ delete(uri: string): Promise<void>; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumDeleteDemoPromise') let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2189,6 +2269,8 @@ recover(uri: string, callback: AsyncCallback<void>): void; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumRecoverDemoCallback'); let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2235,6 +2317,8 @@ recover(uri: string): Promise<void>; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('privateAlbumRecoverDemoPromise') let albumList = await mgr.getPrivateAlbum(userFileManager.PrivateAlbumType.TYPE_TRASH); @@ -2383,7 +2467,7 @@ async function example() { | 名称 | 类型 | 必填 | 说明 | | ---------------------- | ------------------- | ---- |------------------------------------------------ | | fetchColumns | Array<string> | 是 | 检索条件,指定列名查询,如果该参数为空时默认查询uri、name、fileType。示例:
fetchColumns: "uri"| -| predicates | [dataSharePredicates.DataSharePredicates](#../js-apis-data-dataSharePredicates.md) | 是 | 谓词查询,显示过滤条件 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md) | 是 | 谓词查询,显示过滤条件 | ## AlbumFetchOptions @@ -2393,5 +2477,5 @@ async function example() { | 名称 | 类型 | 必填 | 说明 | | ---------------------- | ------------------- | ---- |------------------------------------------------ | -| predicates | [dataSharePredicates.DataSharePredicates](#../js-apis-data-dataSharePredicates.md) | 是 | 谓词查询,显示过滤条件 | +| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md) | 是 | 谓词查询,显示过滤条件 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md index 56391c00706443835901e7160d4d397b56524316..83f0225b3608806804ff66f93633e26c73768783 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-faceauth.md @@ -56,7 +56,7 @@ setSurfaceId(surfaceId: string): void; | -------------- | ---------------------------------- | ---- | -------------------------- | | surfaceId | string | 是 | [XComponent](../arkui-ts/ts-basic-components-xcomponent.md#getxcomponentsurfaceid) 持有 Surface 的 ID。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -69,10 +69,10 @@ setSurfaceId(surfaceId: string): void; **示例:** ```js -import faceAuth from '@ohos.userIAM.faceAuth'; +import userIAM_faceAuth from '@ohos.userIAM.faceAuth'; let surfaceId = "123456"; -let manager = new faceAuth.FaceAuthManager(); +let manager = new userIAM_faceAuth.FaceAuthManager(); try { manager.setSurfaceId(surfaceId); console.info("set surface id success"); diff --git a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md index e984d4b8f834b8adaf75ea4250c7ab8676af2db5..ff2a6a03477551f0ab58419f6fdaac35ac76fecb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -18,7 +18,7 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; **系统能力**:以下各项对应的系统能力均为SystemCapability.UserIAM.UserAuth.Core。 -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名称 | 参数类型 | 必填 | 说明 | | ------------ | ---------- | ---- | -------------------- | | result | number | 是 | 认证结果。 | | token | Uint8Array | 否 | 用户身份认证通过的凭证。 | @@ -44,8 +44,8 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; | 取值类型 | 说明 | | --------- | ----------------------- | -| [AuthResultInfo](#authresultinfo9) | 获取到的认证结果信息 | -| [TipInfo](#tipinfo9) | 认证过程中的提示信息 | +| [AuthResultInfo](#authresultinfo9) | 获取到的认证结果信息。 | +| [TipInfo](#tipinfo9) | 认证过程中的提示信息。 | ## AuthEventKey9+ @@ -70,9 +70,9 @@ callback: (result : EventInfo) => void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------- | ---- | -------------------------------------------------------- | -| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | +| 参数名称 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------------ | +| result | [EventInfo](#eventinfo9) | 是 | 返回的认证结果信息或提示信息。 | **示例:** @@ -86,12 +86,12 @@ let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; try { let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); auth.on("result", { - callback: (result: userIAM_userAuth.AuthResultInfo) => { - console.log("authV9 result " + result.result); - console.log("authV9 token " + result.token); - console.log("authV9 remainAttempts " + result.remainAttempts); - console.log("authV9 lockoutDuration " + result.lockoutDuration); - } + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } }); auth.start(); console.log("authV9 start success"); @@ -103,16 +103,16 @@ try { try { let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); auth.on("tip", { - callback : (result : userIAM_userAuth.TipInfo) => { - switch (result.tip) { - case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: - // do something; - case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: - // do something; - default: - // do others + callback : (result : userIAM_userAuth.TipInfo) => { + switch (result.tip) { + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: + // do something; + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: + // do something; + default: + // do others + } } - } }); auth.start(); console.log("authV9 start success"); @@ -132,16 +132,19 @@ on(name : AuthEventKey, callback : AuthEvent) : void 订阅指定类型的用户认证事件。 +> **说明:** +> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行订阅。 + **系统能力**:SystemCapability.UserIAM.UserAuth.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | --------- | -------------------------- | ---- | ------------------------- | | name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,回调函数返回认证结果;取值为"tip"时,回调函数返回认证过程中的提示信息。 | | callback | [AuthEvent](#authevent9) | 是 | 认证接口的回调函数,用于返回认证结果或认证过程中的提示信息。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -162,25 +165,25 @@ try { let auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); // 订阅认证结果 auth.on("result", { - callback: (result: userIAM_userAuth.AuthResultInfo) => { - console.log("authV9 result " + result.result); - console.log("authV9 token " + result.token); - console.log("authV9 remainAttempts " + result.remainAttempts); - console.log("authV9 lockoutDuration " + result.lockoutDuration); - } + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } }); // 订阅认证过程中的提示信息 auth.on("tip", { - callback : (result : userIAM_userAuth.TipInfo) => { - switch (result.tip) { - case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: - // do something; - case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: - // do something; - default: - // do others + callback : (result : userIAM_userAuth.TipInfo) => { + switch (result.tip) { + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: + // do something; + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: + // do something; + default: + // do others + } } - } }); auth.start(); console.log("authV9 start success"); @@ -196,13 +199,16 @@ off(name : AuthEventKey) : void 取消订阅特定类型的认证事件。 +> **说明:** +> 需要使用已经成功订阅事件的[AuthInstance](#authinstance9)对象调用该接口进行取消订阅。 + **系统能力**:SystemCapability.UserIAM.UserAuth.Core -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | --------- | -------------------------- | ---- | ------------------------- | | name | [AuthEventKey](#autheventkey9) | 是 | 表示认证事件类型,取值为"result"时,取消订阅认证结果;取值为"tip"时,取消订阅认证过程中的提示信息。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -230,12 +236,12 @@ try { try { // 订阅认证结果 auth.on("result", { - callback: (result: userIAM_userAuth.AuthResultInfo) => { - console.log("authV9 result " + result.result); - console.log("authV9 token " + result.token); - console.log("authV9 remainAttempts " + result.remainAttempts); - console.log("authV9 lockoutDuration " + result.lockoutDuration); - } + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } }); console.log("subscribe authentication event success"); } catch (error) { @@ -263,7 +269,7 @@ start() : void **系统能力**:SystemCapability.UserIAM.UserAuth.Core -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -301,13 +307,13 @@ cancel(): void 取消认证。 > **说明:** -> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行取消认证,此[AuthInstance](#authinstance9)应该是正在进行认证的对象。 +> 使用获取到的[AuthInstance](#authinstance9)对象调用该接口进行取消认证,此[AuthInstance](#authinstance9)需要是正在进行认证的对象。 **需要权限**:ohos.permission.ACCESS_BIOMETRIC **系统能力**:SystemCapability.UserIAM.UserAuth.Core -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -348,7 +354,7 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------------- | ---- | ------------------------ | | challenge | Uint8Array | 是 | 挑战值,最大长度为32字节,可以填null。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | @@ -360,7 +366,7 @@ getAuthInstance(challenge : Uint8Array, authType : UserAuthType, authTrustLevel | ----------------------------------------- | ------------ | | [AuthInstance](#authinstance9) | 认证器对象。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -404,7 +410,7 @@ getVersion(): number | ------ | ---------------------- | | number | 认证器版本信息。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -438,12 +444,12 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): vo **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------- | ---- | -------------------------- | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | -以下错误码的详细介绍请参见[用户认证错误码](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/errorcodes/errcode-useriam.md) +以下错误码的详细介绍请参见[用户认证错误码](../errorcodes/errcode-useriam.md) **错误码:** @@ -564,7 +570,7 @@ getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : n **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------- | ---- | -------------------------- | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前只支持FACE。 | | authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | @@ -605,12 +611,12 @@ auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLev **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | -------------- | ---------------------------------------- | ---- | ------------------------ | | challenge | Uint8Array | 是 | 挑战值,可以填null。 | | authType | [UserAuthType](#userauthtype8) | 是 | 认证类型,当前支持FACE。 | -| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | -| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | +| authTrustLevel | [AuthTrustLevel](#authtrustlevel8) | 是 | 认证信任等级。 | +| callback | [IUserAuthCallback](#iuserauthcallbackdeprecated) | 是 | 回调函数。 | **返回值:** @@ -657,7 +663,7 @@ cancelAuth(contextID : Uint8Array) : number **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | --------- | ---------- | ---- | ------------------------------------------ | | contextID | Uint8Array | 是 | 上下文的标识,通过[auth](#authdeprecated)接口获取。 | @@ -705,9 +711,9 @@ onResult: (result : number, extraInfo : AuthResult) => void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------------------------- | ---- | ------------------------------------------------------------ | -| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | +| 参数名称 | 类型 | 必填 | 说明 | +| --------- | -------------------------- | ---- | ------------------------------------------------ | +| result | number | 是 | 认证结果,参见[ResultCode](#resultcodedeprecated)。 | | extraInfo | [AuthResult](#authresultdeprecated) | 是 | 扩展信息,不同情况下的具体信息,
如果身份验证通过,则在extraInfo中返回用户认证令牌,
如果身份验证失败,则在extraInfo中返回剩余的用户认证次数,
如果身份验证执行器被锁定,则在extraInfo中返回冻结时间。 | @@ -748,7 +754,7 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | --------- | ------ | ---- | ------------------------------ | | module | number | 是 | 发送提示信息的模块标识。 | | acquire | number | 是 | 认证执过程中的提示信息。 | @@ -808,7 +814,6 @@ auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLe | TYPE_NOT_SUPPORT | 5 | 不支持的认证类型。 | | TRUST_LEVEL_NOT_SUPPORT | 6 | 不支持的认证等级。 | | BUSY | 7 | 忙碌状态。 | -| INVALID_PARAMETERS | 8 | 无效参数。 | | LOCKED | 9 | 认证器已锁定。 | | NOT_ENROLLED | 10 | 用户未录入认证信息。 | @@ -917,13 +922,13 @@ execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number> **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | --------------------------- | ---- | ------------------------------------------------------------ | +| 参数名称 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------- | | type | AuthType | 是 | 认证类型,当前只支持"FACE_ONLY"。
ALL为预留参数,当前版本暂不支持ALL类型的认证。 | -| level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。
具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。
具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | -| callback | AsyncCallback<number> | 否 | 回调函数。 | +| level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。
具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。
具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | +| callback | AsyncCallback<number> | 否 | 回调函数。 | - callback返回值: +callback返回值: | 类型 | 说明 | | ------ | ------------------------------------------------------------ | @@ -958,7 +963,7 @@ execute(type : AuthType, level : SecureLevel): Promise<number> **参数:** -| 参数名 | 类型 | 必填 | 说明 | +| 参数名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | | type | AuthType | 是 | 认证类型,当前只支持"FACE_ONLY"。
ALL为预留参数,当前版本暂不支持ALL类型的认证。 | | level | SecureLevel | 是 | 安全级别,对应认证的安全级别,有效值为"S1"(最低)、"S2"、"S3"、"S4"(最高)。
具备3D人脸识别能力的设备支持"S3"及以下安全级别的认证。
具备2D人脸识别能力的设备支持"S2"及以下安全级别的认证。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index 164f69a071584ae837c07a4ee960e0a553bbd3c7..cd0687d441e1e57a7dd263880753c2b99e6aa270 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -25,7 +25,7 @@ import Vector from '@ohos.util.Vector'; **系统能力:** SystemCapability.Utils.Lang -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | length | number | 是 | 否 | Vector的元素个数。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md index e34b009be8fc8155eab680bf66c8eded0ab086bf..1daff5659e271364deb8a39ba7d67af97b997ba0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md @@ -225,8 +225,8 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | -| ------------------ | -------------------- | ------------------ | +| 名称 | 值 | 说明 | +| ------------------ | -------------------- | -------------------------------- | | EFFECT_CLOCK_TIMER | "haptic.clock.timer" | 描述用户调整计时器时的振动效果。 | @@ -236,8 +236,8 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | -| ------------------------- | -------- | ------------------------------------------------------------ | +| 名称 | 值 | 说明 | +| ------------------------- | -------- | ------------------------------ | | VIBRATOR_STOP_MODE_TIME | "time" | 停止模式为duration模式的振动。 | | VIBRATOR_STOP_MODE_PRESET | "preset" | 停止模式为预置EffectId的振动。 | @@ -258,7 +258,7 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | ------ | ------------------------------ | | type | "time" | 按照指定持续时间触发马达振动。 | | duration | - | 马达持续振动时长, 单位ms。 | @@ -269,7 +269,7 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | -------- | -------- | ------------------------------ | | type | "preset" | 按照预置振动效果触发马达振动。 | | effectId | - | 预置的振动效果ID。 | @@ -281,7 +281,7 @@ try { **系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.MiscDevice -| 名称 | 默认值 | 说明 | +| 名称 | 值 | 说明 | | ----- | ------ | -------------- | | id | 0 | 振动器id。 | | usage | - | 马达振动的使用场景。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md index b7b6212bd8c6df1c5fa3313c94e084037a1f5f04..733b12273c4ce0ce4a24785a1d86cc01b9430887 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md @@ -5,7 +5,6 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > > - 本模块首批接口从API version 9开始支持。 -> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。 > - 本模块接口为系统接口,三方应用不支持调用。 ## 导入模块 @@ -52,7 +51,7 @@ getAllVolumes(callback: AsyncCallback<Array<Volume>>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------- | ---- | ------------------------------------ | - | callback | callback: AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | + | callback | AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 | **示例:** @@ -110,7 +109,7 @@ mount(volumeId: string, callback:AsyncCallback<boolean>):void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | | volumeId | string | 是 | 卷id | - | callback | callback: AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | + | callback | AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 | **示例:** @@ -167,7 +166,7 @@ unmount(volumeId: string, callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------- | ---- | -------------------- | | volumeId | string | 是 | 卷id | - | callback | callback: AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | + | callback | AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 | **示例:** @@ -226,7 +225,7 @@ getVolumeByUuid(uuid: string, callback: AsyncCallback<Volume>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------------------------------ | ---- | -------------------- | | uuid | string | 是 | 卷uuid | - | callback | callback: AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | + | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | **示例:** @@ -285,7 +284,7 @@ getVolumeById(volumeId: string, callback: AsyncCallback<Volume>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ----------------------------- | | volumeId | string | 是 | 卷id | - | callback | callback:AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | + | callback | AsyncCallback<[Volume](#volume)> | 是 | 获取卷信息之后的回调 | **示例:** @@ -347,7 +346,7 @@ setVolumeDescription(uuid: string, description: string, callback: AsyncCallback& | ---------- | --------------------------------------- | ---- | ---------------- | | uuid | string | 是 | 卷uuid | | description | string | 是 | 卷描述 | - | callback | callback: AsyncCallback<void> | 是 | 设置卷描述之后的回调 | + | callback | AsyncCallback<void> | 是 | 设置卷描述之后的回调 | **示例:** @@ -410,7 +409,7 @@ format(volumeId: string, fsType: string, callback: AsyncCallback<void>): v | -------- | ------------------------- | ---- | ----------------------------- | | volumeId | string | 是 | 卷id | | fsType | string | 是 | 文件系统类型 | - | callback | callback: AsyncCallback<void> | 是 | 对指定卷格式化后的回调 | + | callback | AsyncCallback<void> | 是 | 对指定卷格式化后的回调 | **示例:** @@ -473,7 +472,7 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo | -------- | --------------------------------------- | ---- | ---------------- | | diskId | string | 是 | 卷所属的磁盘id | | type | number | 是 | 分区类型 | - | callback | callback: AsyncCallback<void> | 是 | 对磁盘进行分区 | + | callback | AsyncCallback<void> | 是 | 对磁盘进行分区 | **示例:** @@ -491,12 +490,12 @@ partition(diskId: string, type: number, callback: AsyncCallback<void>): vo ### 属性 -| 名称 | 类型 | 说明 | -| ----------- | ------- | -------------------- | -| id | string | 卷id | -| uuid | string | 卷uuid | -| diskId | string | 卷所属的磁盘id | -| description | string | 卷相关描述 | -| removable | boolean | 是否为可移动存储设备 | -| state | number | 当前卷状态 | -| path | string | 卷的挂载地址 | \ No newline at end of file +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------- | ------- | ----- | -------------------- | +| id | string | 是 | 否 | 卷id | +| uuid | string | 是 | 否 | 卷uuid | +| diskId | string | 是 | 否 | 卷所属的磁盘id | +| description | string | 是 | 否 | 卷相关描述 | +| removable | boolean | 是 | 否 | 是否为可移动存储设备 | +| state | number | 是 | 否 | 当前卷状态 | +| path | string | 是 | 否 | 卷的挂载地址 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-webview.md b/zh-cn/application-dev/reference/apis/js-apis-webview.md index b547ce6a2e72063fd916be7568995a5913aa2566..34e32a7810d8dc63369971310ffdbdb154bf2625 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webview.md @@ -68,9 +68,9 @@ postMessageEvent(message: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------- | ------ | ---- | ------ | :------------- | -| message | string | 是 | - | 要发送的消息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | :------------- | +| message | string | 是 | 要发送的消息。 | **错误码**: @@ -120,9 +120,9 @@ onMessageEvent(callback: (result: string) => void): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | -------- | ---- | ------ | :------------------- | -| callback | function | 是 | - | 接收消息的回调函数。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | ---- | :------------------- | +| callback | function | 是 | 接收消息的回调函数。 | **错误码**: @@ -170,7 +170,20 @@ struct WebComponent { ### 创建对象 ```ts -controller: web_webview.WebviewController = new web_webview.WebviewController(); +// xxx.ets +import web_webview from '@ohos.web.webview' + +@Entry +@Component +struct WebComponent { + controller: web_webview.WebviewController = new web_webview.WebviewController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + } + } +} ``` ### loadUrl @@ -183,10 +196,10 @@ loadUrl(url: string | Resource, headers?: Array\): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------- | ---------------- | ---- | ------ | :-------------------- | -| url | string | 是 | - | 需要加载的 URL。 | -| headers | Array\<[HeaderV9](#headerv9)> | 是 | - | URL的附加HTTP请求头。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------- | ---- | :-------------------- | +| url | string | 是 | 需要加载的 URL。 | +| headers | Array\<[HeaderV9](#headerv9)> | 否 | URL的附加HTTP请求头。 | **错误码**: @@ -235,13 +248,13 @@ loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, his **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ---------- | ------ | ---- | ------ | ------------------------------------------------------------ | -| data | string | 是 | - | 按照”Base64“或者”URL"编码后的一段字符串。 | -| mimeType | string | 是 | - | 媒体类型(MIME)。 | -| encoding | string | 是 | - | 编码类型,具体为“Base64"或者”URL编码。 | -| baseUrl | string | 否 | - | 指定的一个URL路径(“http”/“https”/"data"协议),并由Web组件赋值给window.origin。 | -| historyUrl | string | 否 | - | 历史记录URL。非空时,可被历史记录管理,实现前进后退功能。当baseUrl为空时,此属性无效。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------------------------------ | +| data | string | 是 | 按照”Base64“或者”URL"编码后的一段字符串。 | +| mimeType | string | 是 | 媒体类型(MIME)。 | +| encoding | string | 是 | 编码类型,具体为“Base64"或者”URL编码。 | +| baseUrl | string | 否 | 指定的一个URL路径(“http”/“https”/"data"协议),并由Web组件赋值给window.origin。 | +| historyUrl | string | 否 | 历史记录URL。非空时,可被历史记录管理,实现前进后退功能。当baseUrl为空时,此属性无效。 | **错误码**: @@ -250,6 +263,7 @@ loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, his | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------------ | | 17100001 | Init error. The WebviewController must be associated with a Web component. | +| 17100002 | Invalid url. | **示例:** @@ -606,9 +620,9 @@ accessStep(step: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ------------------------------------------ | -| step | number | 是 | - | 要跳转的步数,正数代表前进,负数代表后退。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ------------------------------------------ | +| step | number | 是 | 要跳转的步数,正数代表前进,负数代表后退。 | **返回值:** @@ -756,11 +770,11 @@ registerJavaScriptProxy(object: object, name: string, methodList: Array\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ---------- | -------------- | ---- | ------ | ------------------------------------------------------------ | -| object | object | 是 | - | 参与注册的应用侧JavaScript对象。只能声明方法,不能声明属性 。其中方法的参数和返回类型只能为string,number,boolean | -| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。注册后window对象可以通过此名字访问应用侧JavaScript对象。 | -| methodList | Array\ | 是 | - | 参与注册的应用侧JavaScript对象的方法。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | -------------- | ---- | ------------------------------------------------------------ | +| object | object | 是 | 参与注册的应用侧JavaScript对象。只能声明方法,不能声明属性 。其中方法的参数和返回类型只能为string,number,boolean | +| name | string | 是 | 注册对象的名称,与window中调用的对象名一致。注册后window对象可以通过此名字访问应用侧JavaScript对象。 | +| methodList | Array\ | 是 | 参与注册的应用侧JavaScript对象的方法。 | **错误码:** @@ -816,10 +830,10 @@ runJavaScript(script: string, callback : AsyncCallback\): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| -------- | ------------------------ | ---- | ------ | ------------------------------------------------------------ | -| script | string | 是 | - | JavaScript脚本。 | -| callback | AsyncCallback\ | 否 | - | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------------------- | +| script | string | 是 | JavaScript脚本。 | +| callback | AsyncCallback\ | 否 | 回调执行JavaScript脚本结果。JavaScript脚本若执行失败或无返回值时,返回null。 | **错误码:** @@ -879,9 +893,9 @@ runJavaScript(script: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ---------------- | -| script | string | 是 | - | JavaScript脚本。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---------------- | +| script | string | 是 | JavaScript脚本。 | **返回值:** @@ -943,9 +957,9 @@ deleteJavaScriptRegister(name: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ------------------------------------------------------------ | -| name | string | 是 | - | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---- | +| name | string | 是 | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | **错误码:** @@ -994,7 +1008,7 @@ zoom(factor: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | factor | number | 是 | 基于当前网页所需调整的相对缩放比例,正值为放大,负值为缩小。 | @@ -1142,9 +1156,9 @@ searchNext(forward: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------- | -------- | ---- | ------ | ---------------------- | -| forward | boolean | 是 | - | 从前向后或者逆向查找。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ---------------------- | +| forward | boolean | 是 | 从前向后或者逆向查找。 | **错误码:** @@ -1328,11 +1342,11 @@ postMessage(name: string, ports: Array\, uri: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ---------------------- | ---- | ------ | :------------------------------- | -| name | string | 是 | - | 要发送的消息,包含数据和消息端口。 | -| ports | Array\ | 是 | - | 接收该消息的URI。 | -| uri | string | 是 | - | 接收该消息的URI。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------- | ---- | :------------------------------- | +| name | string | 是 | 要发送的消息,包含数据和消息端口。 | +| ports | Array\ | 是 | 接收该消息的URI。 | +| uri | string | 是 | 接收该消息的URI。 | **错误码**: @@ -1842,7 +1856,7 @@ storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback\ **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ------------------------------------------------------------ | | baseName | string | 是 | 文件存储路径,该值不能为空。 | | autoName | boolean | 是 | 决定是否自动生成文件名。 如果为false,则将baseName作为文件存储路径。 如果为true,则假定baseName是一个目录,将根据当前页的Url自动生成文件名。 | @@ -2060,9 +2074,9 @@ backOrForward(step: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ---------------------- | -| step | number | 是 | - | 需要前进或后退的步长。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---------------------- | +| step | number | 是 | 需要前进或后退的步长。 | **错误码**: @@ -2114,9 +2128,9 @@ static getCookie(url: string): string **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | :------------------------ | -| url | string | 是 | - | 要获取的cookie所属的url。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | :------------------------ | +| url | string | 是 | 要获取的cookie所属的url。 | **返回值:** @@ -2127,6 +2141,7 @@ static getCookie(url: string): string **错误码**: 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) + | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------ | | 17100002 | Invalid url. | @@ -2169,10 +2184,10 @@ static setCookie(url: string, value: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | :------------------------ | -| url | string | 是 | - | 要设置的cookie所属的url。 | -| value | string | 是 | - | 要设置的cookie的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | :------------------------ | +| url | string | 是 | 要设置的cookie所属的url。 | +| value | string | 是 | 要设置的cookie的值。 | **错误码**: @@ -2220,9 +2235,9 @@ static saveCookieAsync(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | ---------------------- | ---- | ------ | :------------------------------------------------- | -| callback | AsyncCallback\ | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | :------------------------------------------------- | +| callback | AsyncCallback\ | 是 | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | **示例:** @@ -2313,9 +2328,9 @@ static putAcceptCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------- | ---- | ------ | :----------------------------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | :----------------------------------- | +| accept | boolean | 是 | 设置是否拥有发送和接收cookie的权限。 | **示例:** @@ -2392,9 +2407,9 @@ static putAcceptThirdPartyCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------- | ---- | ------ | :----------------------------------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | :----------------------------------------- | +| accept | boolean | 是 | 设置是否拥有发送和接收第三方cookie的权限。 | **示例:** @@ -2575,9 +2590,9 @@ static deleteOrigin(origin : string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------------ | -| origin | string | 是 | - | 指定源的字符串索引. | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| origin | string | 是 | 指定源的字符串索引. | **错误码:** @@ -2627,9 +2642,9 @@ static getOrigins(callback: AsyncCallback\>) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | -------------------------------------- | ---- | ------ | ------------------------------------------------------ | -| callback | AsyncCallback\> | 是 | - | 以数组方式返回源的信息,信息内容参考[WebStorageOrigin](#webstorageorigin)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback\> | 是 | 以数组方式返回源的信息,信息内容参考[WebStorageOrigin](#webstorageorigin)。 | **错误码:** @@ -2749,10 +2764,10 @@ static getOriginQuota(origin : string, callback : AsyncCallback\) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | --------------------- | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | -| callback | AsyncCallback\ | 是 | - | 指定源的存储配额 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 指定源的存储配额 | **错误码:** @@ -2808,9 +2823,9 @@ static getOriginQuota(origin : string) : Promise\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **返回值:** @@ -2872,10 +2887,10 @@ static getOriginUsage(origin : string, callback : AsyncCallback\) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | --------------------- | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | -| callback | AsyncCallback\ | 是 | - | 指定源的存储量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 指定源的存储量。 | **错误码:** @@ -2931,9 +2946,9 @@ static getOriginUsage(origin : string) : Promise\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **返回值:** @@ -3035,10 +3050,10 @@ static getHttpAuthCredentials(host: string, realm: string): Array\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ---------------------------- | -| host | string | 是 | - | HTTP身份验证凭据应用的主机。 | -| realm | string | 是 | - | HTTP身份验证凭据应用的域。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------- | +| host | string | 是 | HTTP身份验证凭据应用的主机。 | +| realm | string | 是 | HTTP身份验证凭据应用的域。 | **返回值:** @@ -3090,12 +3105,12 @@ static saveHttpAuthCredentials(host: string, realm: string, username: string, pa **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | ------ | ---- | ------ | ---------------------------- | -| host | string | 是 | - | HTTP身份验证凭据应用的主机。 | -| realm | string | 是 | - | HTTP身份验证凭据应用的域。 | -| username | string | 是 | - | 用户名。 | -| password | string | 是 | - | 密码。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------------- | +| host | string | 是 | HTTP身份验证凭据应用的主机。 | +| realm | string | 是 | HTTP身份验证凭据应用的域。 | +| username | string | 是 | 用户名。 | +| password | string | 是 | 密码。 | **示例:** @@ -3216,13 +3231,14 @@ static allowGeolocation(origin: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 说明 | +| ------ | ------ | ------------------ | +| origin | string | 指定源的字符串索引 | **错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) + | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------ | | 17100011 | Invalid origin. | @@ -3265,9 +3281,9 @@ static deleteGeolocation(origin: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **错误码:** @@ -3315,10 +3331,10 @@ static getAccessibleGeolocation(origin: string, callback: AsyncCallback\ | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | **错误码:** @@ -3372,9 +3388,9 @@ static getAccessibleGeolocation(origin: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | -------------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------- | ---- | -------------------- | +| origin | string | 是 | 指定源的字符串索引。 | **返回值:** @@ -3433,9 +3449,9 @@ static getStoredGeolocation(callback: AsyncCallback\>): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | ---------------------------- | ---- | ------ | ---------------------------------------- | -| callback | AsyncCallback\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback\> | 是 | 返回已存储地理位置权限状态的所有源信息。 | **示例:** @@ -3557,25 +3573,25 @@ Web组件返回的请求/响应头对象。 **系统能力:** SystemCapability.Web.Webview.Core -| 名称 | 类型 | 说明 | -| ----------- | ------ | :------------------- | -| headerKey | string | 请求/响应头的key。 | -| headerValue | string | 请求/响应头的value。 | +| 名称 | 类型 | 可读 | 可写 |说明 | +| ----------- | ------ | -----|------|------------------- | +| headerKey | string | 是 | 是 | 请求/响应头的key。 | +| headerValue | string | 是 | 是 | 请求/响应头的value。 | ## HitTestTypeV9 **系统能力:** SystemCapability.Web.Webview.Core -| 名称 | 描述 | -| ------------- | ----------------------------------------- | -| EditText | 可编辑的区域。 | -| Email | 电子邮件地址。 | -| HttpAnchor | 超链接,其src为http。 | -| HttpAnchorImg | 带有超链接的图片,其中超链接的src为http。 | -| Img | HTML::img标签。 | -| Map | 地理地址。 | -| Phone | 电话号码。 | -| Unknown | 未知内容。 | +| 名称 | 值 | 说明 | +| ------------- | -- |----------------------------------------- | +| EditText | 0 |可编辑的区域。 | +| Email | 1 |电子邮件地址。 | +| HttpAnchor | 2 |超链接,其src为http。 | +| HttpAnchorImg | 3 |带有超链接的图片,其中超链接的src为http。 | +| Img | 4 |HTML::img标签。 | +| Map | 5 |地理地址。 | +| Phone | 6 |电话号码。 | +| Unknown | 7 |未知内容。 | ## HitTestValue @@ -3583,10 +3599,10 @@ Web组件返回的请求/响应头对象。 **系统能力:** SystemCapability.Web.Webview.Core -| 名称 | 类型 | 说明 | -| ----- | ------------- | :----------------------------------------------------------- | -| type | [HitTestTypeV9](#hittesttypev9) | 当前被点击区域的元素类型。 | -| extra | string | 点击区域的附加参数信息。若被点击区域为图片或链接,则附加参数信息为其url地址。 | +| 名称 | 类型 | 可读 | 可写 | 说明| +| ---- | ---- | ---- | ---- |---- | +| type | [HitTestTypeV9](#hittesttypev9) | 是 | 否 | 当前被点击区域的元素类型。| +| extra | string | 是 | 否 |点击区域的附加参数信息。若被点击区域为图片或链接,则附加参数信息为其url地址。 | ## WebStorageOrigin @@ -3594,8 +3610,8 @@ Web组件返回的请求/响应头对象。 **系统能力:** SystemCapability.Web.Webview.Core -| 名称 | 类型 | 必填 | 说明 | -| ------ | ------ | :--- | -------------------- | -| origin | string | 是 | 指定源的字符串索引。 | -| usage | number | 是 | 指定源的存储量。 | -| quota | number | 是 | 指定源的存储配额。 | \ No newline at end of file +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ---- | +| origin | string | 是 | 否 | 指定源的字符串索引。 | +| usage | number | 是 | 否 | 指定源的存储量。 | +| quota | number | 是 | 否 | 指定源的存储配额。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-wifiext.md b/zh-cn/application-dev/reference/apis/js-apis-wifiext.md index 439e632951d8ebd6e965238e9b6cafde8cb4ad5e..cd3fdb30674f6084c05f916a4d71db0c9bf0aaef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-wifiext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-wifiext.md @@ -1,4 +1,4 @@ -# WLAN +# WLAN扩展接口 该模块主要提供WLAN扩展接口,供非通用类型产品使用。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 162f75d0804a942d1d97097dbfcc6c006a7b63fb..3809bb3af14653ed1c3f460d453f1807759cfc75 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -52,7 +52,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ---------- | -------------------------- | -- | ----------------------------------- | | name | string | 是 | 子窗口名字。 | | windowType | [WindowType](#windowtype7) | 是 | 子窗口类型。 | @@ -108,7 +108,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 必填 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 必填 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ---- | ------------------------------------------------------------ | | statusBarColor | string | 否 | 是 | 否 | 状态栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。默认值:`#0x66000000`。 | | isStatusBarLightIcon7+ | boolean | 否 | 是 | 否 | 状态栏图标是否为高亮状态。true表示高亮;false表示不高亮。默认值:false。 | @@ -161,7 +161,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | type | [WindowType](#windowtype7) | 是 | 否 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | | isEnable | boolean | 是 | 否 | 当前系统栏是否显示。true表示显示;false表示不显示。 | @@ -177,7 +177,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- | | displayId | number | 是 | 否 | 当前物理屏幕id。 | | regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是 | 否 | 当前已改变的所有系统栏信息。 | @@ -188,7 +188,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | ------------------ | | left | number | 是 | 是 | 矩形区域的左边界。 | | top | number | 是 | 是 | 矩形区域的上边界。 | @@ -201,7 +201,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---------- | ------------- | ---- | ---- | ------------------ | | visible9+ | boolean | 是 | 是 | 规避区域是否可见。true表示可见;false表示不可见。 | | leftRect | [Rect](#rect7) | 是 | 是 | 屏幕左侧的矩形区。 | @@ -215,7 +215,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | ---------- | | width | number | 是 | 是 | 窗口宽度。 | | height | number | 是 | 是 | 窗口高度。 | @@ -226,7 +226,7 @@ import window from '@ohos.window'; **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | | windowRect7+ | [Rect](#rect7) | 是 | 是 | 窗口尺寸。 | | type7+ | [WindowType](#windowtype7) | 是 | 是 | 窗口类型。 | @@ -261,7 +261,7 @@ import window from '@ohos.window'; **系统能力**:SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | -------------------------------------------------- | | x | number | 否 | 是 | X轴的缩放参数,默认值为1.0。 | | y | number | 否 | 是 | Y轴的缩放参数,默认值为1.0。 | @@ -276,7 +276,7 @@ import window from '@ohos.window'; **系统能力**:SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | -------- | ---- | ---- | -------------------------------------------------- | | x | number | 否 | 是 | 绕X轴的旋转角度,默认值为0.0。 | | y | number | 否 | 是 | 绕Y轴的旋转角度,默认值为0.0。 | @@ -292,7 +292,7 @@ import window from '@ohos.window'; **系统能力**:SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | ---- | -------- | ---- | ---- | ---------------------------- | | x | number | 否 | 是 | X轴的平移参数,默认值为0.0。 | | y | number | 否 | 是 | Y轴的平移参数,默认值为0.0。 | @@ -339,7 +339,7 @@ try { }); } catch (exception) { console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.createWindow9+ @@ -386,7 +386,7 @@ try { }); } catch (exception) { console.error('Failed to create the window. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.findWindow9+ @@ -412,11 +412,12 @@ findWindow(name: string): Window **示例:** ```js +let windowClass = null; try { - let windowClass = window.findWindow('alertWindow'); + windowClass = window.findWindow('alertWindow'); } catch (exception) { console.error('Failed to find the Window. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.getLastWindow9+ @@ -458,7 +459,7 @@ try { }); } catch (exception) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.getLastWindow9+ @@ -504,7 +505,7 @@ try { }); } catch (exception) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.minimizeAll9+ @@ -535,26 +536,25 @@ minimizeAll(id: number, callback: AsyncCallback<void>): void ```js import display from '@ohos.display' -import window from '@ohos.window' +let displayClass = null; try { displayClass = display.getDefaultDisplaySync(); -} catch (exception) { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); - return; -}; -try { - window.minimizeAll(displayClass.id, (err) => { - if(err.code) { - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Succeeded in minimizing all windows.'); - }); + try { + window.minimizeAll(displayClass.id, (err) => { + if(err.code) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in minimizing all windows.'); + }); + } catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); + } } catch (exception) { - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); -}; + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +} ``` ## window.minimizeAll9+ @@ -590,26 +590,24 @@ minimizeAll(id: number): Promise<void> ```js import display from '@ohos.display' -import window from '@ohos.window' let displayClass = null; try { displayClass = display.getDefaultDisplaySync(); -} catch (exception) { - console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); - return; -}; -try { - let promise = window.minimizeAll(displayClass.id); - promise.then(()=> { - console.info('Succeeded in minimizing all windows.'); - }).catch((err)=>{ - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); - }); + try { + let promise = window.minimizeAll(displayClass.id); + promise.then(()=> { + console.info('Succeeded in minimizing all windows.'); + }).catch((err)=>{ + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err)); + }); + } catch (exception) { + console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); + } } catch (exception) { - console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception)); -}; + console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); +} ``` ## window.toggleShownStateForAllAppWindows9+ @@ -644,7 +642,7 @@ window.toggleShownStateForAllAppWindows((err) => { return; } console.info('Succeeded in toggling shown state for all app windows.'); -}) +}); ``` ## window.toggleShownStateForAllAppWindows9+ @@ -678,7 +676,7 @@ promise.then(()=> { console.info('Succeeded in toggling shown state for all app windows.'); }).catch((err)=>{ console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err)); -}) +}); ``` ## window.setWindowLayoutMode9+ @@ -718,7 +716,7 @@ try { }); } catch (exception) { console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.setWindowLayoutMode9+ @@ -762,7 +760,7 @@ try { }); } catch (exception) { console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.on('systemBarTintChange')8+ @@ -791,7 +789,7 @@ try { }); } catch (exception) { console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.off('systemBarTintChange')8+ @@ -818,7 +816,7 @@ try { window.off('systemBarTintChange'); } catch (exception) { console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ## window.create(deprecated) @@ -1110,7 +1108,7 @@ promise.then((data)=> { console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ## window.getTopWindow(deprecated) @@ -1180,7 +1178,7 @@ promise.then((data)=> { console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ## Window @@ -1222,7 +1220,7 @@ windowClass.hide((err) => { return; } console.info('Succeeded in hiding the window.'); -}) +}); ``` ### hide7+ @@ -1257,7 +1255,7 @@ promise.then(()=> { console.info('Succeeded in hiding the window.'); }).catch((err)=>{ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### hideWithAnimation9+ @@ -1295,7 +1293,7 @@ windowClass.hideWithAnimation((err) => { return; } console.info('Succeeded in hiding the window with animation.'); -}) +}); ``` ### hideWithAnimation9+ @@ -1332,7 +1330,7 @@ promise.then(()=> { console.info('Succeeded in hiding the window with animation.'); }).catch((err)=>{ console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### showWindow9+ @@ -1437,7 +1435,7 @@ windowClass.showWithAnimation((err) => { return; } console.info('Succeeded in showing the window with animation.'); -}) +}); ``` ### showWithAnimation9+ @@ -1474,7 +1472,7 @@ promise.then(()=> { console.info('Succeeded in showing the window with animation.'); }).catch((err)=>{ console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### destroyWindow9+ @@ -1509,7 +1507,7 @@ windowClass.destroyWindow((err) => { return; } console.info('Succeeded in destroying the window.'); -}) +}); ``` ### destroyWindow9+ @@ -1543,7 +1541,7 @@ promise.then(()=> { console.info('Succeeded in destroying the window.'); }).catch((err)=>{ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### moveWindowTo9+ @@ -1584,7 +1582,7 @@ try { }); } catch (exception) { console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); -}; +} ``` ### moveWindowTo9+ @@ -1629,7 +1627,7 @@ try { }); } catch (exception) { console.error('Failed to move the window. Cause:' + JSON.stringify(exception)); -}; +} ``` ### resize9+ @@ -1676,7 +1674,7 @@ try { }); } catch (exception) { console.error('Failed to change the window size. Cause:' + JSON.stringify(exception)); -}; +} ``` ### resize9+ @@ -1727,7 +1725,7 @@ try { }); } catch (exception) { console.error('Failed to change the window size. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowMode9+ @@ -1770,7 +1768,7 @@ try { }); } catch (exception) { console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowMode9+ @@ -1809,7 +1807,7 @@ setWindowMode(mode: WindowMode): Promise<void> ```js let mode = window.WindowMode.FULLSCREEN; try { - let promise = windowClass.setWindowMode(type); + let promise = windowClass.setWindowMode(mode); promise.then(()=> { console.info('Succeeded in setting the window mode.'); }).catch((err)=>{ @@ -1817,7 +1815,7 @@ try { }); } catch (exception) { console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### getWindowProperties9+ @@ -1849,7 +1847,7 @@ try { let properties = windowClass.getWindowProperties(); } catch (exception) { console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### getWindowAvoidArea9+ @@ -1888,7 +1886,7 @@ try { let avoidArea = windowClass.getWindowAvoidArea(type); } catch (exception) { console.error('Failed to obtain the area. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowLayoutFullScreen9+ @@ -1929,7 +1927,7 @@ try { }); } catch (exception) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowLayoutFullScreen9+ @@ -1974,7 +1972,7 @@ try { }); } catch (exception) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowSystemBarEnable9+ @@ -2016,7 +2014,7 @@ try { }); } catch (exception) { console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowSystemBarEnable9+ @@ -2062,7 +2060,7 @@ try { }); } catch (exception) { console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowSystemBarProperties9+ @@ -2092,7 +2090,7 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties, callback: **示例:** ```js -let SystemBarProperties={ +let SystemBarProperties = { statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', //以下两个属性从API Version8开始支持 @@ -2109,7 +2107,7 @@ try { }); } catch (exception) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowSystemBarProperties9+ @@ -2144,7 +2142,7 @@ setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise& **示例:** ```js -let SystemBarProperties={ +let SystemBarProperties = { statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', //以下两个属性从API Version8开始支持 @@ -2160,7 +2158,7 @@ try { }); } catch (exception) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setPreferredOrientation9+ @@ -2200,7 +2198,7 @@ try { }); } catch (exception) { console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setPreferredOrientation9+ @@ -2244,7 +2242,7 @@ try { }); } catch (exception) { console.error('Failed to set window orientation. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setUIContent9+ @@ -2284,7 +2282,7 @@ try { }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setUIContent9+ @@ -2328,7 +2326,7 @@ try { }); } catch (exception) { console.error('Failed to load the content. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### loadContent9+ @@ -2374,7 +2372,7 @@ try { }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); -}; +} ``` ### loadContent9+ @@ -2424,7 +2422,7 @@ try { }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); -}; +} ``` ### isWindowShowing9+ @@ -2457,7 +2455,7 @@ try { console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)); } catch (exception) { console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('windowSizeChange')7+ @@ -2484,7 +2482,7 @@ try { }); } catch (exception) { console.error('Failed to enable the listener for window size changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('windowSizeChange')7+ @@ -2509,7 +2507,7 @@ try { windowClass.off('windowSizeChange'); } catch (exception) { console.error('Failed to disable the listener for window size changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('avoidAreaChange')9+ @@ -2537,7 +2535,7 @@ try { }); } catch (exception) { console.error('Failed to enable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('avoidAreaChange')9+ @@ -2562,7 +2560,7 @@ try { windowClass.off('avoidAreaChange'); } catch (exception) { console.error('Failed to disable the listener for system avoid area changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('keyboardHeightChange')7+ @@ -2589,7 +2587,7 @@ try { }); } catch (exception) { console.error('Failed to enable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('keyboardHeightChange')7+ @@ -2614,7 +2612,7 @@ try { windowClass.off('keyboardHeightChange'); } catch (exception) { console.error('Failed to disable the listener for keyboard height changes. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('touchOutside')9+ @@ -2643,7 +2641,7 @@ try { }); } catch (exception) { console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('touchOutside')9+ @@ -2670,7 +2668,7 @@ try { windowClass.off('touchOutside'); } catch (exception) { console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('screenshot')9+ @@ -2697,7 +2695,7 @@ try { }); } catch (exception) { console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('screenshot')9+ @@ -2718,21 +2716,21 @@ off(type: 'screenshot', callback?: Callback<void>): void **示例:** ```js -let callback = ()=>{ +let callback = () => { console.info('screenshot happened'); }; try { windowClass.on('screenshot', callback); } catch (exception) { console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); -}; +} try { windowClass.off('screenshot', callback); // 如果通过on开启多个callback进行监听,同时关闭所有监听: windowClass.off('screenshot'); } catch (exception) { console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### on('dialogTargetTouch')9+ @@ -2759,7 +2757,7 @@ try { }); } catch (exception) { console.error('Failed to register callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### off('dialogTargetTouch')9+ @@ -2784,7 +2782,7 @@ try { windowClass.off('dialogTargetTouch'); } catch (exception) { console.error('Failed to unregister callback. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### bindDialogTarget9+ @@ -2817,6 +2815,8 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, c **示例:** ```js +import rpc from '@ohos.rpc'; + class MyDeathRecipient { onRemoteDied() { console.log('server died'); @@ -2836,6 +2836,7 @@ class TestRemoteObject extends rpc.RemoteObject { return false; } } + let token = new TestRemoteObject('testObject'); try { windowClass.bindDialogTarget(token, () => { @@ -2849,7 +2850,7 @@ try { }); } catch (exception) { console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); -}; +} ``` ### bindDialogTarget9+ @@ -2887,6 +2888,8 @@ bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): **示例:** ```js +import rpc from '@ohos.rpc'; + class MyDeathRecipient { onRemoteDied() { console.log('server died'); @@ -2906,6 +2909,7 @@ class TestRemoteObject extends rpc.RemoteObject { return false; } } + let token = new TestRemoteObject('testObject'); try { let promise = windowClass.bindDialogTarget(token, () => { @@ -2918,7 +2922,7 @@ try { }); } catch (exception) { console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception)); -}; +} ``` ### isWindowSupportWideGamut9+ @@ -3024,7 +3028,7 @@ try { }); } catch (exception) { console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowColorSpace9+ @@ -3067,7 +3071,7 @@ try { }); } catch (exception) { console.error('Failed to set window colorspace. Cause:' + JSON.stringify(exception)); -}; +} ``` ### getWindowColorSpace9+ @@ -3128,7 +3132,7 @@ try { windowClass.setWindowBackgroundColor(color); } catch (exception) { console.error('Failed to set the background color. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowBrightness9+ @@ -3169,7 +3173,7 @@ try { }); } catch (exception) { console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowBrightness9+ @@ -3214,7 +3218,7 @@ try { }); } catch (exception) { console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowFocusable9+ @@ -3244,7 +3248,7 @@ setWindowFocusable(isFocusable: boolean, callback: AsyncCallback<void>): v **示例:** ```js -let isFocusable= true; +let isFocusable = true; try { windowClass.setWindowFocusable(isFocusable, (err) => { if (err.code) { @@ -3255,7 +3259,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowFocusable9+ @@ -3290,7 +3294,7 @@ setWindowFocusable(isFocusable: boolean): Promise<void> **示例:** ```js -let isFocusable= true; +let isFocusable = true; try { let promise = windowClass.setWindowFocusable(isFocusable); promise.then(()=> { @@ -3300,7 +3304,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowKeepScreenOn9+ @@ -3341,7 +3345,7 @@ try { }); } catch (exception) { console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowKeepScreenOn9+ @@ -3386,7 +3390,7 @@ try { }); } catch (exception) { console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWakeUpScreen()9+ @@ -3422,7 +3426,7 @@ try { windowClass.setWakeUpScreen(wakeUp); } catch (exception) { console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setWindowPrivacyMode9+ @@ -3464,7 +3468,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowPrivacyMode9+ @@ -3510,7 +3514,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setSnapshotSkip9+ @@ -3583,7 +3587,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setWindowTouchable9+ @@ -3628,7 +3632,7 @@ try { }); } catch (exception) { console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setForbidSplitMove9+ @@ -3671,7 +3675,7 @@ try { }); } catch (exception) { console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### setForbidSplitMove9+ @@ -3718,7 +3722,7 @@ try { }); } catch (exception) { console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception)); -}; +} ``` ### snapshot9+ @@ -3822,7 +3826,7 @@ try { windowClass.opacity(0.5); } catch (exception) { console.error('Failed to opacity. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### scale9+ @@ -3863,7 +3867,7 @@ try { windowClass.scale(obj); } catch (exception) { console.error('Failed to scale. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### rotate9+ @@ -3905,7 +3909,7 @@ try { windowClass.rotate(obj); } catch (exception) { console.error('Failed to rotate. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### translate9+ @@ -3945,7 +3949,7 @@ try { windowClass.translate(obj); } catch (exception) { console.error('Failed to translate. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### getTransitionController9+ @@ -3998,16 +4002,16 @@ controller.animationForHidden = (context : window.TransitionContext) => { toWindow.translate(obj); // 设置动画过程中的属性转换 console.info('toWindow translate end'); } - ) + ); console.info('complete transition end'); -} +}; windowClass.hideWithAnimation((err, data) => { if (err.code) { console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err)); return; } console.info('Succeeded in showing the window with animation. Data: ' + JSON.stringify(data)); -}) +}); ``` ### setBlur9+ @@ -4042,7 +4046,7 @@ try { windowClass.setBlur(4.0); } catch (exception) { console.error('Failed to set blur. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setBackdropBlur9+ @@ -4077,7 +4081,7 @@ try { windowClass.setBackdropBlur(4.0); } catch (exception) { console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setBackdropBlurStyle9+ @@ -4112,7 +4116,7 @@ try { windowClass.setBackdropBlurStyle(window.BlurStyle.THIN); } catch (exception) { console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setShadow9+ @@ -4150,7 +4154,7 @@ try { windowClass.setShadow(4.0, '#FF00FF00', 2, 3); } catch (exception) { console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### setCornerRadius9+ @@ -4185,7 +4189,7 @@ try { windowClass.setCornerRadius(4.0); } catch (exception) { console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception)); -}; +} ``` ### show(deprecated) @@ -4215,7 +4219,7 @@ windowClass.show((err) => { return; } console.info('Succeeded in showing the window.'); -}) +}); ``` ### show(deprecated) @@ -4244,7 +4248,7 @@ promise.then(()=> { console.info('Succeeded in showing the window.'); }).catch((err)=>{ console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### destroy(deprecated) @@ -4274,7 +4278,7 @@ windowClass.destroy((err) => { return; } console.info('Succeeded in destroying the window.'); -}) +}); ``` ### destroy(deprecated) @@ -4303,7 +4307,7 @@ promise.then(()=> { console.info('Succeeded in destroying the window.'); }).catch((err)=>{ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### moveTo(deprecated) @@ -4335,7 +4339,6 @@ windowClass.moveTo(300, 300, (err)=>{ return; } console.info('Succeeded in moving the window.'); - }); ``` @@ -4372,7 +4375,7 @@ promise.then(()=> { console.info('Succeeded in moving the window.'); }).catch((err)=>{ console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); -}) +}); ``` ### resetSize(deprecated) @@ -5144,7 +5147,7 @@ windowClass.isSupportWideGamut((err, data) => { return; } console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)); -}) +}); ``` ### isSupportWideGamut(deprecated) @@ -5204,7 +5207,7 @@ windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { return; } console.info('Succeeded in setting window colorspace.'); -}) +}); ``` ### setColorSpace(deprecated) @@ -5269,7 +5272,7 @@ windowClass.getColorSpace((err, data) => { return; } console.info('Succeeded in getting window colorspace. Cause:' + JSON.stringify(data)); -}) +}); ``` ### getColorSpace(deprecated) @@ -5667,7 +5670,7 @@ windowClass.setOutsideTouchable(true, (err) => { return; } console.info('Succeeded in setting the area to be touchable.'); -}) +}); ``` ### setOutsideTouchable(deprecated) @@ -5734,7 +5737,6 @@ windowClass.setPrivacyMode(isPrivacyMode, (err) => { return; } console.info('Succeeded in setting the window to privacy mode.'); - }); ``` @@ -5803,7 +5805,6 @@ windowClass.setTouchable(isTouchable, (err) => { return; } console.info('Succeeded in setting the window to be touchable.'); - }); ``` @@ -5893,6 +5894,7 @@ getMainWindow(callback: AsyncCallback<Window>): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -5906,7 +5908,7 @@ class myAbility extends Ability { console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); }); } -} +}; ``` ### getMainWindow9+ @@ -5938,19 +5940,20 @@ getMainWindow(): Promise<Window> ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; let promise = windowStage.getMainWindow(); - promise.then((data)=> { + promise.then((data) => { windowClass = data; console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ + }).catch((err) => { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); }); } -} +}; ``` ### getMainWindowSync9+ @@ -5982,6 +5985,7 @@ getMainWindowSync(): Window ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -5991,7 +5995,7 @@ class myAbility extends Ability { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(exception)); }; } -} +}; ``` ### createSubWindow9+ @@ -6008,7 +6012,7 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------- | ---- | --------------------------------------------- | -| name | String | 是 | 子窗口的名字。 | +| name | string | 是 | 子窗口的名字。 | | callback | AsyncCallback<[Window](#window)> | 是 | 回调函数。返回当前WindowStage下的子窗口对象。 | **错误码:** @@ -6024,6 +6028,7 @@ createSubWindow(name: string, callback: AsyncCallback<Window>): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6042,7 +6047,7 @@ class myAbility extends Ability { console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); }; } -} +}; ``` ### createSubWindow9+ @@ -6058,7 +6063,7 @@ createSubWindow(name: string): Promise<Window> | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | -------------- | -| name | String | 是 | 子窗口的名字。 | +| name | string | 是 | 子窗口的名字。 | **返回值:** @@ -6079,23 +6084,24 @@ createSubWindow(name: string): Promise<Window> ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; try { let promise = windowStage.createSubWindow('mySubWindow'); - promise.then((data)=> { + promise.then((data) => { windowClass = data; console.info('Succeeded in creating the subwindow. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ + }).catch((err) => { console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); }); } catch (exception) { console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(exception)); }; } -} +}; ``` ### getSubWindow9+ @@ -6126,6 +6132,7 @@ getSubWindow(callback: AsyncCallback<Array<Window>>): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6139,7 +6146,7 @@ class myAbility extends Ability { console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); }); } -} +}; ``` ### getSubWindow9+ @@ -6169,19 +6176,20 @@ getSubWindow(): Promise<Array<Window>> ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); let windowClass = null; let promise = windowStage.getSubWindow(); - promise.then((data)=> { + promise.then((data) => { windowClass = data; console.info('Succeeded in obtaining the subwindow. Data: ' + JSON.stringify(data)); - }).catch((err)=>{ + }).catch((err) => { console.error('Failed to obtain the subwindow. Cause: ' + JSON.stringify(err)); }) } -} +}; ``` ### loadContent9+ @@ -6214,6 +6222,7 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback<void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { @@ -6232,7 +6241,7 @@ class myAbility extends Ability { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); }; } -} +}; ``` ### loadContent9+ @@ -6271,6 +6280,7 @@ loadContent(path: string, storage?: LocalStorage): Promise<void> ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { storage : LocalStorage onWindowStageCreate(windowStage) { @@ -6279,16 +6289,16 @@ class myAbility extends Ability { console.log('onWindowStageCreate'); try { let promise = windowStage.loadContent('pages/page2',this.storage); - promise.then(()=> { + promise.then(() => { console.info('Succeeded in loading the content.'); - }).catch((err)=>{ + }).catch((err) => { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); }); } catch (exception) { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); }; } -} +}; ``` ### loadContent9+ @@ -6321,6 +6331,7 @@ loadContent(path: string, callback: AsyncCallback<void>): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6336,7 +6347,7 @@ class myAbility extends Ability { console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); }; } -} +}; ``` ### on('windowStageEvent')9+ @@ -6369,6 +6380,7 @@ on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType> ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6382,7 +6394,7 @@ class myAbility extends Ability { JSON.stringify(exception)); }; } -} +}; ``` ### off('windowStageEvent')9+ @@ -6415,6 +6427,7 @@ off(eventType: 'windowStageEvent', callback?: Callback<WindowStageEventType&g ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6425,7 +6438,7 @@ class myAbility extends Ability { JSON.stringify(exception)); }; } -} +}; ``` ### disableWindowDecor()9+ @@ -6453,12 +6466,13 @@ disableWindowDecor(): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('disableWindowDecor'); windowStage.disableWindowDecor(); } -} +}; ``` ### setShowOnLockScreen()9+ @@ -6492,6 +6506,7 @@ setShowOnLockScreen(showOnLockScreen: boolean): void ```ts import Ability from '@ohos.application.Ability'; + class myAbility extends Ability { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); @@ -6501,7 +6516,7 @@ class myAbility extends Ability { console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception)); }; } -} +}; ``` ## TransitionContext9+ @@ -6513,7 +6528,7 @@ class myAbility extends Ability { **系统能力**:SystemCapability.WindowManager.WindowManager.Core -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | --------------------- | ----------------- | ---- | ---- | ---------------- | | toWindow9+ | [Window](#window) | 是 | 是 | 动画的目标窗口。 | @@ -6555,7 +6570,7 @@ controller.animationForShown = (context : window.TransitionContext) => { toWindow.translate(obj); console.info('toWindow translate end'); } - ) + ); try { context.completeTransition(true) } catch (exception) { @@ -6610,9 +6625,9 @@ controller.animationForShown = (context : window.TransitionContext) => { toWindow.translate(obj); console.info('toWindow translate end'); } - ) + ); console.info('complete transition end'); -} +}; ``` ### animationForHidden9+ @@ -6658,5 +6673,5 @@ controller.animationForHidden = (context : window.TransitionContext) => { } ) console.info('complete transition end'); -} +}; ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md b/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md index e521ba1a04d671e0f33abd433860479f335994c7..d3c071445b5c412cf1182d76c9b5a1bd491509df 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @@ -136,15 +136,15 @@ windowAnimationManager.setController(controller) let finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback = undefined; windowAnimationManager.minimizeWindowWithAnimation(target, (err, data) => { - if (err.code) { + if (err) { console.error('Failed to minimize the window target. Cause: ' + JSON.stringify(err)); return; } - finishedCallback = data; -}); -finishedCallback.onAnimationFinish(); + // 在收到回调后,需要开始进行窗口动画,在窗口动画结束后,调用onAnimationFinish回调 + finishedCallback.onAnimationFinish(); +}); ``` ## windowAnimationManager.minimizeWindowWithAnimation @@ -381,22 +381,22 @@ onAnimationFinish():void **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 参数 | 类型 | 描述 | -| ------- | ------ | ----------------------- | -| bundleName | string | 动画目标窗口所对应的包名。 | -| abilityName | string | 动画目标窗口所对应的Ability名称。 | -| windowBounds | [RRect](#rrect) | 动画目标窗口所对应的实际大小。 | -| missionId | number | 任务ID,多任务中用于与ability进行匹配。| +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------ | ------ | ----------------------- | +| bundleName | string | 是 |动画目标窗口所对应的包名。 | +| abilityName | string | 是 |动画目标窗口所对应的Ability名称。 | +| windowBounds | [RRect](#rrect) | 是 |动画目标窗口所对应的实际大小。 | +| missionId | number | 是 |任务ID,多任务中用于与ability进行匹配。| ## RRect 圆角矩形。 **系统能力:** SystemCapability.WindowManager.WindowManager.Core -| 参数 | 类型 | 描述 | -| ------- | ------ | ----------------------- | -| left | number | 动画目标窗口左上角相对于屏幕的横坐标。 | -| top | number | 动画目标窗口左上角相对于屏幕的纵坐标。 | -| width | number | 动画目标窗口的宽度大小。 | -| height | number | 动画目标窗口的高度大小。 | -| radius | number | 动画目标窗口的圆角大小。 | \ No newline at end of file +| 名称 | 类型 | 必填 | 说明 | +| ------- | ------ | ------|----------------------- | +| left | number | 是 |动画目标窗口左上角相对于屏幕的横坐标。 | +| top | number | 是 |动画目标窗口左上角相对于屏幕的纵坐标。 | +| width | number | 是 |动画目标窗口的宽度大小。 | +| height | number | 是 |动画目标窗口的高度大小。 | +| radius | number | 是 |动画目标窗口的圆角大小。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-worker.md b/zh-cn/application-dev/reference/apis/js-apis-worker.md index b7daa69d0787b677544129f7117517f77fe83a14..dd9c7d7a255ecc3734a20c592c76dbda30960e72 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-worker.md +++ b/zh-cn/application-dev/reference/apis/js-apis-worker.md @@ -174,7 +174,7 @@ on(type: string, listener: WorkerEventListener): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ---------------------- | | type | string | 是 | 监听的事件类型。 | -| listener | [WorkerEventListener](#workereventlistener9) | 是是 | 回调的事件。回调事件。 | +| listener | [WorkerEventListener](#workereventlistener9) | 是 | 回调的事件。回调事件。 | **示例:** @@ -199,7 +199,7 @@ once(type: string, listener: WorkerEventListener): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ---------------------- | | type | string | 是 | 监听的事件类型。 | -| listener | [WorkerEventListener](#workereventlistener9) | 是是 | 回调的事件。回调事件。 | +| listener | [WorkerEventListener](#workereventlistener9) | 是 | 回调的事件。回调事件。 | **示例:** @@ -224,7 +224,7 @@ off(type: string, listener?: WorkerEventListener): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ---------------------------- | | type | string | 是 | 需要删除的事件类型。 | -| listener | [WorkerEventListener](#workereventlistener9) | 是否 | 回调的事件。删除的回调事件。 | +| listener | [WorkerEventListener](#workereventlistener9) | 否 | 回调的事件。删除的回调事件。 | **示例:** @@ -388,7 +388,7 @@ removeEventListener(type: string, callback?: WorkerEventListener): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------------------------------------------- | ---- | ---------------------------- | | type | string | 是 | 需要删除的监听事件类型。 | -| callback | [WorkerEventListener](#workereventlistener9) | 是否 | 回调的事件。删除的回调事件。 | +| callback | [WorkerEventListener](#workereventlistener9) | 否 | 回调的事件。删除的回调事件。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md index 3c85311c4ba3748b49b6d4ce1764531a94f26dcc..dea1c2781cedb08e8bb2db8001fac4b45fdf89e9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-zlib.md +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -23,7 +23,7 @@ zipFile(inFile: string, outFile: string, options: Options): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[Stage模型](js-apis-application-context.md) | | outFile | string | 是 | 指定压缩结果的文件路径(文件的扩展名zip) | @@ -87,7 +87,7 @@ unzipFile(inFile:string, outFile:string, options: Options): Promise<void> **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | | outFile | string | 是 | 指定的解压文件路径 | @@ -123,13 +123,13 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { compressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback\): void; -压缩文件,压缩的结果通过callback返回。成功时返回null,失败时返回错误码。 +压缩文件,压缩的结果通过callback返回。成功时返回null,失败时返回错误码ID。 **系统能力:** SystemCapability.BundleManager.Zlib **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | | outFile | string | 是 | 指定的解压文件路径 | @@ -138,11 +138,11 @@ compressFile(inFile: string, outFile: string, options: Options, callback: AsyncC **相关错误码** -| 错误码 | 错误信息 | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | **示例** @@ -160,12 +160,12 @@ let options = { try { zlib.compressFile(inFile, outFile, options, (errData) => { - if (erData !== null) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -177,7 +177,7 @@ compressFile(inFile: string, outFile: string, options: Options): Promise\; **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定压缩的文件夹路径或者文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | | outFile | string | 是 | 指定的解压文件路径 | @@ -185,11 +185,11 @@ compressFile(inFile: string, outFile: string, options: Options): Promise\; **相关错误码** -| 错误码 | 错误信息 | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | ```typescript // 【压缩文件 例子2】 @@ -207,10 +207,10 @@ try { zlib.compressFile(inFile, outFile, options).then((data) => { console.info('compressFile success'); }).catch((errData) => { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -226,7 +226,7 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn **参数:** -| 参数名 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------------------- | ------------------- | ---- | ------------------------------------------------------------ | | inFile | string | 是 | 指定的待解压缩文件的文件路径,对应的路径参考[FA模型](js-apis-Context.md),[stage模型](js-apis-application-context.md) | | outFile | string | 是 | 指定的解压后的目录路径 | @@ -235,11 +235,11 @@ decompressFile(inFile: string, outFile: string, options: Options, callback: Asyn **相关错误码** -| 错误码 | 错误信息 | -| ------ | -------------------------------------- | -| 401 | wrong param type | -| 900001 | The Input source file is invalid. | -| 900002 | The Input destination file is invalid. | +| 错误码ID | 错误信息 | +| -------- | -------------------------------------- | +| 401 | wrong param type | +| 900001 | The Input source file is invalid. | +| 900002 | The Input destination file is invalid. | **示例** @@ -257,12 +257,12 @@ let options = { try { zlib.decompressFile(inFile, outFile, options, (errData) => { - if (erData !== null) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + if (errData !== null) { + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` @@ -274,7 +274,7 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\ { - console.info('deCompressFile success'); + zlib.decompressFile(inFile, outFile, options).then((data) => { + console.info('decompressFile success'); }).catch((errData) => { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); }) } catch(errData) { - console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); + console.log(`errData is errCode:${errData.code} message:${errData.message}`); } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index 7c34e92d3b7f9e55b5c90b2221eebfabd6539ae6..d8146c1f6c803a9eccfd039f8ef002db0705db5d 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -96,10 +96,8 @@ - 自定义组件 - [基本用法](js-components-custom-basic-usage.md) + - [数据传递与处理](js-components-custom-props.md) - [继承样式](js-components-custom-style.md) - - [自定义事件](js-components-custom-events.md) - - [Props](js-components-custom-props.md) - - [事件参数](js-components-custom-event-parameter.md) - [slot插槽](js-components-custom-slot.md) - [生命周期定义](js-components-custom-lifecycle.md) - [动态创建组件](js-components-create-elements.md) diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.gif new file mode 100644 index 0000000000000000000000000000000000000000..1ed64a34813209609c7ad742281247145489f8cd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.png deleted file mode 100644 index dc8f8a0cbb105c4d791bb867771bb9bc1bfbb468..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152588538.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152610806.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152610806.png index b3a47a84d8086ca0806bc958f745f29821c47cc2..30ab31575654579e9a00a64d3d67f7420662f203 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152610806.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152610806.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214619417.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214619417.png index 5da42e3e14d601745274cb62d914c6600620bb25..4f6c19892155444ecf63dab3ca80575a8046cc1b 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214619417.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214619417.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214704759.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214704759.png index 6afdd1b39e4bcb3664c7664a55b47b8537f4aeaa..0b4837fc44abc0e1005de3d1259ed924f2969806 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214704759.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214704759.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214811029.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214811029.png index 1d71cee4618f1f2822cea1031c9b0e5d602e0a9b..447e5b819bdddc57b98ccf7629d612eb499aec8b 100644 Binary files a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214811029.png and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214811029.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md index accf16fe944907dd8d36d19b2920656006da5458..2f20964d77b437dfce6db47d3ccec5027f2a6cd5 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md @@ -211,24 +211,24 @@ strokeColor: '#0081ff', fillColor: '#cce5ff', data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628, 791, 505, 613, 575, 475, 553, 491, 680, 657, 716], - gradient: true, + gradient: true } ], lineOps: { xAxis: { min: 0, max: 20, - display: false, + display: false }, yAxis: { min: 0, max: 1000, - display: false, + display: false }, series: { lineStyle: { width: "5px", - smooth: true, + smooth: true }, headPoint: { shape: "circle", @@ -236,14 +236,14 @@ strokeWidth: 5, fillColor: '#ffffff', strokeColor: '#007aff', - display: true, + display: true }, loop: { margin: 2, - gradient: true, + gradient: true } } - }, + } }, addData() { this.$refs.linechart.append({ @@ -294,15 +294,15 @@ barData: [ { fillColor: '#f07826', - data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628], + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628] }, { fillColor: '#cce5ff', - data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410], + data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410] }, { fillColor: '#ff88bb', - data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657], + data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657] }, ], barOps: { @@ -310,14 +310,14 @@ min: 0, max: 20, display: false, - axisTick: 10, + axisTick: 10 }, yAxis: { min: 0, max: 1000, - display: false, - }, - }, + display: false + } + } } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md index 346f5798c77b29c22172b9f6fe82ab60322168c4..db240326e125d4d08f92811c025d00ab87320ac3 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md @@ -54,6 +54,8 @@ > 1. 如果image组件本身的长宽小于svg中的长宽,svg会被裁切,仅显示左上角部分; > > 2. 如果image组件本身的长宽大于svg中的长宽,svg会被放置在image组件的左上角,image组件其他部分显示空白。 +> +> - 图片设置svg图源时,支持的标签范围有限,目前支持的svg标签包括svg、rect、circle、ellipse、path、line、polyline、polygon、animate、animateMotion、animateTransform。 ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md index 73d0d355a411f3cf549ace6f870427b80fc357cc..4921a3c4eb0446567ae16b27aaa994820fd55542 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md @@ -101,26 +101,28 @@ headericon="/common/search.svg" placeholder="Please input text" onchange="change" onenterkeyclick="enterkeyClick"> - + ``` ```css /* xxx.css */ .content { - width: 60%; + width: 100%; flex-direction: column; align-items: center; } .input { + width: 60%; placeholder-color: gray; } .button { + width: 60%; background-color: gray; margin-top: 20px; - } + } ``` - + ```js // xxx.js import prompt from '@system.prompt' @@ -142,9 +144,10 @@ error: 'error text' }); }, - } + } ``` + ![zh-cn_image_0000001252835901](figures/zh-cn_image_0000001252835901.png) 2. type为button diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md index ae7bebf6bbbbe32d419bd75df5587279c3a29553..d134e5bf1090eeddf3c664eee8f8d584eb9050ea 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md @@ -82,7 +82,7 @@ /*xxx.css */ .container { flex-direction: column; - align-items: center; + margin-left: 20px; } .row { flex-direction: row; diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md index 5b156b7bffefe8b1e34d718c789e38d4dc1c4249..d5ac6577506445b3bf87d3b276758d9f0ca940c8 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md @@ -58,8 +58,6 @@
- Value - 123 Type Color @@ -96,7 +94,6 @@ select{ /* index.js */ export default { data: { - qr_value:'', qr_type: 'rect', qr_size: '300px', qr_col: '#87ceeb', @@ -111,9 +108,6 @@ export default { this.qr_type = 'circle' } }, - setvalue(e) { - this.qr_value = e.newValue - }, setcol(e) { this.qr_col = e.newValue }, @@ -125,4 +119,3 @@ export default { ![zh-cn_image_0000001222948301](figures/zh-cn_image_0000001222948301.gif) - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md index f7f8893c08e1d4e6c84fb5cc93b5ec4874209cda..ca90d9e0df36b92ed67872cc05b5a93a03c2ab57 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md @@ -49,36 +49,65 @@ ```html
- +
``` ```css /* xxx.css */ .container { - display: flex; - justify-content: center; - align-items: center; + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 100%; } ``` ```js -// ×××.js +// xxx.js export default { - changeFruit(e){ - console.log("newValue:" + e.newValue) - } + data: { + array: [ + { + "value": "下拉选项0", "name": "选项0" + }, + { + "value": "下拉选项1", "name": "选项1" + }, + { + "value": "下拉选项2", "name": "选项2" + }, + { + "value": "下拉选项3", "name": "选项3" + }, + ] + }, + getData() { + let other = [ + { + "value": "下拉选项a", "name": "选项a" + }, + { + "value": "下拉选项b", "name": "选项b" + }, + { + "value": "下拉选项c", "name": "选项c" + }, + { + "value": "下拉选项d", "name": "选项d" + }, + ] + return other + }, + onChange() { + this.array = this.getData() + } } ``` -![zh-cn_image_0000001152588538](figures/zh-cn_image_0000001152588538.png) \ No newline at end of file +![zh-cn_image_0000001152588538](figures/zh-cn_image_0000001152588538.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md index 6715bc42fc91491db5d363173a0962962603faec..637be8eba85b2792272b3d59cdd07e4940cb6313 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md @@ -37,7 +37,7 @@ ### getContext -getContext(type: '2d', options?: ContextAttrOptions): CanvasRendering2dContext +getContext(type: '2d', options?: ContextAttrOptions): CanvasRenderingContext2D 获取canvas绘图上下文。不支持在onInit和onReady中进行调用。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md index 6f6a7992c56adb2b92150507c88dceefc647f313..807122809834e844ae1f2ded1c70f49141b7514a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md @@ -25,19 +25,21 @@ addColorStop(offset: number, color: string): void
-
``` ```js // xxx.js export default { - handleClick() { + onShow() { const el =this.$refs.canvas; - const ctx =el.getContext('2d'); - const gradient = ctx.createLinearGradient(0,0,100,0); - gradient.addColorStop(0,'#00ffff'); - gradient.addColorStop(1,'#ffff00'); + const ctx = el.getContext('2d'); + const gradient = ctx.createLinearGradient(50,0,300,100); + gradient.addColorStop(0.0, 'red') + gradient.addColorStop(0.5, 'white') + gradient.addColorStop(1.0, 'green') + ctx.fillStyle = gradient + ctx.fillRect(0, 0, 300, 300) } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index fa2d921d02097ffda89f80b016ab3b7f5661b0bc..ecae9a9fba09726ebf36874ae86605c0c9eea964 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -584,7 +584,7 @@ fillRect(x: number, y: number, width:number, height: number): void ```html
- +
``` @@ -620,7 +620,7 @@ clearRect(x: number, y: number, width:number, height: number): void ```html
- +
``` @@ -983,7 +983,7 @@ createPattern(image: Image, repetition: string): Object ```html
- +
``` @@ -997,7 +997,7 @@ createPattern(image: Image, repetition: string): Object img.src = 'common/images/example.jpg'; var pat = ctx.createPattern(img, 'repeat'); ctx.fillStyle = pat; - ctx.fillRect(0, 0, 20, 20); + ctx.fillRect(0, 0, 500, 500); } } ``` @@ -1573,7 +1573,7 @@ drawImage(image: Image | PixelMap, sx: number, sy: number, sWidth: number, sHeig ```html
- +
``` @@ -1581,11 +1581,11 @@ drawImage(image: Image | PixelMap, sx: number, sy: number, sWidth: number, sHeig //xxx.js export default { onShow() { - var test = this.$element('drawImage'); + var test = this.$refs.canvas; var ctx = test.getContext('2d'); var img = new Image(); img.src = 'common/image/test.jpg'; - ctx.drawImage(img, 50, 80, 80, 80); + ctx.drawImage(img, 0, 0, 200, 200, 10, 10, 200, 200); } } ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md index e09ea90de9b7d96609d7ea9430c64dfbbcecb2f1..9e1edeb0c09f9f23b7f078b2bd0aa5e7dcc5fe44 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md @@ -65,7 +65,7 @@ setTransform(scaleX: number, skewX: number, skewY: number, scaleY: number, trans ```html
- +
``` @@ -96,7 +96,7 @@ closePath(): void ```html
- +
``` @@ -224,7 +224,7 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, ```html
- +
``` @@ -265,7 +265,7 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void ```html
- +
``` @@ -308,7 +308,7 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, ```html
- +
``` @@ -349,7 +349,7 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void ```html
- +
``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md index 72a3f7ffd4771995ecbe8fd232d60457c2085e1b..9087710e1ac8b5a25fb852c3c17f08b9bf27d111 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md @@ -102,7 +102,7 @@ animate( keyframes: Keyframes, options: Options):void start
diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md index aa97784b94fe7147ad513fcb3c88b9c174cf0632..c7b1564625c586cff13822fc2eedfc85f6745ad7 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md @@ -75,10 +75,10 @@ ```html
- + contentBox - + borderBox
diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index 67e55748dcf4baf58b5df617cc9bd0300baab7a0..0921eaa35c63df9e8d52346c054c573921438b6c 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -59,12 +59,12 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage ```js // xxx.js -import router from '@system.router'; +import router from '@ohos.router'; export default { jump() { router.push({ // 路径要与config.json配置里面的相同 - uri: 'pages/detailpage', + url: 'pages/detailpage', }); }, } @@ -92,7 +92,7 @@ export default { ```js // xxx.js -import router from '@system.router'; +import router from '@ohos.router'; export default { jumpBack() { router.back(); @@ -138,7 +138,7 @@ source_page包含顶部内容以及卡片列表,点击卡片可以跳转到tar MAIN TITLE - + {{$item.title}} @@ -147,19 +147,19 @@ source_page包含顶部内容以及卡片列表,点击卡片可以跳转到tar ```js // xxx.js -import router from '@system.router' +import router from '@ohos.router' export default { data: { list: [] }, onInit() { for(var i = 0; i < 10; i++) { - var item = { uri: "pages/card_transition/target_page/index", + var item = { url: "pages/card_transition/target_page/index", title: "this is title" + i, id: "item_" + i } this.list.push(item); } }, - jumpPage(id, uri) { + jumpPage(id, url) { var cardId = this.$element(id).ref; - router.push({ uri: uri, params : { ref : cardId } }); + router.push({ url: url, params : { ref : cardId } }); } } ``` @@ -167,6 +167,8 @@ export default { ```css /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; align-items: center; background-color: #ABDAFF; @@ -197,6 +199,8 @@ export default { ```css /* xxx.css */ .container { + width: 100%; + height: 100%; flex-direction: column; align-items: center; background-color: #EBFFD7; @@ -255,14 +259,14 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 ```css // xxx.js - import router from '@system.router'; + import router from '@ohos.router'; export default { data: { - + }, jump() { router.push({ - uri:'pages/transition2/transition2' + url:'pages/transition2/transition2' }) } } @@ -286,13 +290,13 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transition-duration: 5s; transition-timing-function: friction; } - + @keyframes go_page { from { opacity: 0; transform: translate(0px) rotate(60deg) scale(1.0); } - + to { opacity: 1; transform: translate(100px) rotate(360deg) scale(1.0); @@ -303,7 +307,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 opacity: 1; transform: translate(200px) rotate(60deg) scale(2); } - + to { opacity: 0; transform: translate(200px) rotate(360deg) scale(2); @@ -319,15 +323,15 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2
transition
-
``` ```js // xxx.js - import router from '@system.router'; + import router from '@ohos.router'; export default { data: { - + }, jumpBack() { router.back() @@ -344,7 +348,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 width: 100%; height: 100%; } - + .move_page { width: 100px; height: 100px; @@ -354,7 +358,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transition-duration: 5s; transition-timing-function: ease; } - + @keyframes go_page { from { opacity: 0; @@ -365,7 +369,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2 transform:translate(100px) rotate(180deg) scale(2.0); } } - + @keyframes exit_page { from { opacity: 1; diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md index 7414bbdc09505ec7ba9523eeaf200349bbcb1fbd..d5ca0fc58411acef62562fb9d23aec49b3921d14 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md @@ -62,16 +62,16 @@ 除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -| 名称 | 参数 | 描述 | -| -------------------------- | ---------------------------------------- | ---------------------------------------- | -| indexerchange5+ | { local: booleanValue } | 多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:
- true: 当前展示本地索引。
- false: 当前展示字母索引。 | +| 名称 | 参数 | 描述 | +| -------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| indexerchange5+ | { local: booleanValue } | 多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:
- true: 当前展示本地索引。
- false: 当前展示字母索引。 | | scroll | { scrollX: scrollXValue, scrollY: scrollYValue, scrollState: stateValue } | 列表滑动的偏移量和状态回调。
stateValue: 0表示列表滑动已经停止。
stateValue: 1表示列表正在用户触摸状态下滑动。
stateValue: 2表示列表正在用户松手状态下滑动。 | -| scrollbottom | - | 当前列表已滑动到底部位置。 | -| scrolltop | - | 当前列表已滑动到顶部位置。 | -| scrollend | - | 列表滑动已经结束。 | -| scrolltouchup | - | 手指已经抬起且列表仍在惯性滑动。 | -| requestitem | - | 请求创建新的list-item。
长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。 | -| rotate7+ | { rotateValue: number } | 返回表冠旋转角度增量值,仅智能穿戴支持。 | +| scrollbottom | - | 当前列表已滑动到底部位置。 | +| scrolltop | - | 当前列表已滑动到顶部位置。 | +| scrollend | - | 列表滑动已经结束。 | +| scrolltouchup | - | 手指已经抬起且列表仍在惯性滑动。 | +| requestitem | - | 请求创建新的list-item。
长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。 | +| rotation7+ | { rotateValue: number } | 返回表冠旋转角度增量值,仅智能穿戴支持。 | ## 方法 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md index 4cfab1d92123f922b591eae1b5f70a4433f446fb..bbd00b8c1bf389bc026f2f3617fc3cc70e93cdd4 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md @@ -1,6 +1,7 @@ -# 基本用法 +# 自定义组件的基本用法 自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,从而提高代码的可读性。自定义组件通过element引入到宿主页面,使用方法如下: + ```html
@@ -8,8 +9,8 @@
``` +结合if-else使用自定义组件的示例,showComp1为true时显示自定义组件comp1,否则显示comp2: -结合if-else使用自定义组件的示例: ```html @@ -19,17 +20,142 @@ ``` +自定义组件的name属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写。src属性指自定义组件hml文件路径(必填),若没有设置name属性,则默认使用hml文件名作为组件名。 + + +## 自定义事件 + +父组件中绑定自定义子组件的事件使用(on|@)event-name="bindParentVmMethod"语法,子组件中通过this.$emit('eventName', { params: '传递参数' })触发事件并向上传递参数,父组件执行bindParentVmMethod方法并接收子组件传递的参数。 + +> **说明:** +> +> 子组件中使用驼峰命名法命名的事件,在父组件中绑定时需要使用短横线分隔命名形式,例如:\@children-event表示绑定子组件的childrenEvent事件。 + +**示例1:无参数传递** + +子组件comp定义如下: + +```html + +
+ 点击这里查看隐藏文本 + hello world +
+``` + +```css +/* comp.css */ +.item { + width: 700px; + flex-direction: column; + height: 300px; + align-items: center; + margin-top: 100px; +} +.text-style { + font-weight: 500; + font-family: Courier; + font-size: 40px; +} +``` + +```js +// comp.js +export default { + data: { + showObj: false, + }, + childClicked () { + this.$emit('eventType1'); + this.showObj = !this.showObj; + }, +} +``` + +引入子组件comp的父组件示例如下: + +```html + + +
+ +
+``` + +```css +/* xxx.css */ +.container { + background-color: #f8f8ff; + flex: 1; + flex-direction: column; + align-content: center; +} +``` + +```js +// xxx.js +export default { + textClicked () {} +} +``` + +**示例2:有参数传递** + +子组件comp定义如下: + +```html + +
+ 点击这里查看隐藏文本 + hello world +
+``` + +```js +// comp.js +export default { + childClicked () { + this.$emit('eventType1', { text: '收到子组件参数' }); + this.showObj = !this.showObj; + }, +} +``` + +子组件向上传递参数text,父组件接收时通过e.detail来获取该参数: + +```html + + +
+ 父组件:{{text}} + +
+``` + +```js +// xxx.js +export default { + data: { + text: '开始', + }, + textClicked (e) { + this.text = e.detail.text; + }, +} +``` + +![EventParameters](figures/EventParameters.gif) + + +## 自定义组件数据 -- name属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写。src属性指自定义组件hml文件路径(必填),若没有设置name属性,则默认使用hml文件名作为组件名。 -- 事件绑定:自定义组件中绑定子组件事件使用(on|@)child1语法,子组件中通过this.$emit('child1', { params: '传递参数' })触发事件并进行传值,父组件执行bindParentVmMethod方法并接收子组件传递的参数。 - > **说明:** - > 子组件中使用驼峰命名法命名的事件,在父组件中绑定时需要使用短横线分隔命名形式,例如:\@children-event表示绑定子组件的childrenEvent事件,如 \@children-event="bindParentVmMethod"。 +自定义组件的js文件中可以通过声明data、props、computed等字段完成数据的定义、传递与处理,其中props与computed的具体使用请参考[数据传递与处理](js-components-custom-props.md)章节。 -**表1** 对象 +**表1** 自定义组件数据 -| 属性 | 类型 | 描述 | +| 名称 | 类型 | 描述 | | -------- | --------------- | ---------------------------------------- | -| data | Object/Function | 页面的数据模型,类型是对象或者函数,如果类型是函数,返回值必须是对象。属性名不能以$或_开头,不要使用保留字for, if, show, tid。
data与private和public不能重合使用。(Rich) | -| props | Array/Object | props用于组件之间的通信,可以通过<tag xxxx='value'>方式传递给组件;props名称必须用小写,不能以$或_开头,不要使用保留字for, if, show, tid。目前props的数据类型不支持Function。 | -| computed | Object | 计算属性,用于在读取或设置时,进行预先处理,其结果会被缓存。计算属性名不能以$或_开头,不要使用保留字。 | +| data | Object \| Function | 页面的数据模型,类型是对象或者函数,如果类型是函数,返回值必须是对象。属性名不能以$或_开头,不要使用保留字for, if, show, tid。
data与private和public不能重合使用。 | +| props | Array \| Object | props用于组件之间的数据通信,可以通过<tag xxxx='value'>方式传递给组件;props名称必须用小写,不能以$或_开头,不要使用保留字for, if, show, tid。目前props的数据类型不支持Function。 | +| computed | Object | 计算属性,用于在读取或设置参数时,进行预先处理,其结果会被缓存。计算属性名不能以$或_开头,不要使用保留字。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md deleted file mode 100644 index f134127293bc49786845f7a2d42cd46a39072426..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md +++ /dev/null @@ -1,51 +0,0 @@ -# 事件参数 - -子组件也可以通过绑定的事件向上传递参数,在自定义事件上添加传递参数的示例如下: - - -```html - -
- 点击这里查看隐藏文本 - hello world -
-``` - - -```js -// comp.js -export default { - childClicked () { - this.$emit('eventType1', {text: '收到子组件参数'}); - this.showObj = !this.showObj; - }, -} -``` - - -子组件向上传递参数text,父组件接收时通过e.detail来获取参数: - - -```html - - -
- 父组件:{{text}} - -
-``` - - -```js -// xxx.js -export default { - data: { - text: '开始', - }, - textClicked (e) { - this.text = e.detail.text; - }, -} -``` - -![EventParameters](figures/EventParameters.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md deleted file mode 100644 index 33718f75e5350b02d3c5307093b7519111d71077..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md +++ /dev/null @@ -1,76 +0,0 @@ -# 自定义事件 - -子组件comp定义如下: - - -```html - -
- 点击这里查看隐藏文本 - hello world -
-``` - - -```css -/* comp.css */ -.item { - width: 700px; - flex-direction: column; - height: 300px; - align-items: center; - margin-top: 100px; -} -.text-style { - font-weight: 500; - font-family: Courier; - font-size: 40px; -} -``` - - -```js -// comp.js -export default { - data: { - showObj: false, - }, - childClicked () { - this.$emit('eventType1'); - this.showObj = !this.showObj; - }, -} -``` - - -引入子组件的示例如下: - - -```html - - -
- -
-``` - - -```css -/* xxx.css */ -.container { - background-color: #f8f8ff; - flex: 1; - flex-direction: column; - align-content: center; -} -``` - - -```js -// xxx.js -export default { - textClicked () {}, -} -``` - -其他相关说明详见:[基本用法](./js-components-custom-basic-usage.md)。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md index 40d466372f5fa8a8a9147dbd8d739479a2d6776d..9ddc7a88e7e07f1f3040784dab60e46828a04794 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md @@ -1,6 +1,7 @@ # 生命周期定义 > **说明:** +> > 从API Version 5 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 @@ -12,7 +13,7 @@ | onInit | Function | 初始化自定义组件 | 自定义组件初始化生命周期回调,当自定义组件创建时,触发该回调,主要用于自定义组件中必须使用的数据初始化,该回调只会触发一次调用。 | | onAttached | Function | 自定义组件装载 | 自定义组件被创建后,加入到Page组件树时,触发该回调,该回调触发时,表示组件将被进行显示,该生命周期可用于初始化显示相关数据,通常用于加载图片资源、开始执行动画等场景。 | | onLayoutReady | Function | 自定义组件布局完成 | 自定义组件插入Page组件树后,将会对自定义组件进行布局计算,调整其内容元素尺寸与位置,当布局计算结束后触发该回调。 | -| onDetached | Function | 自定义组件摘除 | 自定义组件摘除时,触发该回调,常用于停止动画或异步逻辑停止执行的场景。 | +| onDetached | Function | 自定义组件卸载 | 自定义组件卸载时,触发该回调,常用于停止动画或异步逻辑停止执行的场景。 | | onDestroy | Function | 自定义组件销毁 | 自定义组件销毁时,触发该回调,常用于资源释放。 | | onShow | Function | 自定义组件Page显示 | 自定义组件所在Page显示后,触发该回调。 | | onHide | Function | 自定义组件Page隐藏 | 自定义组件所在Page隐藏后,触发该回调。 | @@ -23,7 +24,7 @@ ```html
- {{value}} + {{ value }}
``` @@ -37,10 +38,8 @@ export default { console.log("组件创建") }, onAttached() { - this.value = "组件挂载" - }, - onDetached() { - this.value = "" + this.value = "组件挂载", + console.log("组件挂载") }, onShow() { console.log("Page显示") diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md index 4570de1995858244da4762a31b414eb87789b8ab..a384d0cce0f98cbb715089815d29acc5285db440 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md @@ -1,7 +1,9 @@ -# Props +# 数据传递与处理 -自定义组件可以通过props声明属性,父组件通过设置属性向子组件传递参数,props支持类型包括:String,Number,Boolean,Array,Object,Function。camelCase (驼峰命名法) 的 prop 名,在外部父组件传递参数时需要使用 kebab-case (短横线分隔命名) 形式,即当属性compProp在父组件引用时需要转换为comp-prop。给自定义组件添加props,通过父组件向下传递参数的示例如下: +## Props + +自定义组件可以通过props声明属性,父组件通过设置属性向子组件传递参数,props支持类型包括:String,Number,Boolean,Array,Object,Function。camelCase (驼峰命名法) 的 prop 名,在外部父组件传递参数时需要使用 kebab-case (短横线分隔命名) 形式,即当属性compProp在父组件引用时需要转换为comp-prop。给自定义组件添加props,通过父组件向下传递参数的示例如下: ```html @@ -10,7 +12,6 @@ ``` - ```js // comp.js export default { @@ -18,7 +19,6 @@ export default { } ``` - ```html @@ -27,12 +27,11 @@ export default { ``` - > **说明:** +> > 自定义属性命名时禁止以on、@、on:、grab: 等保留关键字为开头。 - -## 添加默认值 +### 添加默认值 子组件可以通过固定值default设置默认值,当父组件没有设置该属性时,将使用其默认值。此情况下props属性必须为对象形式,不能用数组形式,示例如下: @@ -64,8 +63,7 @@ export default { ``` - -## 数据单向性 +### 数据单向性 父子组件之间数据的传递是单向的,只能从父组件传递给子组件,子组件不能直接修改父组件传递下来的值,可以将props传入的值用data接收后作为默认值,再对data的值进行修改。 @@ -84,8 +82,7 @@ export default { } ``` - -## $watch 感知数据改变 +### $watch 感知数据改变 如果需要观察组件中属性变化,可以通过$watch方法增加属性变化回调。使用方法如下: @@ -103,9 +100,9 @@ export default { ``` -## computed 计算属性 +## computed -自定义组件中经常需要在读取或设置某个属性时进行预先处理,提高开发效率,此种情况就需要使用computed字段。computed字段中可通过设置属性的getter和setter方法在属性读写的时候进行触发,使用方式如下: +自定义组件中经常需要在读取或设置某个属性时进行预先处理,提高开发效率,此种情况就需要使用computed计算属性。computed字段中可通过设置属性的getter和setter方法在属性读写的时候进行触发,使用方式如下: ```js // comp.js @@ -137,4 +134,4 @@ export default { } ``` -这里声明的第一个计算属性message默认只有getter函数,message的值会取决于objTitle的值的变化。getter函数只能读取不能改变设值,当需要赋值给计算属性的时候可以提供一个setter函数,如示例中的notice。 +这里声明的第一个计算属性message默认只有getter函数,message的值会取决于objTitle的值的变化。getter函数只能读取不能改变参数值,例如data中初始化定义的time,当需要赋值给计算属性的时候可以提供一个setter函数,如示例中的notice。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md index f52f75e1abffbf7d0c7516b06dcd9757afe73dee..f5bceca1a24068409268c4e600872f24afafcba3 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md @@ -1,6 +1,7 @@ # slot插槽 > **说明:** +> > 从API Version 7 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 @@ -54,4 +55,5 @@ ``` > **说明:** +> > name 和 slot 属性不支持绑定动态数据。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-style.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-style.md index e17307394e34e23ee1c65349938df6e6a782a9a8..75bcb99c870765c86099d71132db87e198c18357 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-style.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-style.md @@ -1,5 +1,7 @@ # 继承样式 + > **说明:** +> > 从API version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 自定义组件具有inherit-class属性,定义如下: @@ -10,7 +12,8 @@ 可以通过设置inherit-calss属性来继承父组件的样式。 -父页面的hml文件,其中自定义组件comp通过inherit-class属性来指定继承其父组件的样式:parent-class1和parent-class2。 +父组件的hml文件,其中自定义组件comp通过inherit-class属性来指定继承其父组件的样式,即parent-class1和parent-class2: + ```html @@ -20,7 +23,8 @@ ``` -父页面的css文件 +父组件的css文件: + ```css /* xxx.css */ .parent-class1 { @@ -33,7 +37,8 @@ } ``` -自定义组件的hml文件,其中parent-class1和parent-class2是从父组件继承的样式。 +自定义组件的hml文件,其中parent-class1和parent-class2是从父组件继承的样式: + ```html
diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md index 64066963bcd7664ceb0a409403984bf8ead3c203..73090b6498defa2b2ac7b9a27028fae45ec809dd 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md @@ -5,15 +5,6 @@ > > - 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > -> - 需要在config.json对应的"abilities"中设置"configChanges"属性为"orientation" -> ``` -> "abilities": [ -> { -> "configChanges": ["orientation"], -> ... -> } -> ] -> ``` 视频播放组件。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md index 8949e3981cddff96318eb7a61b8fd802cd93ba29..f5bee524836e80401f3304708ae53233e1697b3d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md @@ -37,7 +37,7 @@ - + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md index 972fd27969efe8ad2ffa71b35e0be846f244695b..c431b6fc33c8a437929f724246b53f7e5c0b459b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md @@ -193,6 +193,7 @@ transform动效,支持的组件范围: dur="3s" repeatCount="indefinite"> + animate-transform diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md index 410178c1966080c4153b4f1172d495ff5d0a787b..10e0739fa5645a7ac50e9114c148816a4b12850b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md @@ -97,9 +97,9 @@ textpath与tspan组合示例与效果图
- + - + This is TextPath. This is tspan onTextPath. Let's play. @@ -117,11 +117,11 @@ textpath与tspan组合示例与效果图
- + - + This is TextPath. This is first tspan. This is second tspan. @@ -172,10 +172,10 @@ textpath与tspan组合属性动画与效果图
- + - + This is TextPath. tspan attribute x|rotate @@ -209,11 +209,11 @@ textpath与tspan组合属性动画与效果图
- - + This is TextPath. tspan attribute fill|fill-opacity @@ -247,11 +247,11 @@ textpath与tspan组合属性动画与效果图
- - + This is TextPath. tspan attribute stroke diff --git a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md index 890e8e08f9d68ad387547f9cc37e3d61b334bb45..f6807fbb67924a99dbe3103c5e762587c2fd3b7f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md @@ -18,7 +18,7 @@ **示例:** ```html -
+
``` @@ -94,7 +94,7 @@ isPointInPath(path?: Path2D, x: number, y: number): boolean **示例:** ```html -
+
In path:{{textValue}}
@@ -144,7 +144,7 @@ isPointInStroke(path?: Path2D, x: number, y: number): boolean **示例:** ```html -
+
In path:{{textValue}}
@@ -180,7 +180,7 @@ resetTransform(): void **示例:** ```html -
+
In path:{{textValue}}
diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index a18461d4052bad0b0abaad9ab8925115a424b12f..3fa8f6e43b7c1a789255a82c614f3d686cd608e7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -1,5 +1,6 @@ # 基于ArkTS的声明式开发范式 +- [组件导读](ts-components-summary.md) - 组件通用信息 - 通用事件 - [点击事件](ts-universal-events-click.md) @@ -65,6 +66,8 @@ - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) - [Navigation](ts-basic-components-navigation.md) + - [NavRouter](ts-basic-components-navrouter.md) + - [NavDestination](ts-basic-components-navdestination.md) - [PatternLock](ts-basic-components-patternlock.md) - [PluginComponent](ts-basic-components-plugincomponent.md) - [Progress](ts-basic-components-progress.md) @@ -140,8 +143,6 @@ - [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md) - [Path2D对象](ts-components-canvas-path2d.md) - [Lottie](ts-components-canvas-lottie.md) - - - 动画 - [属性动画](ts-animatorproperty.md) - [显式动画](ts-explicit-animation.md) @@ -164,5 +165,4 @@ - [枚举说明](ts-appendix-enums.md) - [类型说明](ts-types.md) - 已停止维护的组件 - - - [GridContainer(栅格)](ts-container-gridcontainer.md) + - [GridContainer(栅格)](ts-container-gridcontainer.md) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/Web.png b/zh-cn/application-dev/reference/arkui-ts/figures/Web.png deleted file mode 100644 index a9566a229865d250ba1a8c447d93ea577dc0dbc5..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/Web.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png b/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png deleted file mode 100644 index fc2c9b7d49f7d698aac11d2ede6b0cc58222c7ca..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/image-effect.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/loadingProgress.png b/zh-cn/application-dev/reference/arkui-ts/figures/loadingProgress.png deleted file mode 100644 index afc52b1a469c858e3029282e193b684114803db0..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/loadingProgress.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.gif deleted file mode 100644 index 391353977d32956cde03890e501d11766dae2648..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.gif and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.png new file mode 100644 index 0000000000000000000000000000000000000000..4248727e91ebbd2ad2dd35211936745a8800f94c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001169582302.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png deleted file mode 100644 index 2243912034c109d0ffa57837aa28f4fab4ed55d7..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174264370.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png deleted file mode 100644 index 5b72c400df568916e04f666f40f80d72ca5195f5..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001174582846.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194032484.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194032484.png deleted file mode 100644 index 801bf97495213f41c2b196b2f170af85b156dd5b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194032484.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.png deleted file mode 100644 index 160278c82fcdf310c796609d5ee29a2a4869af9e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194192454.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352458.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352458.png deleted file mode 100644 index d3db21e0e3da6d8663f59b2ddabd9e50d6eb1e6a..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001194352458.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001208256092.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001208256092.png deleted file mode 100644 index b15b9d83968672a6771322069b47394cfb3b8c1f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001208256092.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744183.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744183.gif index 9ead4d671531532629b2fbf2f411ce4008dde3ba..0f974cc65ddbbef89654d62efd8391b2d72c810c 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744183.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744183.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744197.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744197.png deleted file mode 100644 index 884eb29ed12c00641fec55f358a41f15f581c335..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219744197.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864137.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864137.png deleted file mode 100644 index 3fbc152bb27dc98b9db8ace65a5b820c72f77879..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864137.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864159.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864159.gif index 557213e5ff5c63c5f3b3db7ffbd56e80eef688f1..badadbdb856c478fdb2ec53f70015b29bb10041f 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864159.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001219864159.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001231374661.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001231374661.png deleted file mode 100644 index 438d698967ec582748d39118ad509743c131aa3c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001231374661.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712441.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712441.png deleted file mode 100644 index 4fb651372a67eca9de3848baa6b66cac0ee9f173..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238712441.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832407.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832407.png deleted file mode 100644 index e3b4b42aecaef72ed4a08b3566a895b3f9b12343..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832407.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832411.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832411.png deleted file mode 100644 index 138e011909c2d4738f3cd9671a79ea0c37cb5b87..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001238832411.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001239032427.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001239032427.png deleted file mode 100644 index 2eed5759714b99dc039faab67acdfe6d67bfc6ac..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001239032427.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252653499.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252653499.png deleted file mode 100644 index 77113dac339f335dc44b3fb4a271e92f7c8cbb00..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001252653499.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777773.png b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777773.png deleted file mode 100644 index 7dbcbb2d5710b17866b9d5b034437b91a700a3f9..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_000000127777773.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 95ea376b2a4dec554b07cc11bcb75c95eff7dbf1..85cef5202529f9a5fde1ef1ae91390444336fac3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -35,14 +35,14 @@ Image(src: string | PixelMap | Resource) | 名称 | 参数类型 | 描述 | | --------------------- | ------------------------------------------------------- | ------------------------------------------------------------ | -| alt | string \| [Resource](ts-types.md#resource类型) | 加载时显示的占位图,支持本地图片和网络图片。 | +| alt | string \| [Resource](ts-types.md#resource类型) | 加载时显示的占位图,支持本地图片。 | | objectFit | [ImageFit](ts-appendix-enums.md#imagefit) | 设置图片的缩放类型。
默认值:ImageFit.Cover | | objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | 设置图片的重复样式。
默认值:NoRepeat
**说明:**
svg类型图源不支持该属性。 | | interpolation | [ImageInterpolation](#imageinterpolation) | 设置图片的插值效果,即减轻低清晰度图片在放大显示的时候出现的锯齿问题,仅针对图片放大插值。
默认值:ImageInterpolation.None
**说明:**
svg类型图源不支持该属性。
PixelMap资源不支持该属性。 | | renderMode | [ImageRenderMode](#imagerendermode) | 设置图片渲染的模式。
默认值:ImageRenderMode.Original
**说明:**
svg类型图源不支持该属性。 | | sourceSize | {
width: number,
height: number
} | 设置图片裁剪尺寸,将原始图片解码成pixelMap,指定尺寸的图片,单位为px。
**说明:**
PixelMap资源不支持该属性。 | | matchTextDirection | boolean | 设置图片是否跟随系统语言方向,在RTL语言环境下显示镜像翻转显示效果。
默认值:false | -| fitOriginalSize | boolean | 图片组件尺寸未设置时,其显示尺寸是否跟随图源尺寸。
默认值:true | +| fitOriginalSize | boolean | 图片组件尺寸未设置时,其显示尺寸是否跟随图源尺寸。
默认值:false | | fillColor | [ResourceColor](ts-types.md#resourcecolor) | 填充颜色。设置的填充颜色会覆盖在图片上。仅对svg图源生效,设置后会替换svg图片的fill颜色。 | | autoResize | boolean | 是否需要在图片解码过程中对图源做resize操作,该操作会根据显示区域的尺寸决定用于绘制的图源尺寸,有利于减少内存占用。
默认值:true | | syncLoad8+ | boolean | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。
默认值:false | @@ -352,50 +352,54 @@ struct ImageExample3 { ### 渲染沙箱路径图片 -``` +```ts import fileio from '@ohos.fileio' -import image from '@ohos.multimedia.image' - -const EMPTY_PATH = 'file://' +import context from '@ohos.application.context' @Entry @Component struct LoadImageExample { - @State fileContent: string = '' - @State path: string = EMPTY_PATH - @State accountInfoHeadPic: any = '' + @State resourcesPath: string = '' + @State sandboxPath: string = '' + context: context.AbilityContext + + aboutToAppear() { + this.context = getContext(this) as context.AbilityContext + } build() { Column() { Button('读取沙箱图片') - .margin({ bottom: 10 }) + .margin({ bottom: 10, top: 10 }) .onClick(() => { - try { - this.path = EMPTY_PATH - let context = getContext(this) - let path = context.getApplicationContext().filesDir + '/icon.png' - console.log(`读取沙箱图片=========>${path}`) - let fd = fileio.openSync(path, 0o100, 0o666) - console.log(`create file========>${fd}`) - let srcPath = context.bundleCodeDir + '/entry/resource/base/media/icon.png' - fileio.copyFileSync(srcPath, path) - console.log(`error:=============>${e.message}`) - } + this.sandboxPath = this.context.getApplicationContext().filesDir + '/icon.png' + console.log(`读取沙箱图片=========>${this.sandboxPath}`) + let fd = fileio.openSync(this.sandboxPath, 0o100, 0o666) + console.log(`create file========>${fd}`) + let srcPath = this.context.bundleCodeDir + '/entry/resources/base/media/icon.png' + console.log('mySrcpath' + srcPath) + fileio.copyFileSync(srcPath, this.sandboxPath) // 复制图片到沙箱路径 + this.sandboxPath = 'file://' + this.context.getApplicationContext().filesDir + '/icon.png' }) Button('读取资源图片') .margin({ bottom: 10 }) .onClick(() => { - this.path = EMPTY_PATH; - this.path += getContext(this.bundleCodeDir + '/entry/resource/base/media/icon.png') + this.resourcesPath = 'file://' + this.context.bundleCodeDir + '/entry/resources/base/media/icon.png' }) - Text(`图片路径:${this.path}`) + Text(`资源图片路径:${this.resourcesPath}`) + .fontSize(20) + .margin({ bottom: 10 }) + Image(this.resourcesPath) + .width(100) + .height(100) + Text(`沙箱图片路径:${this.sandboxPath}`) .fontSize(20) .margin({ bottom: 10 }) - Image(this.path) + Image(this.sandboxPath) .width(100) .height(100) } .width('100%').height('100%') } } -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md new file mode 100644 index 0000000000000000000000000000000000000000..49669a8f1be61875c2538ee030347e2edb559ea4 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navdestination.md @@ -0,0 +1,27 @@ +# NavDestination + +作为NavRouter组件的子组件,用于显示导航内容区。 + +> **说明:** +> +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +可以包含子组件。 + + +## 接口 + +NavDestination() + + +## 属性 + +仅支持[backgroundColor](ts-universal-attributes-background.md)通用属性。 + +| 名称 | 参数类型 | 描述 | +| -------------- | ---------------------------------------- | ---------------------------------------- | +| title | string \| [CustomBuilder](ts-types.md#custombuilder8) \| [NavigationCommonTitle](ts-basic-components-navigation.md#navigationcommontitle类型说明) \| [NavigationCustomTitle](ts-basic-components-navigation.md##navigationcustomtitle类型说明) | 页面标题。 | +| hideTitleBar | boolean | 是否显示标题栏。
默认值:false
true: 隐藏标题栏。
false: 显示标题栏。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index 9c21ba142bb83e9a3a8c4443ea8d074dd0041d79..69a4680cbbbc930a8f69485fc2f03ef6342457a6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -1,6 +1,6 @@ # Navigation -Navigation组件一般作为Page页面的根容器,通过属性设置来展示页面的标题、工具栏、菜单。 +Navigation组件一般作为Page页面的根容器,通过属性设置来展示页面的标题栏、工具栏、导航栏等。 > **说明:** > @@ -9,14 +9,13 @@ Navigation组件一般作为Page页面的根容器,通过属性设置来展示 ## 子组件 -可以包含子组件。 +可以包含子组件。从API Version 9开始,推荐与[NavRouter](ts-basic-components-navrouter.md)组件搭配使用。 ## 接口 Navigation() -创建可以根据属性设置,自动展示导航栏、标题、工具栏的组件。 ## 属性 @@ -24,14 +23,20 @@ Navigation() | 名称 | 参数类型 | 描述 | | -------------- | ---------------------------------------- | ---------------------------------------- | -| title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面标题。 | -| subTitle | string | 页面副标题。 | +| title | string \| [CustomBuilder](ts-types.md#custombuilder8)8+ \| [NavigationCommonTitle](#navigationcommontitle类型说明)9+ \| [NavigationCustomTitle](#navigationcustomtitle类型说明)9+ | 页面标题。 | +| subTitledeprecated | string | 页面副标题。从API Version 9开始废弃,建议使用title代替。 | | menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)> \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 页面右上角菜单。 | | titleMode | [NavigationTitleMode](#navigationtitlemode枚举说明) | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | | toolBar | [object](#object类型说明) \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | -| hideToolBar | boolean | 隐藏工具栏:
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | +| hideToolBar | boolean | 隐藏工具栏。
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | | hideTitleBar | boolean | 隐藏标题栏。
默认值:false
true: 隐藏标题栏。
false: 显示标题栏。 | | hideBackButton | boolean | 隐藏返回键。
默认值:false
true: 隐藏返回键。
false: 显示返回键。 | +| navBarWidth9+ | [Length](ts-types.md#length) | 导航栏宽度。
默认值:200vp | +| navBarPosition9+ | [NavBarPosition](#navbarposition枚举说明) | 导航栏位置。
默认值:NavBarPosition.Start | +| mode9+ | [NavigationMode](#navigationmode枚举说明) | 导航栏的显示模式。
默认值:NavigationMode.Auto | +| backButtonIcon9+ | string \| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource) | 设置导航栏返回图标。 | +| hideNavBar9+ | boolean | 是否显示导航栏(仅在mode为NavigationMode.Split时生效)。 | + ## NavigationMenuItem类型说明 @@ -54,8 +59,45 @@ Navigation() | 名称 | 描述 | | ---- | ---------------------------------------- | | Free | 当内容为可滚动组件时,标题随着内容向上滚动而缩小(子标题的大小不变、淡出)。向下滚动内容到顶时则恢复原样。 | -| Mini | 固定为小标题模式(图标+主副标题)。 | -| Full | 固定为大标题模式(主副标题)。 | +| Mini | 固定为小标题模式。 | +| Full | 固定为大标题模式。 | + +## NavigationCommonTitle类型说明 + +| 名称 | 类型 | 必填 | 描述 | +| ------ | --------- | ---- | -------- | +| main | string | 是 | 设置主标题。 | +| sub | string | 是 | 设置副标题。 | + +## NavigationCustomTitle类型说明 + +| 名称 | 类型 | 必填 | 描述 | +| ------ | ----------------------- | ---- | ------------------------------ | +| builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 设置标题栏内容。 | +| height | [TitleHeight](#titleheight枚举说明) \| [Length](ts-types.md#length) | 是 | 设置标题栏高度。 | + +## NavBarPosition枚举说明 + +| 名称 | 描述 | +| ---- | ---------------------------------------- | +| Start | 双栏显示时,主列在主轴方向首部。 | +| End | 双栏显示时,主列在主轴方向尾部。 | + +## NavigationMode枚举说明 + +| 名称 | 描述 | +| ---- | ---------------------------------------- | +| Stack | 导航栏与内容区独立显示,相当于两个页面。 | +| Split | 导航栏与内容区分两栏显示。 | +| Auto | 窗口宽度>=520vp时,采用Split模式显示;窗口宽度<520vp时,采用Stack模式显示。 | + +## TitleHeight枚举说明 + +| 名称 | 描述 | +| ---- | ---------------------------------------- | +| MainOnly | 只有主标题时标题栏的推荐高度(56vp)。 | +| MainWithSub | 同时有主标题和副标题时标题栏的推荐高度(82vp)。 | + > **说明:** > 目前可滚动组件只支持List。 @@ -66,6 +108,7 @@ Navigation() | 名称 | 功能描述 | | ---------------------------------------- | ---------------------------------------- | | onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void) | 当titleMode为NavigationTitleMode.Free时,随着可滚动组件的滑动标题栏模式发生变化时触发此回调。 | +| onNavBarStateChange(callback: (isVisible: boolean) => void) | 导航栏显示状态切换时触发该回调。返回值isVisible为true时表示显示,为false时表示隐藏。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md new file mode 100644 index 0000000000000000000000000000000000000000..124c299714c41b97f5239c3d3ad2087b24573ca0 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navrouter.md @@ -0,0 +1,22 @@ +# NavRouter + +导航组件,默认提供点击响应处理,不需要开发者自定义点击事件逻辑。 + +> **说明:** +> +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 子组件 + +必须包含两个子组件,其中第二个子组件必须为[NavDestination](ts-basic-components-navdestination.md)。 + +## 接口 + +NavRouter() + + +## 事件 + +| 名称 | 功能描述 | +| ---------------------------------------- | ---------------------------------------- | +| onStateChange(callback: (isActivated: boolean) => void) | 组件激活状态切换时触发该回调。返回值isActivated为true时表示激活,为false时表示未激活。
**说明:**用户点击NavRouter,激活NavRouter,加载对应的NavDestination子组件时,回调onStateChange(true);NavRouter对应的NavDestination子组件不再显示时,回调onStateChange(false)。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md index 2bc0322f27d016b6d0ae55eec0dcde7cf8f11e07..98e907ab66bc8fabb12dc522ef6a7439bfd26fb7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -39,6 +39,7 @@ RichText(content:string) | \

\

| 定义段落。 | \

这是一个段落\

| | \
| 插入一个简单的换行符。 | \

这是一个段落\
这是换行段落\

| | \
| 定义HTML页面中的主题变化(比如话题的转移),并显示为一条水平线。 | \

这个一个段落\

\
\

这是一个段落\

| +| \\ | 用来定义图片。 | \\ | | \
\
| 常用于组合块级元素,以便通过CSS来对这些元素进行格式化。 | \
\

这是一个在div元素中的标题。\

\
| | \\ | 定义与文本中其余部分不同的部分,并把这部分文本呈现为斜体文本。 | \这是一个斜体\ | | \\ | 定义与常规文本风格不同的文本,像拼写错误的单词或者汉语中的专有名词,应尽量避免使用\为文本加下划线,用户会把它混淆为一个超链接。 | \

\这是带有下划线的段落\\

| diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md index c2bdbd8b10ce8588b99e41090ac5c27b34bad87c..96f6ea4e8d5d0d27c45970c2d4c744fa703d5123 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-timepicker.md @@ -38,7 +38,8 @@ TimePicker(options?: {selected?: Date}) | ---------------------------------------- | ----------- | | onChange(callback: (value: TimePickerResult ) => void) | 选择时间时触发该事件。 | -### TimePickerResult对象说明 +## TimePickerResult对象说明 + | 名称 | 参数类型 | 描述 | | ------ | ------ | ------- | | hour | number | 选中时间的时。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index 54fb54c658025a7089ef86bb7faf31aad8b5edea..e810ec960e554e29a36275ff78400e3e6da2a499 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -19,7 +19,7 @@ PanGesture(value?: { fingers?: number; direction?: PanDirection; distance?: numb | -------- | -------- | -------- | -------- | | fingers | number | 否 | 触发拖动的最少手指数,最小为1指, 最大取值为10指。
默认值:1 | | direction | PanDirection | 否 | 触发拖动的手势方向,此枚举值支持逻辑与(&)和逻辑或(\|)运算。
默认值:PanDirection.All | -| distance | number | 否 | 最小拖动识别距离,单位为vp。
默认值:5
**说明:**
> [Tabs组件](ts-container-tabs.md)滑动与该拖动手势事件同时存在时,可将distance值设为1,使拖动更灵敏,避免造成事件错乱。 | +| distance | number | 否 | 最小拖动识别距离,单位为vp。
默认值:5
**说明:**
[Tabs组件](ts-container-tabs.md)滑动与该拖动手势事件同时存在时,可将distance值设为1,使拖动更灵敏,避免造成事件错乱。 | ## PanDirection枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 0bc8ae2307857deca73d21c02c55a1be8f53c17f..8abf78ab1d71dbdb0b6d16b3c427f1f984af61de 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -15,8 +15,8 @@ TapGesture(value?: { count?: number, fingers?: number }) | 参数名称 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| count | number | 否 | 识别的连续点击次数。如果设置小于1,会被转化为默认值。
默认值:1
>  **说明:**
> 如配置多击,上一次抬起和下一次按下的超时时间为300毫秒。 | -| fingers | number | 否 | 触发点击的手指数,最小为1指, 最大为10指。
默认值:1
>  **说明:**
> 1. 当配置多指时,第一根手指按下后300毫秒内未有足够的手指数按下,手势识别失败。
> 2. 实际点击手指数超过配置值,手势识别失败。 | +| count | number | 否 | 识别的连续点击次数。如果设置小于1,会被转化为默认值。
默认值:1
**说明:**
如配置多击,上一次抬起和下一次按下的超时时间为300毫秒。 | +| fingers | number | 否 | 触发点击的手指数,最小为1指, 最大为10指。
默认值:1
**说明:**
1. 当配置多指时,第一根手指按下后300毫秒内未有足够的手指数按下,手势识别失败。
2. 实际点击手指数超过配置值,手势识别失败。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index d93f1e3aff2614ef0662a3ac91cf528835f750e3..66adc3e73e3083a309db834bd5b0db9795e8df4b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -1745,7 +1745,7 @@ rotate(angle: number): void .height('100%') .backgroundColor('#ffff00') .onReady(() =>{ - this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.context.rotate(45 * Math.PI / 180) this.context.fillRect(70, 20, 50, 50) }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md index c7e75844c0510121776eff37d1688f11ee83f6aa..2dab45e8523430be89c0723ba7e7dff2b38352e4 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-canvas-lottie.md @@ -31,15 +31,15 @@ path: string, container: object, render: string, loop: boolean, autoplay: boolea **参数:** - | 参数 | 类型 | 必填 | 描述 | - | -------------- | --------------------------- | ---- | ---------------------------------------- | - | path | string | 是 | hap包内动画资源文件路径,仅支持json格式。示例:path: "common/lottie/data.json" | - | container | object | 是 | canvas绘图上下文,声明范式需提前声明CanvasRenderingContext2D。 | - | render | string | 是 | 渲染类型,仅支持“canvas”。 | - | loop | boolean \| number | 否 | 动画播放结束后,是否循环播放,默认值true。值类型为number,且大于等于1时为设置的重复播放的次数。 | - | autoplay | boolean | 否 | 是否自动播放动画,默认值true。 | - | name | string | 否 | 开发者自定义的动画名称,后续支持通过该名称引用控制动画,默认为空。 | - | initialSegment | [number, number] | 否 | 指定动画播放的起始帧号,指定动画播放的结束帧号。 | +| 参数 | 类型 | 必填 | 描述 | +| -------------- | --------------------------- | ---- | ---------------------------------------- | +| path | string | 是 | hap包内动画资源文件路径,仅支持json格式。示例:path: "common/lottie/data.json" | +| container | object | 是 | canvas绘图上下文,声明范式需提前声明CanvasRenderingContext2D。 | +| render | string | 是 | 渲染类型,仅支持“canvas”。 | +| loop | boolean \| number | 否 | 动画播放结束后,是否循环播放,默认值true。值类型为number,且大于等于1时为设置的重复播放的次数。 | +| autoplay | boolean | 否 | 是否自动播放动画,默认值true。 | +| name | string | 否 | 开发者自定义的动画名称,后续支持通过该名称引用控制动画,默认为空。 | +| initialSegment | [number, number] | 否 | 指定动画播放的起始帧号,指定动画播放的结束帧号。 | ## lottie.destroy @@ -50,9 +50,9 @@ destroy(name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | ---------------------------------------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name, 缺省时销毁所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 被指定的动画名,同loadAnimation接口参数name, 缺省时销毁所有动画。 | **示例:** ```ts @@ -78,7 +78,7 @@ destroy(name: string): void .width('30%') .height('20%') .backgroundColor('#0D9FFB') - .onAppear(() => { + .onReady(() => { console.log('canvas onAppear'); this.animateItem = lottie.loadAnimation({ container: this.controller, @@ -131,9 +131,9 @@ play(name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | ---------------------------------------- | - | name | string | 是 | 被指定的动画名, 同loadAnimation接口参数name,缺省时播放所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 被指定的动画名, 同loadAnimation接口参数name,缺省时播放所有动画。 | **示例:** @@ -150,9 +150,9 @@ pause(name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | ---------------------------------------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口入参name,缺省时暂停所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 被指定的动画名,同loadAnimation接口入参name,缺省时暂停所有动画。 | **示例:** @@ -169,9 +169,9 @@ togglePause(name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | ---------------------------------------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | **示例:** @@ -188,9 +188,9 @@ stop(name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | ---------------------------------------- | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | ---------------------------------------- | +| name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时停止所有动画。 | **示例:** @@ -207,10 +207,10 @@ setSpeed(speed: number, name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ----- | ------ | ---- | ---------------------------------------- | - | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0/-1.0正常速度播放。 | - | name | string | 是 | 被指定的动画,同loadAnimation接口参数name,缺省时停止所有动画。 | +| 参数 | 类型 | 必填 | 描述 | +| ----- | ------ | ---- | ---------------------------------------- | +| speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0/-1.0正常速度播放。 | +| name | string | 是 | 被指定的动画,同loadAnimation接口参数name,缺省时停止所有动画。 | **示例:** @@ -227,10 +227,10 @@ setDirection(direction: AnimationDirection, name: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | --------- | ------------------ | ---- | ---------------------------------------- | - | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1 | - | name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时设置所有动画方向。 | +| 参数 | 类型 | 必填 | 描述 | +| --------- | ------------------ | ---- | ---------------------------------------- | +| direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1 | +| name | string | 是 | 被指定的动画名,同loadAnimation接口参数name,缺省时设置所有动画方向。 | **示例:** @@ -275,9 +275,9 @@ play(name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | --------------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | --------------- | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -294,9 +294,9 @@ destroy(name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | --------------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | --------------- | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -313,9 +313,9 @@ pause(name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | --------------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | --------------- | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -332,9 +332,9 @@ togglePause(name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | --------------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | --------------- | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -351,9 +351,9 @@ stop(name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------ | ---- | --------------- | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------ | ---- | --------------- | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -370,9 +370,9 @@ setSpeed(speed: number): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ----- | ------ | ---- | ---------------------------------------- | - | speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | +| 参数 | 类型 | 必填 | 描述 | +| ----- | ------ | ---- | ---------------------------------------- | +| speed | number | 是 | 值为浮点类型, speed>0正向播放, speed<0反向播放, speed=0暂停播放, speed=1.0 \| -1.0正常速度播放。 | **示例:** @@ -389,9 +389,9 @@ setDirection(direction: AnimationDirection): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | --------- | ------------------ | ---- | ---------------------------------------- | - | direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1。 | +| 参数 | 类型 | 必填 | 描述 | +| --------- | ------------------ | ---- | ---------------------------------------- | +| direction | AnimationDirection | 是 | 1为正向,-1为反向; 当设置为反向时,从当前播放进度开始回播直到首帧,loop值为true时可无限倒放;speed<0叠加时也是倒放。
AnimationDirection:1 \| -1。 | **示例:** @@ -408,11 +408,11 @@ goToAndStop(value: number, isFrame?: boolean): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ------- | ------- | ---- | ---------------------------------------- | - | value | number | 是 | 帧号(值大于等于0)或时间进度(ms)。 | - | isFrame | boolean | 否 | true: 按指定帧控制,false:按指定时间控制,缺省默认false。 | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ------- | ------- | ---- | ---------------------------------------- | +| value | number | 是 | 帧号(值大于等于0)或时间进度(ms)。 | +| isFrame | boolean | 否 | true: 按指定帧控制,false:按指定时间控制,缺省默认false。 | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -432,11 +432,11 @@ goToAndPlay(value: number, isFrame: boolean, name?: string): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ------- | ------- | ---- | ---------------------------------------- | - | value | number | 是 | 帧号(值大于等于0)或时间进度(ms) | - | isFrame | boolean | 是 | true:按指定帧控制, false:按指定时间控制,缺省默认false。 | - | name | string | 否 | 被指定的动画名,缺省默认为空。 | +| 参数 | 类型 | 必填 | 描述 | +| ------- | ------- | ---- | ---------------------------------------- | +| value | number | 是 | 帧号(值大于等于0)或时间进度(ms) | +| isFrame | boolean | 是 | true:按指定帧控制, false:按指定时间控制,缺省默认false。 | +| name | string | 否 | 被指定的动画名,缺省默认为空。 | **示例:** @@ -456,10 +456,10 @@ playSegments(segments: AnimationSegment | AnimationSegment[], forceFlag: boolean **参数:** - | 参数 | 类型 | 必填 | 描述 | - | --------- | ---------------------------------------- | ---- | ---------------------------------------- | - | segments | AnimationSegment = [number, number] \| AnimationSegment[] | 是 | 片段或片段列表;
如果片段列表全部播放完毕后,下轮循环播放仅播放最后一个片段 | - | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | +| 参数 | 类型 | 必填 | 描述 | +| --------- | ---------------------------------------- | ---- | ---------------------------------------- | +| segments | AnimationSegment = [number, number] \| AnimationSegment[] | 是 | 片段或片段列表;
如果片段列表全部播放完毕后,下轮循环播放仅播放最后一个片段 | +| forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | **示例:** @@ -479,9 +479,9 @@ resetSegments(forceFlag: boolean): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | --------- | ------- | ---- | ------------------------------ | - | forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | +| 参数 | 类型 | 必填 | 描述 | +| --------- | ------- | ---- | ------------------------------ | +| forceFlag | boolean | 是 | true:即时生效播放,false:延迟到下轮循环播放再生效 | **示例:** @@ -511,9 +511,9 @@ setSubframe(useSubFrame: boolean): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ------------ | ------- | ---- | ---------------------------------------- | - | useSubFrames | boolean | 是 | currentFrame属性默认显示浮点数,该接口参数将影响currentFrame属性的精度。
true:属性currentFrame显示浮点。
false:属性currentFrame去浮点数显示整数。 | +| 参数 | 类型 | 必填 | 描述 | +| ------------ | ------- | ---- | ---------------------------------------- | +| useSubFrames | boolean | 是 | currentFrame属性默认显示浮点数,该接口参数将影响currentFrame属性的精度。
true:属性currentFrame显示浮点。
false:属性currentFrame去浮点数显示整数。 | **示例:** @@ -530,9 +530,9 @@ getDuration(inFrames?: boolean): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | -------- | ------- | ---- | ---------------------------------------- | - | inFrames | boolean | 否 | true:获取帧数, false:获取时间(单位ms),缺省默认false。 | +| 参数 | 类型 | 必填 | 描述 | +| -------- | ------- | ---- | ---------------------------------------- | +| inFrames | boolean | 否 | true:获取帧数, false:获取时间(单位ms),缺省默认false。 | **示例:** @@ -549,10 +549,10 @@ addEventListener<T = any>(name: AnimationEventName, callback: AnimationEve **参数:** - | 参数 | 类型 | 必填 | 描述 | - | -------- | ------------------------------- | ---- | ---------------------------------------- | - | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | - | callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数 | +| 参数 | 类型 | 必填 | 描述 | +| -------- | ------------------------------- | ---- | ---------------------------------------- | +| name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | +| callback | AnimationEventCallback<T> | 是 | 用户自定义回调函数 | **示例:** @@ -575,10 +575,10 @@ removeEventListener<T = any>(name: AnimationEventName, callback?: Animatio **参数:** - | 参数 | 类型 | 必填 | 描述 | - | -------- | ------------------------------- | ---- | ---------------------------------------- | - | name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | - | callback | AnimationEventCallback<T> | 否 | 用户自定义回调函数;缺省为空时,删除此事件的所有回调函数。 | +| 参数 | 类型 | 必填 | 描述 | +| -------- | ------------------------------- | ---- | ---------------------------------------- | +| name | AnimationEventName | 是 | 指定动画事件类型,Lottie内置动画事件类型AnimationEventName:
'enterFrame'、'loopComplete'、'complete'、'segmentStart'、'destroy'、'config_ready'、'data_ready'、'DOMLoaded'、'error'、'data_failed'、'loaded_images' | +| callback | AnimationEventCallback<T> | 否 | 用户自定义回调函数;缺省为空时,删除此事件的所有回调函数。 | **示例:** @@ -595,10 +595,10 @@ triggerEvent<T = any>(name: AnimationEventName, args: T): void **参数:** - | 参数 | 类型 | 必填 | 描述 | - | ---- | ------------------ | ---- | --------- | - | name | AnimationEventName | 是 | 指定动画事件类型 | - | args | any | 是 | 用户自定义回调参数 | +| 参数 | 类型 | 必填 | 描述 | +| ---- | ------------------ | ---- | --------- | +| name | AnimationEventName | 是 | 指定动画事件类型 | +| args | any | 是 | 用户自定义回调参数 | **示例:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md new file mode 100644 index 0000000000000000000000000000000000000000..4ddc18329b5ed829cd3258012a3ca3c8befa6157 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md @@ -0,0 +1,290 @@ +# 组件导读 + + +## 行列与分栏 + +- [Column](ts-container-column.md) + + 沿垂直方向布局的容器组件。 +- [ColumnSplit](ts-container-columnsplit.md) + + 垂直方向分隔布局容器组件,将子组件纵向布局,并在每个子组件之间插入一根横向的分割线。 +- [Row](ts-container-row.md) + + 沿水平方向布局的容器组件。 +- [RowSplit](ts-container-rowsplit.md) + + 水平方向分隔布局容器组件,将子组件横向布局,并在每个子组件之间插入一根纵向的分割线。 +- [SideBarContainer](ts-container-sidebarcontainer.md) + + 提供侧边栏可以显示和隐藏的侧边栏容器组件,通过子组件定义侧边栏和内容区,第一个子组件表示侧边栏,第二个子组件表示内容区。 + + +## 堆叠Flex与栅格 + +- [Stack](ts-container-stack.md) + + 堆叠容器组件,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 +- [Flex](ts-container-flex.md) + + 以弹性方式布局子组件的容器组件。 +- [GridContainer](ts-container-gridcontainer.md) + + 纵向排布栅格布局容器组件,仅在栅格布局场景中使用。 +- [GridRow](ts-container-gridrow.md) + + 栅格容器组件,仅可以和栅格子组件(GridCol)在栅格布局场景中使用。 +- [GridCol](ts-container-gridcol.md) + + 栅格子组件,必须作为栅格容器组件(GridRow)的子组件使用。 +- [RelativeContainer](ts-container-relativecontainer.md) + + 相对布局组件,用于复杂场景中元素对齐的布局。 + + +## 列表与宫格 + +- [List](ts-container-list.md) + + 列表包含一系列相同宽度的列表项,适合连续、多行呈现同类数据,例如图片和文本。 +- [ListItem](ts-container-listitem.md) + + 用来展示具体列表项,必须配合List来使用。 +- [ListItemGroup](ts-container-listitemgroup.md) + + 用来展示分组列表项的组件,必须配合List组件来使用。 +- [Grid](ts-container-grid.md) + + 网格容器组件,由“行”和“列”分割的单元格所组成,通过指定“项目”所在的单元格做出各种各样的布局。 +- [GridItem](ts-container-griditem.md) + + 网格容器中单项内容容器。 + + +## 滚动与滑动 + +- [Scroll](ts-container-scroll.md) + + 可滚动的容器组件,当子组件的布局尺寸超过父组件的尺寸时,内容可以滚动。 +- [Swiper](ts-container-swiper.md) + + 滑块视图容器组件,提供子组件滑动轮播显示的能力。 +- [WaterFlow](ts-container-waterflow.md) + + 瀑布流容器组件,由“行”和“列”分割的单元格所组成,通过容器自身的排列规则,将不同大小的“项目”自上而下,如瀑布般紧密布局。 +- [FlowItem](ts-container-flowitem.md) + + 瀑布流组件WaterFlow的子组件,用来展示瀑布流具体item。 + + +## 导航 + +- [Navigator](ts-container-navigator.md) + + 路由容器组件,提供路由跳转能力。 +- [Navigation](ts-basic-components-navigation.md) + + 一般作为Page页面的根容器,通过属性设置来展示页面的标题栏、工具栏、导航栏等。 +- [NavRouter](ts-basic-components-navrouter.md) + + 导航组件,默认提供点击响应处理,不需要开发者自定义点击事件逻辑。 +- [NavDestination](ts-basic-components-navdestination.md) + + 作为NavRouter组件的子组件,用于显示导航内容区。 +- [Stepper](ts-basic-components-stepper.md) + + 步骤导航器组件,适用于引导用户按照步骤完成任务的导航场景。 +- [StepperItem](ts-basic-components-stepperitem.md) + + Stepper组件的子组件。 +- [Tabs](ts-container-tabs.md) + + 通过页签进行内容视图切换的容器组件,每个页签对应一个内容视图。 +- [TabContent](ts-container-tabcontent.md) + + 仅在Tabs组件中使用,对应一个切换页签的内容视图。 + + +## 按钮与选择 + +- [Button](ts-basic-components-button.md) + + 按钮组件,可快速创建不同样式的按钮。 +- [Toggle](ts-basic-components-toggle.md) + + 组件提供勾选框样式、状态按钮样式及开关样式。 +- [Checkbox](ts-basic-components-checkbox.md) + + 提供多选框组件,通常用于某选项的打开或关闭。 +- [CheckboxGroup](ts-basic-components-checkboxgroup.md) + + 多选框群组,用于控制多选框全选或者不全选状态。 +- [DatePicker](ts-basic-components-datepicker.md) + + 选择日期的滑动选择器组件。 +- [TextPicker](ts-basic-components-textpicker.md) + + 滑动选择文本内容的组件。 +- [TimePicker](ts-basic-components-timepicker.md) + + 滑动选择时间的组件。 +- [Radio](ts-basic-components-radio.md) + + 单选框,提供相应的用户交互选择项。 +- [Rating](ts-basic-components-rating.md) + + 提供在给定范围内选择评分的组件。 +- [Select](ts-basic-components-select.md) + + 提供下拉选择菜单,可以让用户在多个选项之间选择。 +- [Slider](ts-basic-components-slider.md) + + 滑动条组件,通常用于快速调节设置值,如音量调节、亮度调节等应用场景。 +- [Counter](ts-container-counter.md) + + 计数器组件,提供相应的增加或者减少的计数操作。 + + +## 文本与输入 + +- [Text](ts-basic-components-text.md) + + 显示一段文本的组件。 +- [Span](ts-basic-components-span.md) + + 作为Text组件的子组件,用于显示行内文本片段的组件。 +- [Search](ts-basic-components-search.md) + + 搜索框组件,适用于浏览器的搜索内容输入框等应用场景。 +- [TextArea](ts-basic-components-textarea.md) + + 多行文本输入框组件,当输入的文本内容超过组件宽度时会自动换行显示。 +- [TextInput](ts-basic-components-textinput.md) + + 单行文本输入框组件。 +- [PatternLock](ts-basic-components-patternlock.md) + + 图案密码锁组件,以九宫格图案的方式输入密码,用于密码验证场景。手指在PatternLock组件区域按下时开始进入输入状态,手指离开屏幕时结束输入状态完成密码输入。 +- [RichText](ts-basic-components-richtext.md) + + 富文本组件,解析并显示HTML格式文本。 + + +## 图片视频与媒体 + +- [Image](ts-basic-components-image.md) + + 图片组件,支持本地图片和网络图片的渲染展示。 +- [ImageAnimator](ts-basic-components-imageanimator.md) + + 提供逐帧播放图片能力的帧动画组件,可以配置需要播放的图片列表,每张图片可以配置时长。 +- [Video](ts-media-components-video.md) + + 用于播放视频文件并控制其播放状态的组件。 +- [PluginComponent](ts-basic-components-plugincomponent.md) + + 提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。 +- [XComponent](ts-basic-components-xcomponent.md) + + 用于EGL/OpenGLES和媒体数据写入。 + + +## 信息展示 + +- [DataPanel](ts-basic-components-datapanel.md) + + 数据面板组件,用于将多个数据占比情况使用占比图进行展示。 +- [Gauge](ts-basic-components-gauge.md) + + 数据量规图表组件,用于将数据展示为环形图表。 +- [LoadingProgress](ts-basic-components-loadingprogress.md) + + 用于显示加载动效的组件。 +- [Marquee](ts-basic-components-marquee.md) + + 跑马灯组件,用于滚动展示一段单行文本,仅当文本内容宽度超过跑马灯组件宽度时滚动。 +- [Progress](ts-basic-components-progress.md) + + 进度条组件,用于显示内容加载或操作处理等进度。 +- [QRCode](ts-basic-components-qrcode.md) + + 用于显示单个二维码的组件。 +- [TextClock](ts-basic-components-textclock.md) + + 通过文本将当前系统时间显示在设备上。支持不同时区的时间显示,最高精度到秒级。 +- [TextTimer](ts-basic-components-texttimer.md) + + 通过文本显示计时信息并控制其计时器状态的组件。 + + +## 空白与分隔 + +- [Blank](ts-basic-components-blank.md) + + 空白填充组件,在容器主轴方向上,空白填充组件具有自动填充容器空余部分的能力。仅当父组件为Row/Column时生效。 +- [Divider](ts-basic-components-divider.md) + + 分隔器组件,分隔不同内容块/内容元素。 + + +## 画布与图形绘制 + +- [Canvas](ts-components-canvas-canvas.md) + + 提供画布组件,用于自定义绘制图形。 +- [Circle](ts-drawing-components-circle.md) + + 用于绘制圆形的组件。 +- [Ellipse](ts-drawing-components-ellipse.md) + + 椭圆绘制组件。 +- [Line](ts-drawing-components-line.md) + + 直线绘制组件。 +- [Polyline](ts-drawing-components-polyline.md) + + 折线绘制组件。 +- [Polygon](ts-drawing-components-polygon.md) + + 多边形绘制组件。 +- [Path](ts-drawing-components-path.md) + + 路径绘制组件,根据绘制路径生成封闭的自定义形状。 +- [Rect](ts-drawing-components-rect.md) + + 矩形绘制组件。 +- [Shape](ts-drawing-components-shape.md) + + 作为绘制组件的父组件,实现类似SVG的效果,父组件中会描述所有绘制组件均支持的通用属性。 + + +## 网络 + +- [Web](ts-basic-components-web.md) + + 提供具有网页显示能力的Web组件。 + + +## 其他 + +- [ScrollBar](ts-basic-components-scrollbar.md) + + 滚动条组件,用于配合可滚动组件使用,如List、Grid、Scroll等。 +- [Badge](ts-container-badge.md) + + 可以附加在单个组件上用于信息标记的容器组件。 +- [AlphabetIndexer](ts-container-alphabet-indexer.md) + + 可以与容器组件联动用于按逻辑结构快速定位容器显示区域的索引条组件。 +- [Panel](ts-container-panel.md) + + 可滑动面板,提供一种轻量的内容展示窗口,方便在不同尺寸中切换。 +- [Refresh](ts-container-refresh.md) + + 可以进行页面下拉操作并显示刷新动效的容器组件。 +- [AbilityComponent](ts-container-ability-component.md) + + 独立显示Ability的容器组件。 +- [RemoteWindow](ts-basic-components-remotewindow.md) + + 远程控制窗口组件,可以通过此组件控制应用窗口,提供启动退出过程中控件动画和应用窗口联动动画的能力。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md index 6b34c3cee54a5b1d6094505abe506a6b9e2bc00b..0e4a307c4f856cf2d330051642853dd1d94c285b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-column.md @@ -20,7 +20,7 @@ Column(value?: {space?: string | number}) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 纵向布局元素垂直方向间距。
默认值:0 | +| space | string \| number | 否 | 纵向布局元素垂直方向间距。
从API version 9开始,space为负数时不生效。
默认值:0 | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md index f8fc0b4ad9a90f363be6e7d26701ea6b697895df..34342bef756369527367d85e11077db6fae4cf73 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md @@ -66,7 +66,7 @@ Grid只展示固定行列数的元素,其余元素不展示,且Grid不可滚 ## GridDirection8+枚举说明 | 名称 | 描述 | - | ------ | -------------------------------------- | +| ------ | -------------------------------------- | | Row | 主轴布局方向沿水平方向布局,即自左往右先填满一行,再去填下一行。 | | Column | 主轴布局方向沿垂直方向布局,即自上往下先填满一列,再去填下一列。 | | RowReverse | 主轴布局方向沿水平方向反向布局,即自右往左先填满一行,再去填下一行。 | @@ -100,6 +100,7 @@ Grid只展示固定行列数的元素,其余元素不展示,且Grid不可滚 @Component struct GridExample { @State Number: String[] = ['0', '1', '2', '3', '4'] + scroller: Scroller = new Scroller() build() { Column({ space: 5 }) { @@ -126,7 +127,7 @@ struct GridExample { .height(300) Text('scroll').fontColor(0xCCCCCC).fontSize(9).width('90%') - Grid() { + Grid(this.scroller) { ForEach(this.Number, (day: string) => { ForEach(this.Number, (day: string) => { GridItem() { @@ -149,6 +150,10 @@ struct GridExample { .width('90%') .backgroundColor(0xFAEEE0) .height(300) + Button('next page') + .onClick(() => { // 点击后滑到下一页 + this.scroller.scrollPage({ next: true }) + }) }.width('100%').margin({ top: 5 }) } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md index c67914d7f0af03f543fc272e3b187cc8df3683d8..75e927bf604194c4d19b99c2a291b8cd94c1876d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-gridrow.md @@ -133,17 +133,18 @@ onBreakpointChange(callback: (breakpoints: string) => void) struct GridRowExample { @State bgColors: Color[] = [Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Pink, Color.Grey, Color.Blue, Color.Brown] @State currentBp: string = 'unknown' + build() { Column() { GridRow({ columns: 5, - gutter: {x:5, y:10}, - breakpoints: {value:["400vp", "600vp", "800vp"], - reference: BreakpointsReference.WindowSize}, + gutter: { x: 5, y: 10 }, + breakpoints: { value: ["400vp", "600vp", "800vp"], + reference: BreakpointsReference.WindowSize }, direction: GridRowDirection.Row }) { - ForEach(this.bgColors, (color)=>{ - GridCol({ span: {xs:1, sm:2, md:3, lg:4}}) { + ForEach(this.bgColors, (color) => { + GridCol({ span: { xs: 1, sm: 2, md: 3, lg: 4 } }) { Row().width("100%").height("20vp") }.borderColor(color).borderWidth(2) }) @@ -151,8 +152,8 @@ struct GridRowExample { .onBreakpointChange((breakpoint) => { this.currentBp = breakpoint }) - }.width('80%').margin({ left: 10,top: 5, bottom:5 }).height(200) - .border({color:Color.Blue, width:2}) + }.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200) + .border({ color: '#880606', width: 2 }) } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md index 281dbaeca112580429e30278772597160d41a568..0f36cfe25611d736164106ad72b19df528e1d555 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitem.md @@ -22,12 +22,13 @@ ListItem(value?: string) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| sticky | [Sticky](#sticky枚举说明) | 设置ListItem吸顶效果。
默认值:Sticky.None | +| sticky(deprecated) | [Sticky](#stickydeprecated枚举说明) | 设置ListItem吸顶效果。
默认值:Sticky.None
从API version9开始废弃,推荐使用[List组件sticky属性](ts-container-list.md#属性)。 | | editable | boolean \| [EditMode](#editmode枚举说明) | 当前ListItem元素是否可编辑,进入编辑模式后可删除或移动列表项。
默认值:false | | selectable8+ | boolean | 当前ListItem元素是否可以被鼠标框选。
**说明:**
外层List容器的鼠标框选开启时,ListItem的框选才生效。
默认值:true | | swipeAction9+ | {
start?: CustomBuilder,
end?:CustomBuilder,
edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9枚举说明),
} | 用于设置ListItem的划出组件。
- start: ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。
- end: ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。
- edgeEffect: 滑动效果。
| -## Sticky枚举说明 +## Sticky(deprecated)枚举说明 +从API version9开始废弃,推荐使用[List组件stickyStyle枚举](ts-container-list.md#stickystyle9枚举说明)。 | 名称 | 描述 | | -------- | -------- | | None | 无吸顶效果。 | @@ -63,35 +64,18 @@ ListItem(value?: string) @Component struct ListItemExample { private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - @State editFlag: boolean = false build() { Column() { List({ space: 20, initialIndex: 0 }) { - ListItem() { - Text('sticky:Normal , click me edit list') - .width('100%').height(40).fontSize(12).fontColor(0xFFFFFF) - .textAlign(TextAlign.Center).backgroundColor(0x696969) - .onClick(() => { - this.editFlag = !this.editFlag - }) - }.sticky(Sticky.Normal) - ForEach(this.arr, (item) => { ListItem() { Text('' + item) .width('100%').height(100).fontSize(16) .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) - }.editable(this.editFlag) + } }, item => item) - } - .editMode(true) - .onItemDelete((index: number) => { - console.info(this.arr[index - 1] + 'Delete') - this.arr.splice(index - 1,1) - this.editFlag = false - return true - }).width('90%') + }.width('90%') }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md index a5c39cd63bb5a4d76bf939a4748781b1187ebace..2cce7da6c3f8fc6db03069205acff62a4ad92c51 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -78,7 +78,7 @@ import router from '@ohos.router' @Component struct DetailExample { // 接收Navigator.ets的传参 - @State text: any = router.getParams().text + @State text: any = router.getParams()['text'] build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md index ba536c338ffb88ce73f1a0619d722f8b1c2743c0..f9039ed0b31460923fc72a386ac31dab47ac6eba 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-row.md @@ -20,7 +20,7 @@ Row(value?:{space?: number | string }) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| space | string \| number | 否 | 横向布局元素间距。
默认值:0,单位vp | +| space | string \| number | 否 | 横向布局元素间距。
从API version 9开始,space为负数时不生效。
默认值:0,单位vp | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md index b9d2e3f3300160393745c24a49bc8b3ac82b479b..5ac4e16276a39de5b64b2e1a558413162ca40671 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -52,14 +52,6 @@ Swiper(controller?: SwiperController) | Stretch | Swiper滑动一页的宽度为Swiper组件自身的宽度。| | AutoLinear | Swiper滑动一页的宽度为子组件宽度中的最大值。| -## EdgeEffect枚举说明 - -| 名称 | 描述 | -| ------ | ------------------------------------------------------------------------- | -| Spring | 弹性物理动效,滑动到边缘后可以通过触摸事件继续滑动一段距离,松手后回弹。 | -| Fade | 滑动到边缘后,可以通过触摸事件继续滑动一段阴影,松手后阴影回弹。 | -| None | 滑动到边缘后无效果。 | - ## SwiperController Swiper容器组件的控制器,可以将此对象绑定至Swiper组件,然后通过它控制翻页。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index 1d790cb18e416d3369d63c4d07e7513972c67a81..e22cce09553a92a516fc3ffc7fd2c182000fbf1f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -16,29 +16,30 @@ Circle(options?: {width?: string | number, height?: string | number}) -- 参数 - | 参数名 | 参数类型 | 必填 | 参数描述 | - | -------- | -------- | -------- | -------- | - | width | string \| number | 否 | 宽度。
默认值:0 | - | height | string \| number | 否 | 高度。
默认值:0 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| width | string \| number | 否 | 宽度。
默认值:0 | +| height | string \| number | 否 | 高度。
默认值:0 | ## 属性 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -| fill | [ResourceColor](ts-types.md) | 否 | 设置填充区域颜色。
默认值:Color.Black | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 否 | 设置填充区域透明度。
默认值:1 | -| stroke | [ResourceColor](ts-types.md) | 否 | 设置边框颜色,不设置时,默认没有边框。 | -| strokeDashArray | Array<Length> | 否 | 设置边框间隙。
默认值:[] | -| strokeDashOffset | number \| string | 否 | 边框绘制起点的偏移量。
默认值:0 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 否 | 设置边框端点绘制样式。
默认值:LineCapStyle.Butt | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 否 | 设置边框拐角绘制样式。
默认值:LineJoinStyle.Miter | -| strokeMiterLimit | number \| string | 否 | 设置锐角绘制成斜角的极限值。
默认值:4 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 否 | 设置边框透明度。
默认值:1 | -| strokeWidth | Length | 否 | 设置边框宽度。
默认值:1 | -| antiAlias | boolean | 否 | 是否开启抗锯齿效果。
默认值:true | +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| fill | [ResourceColor](ts-types.md) | 设置填充区域颜色。
默认值:Color.Black | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 设置填充区域透明度。
默认值:1 | +| stroke | [ResourceColor](ts-types.md) | 设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | 设置边框间隙。
默认值:[] | +| strokeDashOffset | number \| string | 边框绘制起点的偏移量。
默认值:0 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 设置边框端点绘制样式。
默认值:LineCapStyle.Butt | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | 设置边框拐角绘制样式。
默认值:LineJoinStyle.Miter | +| strokeMiterLimit | number \| string | 设置锐角绘制成斜角的极限值。
默认值:4
**说明:**
Circle组件无法设置锐角图形,该属性设置无效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 设置边框透明度。
默认值:1 | +| strokeWidth | Length | 设置边框宽度。
默认值:1 | +| antiAlias | boolean | 是否开启抗锯齿效果。
默认值:true | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index bedfc7713757b2291914cab626aa27af1501923f..090fb561e60a7cdcf8dd5b79bdcbea8bb7c8a1d9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -14,7 +14,7 @@ ## 接口 -ellipse(options?: {width?: string | number, height?: string | number}) +Ellipse(options?: {width?: string | number, height?: string | number}) **参数:** @@ -27,19 +27,19 @@ ellipse(options?: {width?: string | number, height?: string | number}) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 |设置边框颜色,不设置时,默认没有边框。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | -| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - |设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | [] | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 设置边框宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md index 8c5b3995696b5a85498a5b7f4dd5a49012493832..6487fe0fa436e686a9f093c158f49d46933e68a7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -34,21 +34,21 @@ Line(value?: {width?: string | number, height?: string | number}) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| startPoint | Array<Length> | [0, 0] | 否 | 直线起点坐标点(相对坐标),单位vp。 | -| endPoint | Array<Length> | [0, 0] | 否 | 直线终点坐标点(相对坐标),单位vp。 | -| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| startPoint | Array<Length> | [0, 0] | 直线起点坐标点(相对坐标),单位vp。 | +| endPoint | Array<Length> | [0, 0] | 直线终点坐标点(相对坐标),单位vp。 | +| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | 设置填充区域颜色。
**说明:**
Line组件无法形成闭合区域,该属性设置无效。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。
**说明:**
Line组件无法形成闭合区域,该属性设置无效。 | +| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | 设置线条颜色。 | +| strokeDashArray | Array<Length> | [] | 设置线条间隙。 | +| strokeDashOffset | number \| string | 0 | 线条绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置线条端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。
**说明:**
Line组件无法设置锐角图形,该属性设置无效。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。 | +| strokeWidth | Length | 1 | 设置线条宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md index fbf5860c2bc5b6fc98d7bb9a8c113e3c247aacc9..097259b858a7a7c3be9fab7c87c6450cd128e63f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -27,20 +27,20 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | ----------------------------------- | ---- | ---- | ---------------------------------------- | -| commands | string | '' | 否 | 路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](ts-pixel-units.md)。 | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | ----------------------------------- | ---- | ---------------------------------------- | +| commands | string | '' | 路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](ts-pixel-units.md)。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - | 设置线条颜色。 | +| strokeDashArray | Array<Length> | [] | 设置线条间隙。 | +| strokeDashOffset | number \| string | 0 | 线条绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置线条端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。 | +| strokeWidth | Length | 1 | 设置线条宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | commands支持的绘制命令如下: diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index eefd1d43c4fc7e487001ed1c1945591f5a38f0fc..d573d7a8b0a22e6dffdc0c6b785455ca6f3ebf00 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -28,20 +28,20 @@ Polygon(value?: {width?: string | number, height?: string | number}) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| points | Array<Point> | [] | 否 | 多边形的顶点坐标列表。 | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框线条。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | -| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| points | Array<Point> | [] | 多边形的顶点坐标列表。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - | 设置边框颜色,不设置时,默认没有边框线条。 | +| strokeDashArray | Array<Length> | [] | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 设置边框宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | ## Point diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index 8042a9947528a5f0e70761fb56a9df721a8a688c..a592609717b8bbd07c2eff7524b369a308dc0a0d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -28,20 +28,20 @@ Polyline(value?: {width?: string | number, height?: string | number}) 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| points | Array<Point> | [] | 否 | 折线经过坐标点列表。 | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置线条颜色。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | -| strokeWidth | Length | 1 | 否 | 设置线条宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| points | Array<Point> | [] | 折线经过坐标点列表。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - | 设置线条颜色。 | +| strokeDashArray | Array<Length> | [] | 设置线条间隙。 | +| strokeDashOffset | number \| string | 0 | 线条绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置线条端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置线条拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置线条透明度。 | +| strokeWidth | Length | 1 | 设置线条宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | ## Point diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index 9ea5950c76a29569a4352278022675b9d4235e67..7ef5471abf93317154a1b385e5ce36b83744a1d9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -32,22 +32,22 @@ Rect(value?: {width?: string | number,height?: string | number,radius?: string | 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| radiusWidth | string \| number | 0 | 否 | 圆角的宽度,仅设置宽时宽高一致。 | -| radiusHeight | string \| number | 0 | 否 | 圆角的高度,仅设置高时宽高一致。 | -| radius | string \| number \| Array<string \| number> | 0 | 否 | 圆角半径大小。 | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | -| strokeWidth | Length | 1 | 否 | 设置边框宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| radiusWidth | string \| number | 0 | 圆角的宽度,仅设置宽时宽高一致。 | +| radiusHeight | string \| number | 0 | 圆角的高度,仅设置高时宽高一致。 | +| radius | string \| number \| Array<string \| number> | 0 | 圆角半径大小。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - | 设置边框颜色,不设置时,默认没有边框。 | +| strokeDashArray | Array<Length> | [] | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。 | +| strokeWidth | Length | 1 | 设置边框宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 365f1333b677c98e55b5323b45cb20c2daa6ebde..b3f695718de89fe04b96d7074ed21839b0eccd44 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -21,31 +21,32 @@ Shape(value?: PixelMap) -- 参数 - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | value | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 否 | - | 绘制目标,可将图形绘制在指定的PixelMap对象中,若未设置,则在当前绘制目标中进行绘制。 | +**参数:** + +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 否 | - | 绘制目标,可将图形绘制在指定的PixelMap对象中,若未设置,则在当前绘制目标中进行绘制。 | ## 属性 除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: -| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | -| -------- | -------- | -------- | -------- | -------- | -| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | 否 | 形状的视口。 | -| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](ts-types.md) | - | 否 | 设置边框颜色,不设置时,默认没有边框线条。 | -| strokeDashArray | Array<Length> | [] | 否 | 设置边框间隙。 | -| strokeDashOffset | number \| string | 0 | 否 | 边框绘制起点的偏移量。 | -| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置边框端点绘制样式。 | -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置边框拐角绘制样式。 | -| strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置边框透明度。 | -| strokeWidth | number \| string | 1 | 否 | 设置边框宽度。 | -| antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | -| mesh8+ | Array<number>,number,number | [],0,0 | 否 | 设置mesh效果。第一个参数为长度(column + 1)* (row + 1)* 2的数组,它记录了扭曲后的位图各个顶点位置,第二个参数为mesh矩阵列数column,第三个参数为mesh矩阵行数row。 | +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | 形状的视口。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | - | 设置边框颜色,不设置时,默认没有边框线条。 | +| strokeDashArray | Array<Length> | [] | 设置边框间隙。 | +| strokeDashOffset | number \| string | 0 | 边框绘制起点的偏移量。 | +| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 设置边框端点绘制样式。 | +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 设置边框拐角绘制样式。 | +| strokeMiterLimit | number \| string | 4 | 设置锐角绘制成斜角的极限值。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 设置边框透明度。 | +| strokeWidth | number \| string | 1 | 设置边框宽度。 | +| antiAlias | boolean | true | 是否开启抗锯齿效果。 | +| mesh8+ | Array<number>,number,number | [],0,0 | 设置mesh效果。第一个参数为长度(column + 1)* (row + 1)* 2的数组,它记录了扭曲后的位图各个顶点位置,第二个参数为mesh矩阵列数column,第三个参数为mesh矩阵行数row。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md index eef21726017bab7f983eaa66d92615778127de09..17328cec7f6387f6526810d6ffb50fe33ee49553 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-explicit-animation.md @@ -69,7 +69,7 @@ struct AnimateToExample { }) Button('change rotate angle') .margin(50) - .rotate({ angle: this.rotateAngle }) + .rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }) .onClick(() => { animateTo({ duration: 1200, diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md index d31658612f6d098d7bac990af1899929c541aed6..820834e1daac886c0781895b1b73c89200da08e5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-gesture-settings.md @@ -40,10 +40,11 @@ 组件通过手势事件绑定不同GestureType的手势对象,各手势对象在响应手势操作的事件回调中提供手势相关信息。下面通过TapGesture手势对象的onAction事件响应点击事件,获取事件相关信息。其余手势对象的事件定义见各个手势对象章节。 若需绑定多种手势请使用 [组合手势](ts-combined-gestures.md)。 -- TapGesture事件说明 - | 名称 | 功能描述 | - | -------- | -------- | - | onAction((event?:GestureEvent) => void) | Tap手势识别成功回调。 | +**TapGesture事件说明** + +| 名称 | 功能描述 | +| -------- | -------- | +| onAction((event?:GestureEvent) => void) | Tap手势识别成功回调。 | ## GestureEvent对象说明 | 名称 | 类型 | 描述 | @@ -60,6 +61,10 @@ | timestamp8+ | number | 事件时间戳。 | | target8+ | [EventTarget](ts-universal-events-click.md#eventtarget8对象说明) | 触发手势事件的元素对象显示区域。 | | source8+ | [SourceType](#sourcetype枚举说明) | 事件输入设备。 | +| pressure9+ | number | 按压的压力大小。 | +| tiltX9+ | number | 手写笔在设备平面上的投影与设备平面X轴的夹角。 | +| tiltY9+ | number | 手写笔在设备平面上的投影与设备平面Y轴的夹角。 | +| sourceTool9+ | [SourceTool](#sourcetool枚举说明) | 事件输入源。 | ## SourceType枚举说明 | 名称 | 描述 | @@ -77,6 +82,13 @@ | localX | number | 相对于当前组件元素左上角的x轴坐标。 | | localY | number | 相对于当前组件元素左上角的y轴坐标。 | +## SourceTool枚举说明 +| 名称 | 描述 | +| -------- | -------- | +| Unknown | 未知输入源。 | +| Finger | 手指输入。 | +| Pen | 手写笔输入。 | + ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index 7330ab11ee2cca5e1c9ba87f81952b0fd4cae3f3..50d072a9a221958dc2a7b21aa4608c913bc004fd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -13,17 +13,17 @@ show(options?: DatePickerDialogOptions) 定义日期滑动选择器弹窗并弹出。 -- DatePickerDialogOptions参数说明 +**DatePickerDialogOptions参数:** - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | start | Date | 否 | Date('1970-1-1') | 设置选择器的起始日期。 | - | end | Date | 否 | Date('2100-12-31') | 设置选择器的结束日期。 | - | selected | Date | 否 | 当前系统日期 | 设置当前选中的日期。 | - | lunar | boolean | 否 | false | 日期是否显示为农历。 |确定 - | onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 点击弹窗中的“确定”按钮时触发该回调。 | - | onCancel | () => void | 否 | - | 点击弹窗中的“取消”按钮时触发该回调。 | - | onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | -------- | -------- | -------- | +| start | Date | 否 | Date('1970-1-1') | 设置选择器的起始日期。 | +| end | Date | 否 | Date('2100-12-31') | 设置选择器的结束日期。 | +| selected | Date | 否 | 当前系统日期 | 设置当前选中的日期。 | +| lunar | boolean | 否 | false | 日期是否显示为农历。 |确定 +| onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 点击弹窗中的“确定”按钮时触发该回调。 | +| onCancel | () => void | 否 | - | 点击弹窗中的“取消”按钮时触发该回调。 | +| onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult对象说明)) => void | 否 | - | 滑动弹窗中的滑动选择器使当前选中项改变时触发该回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 5772b95f5602c0706b4baaa5fa4f2e7c82060c07..7bb99f5f46e8bcd2992b36025ca6e3c74a6465fc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -13,7 +13,7 @@ show(options?: TextPickerDialogOptions) 定义文本滑动选择器弹窗并弹出。 -**TextPickerDialogOptions参数说明:** +**TextPickerDialogOptions参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index 61dd5ab8e724f97b8e9d0b4a87bc71627980d9da..97229576c98b61f2d7fb69cf0512adc03e00f8c6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -12,15 +12,16 @@ show(options?: TimePickerDialogOptions) 定义时间滑动选择器弹窗并弹出。 -- TimePickerDialogOptions参数 +**TimePickerDialogOptions参数:** - | 参数名 | 参数类型 | 必填 | 参数描述 | - | -------- | -------- | -------- | -------- | - | selected | Date | 否 | 设置当前选中的时间。
默认值:当前系统时间 | - | useMilitaryTime | boolean | 否 | 展示时间是否为24小时制,默认为12小时制。
默认值:false | - | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | - | onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | - | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动弹窗中的选择器使当前选中时间改变时触发该回调。 | + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| selected | Date | 否 | 设置当前选中的时间。
默认值:当前系统时间 | +| useMilitaryTime | boolean | 否 | 展示时间是否为24小时制,默认为12小时制。
默认值:false | +| onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 点击弹窗中的“确定”按钮时触发该回调。 | +| onCancel | () => void | 否 | 点击弹窗中的“取消”按钮时触发该回调。 | +| onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult对象说明)) => void | 否 | 滑动弹窗中的选择器使当前选中时间改变时触发该回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md index e9a0cd9f65503c3a52ad4a967d241c403837b797..adb197b0bff707b0f237933e1b48e21689e1154a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-motion-path-animation.md @@ -11,7 +11,7 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
**说明:**
path中支持使用start和end进行起点和终点的替代,如:
'Mstart.x start.y L50 50 Lend.x end.y Z'| {
'',
0.0,
1.0,
false
} | 设置组件的运动路径,入参说明如下:
- path:位移动画的运动路径,使用svg路径字符串。
- from:运动路径的起点,默认为0.0。
- to:运动路径的终点,默认为1.0。
- rotatable:是否跟随路径进行旋转。 | +| motionPath | {
path: string,
from?: number,
to?: number,
rotatable?: boolean
}
**说明:**
path中支持使用start和end进行起点和终点的替代,如:
'Mstart.x start.y L50 50 Lend.x end.y Z',更多说明请参考[绘制路径](../../ui/ui-js-components-svg-path.md)。 | {
'',
0.0,
1.0,
false
} | 设置组件的运动路径,入参说明如下:
- path:位移动画的运动路径,使用svg路径字符串。
- from:运动路径的起点,默认为0.0。
- to:运动路径的终点,默认为1.0。
- rotatable:是否跟随路径进行旋转。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index f243c3342ad7ee14e6d77fece525d2c149cd1e78..a6e2d28cb802e7bfe22f90fb8fc3bcaa368f0007 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -1850,7 +1850,7 @@ rotate(angle: number): void .height('100%') .backgroundColor('#ffff00') .onReady(() =>{ - this.offContext.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees + this.offContext.rotate(45 * Math.PI / 180) this.offContext.fillRect(70, 20, 50, 50) var image = this.offContext.transferToImageBitmap() this.context.transferFromImageBitmap(image) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md index da8af9d48ef6997675a1933f68725ad0ac5847b5..fb10ce9cc1a0dacdd5b28ccdc97a728435f005b2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-page-transition-animation.md @@ -5,20 +5,21 @@ > **说明:** > > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> | 名称 | 参数 | 参数描述 | | ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| PageTransitionEnter | {
type: RouteType,
duration: number,
curve: [Curve](ts-appendix-enums.md#curve) \| string,
delay: number
} | 设置当前页面的自定义入场动效。
- type:不配置时表明pop为push时效果的逆播。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线。string类型的取值支持"ease"、"ease-in"、"ease-out"、"ease-in-out"、"extreme-deceleration"、"fast-out-linear-in"、"fast-out-slow-in"、"friction"、"linear"、"linear-out-slow-in"、"rhythm"、"sharp"、"smooth"。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | -| PageTransitionExit | {
type: RouteType,
duration: number,
curve: [Curve](ts-appendix-enums.md#curve) \| string,
delay: number
} | 设置当前页面的自定义退场动效。
- type:不配置时表明pop为push时效果的逆播
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,string类型取值与PageTransitionEnter相同。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionEnter | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义入场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:**没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线。string类型的取值支持"ease"、"ease-in"、"ease-out"、"ease-in-out"、"extreme-deceleration"、"fast-out-linear-in"、"fast-out-slow-in"、"friction"、"linear"、"linear-out-slow-in"、"rhythm"、"sharp"、"smooth"。
默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | +| PageTransitionExit | {
type?: RouteType,
duration?: number,
curve?: [Curve](ts-appendix-enums.md#curve) \| string,
delay?: number
} | 设置当前页面的自定义退场动效。
- type:页面转场效果生效的路由类型。
默认值:RouteType.None。
**说明:**没有匹配时使用系统默认的页面转场效果(根据设备可能会有差异),如需禁用系统默认页面转场效果,可以指定duration为0。
- duration:动画的时长,单位为毫秒。
- curve:动画曲线,string类型取值与PageTransitionEnter相同。
 默认值:Curve.Linear
- delay:动画延迟时长,单位为毫秒,默认不延迟播放。 | ## RouteType枚举说明 | 名称 | 描述 | | ---- | ------------------------------------------------------------ | -| Pop | 重定向指定页面。PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。 | -| Push | 跳转到下一页面。PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。 | -| None | 页面未重定向。 | +| Pop | 重定向指定页面。从PageB回退到之前的页面PageA。对于PageB,指定RouteType为None或者Pop的PageTransitionExit组件样式生效,对于PageA,指定RouteType为None或者Pop的PageTransitionEnter组件样式生效。 | +| Push | 跳转到下一页面。PageA跳转到下一个新的界面PageB。对于PageA,指定RouteType为None或者Push的PageTransitionExit组件样式生效,对于PageB,指定RouteType为None或者Push的PageTransitionEnter组件样式生效。 | +| None | 页面未重定向。如Push和Pop描述中RouteType为None的情形,即页面进场时PageTransitionEnter的转场效果生效;退场时PageTransitionExit的转场效果生效。 | ## 属性 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md b/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md index aa077567dec5f971cb4ecc13de55214026107413..5df2adf1743dc74464863df7ecc0f3c5aa29c747 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-pixel-units.md @@ -71,7 +71,7 @@ struct Example { } ``` -![zh-cn_image_0000001169582302](figures/zh-cn_image_0000001169582302.gif) +![zh-cn_image_0000001169582302](figures/zh-cn_image_0000001169582302.png) ## 相关实例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md index 25b640efc283b43e386883a4263e172f1ba98a6c..be16f57753ecab53f6f211b70b75dd9380d990e9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md @@ -701,7 +701,7 @@ EnvProp\(key: string, value: S): boolean | key | 类型 | 说明 | | ------------ | ------------- | ------------------- | -| accessibilityEnabled | boolean | 无障碍屏幕朗读是否启用。 | +| accessibilityEnabled | string | 无障碍屏幕朗读是否启用。 | | colorMode | ColorMode | 深浅色模式,可选值为:
- ColorMode.LIGHT:浅色模式;
- ColorMode.DARK:深色模式。 | | fontScale | number | 字体大小比例。 | | fontWeightScale | number | 字重比例。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md index f1ad36dfd7f9caec182fb07f44812112c588ebe6..6a779423197d371aa4a5f96447f5dd12b16a4f72 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-component-id.md @@ -229,7 +229,11 @@ struct IdExample { } } }, - source: SourceType.Mouse + source: SourceType.Mouse, + pressure: 1, + tiltX: 1, + tiltY: 1, + sourceTool: SourceTool.Unknown } sendMouseEvent(mouseEvent) // 发送鼠标事件 }, 2000) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md index e915efdd2c514a9a015f19d6b5060cfb37e30412..4c1606fddcb6cb2e24e2830009a16fcccaba6644 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md @@ -11,7 +11,7 @@ | **名称** | **参数类型** | **描述** | | -------------------- | -------- | ---------------------------------------- | -| focusable | boolean | 设置当前组件是否可以获焦。
**说明:**
存在默认交互逻辑的组件例如Button、TextInput等,默认即为可获焦,Text、Image等组件则默认状态为不可获焦。 | +| focusable | boolean | 设置当前组件是否可以获焦。
**说明:**
存在默认交互逻辑的组件例如Button、TextInput等,默认即为可获焦,Text、Image等组件则默认状态为不可获焦。不可获焦状态下,无法触发[焦点事件](ts-universal-focus-event.md)。 | | tabIndex9+ | number | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。
- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,tabIndex值越小,则优先获焦;反之,则后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦
- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素。
默认值:0 | | defaultFocus9+ | boolean | 设置当前组件是否为当前页面上的默认焦点,仅在初次创建的页面第一次进入时生效。
默认值:false | | groupDefaultFocus9+ | boolean | 设置当前组件是否为当前组件所在容器获焦时的默认焦点,仅在初次创建容器节点第一次获焦时生效。
默认值:false
**说明:** 必须与tabIndex联合使用,当某个容器设置了tabIndex,且容器内某子组件设置了groupDefaultFocus,当该容器首次获焦时,会自动将焦点转移至该组件上。
| diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index c909c6988b7711c00f9febca084960e0d3caebe1..ab47fc96adfd0e3f7bfa5b006be15dfe050f15dd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -85,7 +85,7 @@ struct PopupExample { } }, onStateChange: (e) => { - console.info(e.isVisible.toString()) + console.info(JSON.stringify(e.isVisible)) if (!e.isVisible) { this.handlePopup = false } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index 505d064a9d292f502a440dbda39b4ff3c0da5382..fdd40a40fabab1ba523af3337ecd1593e3265788 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -47,15 +47,27 @@ ```ts // xxx.ets +@Extend(Text) function textStyle () { + .width('25%') + .height(35) + .fontSize(16) + .textAlign(TextAlign.Center) + .backgroundColor(0xAFEEEE) +} + @Entry @Component struct DragExample { @State numbers: string[] = ['one', 'two', 'three', 'four', 'five', 'six'] @State text: string = '' - @State bool: boolean = false + @State bool: boolean = true + @State eventType: string = '' @State appleVisible: Visibility = Visibility.Visible @State orangeVisible: Visibility = Visibility.Visible @State bananaVisible: Visibility = Visibility.Visible + private dragList: string[] = ['apple', 'orange', 'banana'] + @State fruitVisible: Visibility[] = [Visibility.Visible, Visibility.Visible, Visibility.Visible] + @State index: number = 0 // 自定义拖拽过程中显示的内容 @Builder pixelMapBuilder() { @@ -79,46 +91,29 @@ struct DragExample { .textAlign(TextAlign.Start) .margin(5) Row({ space: 15 }) { - Text('apple') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.appleVisible) - .onDragStart(() => { - this.bool = true - this.text = 'apple' - this.appleVisible = Visibility.None - return this.pixelMapBuilder - }) - Text('orange') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.orangeVisible) - .onDragStart(() => { - this.bool = true - this.text = 'orange' - this.orangeVisible = Visibility.None - return this.pixelMapBuilder - }) - Text('banana') - .width('25%') - .height(35) - .fontSize(16) - .textAlign(TextAlign.Center) - .backgroundColor(0xAFEEEE) - .visibility(this.bananaVisible) - .onDragStart((event: DragEvent, extraParams: string) => { - console.log('Text onDragStart, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()) - this.bool = true - this.text = 'banana' - this.bananaVisible = Visibility.None - return this.pixelMapBuilder - }) + ForEach(this.dragList, (item, index) => { + Text(item) + .textStyle() + .visibility(this.fruitVisible[index]) + .onDragStart(() => { + this.bool = true + this.text = item + this.fruitVisible[index] = Visibility.None + return this.pixelMapBuilder + }) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down' + this.index = index + } + if (event.type === TouchType.Up) { + this.eventType = 'Up' + if (this.bool) { + this.fruitVisible[index] = Visibility.Visible + } + } + }) + }) }.padding({ top: 10, bottom: 10 }).margin(10) Text('This is a List element') @@ -156,12 +151,13 @@ struct DragExample { console.log('List onDragLeave, ' + extraParams + 'X:' + event.getX() + 'Y:' + event.getY()) }) .onDrop((event: DragEvent, extraParams: string) => { - var jsonString = JSON.parse(extraParams); + let jsonString = JSON.parse(extraParams); if (this.bool) { // 通过splice方法插入元素 this.numbers.splice(jsonString.insertIndex, 0, this.text) this.bool = false } + this.fruitVisible[this.index] = Visibility.None }) }.width('100%').height('100%').padding({ top: 20 }).margin({ top: 20 }) } diff --git a/zh-cn/application-dev/reference/errorcodes/Readme-CN.md b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..2167160bcd9e984da617fa5a929a4700fb6e7eff --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/Readme-CN.md @@ -0,0 +1,78 @@ +# 错误码 + +- [通用错误码](errorcode-universal.md) +- Ability框架 + - [元能力子系统错误码](errorcode-ability.md) + - [DistributedSchedule错误码](errorcode-DistributedSchedule.md) +- 包管理 + - [包管理子系统通用错误码](errorcode-bundle.md) + - [zlib子系统错误码](errorcode-zlib.md) +- 公共事件与通知 + - [事件错误码](errorcode-CommonEventService.md) + - [DistributedNotificationService错误码](errorcode-DistributedNotificationService.md) +- UI界面 + - [动画错误码](errorcode-animator.md) + - [弹窗错误码](errorcode-promptAction.md) + - [页面路由错误码](errorcode-router.md) +- 图形图像 + - [色彩管理错误码](errorcode-colorspace-manager.md) + - [屏幕错误码](errorcode-display.md) + - [窗口错误码](errorcode-window.md) +- 媒体 + - [Audio错误码](errorcode-audio.md) + - [媒体会话管理错误码](errorcode-avsession.md) +- 资源管理 + - [I18n错误码](errorcode-i18n.md) + - [资源管理错误码](errorcode-resource-manager.md) +- 资源调度 + - [backgroundTaskManager错误码](errorcode-backgroundTaskMgr.md) + - [DeviceUsageStatistics错误码](errorcode-DeviceUsageStatistics.md) + - [reminderAgentManager错误码](errorcode-reminderAgentManager.md) + - [workScheduler错误码](errorcode-workScheduler.md) +- 安全 + - [AccessToken错误码](errorcode-access-token.md) + - [HUKS错误码](errorcode-huks.md) +- 数据管理 + - [关系型数据库错误码](errorcode-data-rdb.md) + - [数据共享错误码](errorcode-datashare.md) + - [分布式数据对象错误码](errorcode-distributed-dataObject.md) + - [分布式键值数据库错误码](errorcode-distributedKVStore.md) + - [首选项错误码](errorcode-preferences.md) +- 网络管理 + - [上传下载错误码](errorcode-request.md) +- 通信与连接 + - [NFC错误码](errorcode-nfc.md) + - [RPC错误码](errorcode-rpc.md) +- 系统基础能力 + - [无障碍子系统错误码](errorcode-accessibility.md) + - [Faultlogger错误码](errorcode-faultlogger.md) + - [应用事件打点错误码](errorcode-hiappevent.md) + - [系统事件错误码](errorcode-hisysevent.md) + - [Hidebug错误码](errorcode-hiviewdfx-hidebug.md) + - [输入法框架错误码](errorcode-inputmethod-framework.md) + - [剪贴板错误码](errorcode-pasteboard.md) + - [Webview错误码](errorcode-webview.md) +- 帐号管理 + - [Account错误码](errorcode-account.md) + - [应用帐号错误码](errorcode-app-account.md) +- 设备管理 + - [耗电统计错误码](errorcode-batteryStatistics.md) + - [屏幕亮度错误码](errorcode-brightness.md) + - [系统电源管理错误码](errorcode-power.md) + - [RunningLock锁错误码](errorcode-runninglock.md) + - [热管理错误码](errorcode-thermal.md) + - [设备管理错误码](errorcode-device-manager.md) + - [位置服务子系统错误码](errorcode-geoLocationManager.md) + - [键鼠穿越管理错误码](errorcode-multimodalinput.md) + - [传感器错误码](errorcode-sensor.md) + - [振动错误码](errorcode-vibrator.md) + - [系统参数错误码](errorcode-system-parameterV9.md) + - [USB服务错误码](errorcode-usb.md) + - [升级错误码](errorcode-update.md) +- 定制管理 + - [企业设备管理错误码](errorcode-enterpriseDeviceManager.md) +- 语言基础类库 + - [buffer错误码](errorcode-buffer.md) + - [containers错误码](errorcode-containers.md) +- 测试 + - [uitest错误码](errorcode-uitest.md) diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-CommonEventService.md b/zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-CommonEventService.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-CommonEventService.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-DeviceUsageStatistics.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-DeviceUsageStatistics.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-DeviceUsageStatistics.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-DistributedNotificationService.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-DistributedNotificationService.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-DistributedNotificationService.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md b/zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-DistributedSchedule.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-DistributedSchedule.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-Account.md b/zh-cn/application-dev/reference/errorcodes/errorcode-account.md similarity index 99% rename from zh-cn/application-dev/reference/errorcodes/errcode-Account.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-account.md index b7c29b43401ba05a1bf6a4d0b908271f6ba701d2..0894a278080b8ac2be19eb4b7ccade4a82c324d5 100644 --- a/zh-cn/application-dev/reference/errorcodes/errcode-Account.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-account.md @@ -320,7 +320,7 @@ The auth type is not supported. 请提供系统支持的认证类型。 -## 12300007 认证类型不存在 +## 12300107 认证类型不存在 **错误信息** @@ -335,7 +335,7 @@ The auth type does not exist. 请使用存在的认证类型查询/删除。 -## 12300008 认证会话不存在 +## 12300108 认证会话不存在 **错误信息** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md index 96e986813706ea59bcb629891e821f561fe2a72a..0746dc22f236b5c62a392bbde82dc0db4c318203 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-audio.md @@ -4,7 +4,7 @@ **错误信息** -invalid parameter. +Invalid parameter. **错误描述** @@ -22,7 +22,7 @@ invalid parameter. **错误信息** -allocate memory failed. +Memory allocation failure. **错误描述** @@ -42,7 +42,7 @@ allocate memory failed. **错误信息** -Operation not permit at current state. +Unsupported state. **错误描述** @@ -61,7 +61,7 @@ Operation not permit at current state. **错误信息** -unsupported operation. +Unsupported parameter value. **错误描述** @@ -80,7 +80,7 @@ unsupported operation. **错误信息** -time out. +Processing timeout. **错误描述** @@ -98,7 +98,7 @@ time out. **错误信息** -stream number limited. +Too many audio streams. **错误描述** @@ -116,7 +116,7 @@ stream number limited. **错误信息** -system error. +System error. **错误描述** diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-bundle.md b/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md similarity index 73% rename from zh-cn/application-dev/reference/errorcodes/errcode-bundle.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md index 23752692a6dd21cf67de3ba36d5ff94f5a93b94f..1995604ae0c45e85c04bfeb1df7205c79a7f23ce 100644 --- a/zh-cn/application-dev/reference/errorcodes/errcode-bundle.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md @@ -6,7 +6,7 @@ The specified bundle name is not found. **错误描述**
-调用接口时,传入的bundleName不存在。 +调用查询等接口时,传入的bundleName不存在。 **可能原因**
1. 输入的bundleName有误。 @@ -22,7 +22,7 @@ The specified bundle name is not found. The specified module name is not found. **错误描述**
-调用接口时,传入的moduleName不存在。 +调用查询或者免安装相关接口时,传入的moduleName不存在。 **可能原因**
1. 输入的moduleName有误。 @@ -38,7 +38,7 @@ The specified module name is not found. The specified ability name is not found. **错误描述**
-调用接口时,传入的abilityName不存在。 +调用查询等接口时,传入的abilityName不存在。 **可能原因**
1. 输入的abilityName有误。 @@ -46,15 +46,15 @@ The specified ability name is not found. **处理步骤**
1. 检查abilityName拼写是否正确。 -2. 确认对应的应用是否安装该模块。 +2. 确认对应的应用是否安装该组件。 ## 17700004 指定的用户不存在 **错误信息**
-The specified user id is not found. +The specified user ID is not found. **错误描述**
-调用接口时,传入的用户不存在。 +调用与用户相关接口时,传入的用户不存在。 **可能原因**
输入的用户名有误,系统中没有该用户。 @@ -66,10 +66,10 @@ The specified user id is not found. ## 17700005 指定的appId不存在 **错误信息**
-The specified appId is not found. +The specified app ID is not found. **错误描述**
-调用接口时,传入的appId为空字符串。 +调用appControl模块中的相关接口时,传入的appId为空字符串。 **可能原因**
传入的appId为空字符串。 @@ -83,7 +83,7 @@ The specified appId is not found. The specified permission is not found. **错误描述**
-调用接口时,传入的权限不存在。 +调用bundleManager模块中的getPermissionDef接口时,传入的权限不存在。 **可能原因**
1. 传入的permission名称拼写有误。 @@ -96,10 +96,10 @@ The specified permission is not found. ## 17700007 输入的设备Id有误 **错误信息**
-The specified deviceId is not found. +The specified device ID is not found. **错误描述**
-调用接口时,传入的设备id有误。 +调用distributedBundle模块相关接口时,传入的设备id有误。 **可能原因**
1. 传入的deviceId拼写有误。 @@ -112,10 +112,10 @@ The specified deviceId is not found. ## 17700010 文件解析失败导致应用安装失败 **错误信息**
-Failed to install the hap since the hap fails to be parsed. +Failed to install the HAP because the HAP fails to be parsed. **错误描述**
-文件解析失败导致应用安装失败。 +调用installer模块中的install接口时,传入的HAP包解析失败。 **可能原因**
1. hap包的格式不是zip格式。 @@ -130,10 +130,10 @@ Failed to install the hap since the hap fails to be parsed. ## 17700011 签名校验失败导致应用安装失败 **错误信息**
-Failed to install the hap since the hap signature fails to be verified. +Failed to install the HAP because the HAP signature fails to be verified. **错误描述**
-签名校验失败导致应用安装失败。 +调用installer模块中的install接口时,签名校验失败导致应用安装失败。 **可能原因**
@@ -150,10 +150,10 @@ Failed to install the hap since the hap signature fails to be verified. ## 17700012 安装包路径无效或者文件过大导致应用安装失败 **错误信息**
-Failed to install the hap since the path of the hap is invalid or too large size. +Failed to install the HAP because the HAP path is invalid or the HAP is too large. **错误描述**
-安装包路径无效或者文件过大导致应用安装失败。 +调用installer模块中的install接口时,安装包路径无效或者文件过大导致应用安装失败。 **可能原因**
1. 输入错误,hap包的文件路径不存在。 @@ -168,10 +168,10 @@ Failed to install the hap since the path of the hap is invalid or too large size ## 17700015 多个hap包配置信息不同导致应用安装失败 **错误信息**
-Failed to install haps since the configuration information of multi haps is inconsistent. +Failed to install the HAPs because they have different configuration information. **错误描述**
-多个hap包配置信息不同导致应用安装失败。 +调用installer模块中的install接口时,多个hap包配置信息不同导致应用安装失败。 **可能原因**
多个hap包中配置文件app下面的字段不一致。 @@ -182,10 +182,10 @@ Failed to install haps since the configuration information of multi haps is inco ## 17700016 系统磁盘空间不足导致应用安装失败 **错误信息**
-Failed to install the hap since the system disk space is insufficient. +Failed to install the HAP because of insufficient system disk space. **错误描述**
-系统磁盘空间不足导致应用安装失败。 +调用installer模块中的install接口时,系统磁盘空间不足导致应用安装失败。 **可能原因**
系统空间不足。 @@ -196,10 +196,10 @@ Failed to install the hap since the system disk space is insufficient. ## 17700017 新安装的应用版本号低于已安装的版本号导致应用安装失败 **错误信息**
-Failed to install the hap since the version of the newly installed hap is too early. +Failed to install the HAP since the version of the HAP to install is too early. **错误描述**
-新安装的应用版本号低于已安装的版本号导致应用安装失败。 +调用installer模块中的install接口时,新安装的应用版本号低于已安装的版本号导致应用安装失败。 **可能原因**
新安装的应用版本号低于已安装的版本号。 @@ -213,7 +213,7 @@ Failed to install the hap since the version of the newly installed hap is too ea The preinstalled app cannot be uninstalled. **错误描述**
-预置应用无法卸载。 +调用installer模块中的uninstall接口卸载预置应用时,无法卸载。 **可能原因**
1. 传入的bundleName拼写有误。 @@ -229,7 +229,7 @@ The preinstalled app cannot be uninstalled. The specified uid is invalid. **错误描述**
-指定的uid无效。 +调用bundleManager模块中的getBundleNameByUid接口时,指定的uid无效。 **可能原因**
1. 传入的uid拼写有误。 @@ -245,7 +245,7 @@ The specified uid is invalid. The input source file is invalid. **错误描述**
-输入的待解析源文件无效。 +调用bundleManager模块中的getBundleArchiveInfo接口时,传入的HAP路径无效。 **可能原因**
1. 待解析的源文件不存在。 @@ -261,7 +261,7 @@ The input source file is invalid. The specified default app does not exist. **错误描述**
-指定的默认应用不存在。 +调用defaultAppManager模块中的getDefaultApplication接口时,指定的默认应用不存在。 **可能原因**
设备没有设置对应的默认应用。 @@ -272,10 +272,10 @@ The specified default app does not exist. ## 17700024 没有相应的配置文件 **错误信息**
-Failed to get profile since no profile in the hap. +Failed to get the profile because there is no profile in the HAP. **错误描述**
-没有相应的配置文件。 +调用查询profile文件的相关接口时,没有相应的配置文件。 **可能原因**
1. 输入的metadata name在配置文件中不存在。 @@ -291,7 +291,7 @@ Failed to get profile since no profile in the hap. The specified type is invalid. **错误描述**
-输入的type无效。 +调用defaultAppManager模块的相关接口时,输入的type无效。 **可能原因**
1. 输入的type拼写有误。 @@ -306,7 +306,7 @@ The specified type is invalid. The specified bundle is disabled. **错误描述**
-指定应用被禁用。 +当调用查询应用的相关信息接口时,指定应用被禁用。 **可能原因**
设备上对应的应用已经被禁用,无法查询。 @@ -320,7 +320,7 @@ The specified bundle is disabled. The distributed service is not running. **错误描述**
-分布式服务未启动。 +当调用distributedBundle模块的相关接口时,分布式服务未启动。 **可能原因**
设备未组网。 @@ -330,10 +330,10 @@ The distributed service is not running. ## 17700028 输入的ability与type不匹配 **错误信息**
-The distributed service is not running. +The ability does not match the type. **错误描述**
-输入的ability与type不匹配。 +当调用defaultAppManager模块中的setDefaultApplication接口时,输入的ability与type不匹配。 **可能原因**
输入的ability和type拼写有误。 @@ -347,7 +347,7 @@ The distributed service is not running. The specified ability is disabled. **错误描述**
-指定的ability被禁用。 +当调用查询ability相关信息的接口时,指定的ability被禁用。 **可能原因**
指定的ability被禁用。 @@ -358,10 +358,10 @@ The specified ability is disabled. ## 17700030 指定的应用不支持清除缓存文件 **错误信息**
-The specified bundle does not support clearing cache files. +The specified bundle does not support clearing of cache files. **错误描述**
-指定的应用不支持清除缓存文件。 +当调用bundleManager模块中的cleanBundleCacheFiles接口时,指定的应用不支持清除缓存文件。 **可能原因**
指定的应用为系统应用且在签名证书中配置了不能清除数据(AllowAppDataNotCleared)的字段。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-data_object.md b/zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errorcode-distributed-data_object.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-distributed-dataObject.md diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md index 4ff21bd81fa914f96f5836dd73da6abd1b959643..e47bdda1481e9cae8480968f9379a0ebcc9e513f 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-distributedKVStore.md @@ -2,65 +2,81 @@ ## 15100001 超过最大订阅数量 -### 错误信息 +**错误信息** + Over max subscribe limits. -### 错误描述 +**错误描述** + 该错误码表示在调用数据库变化订阅on接口时,订阅数量已超过最大限制。 -### 可能原因 +**可能原因** + 在调用订阅数据库变化接口时,对数据库的订阅数量已超过最大限制。 -### 处理步骤 +**处理步骤** + 取消对数据库的部分订阅后,再次尝试订阅。 ## 15100002 打开已有数据库时参数配置发生变化 -### 错误信息 +**错误信息** + Open existed database with changed options. -### 错误描述 +**错误描述** + 该错误码表示在调用getKVStore接口打开已创建的数据库时,options配置参数发生变化。 -### 可能原因 +**可能原因** + 打开已创建的数据库时,options参数配置发生了变化,可能原因如下: 1. 期望新建数据库时,使用了已创建过的数据库名称storeId。 2. 期望改变已创建数据库的options参数配置。 -### 处理步骤 +**处理步骤** + 1. 新建数据库前,请检查数据库名称storeId不与已创建数据库的storeId重名。 2. 期望改变已创建数据库的options参数配置时,当前不支持该操作,请自行删除数据库后使用新的options参数重新创建。 ## 15100003 数据库损坏 -### 错误信息 +**错误信息** + Database corrupted. -### 错误描述 +**错误描述** + 该错误码表示在调用数据库增、删、查、数据同步等接口时,数据库已损坏。 -### 可能原因 +**可能原因** + 调用数据库增、删、查、数据同步等接口操作数据库时,数据库文件已损坏。 -### 处理步骤 +**处理步骤** + 1. 如果之前备份过数据库,可尝试使用已备份的数据库文件恢复数据库。 2. 如果之前没有备份过数据库,可尝试删除数据库后重新创建。 ## 15100004 未找到相关数据 -### 错误信息 +**错误信息** + Not found. -### 错误描述 +**错误描述** + 该错误码表示在调用数据库deleteKVStore、delete、deleteBatch、get等接口时,未找到相关数据。 -### 可能原因 +**可能原因** + 在调用删除数据库、数据查询、数据删除等接口时未找到相关数据,可能原因如下。 1. 删除数据库操作时,数据库不存在或已删除。 2. 数据库数据查询操作时,相关数据不存在或已删除。 3. 数据库数据删除操作时,相关数据不存在或已删除。 -### 处理步骤 +**处理步骤** + 1. 在删除数据库操作前,请检查数据库名称是否正确或是否重复删除。 2. 在数据库数据查询操作前,请检查查询关键字是否正确。 3. 在数据库数据删除操作前,请检查删除关键字是否正确或是否重复删除。 @@ -68,29 +84,37 @@ Not found. ## 15100005 不支持当前操作 -### 错误信息 +**错误信息** + Not support the operation. -### 错误描述 +**错误描述** + 该错误码表示在调用数据库backup、restore等接口时,当前数据库不支持该操作。 -### 可能原因 +**可能原因** + 在调用数据库备份、恢复等接口时,当前数据库不支持该操作。 -### 处理步骤 +**处理步骤** + 检查当前数据库是否支持备份、恢复操作。 ## 15100006 数据库或查询结果集已关闭 -### 错误信息 +**错误信息** + Database or result set already closed. -### 错误描述 +**错误描述** + 该错误码表示在调用数据库或查询结果集相关接口时,数据库或查询结果集为关闭状态。 -### 可能原因 +**可能原因** + 在数据库或查询结果集操作前,已经手动关闭了数据库或查询结果集。 -### 处理步骤 +**处理步骤** + 1. 在数据库相关操作前,请重新打开数据库之后再重试当前操作。 -2. 在查询结果集相关操作前,请重新查询获取结果集之后再重试当前操作。 +2. 在查询结果集相关操作前,请重新查询获取结果集之后再重试当前操作。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-EnterpriseDeviceManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errorcode-EnterpriseDeviceManager.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-enterpriseDeviceManager.md diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md b/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md index 397279658180123ee8d4b8989810ff549e29b6bd..3ed4da85c694859065392150c442d49fa7dcab10 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-faultlogger.md @@ -1,4 +1,4 @@ -# faultlogger 错误码 +# Faultlogger 错误码 ## 10600001 服务未启动或故障 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md index 406191299dbf529e845b5b54766efe5423c46be9..d7222587ff651d569577e796449b74a011ca34ef 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-huks.md @@ -1,4 +1,4 @@ -# huks错误码 +# HUKS错误码 ## 12000001 该子功能不支持(特性) diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-inputmethod-framework.md b/zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-inputmethod-framework.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-inputmethod-framework.md diff --git a/zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md b/zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errorcodes-multimodalinput.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-multimodalinput.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-reminderAgentManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md similarity index 95% rename from zh-cn/application-dev/reference/errorcodes/errcode-reminderAgentManager.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md index 6087eb0f9bd03b8befc8d516ad174d58eaa61854..faeac6fddca8d11815797258e7a44a1fa9a87edd 100644 --- a/zh-cn/application-dev/reference/errorcodes/errcode-reminderAgentManager.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md @@ -4,7 +4,7 @@ **错误信息** -Notification does not enable. +Notification is not enabled. **错误描述** @@ -63,7 +63,7 @@ The reminder does not exist. **错误信息** -The package name does not exist. +The bundle name does not exist. **错误描述** diff --git a/zh-cn/application-dev/reference/errorcodes/errorcodes-request.md b/zh-cn/application-dev/reference/errorcodes/errorcode-request.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errorcodes-request.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-request.md diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-system-parameterV9.md b/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md similarity index 93% rename from zh-cn/application-dev/reference/errorcodes/errcode-system-parameterV9.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md index effa914b588691613a686964e134ec2f400d4cc6..58b8a3e1340479efa4dae169c9f0c7e787654d29 100644 --- a/zh-cn/application-dev/reference/errorcodes/errcode-system-parameterV9.md +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-system-parameterV9.md @@ -1,74 +1,74 @@ -# 系统参数错误码 - -## 14700101 系统参数查找失败 - -**错误信息** - -System parameter can not be found. - -**错误描述** - -workspace中没有相应节点,或者没有设置key值,系统会报此错误码。 - -**可能原因** - -参数没有设置,或设置失败。 - -**处理步骤** - -设置合法的参数。 - -## 14700102 系统参数值无效 - -**错误信息** - -System parameter value is invalid. - -**错误描述** - -当系统参数value值为空字符、非法字符或长度超出范围时,系统会报此错误码。 - -**可能原因** - -接口的参数值超出设置范围或者含有特殊字符,比如,"const..param.xxx"。 - -**处理步骤** - -修改value值为合法字符串。 - -## 14700103 系统权限操作权限被拒绝 - -**错误信息** - -System permission operation permission denied. - -**错误描述** - -系统参数没有DAC或MAC权限时,系统会报此错误码。 - -**可能原因** - -没有配置DAC或MAC权限。 - -**处理步骤** - -添加相应的DAC或MAC权限。 - -## 14700104 系统内部错误,包括内存不足,死锁等 - -**错误信息** - -System internal error including out of memory, deadlock etc. - -**错误描述** - -当试图修改const属性参数、socket连接失败、内存拷贝失败等错误时,系统会报此错误码。 - -**可能原因** - -当socket连接异常,添加节点或获取节点失败。 - -**处理步骤** - -1. 内存不足,需要分析整个进程的内存占用情况,是否有内存泄露的情况。 +# 系统参数错误码 + +## 14700101 系统参数查找失败 + +**错误信息** + +System parameter can not be found. + +**错误描述** + +workspace中没有相应节点,或者没有设置key值,系统会报此错误码。 + +**可能原因** + +参数没有设置,或设置失败。 + +**处理步骤** + +设置合法的参数。 + +## 14700102 系统参数值无效 + +**错误信息** + +System parameter value is invalid. + +**错误描述** + +当系统参数value值为空字符、非法字符或长度超出范围时,系统会报此错误码。 + +**可能原因** + +接口的参数值超出设置范围或者含有特殊字符,比如,"const..param.xxx"。 + +**处理步骤** + +修改value值为合法字符串。 + +## 14700103 系统权限操作权限被拒绝 + +**错误信息** + +System permission operation permission denied. + +**错误描述** + +系统参数没有DAC或MAC权限时,系统会报此错误码。 + +**可能原因** + +没有配置DAC或MAC权限。 + +**处理步骤** + +添加相应的DAC或MAC权限。 + +## 14700104 系统内部错误,包括内存不足,死锁等 + +**错误信息** + +System internal error including out of memory, deadlock etc. + +**错误描述** + +当试图修改const属性参数、socket连接失败、内存拷贝失败等错误时,系统会报此错误码。 + +**可能原因** + +当socket连接异常,添加节点或获取节点失败。 + +**处理步骤** + +1. 内存不足,需要分析整个进程的内存占用情况,是否有内存泄露的情况。 2. 死锁,多出现在多线程场景下,需要通过错误堆栈查看是否有死锁的场景。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md b/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md new file mode 100644 index 0000000000000000000000000000000000000000..a063b9df2ae5245aeb712e9a4b927d093c9d9f59 --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-universal.md @@ -0,0 +1,73 @@ +# 通用错误码 + +## 201 权限校验失败 + +**错误信息** + +Permission verification failed, usually the result returned by VerifyAccessToken. + +**错误描述** + +权限校验失败,应用无权限使用该API,需要申请权限。 + +**可能原因** + +该错误码表示权限校验失败,通常为没有权限,却调用了需要权限的API。 + +**处理步骤** + +请检查是否有调用API的权限。 + +## 202 系统API权限校验失败 + +**错误信息** + +Permission verification failed, application which is not a system application uses system API. + +**错误描述** + +权限校验失败,非系统应用使用了系统API。 + +**可能原因** + +非系统应用,使用了系统API,请校验是否使用了系统API。 + +**处理步骤** + +请检查是否调用了系统API,并且去掉。 + +## 401 参数检查失败 + +**错误信息** + +BusinessError 401: Parameter error. The type of "${参数名}" must be ${正确的类型}[or ${其他正确的输入}]. + +**错误描述** + +参数检查失败,包括必选参数没有传入,参数类型错误。 + +**可能原因** + +必选参数没有传入,或者参数类型错误。 + +**处理步骤** + +请检查必选参数是否没有传入,或者传的参数类型是否错误。 + +## 801 该设备不支持此API + +**错误信息** + +BusinessError 801: Capability not supported. function ${函数名} can not work correctly due to limited device capabilities. + +**错误描述** + +该设备不支持此API,通常用于在设备已支持该SysCap时,针对其少量的API的支持处理。 + +**可能原因** + +该设备不支持此API。 + +**处理步骤** + +请检查设备是否支持使用的API。 diff --git a/zh-cn/application-dev/reference/errorcodes/errorcode-update.md b/zh-cn/application-dev/reference/errorcodes/errorcode-update.md new file mode 100644 index 0000000000000000000000000000000000000000..22ae27375a550ebc47d1ddadd2d9ea843254907c --- /dev/null +++ b/zh-cn/application-dev/reference/errorcodes/errorcode-update.md @@ -0,0 +1,20 @@ +# 升级错误码 + +## 11500104 IPC通信异常 + +**错误信息** + +BusinessError 11500104: IPC error. + +**错误描述** + +调用过程中出现异常。 + +**可能原因** + +IPC 调用过程中出现异常,接口调用失败。 + +**处理步骤** + +1. 检查升级 SA 是否启动,若未启动请启动升级 SA。 +2. 检查 IPC 数据转换是否正常,若异常请检查转换流程。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/errorcodes/errcode-usb.md b/zh-cn/application-dev/reference/errorcodes/errorcode-usb.md similarity index 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-usb.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-usb.md diff --git a/zh-cn/application-dev/security/app-provision-structure.md b/zh-cn/application-dev/security/app-provision-structure.md index fe74ba5402db55668d8a8b6e54c9f43907921135..a0bc15058289791d98d02b48bb1ff499d79e5faf 100644 --- a/zh-cn/application-dev/security/app-provision-structure.md +++ b/zh-cn/application-dev/security/app-provision-structure.md @@ -67,7 +67,7 @@ HarmonyAppProvision文件示例: | distribution-certificate | 表示[发布证书](hapsigntool-guidelines.md)的信息。 | 数值 | 当type属性为release时,该标签必选;否则,该标签可选。 | 不可缺省 | | bundle-name | 表示应用程序的包名。 | 字符串 | 必选 | 不可缺省 | | apl | 表示应用程序的[apl级别](accesstoken-overview.md),系统预定义的apl包括:normal、system_basic和system_core。 | 字符串 | 必选 | 不可缺省 | -| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用)。 | 字符串 | 必选 | 不可缺省 | +| app-feature | 表示应用程序的类型,系统预定义的app-feature包括hos_system_app (系统应用)和hos_normal_app(普通应用)。只有系统应用才允许调用系统API,普通应用调用系统API可能会调用失败或运行异常。 | 字符串 | 必选 | 不可缺省 | ### acls对象内部结构 @@ -79,7 +79,7 @@ acls对象包含已授权的[acl权限](accesstoken-overview.md)。需要指出 | allowed-acls | 表示已授权的[acl权限](accesstoken-overview.md)列表。 | 字符串数组 | 可选 | 不可缺省 | ### permissions对象内部结构 -permissions对象包含允许使用的受限敏感权限。不同于acls对象,permissions对象中的权限仅代表应用允许使用该敏感权限,权限最终由用户运行时授权。需要指出的是,开发者仍然需要在应用包配置文件([config.json](package-structure.md))将permissions权限信息填写到reqPermissions属性中。 +permissions对象包含允许使用的受限敏感权限。不同于acls对象,permissions对象中的权限仅代表应用允许使用该敏感权限,权限最终由用户运行时授权。需要指出的是,开发者仍然需要在应用包配置文件([config.json](../quick-start/package-structure.md))将permissions权限信息填写到reqPermissions属性中。 表5 permissions对象的内部结构 | 属性名称 | 含义 | 数据类型 | 是否必选 | 是否可缺省 | diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index 53e9dd5e8656813eebb9c420e92afb6fc5e1e8d1..03b3ea481ba6732cf777300b0c70b311714ffb5f 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -94,9 +94,10 @@ | ohos.permission.MANAGE_SECURE_SETTINGS | system_basic | system_grant | TRUE | 允许应用修改安全类系统设置。 | | ohos.permission.READ_DFX_SYSEVENT | system_basic | system_grant | FALSE | 允许获取所有应用账号信息。 | | ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN | system_core | system_grant | TRUE | 允许应用激活设备管理员应用。 | -| ohos.permission.SET_ENTERPRISE_INFO | system_basic | system_grant | FALSE | 允许设备管理员应用设置企业信息。 | -| ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT | system_basic | system_grant | FALSE | 允许设备管理员应用订阅管理事件。 | -| ohos.permission.ENTERPRISE_SET_DATETIME | system_basic | system_grant | FALSE | 允许设备管理员应用设置系统时间。 | +| ohos.permission.SET_ENTERPRISE_INFO | system_basic | system_grant | TRUE | 允许设备管理员应用设置企业信息。 | +| ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT | system_basic | system_grant | TRUE | 允许设备管理员应用订阅管理事件。 | +| ohos.permission.ENTERPRISE_SET_DATETIME | system_basic | system_grant | TRUE | 允许设备管理员应用设置系统时间。 | +| ohos.permission.ENTERPRISE_GET_DEVICE_INFO | system_basic | system_grant | TRUE | 允许设备管理员读取设备信息。 | | ohos.permission.NFC_TAG | normal | system_grant | FALSE | 允许应用读取Tag卡片。 | | ohos.permission.NFC_CARD_EMULATION | normal | system_grant | FALSE | 允许应用实现卡模拟功能。 | | ohos.permission.PERMISSION_USED_STATS | system_basic | system_grant | TRUE | 允许系统应用访问权限使用记录。 | diff --git a/zh-cn/application-dev/security/userauth-guidelines.md b/zh-cn/application-dev/security/userauth-guidelines.md index abf265ad1af39ce6f9a053faf9d1be652b3073a7..f412e9c140fc60bcc7eaf1e7df4a5f83440e6061 100644 --- a/zh-cn/application-dev/security/userauth-guidelines.md +++ b/zh-cn/application-dev/security/userauth-guidelines.md @@ -9,18 +9,18 @@ ## 接口说明 -userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证能力、发起认证和取消认证等,用户可以使用人脸、指纹等生物特征信息进行认证操作。具体接口说明可以查阅[API参考](../reference/apis/js-apis-useriam-userauth.md)。 +userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证能力、发起认证和取消认证等,用户可以使用人脸、指纹等生物特征信息进行认证操作。具体接口说明可以查阅[API参考文档](../reference/apis/js-apis-useriam-userauth.md)。 -在执行认证前,需要指认证类型和认证等级,查询设备是否支持该认证能力。如果不支持,需要考虑使用其他认证能力。 +在执行认证前,需要指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),查询设备是否支持该认证能力。 **表1** 用户认证开放能力列表 -| 接口名称 | 功能描述 | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| getVersion() : number | 获取认证对象的版本信息。 | -| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel) : number | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | -| auth(challenge: Uint8Array, authType: UserAuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array | 执行用户认证,使用callback方式作为异步方法返回结果。 | -| cancelAuth(contextID : Uint8Array) : number | 通过contextID取消本次认证操作。 | +| 接口名称 | 功能描述 | +| ---------- | ----------------------- | +| getVersion() : number | 获取认证对象的版本信息。 | +| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | 根据指定的认证类型、认证等级,检测当前设备是否支持相应的认证能力。 | +| start: void | 执行用户认证。 | +| cancel: void | 取消本次认证操作。 | ## 获取认证对象的版本信息 @@ -28,16 +28,17 @@ userIAM_userAuth模块提供了用户认证的相关方法,包括查询认证 1. 申请权限。调用getVersion接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md)。 -2. 获取认证对象。 - -3. 调用getVersion接口获取版本信息。 +2. 调用getVersion接口获取版本信息。 ```js -import userIAM_userAuth from '@ohos.userIAM.userAuth' +import userIAM_userAuth from '@ohos.userIAM.userAuth'; -let auth = new userIAM_userAuth.UserAuth(); -let version = auth.getVersion(); -console.info("auth version = " + version); +try { + let version = userIAM_userAuth.getVersion(); + console.info("auth version = " + version); +} catch (error) { + console.info("get version failed, error = " + error); +} ``` ## 查询当前设备是否支持相应的认证能力 @@ -46,63 +47,139 @@ console.info("auth version = " + version); 1. 申请权限。调用getAvailableStatus接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md)。 -2. 获取认证对象。 +2. 指定[认证类型](../reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](../reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),调用getAvailableStatus接口查询当前的设备是否支持相应的认证能力。 + +```js +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +try { + userIAM_userAuth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); + console.info("current auth trust level is supported"); +} catch (error) { + console.info("current auth trust level is not supported, error = " + error); +} +``` + +## 执行认证操作并请阅认证结果 + +### 开发步骤 + +1. 申请权限。调用auth接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md)。 + +2. 指定challenge、[认证类型](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 + +3. 调用on接口订阅认证结果。 -3. 指定认证类型和认证等级,调用getAvailableStatus接口查询当前的设备是否支持相应的认证能力。 +4. 调用start接口发起认证,通过callback回调返回认证结果。 + +5. 调用off接口取消订阅认证结果。 ```js -import userIAM_userAuth from '@ohos.userIAM.userAuth' - -let auth = new userIAM_userAuth.UserAuth(); -let checkCode = auth.getAvailableStatus(userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1); -if (checkCode == userIAM_userAuth.ResultCode.SUCCESS) { - console.info("check auth support success"); - // 此处添加支持相应认证能力的逻辑 -} else { - console.error("check auth support fail, code = " + checkCode); - // 此处添加不支持相应认证能力的逻辑 +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); +let authType = userIAM_userAuth.UserAuthType.FACE; +let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; +let auth; +try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); +} catch (error) { + console.log("get auth instance failed" + error); +} + +try { + // 订阅认证结果 + auth.on("result", { + callback: (result: userIAM_userAuth.AuthResultInfo) => { + console.log("authV9 result " + result.result); + console.log("authV9 token " + result.token); + console.log("authV9 remainAttempts " + result.remainAttempts); + console.log("authV9 lockoutDuration " + result.lockoutDuration); + } + }); + console.log("subscribe authentication event success"); +} catch (error) { + console.log("subscribe authentication event failed " + error); +} + +try { + auth.start(); + console.info("authV9 start auth success"); +} catch (error) { + console.info("authV9 start auth failed, error = " + error); +} + +// 取消订阅认证结果 +try { + auth.off("result"); + console.info("cancel subscribe authentication event success"); +} catch (error) { + console.info("cancel subscribe authentication event failed, error = " + error); } ``` -## 执行认证操作 +## 执行认证操作并订阅认证过程中的提示信息 ### 开发步骤 1. 申请权限。调用auth接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md)。 -2. 获取认证对象。 +2. 指定challenge、[认证类型](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 + +3. 调用on接口订阅认证过程中的提示信息。 -3. 指定认证类型和认证等级,调用auth接口发起认证,通过onResult回调返回认证结果,通过onAcquireInfo回调返回认证过程中的提示信息。 +4. 调用start接口发起认证,通过callback回调返回认证过程中的提示信息。 + +5. 调用off接口取消订阅认证过程中的提示信息。 ```js -import userIAM_userAuth from '@ohos.userIAM.userAuth' - -let auth = new userIAM_userAuth.UserAuth(); -auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - try { - console.info("auth onResult result = " + result); - console.info("auth onResult extraInfo = " + JSON.stringify(extraInfo)); - if (result == userIAM_userAuth.ResultCode.SUCCESS) { - // 此处添加认证成功逻辑 - } else { - // 此处添加认证失败逻辑 +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); +let authType = userIAM_userAuth.UserAuthType.FACE; +let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; +let auth; +try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); +} catch (error) { + console.log("get auth instance failed" + error); +} + +try { + // 订阅认证过程中的提示信息 + auth.on("tip", { + callback : (result : userIAM_userAuth.TipInfo) => { + switch (result.tip) { + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_BRIGHT: + // do something; + case userIAM_userAuth.FaceTips.FACE_AUTH_TIP_TOO_DARK: + // do something; + default: + // do others } - } catch (e) { - console.info("auth onResult error = " + e); - } - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - try { - console.info("auth onAcquireInfo module = " + module); - console.info("auth onAcquireInfo acquire = " + acquire); - console.info("auth onAcquireInfo extraInfo = " + JSON.stringify(extraInfo)); - } catch (e) { - console.info("auth onAcquireInfo error = " + e); } - } -}); + }); + console.log("subscribe authentication event success"); +} catch (error) { + console.log("subscribe authentication event failed " + error); +} + +try { + auth.start(); + console.info("authV9 start auth success"); +} catch (error) { + console.info("authV9 start auth failed, error = " + error); +} + +// 取消订阅认证结果 +try { + auth.off("tip"); + console.info("cancel subscribe tip information success"); +} catch (error) { + console.info("cancel subscribe tip information failed, error = " + error); +} ``` ## 认证过程中取消认证 @@ -111,30 +188,37 @@ auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLe 1. 申请权限。调用cancelAuth接口,需要在module.json5文件的requestPermissions对象中配置ohos.permission.ACCESS_BIOMETRIC权限。更多配置信息[应用包结构配置文件的说明](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/stage-structure.md)。 -2. 获取认证对象。 +2. 指定challenge、[认证类型](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#userauthtype8)和[认证等级](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-useriam-userauth.md#authtrustlevel8),获取认证对象。 -3. 指定认证类型和认证等级,调用auth接口发起认证,通过onResult回调返回认证结果,通过onAcquireInfo回调返回认证过程中的提示信息。 +3. 调用start接口发起认证。 -4. 通过调用cancelAuth接口取消本次认证。 +4. 通过调用cancel接口取消本次认证。 ```js -import userIAM_userAuth from '@ohos.userIAM.userAuth' - -let auth = new userIAM_userAuth.UserAuth(); -// contextId通过auth接口获取 -let contextId = auth.auth(null, userIAM_userAuth.UserAuthType.FACE, userIAM_userAuth.AuthTrustLevel.ATL1, { - onResult: (result, extraInfo) => { - console.info("auth onResult result = " + result); - }, - - onAcquireInfo: (module, acquire, extraInfo) => { - console.info("auth onAcquireInfo module = " + module); - } -}); -let cancelCode = auth.cancelAuth(contextId); -if (cancelCode == userIAM_userAuth.ResultCode.SUCCESS) { +import userIAM_userAuth from '@ohos.userIAM.userAuth'; + +let challenge = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); +let authType = userIAM_userAuth.UserAuthType.FACE; +let authTrustLevel = userIAM_userAuth.AuthTrustLevel.ATL1; +let auth; +try { + auth = userIAM_userAuth.getAuthInstance(challenge, authType, authTrustLevel); + console.log("get auth instance success"); +} catch (error) { + console.log("get auth instance failed" + error); +} + +try { + auth.start(); + console.info("authV9 start auth success"); +} catch (error) { + console.info("authV9 start auth failed, error = " + error); +} + +try { + auth.cancel(); console.info("cancel auth success"); -} else { - console.error("cancel auth fail"); +} catch (error) { + console.info("cancel auth failed, error = " + error); } ``` diff --git a/zh-cn/application-dev/security/userauth-overview.md b/zh-cn/application-dev/security/userauth-overview.md index 8cd2ae976f17d3466b02eefb3ad15562db6e5a4b..7901bddc906a14da43ebfbb222dec6b3df637b87 100644 --- a/zh-cn/application-dev/security/userauth-overview.md +++ b/zh-cn/application-dev/security/userauth-overview.md @@ -1,8 +1,10 @@ # 用户认证开发概述 -提供用户认证能力,可应用于设备解锁、支付、应用登录等身份认证场景。 +## 用户认证模块的定义 -当前用户认证提供人脸识别和指纹识别能力,设备具备哪种识别能力,取决于设备的硬件能力和技术实现。 +用户认证模块提供用户认证能力,对应用开发者而言,可使用该模块进行用户身份认证,用于设备解锁、支付、应用登录等身份认证场景。 + +当前用户认证提供人脸识别和指纹识别能力,设备具备哪种识别能力,取决于当前设备的硬件能力和技术实现。 ## 基本概念 diff --git a/zh-cn/application-dev/task-management/continuous-task-dev-guide.md b/zh-cn/application-dev/task-management/continuous-task-dev-guide.md index 9d50c74836d61261433ced3a5a6b30e10163f446..b6e1859e17ddf15c6056de16bab6b148a520900c 100644 --- a/zh-cn/application-dev/task-management/continuous-task-dev-guide.md +++ b/zh-cn/application-dev/task-management/continuous-task-dev-guide.md @@ -19,17 +19,17 @@ **表2** 后台模式类型 -| 参数名 | id值 | 描述 | 配置项 | -| ----------------------- | ---- | -------------- | --------------------- | -| DATA_TRANSFER | 1 | 数据传输 | dataTransfer | -| AUDIO_PLAYBACK | 2 | 音频播放 | audioPlayback | -| AUDIO_RECORDING | 3 | 录音 | audioRecording | -| LOCATION | 4 | 定位导航 | location | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | bluetoothInteraction | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | multiDeviceConnection | -| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | wifiInteraction | -| VOIP | 8 | 音视频通话(系统保留) | voip | -| TASK_KEEPING | 9 | 计算任务(仅供特定设备使用) | taskKeeping | +| 参数名 | 描述 | 配置项 | +| ----------------------- | -------------- | --------------------- | +| DATA_TRANSFER | 数据传输 | dataTransfer | +| AUDIO_PLAYBACK | 音频播放 | audioPlayback | +| AUDIO_RECORDING | 录音 | audioRecording | +| LOCATION | 定位导航 | location | +| BLUETOOTH_INTERACTION | 蓝牙相关 | bluetoothInteraction | +| MULTI_DEVICE_CONNECTION | 多设备互联 | multiDeviceConnection | +| WIFI_INTERACTION | WLAN相关(系统保留) | wifiInteraction | +| VOIP | 音视频通话(系统保留) | voip | +| TASK_KEEPING | 计算任务(仅供特定设备使用) | taskKeeping | ## 开发步骤 diff --git a/zh-cn/application-dev/task-management/transient-task-dev-guide.md b/zh-cn/application-dev/task-management/transient-task-dev-guide.md index 86ca50c4f7c8c8a3d0d606280ac2dd520e941531..18c3030bfe2fec8941c386c76a1078da52394cf9 100644 --- a/zh-cn/application-dev/task-management/transient-task-dev-guide.md +++ b/zh-cn/application-dev/task-management/transient-task-dev-guide.md @@ -18,7 +18,7 @@ | 接口名 | 描述 | | ---------------------------------------- | ---------------------------------------- | -| requestSuspendDelay(reason: string, callback: Callback<void>): [DelaySuspendInfo](../reference/apis/js-apis-backgroundTaskManager.md#delaysuspendinfo) | 后台应用申请延迟挂起。
延迟挂起时间一般情况下默认值为180000,低电量时默认值为60000。 | +| requestSuspendDelay(reason: string, callback: Callback<void>): [DelaySuspendInfo](../reference/apis/js-apis-backgroundTaskManager.md#delaysuspendinfo) | 后台应用申请延迟挂起。
延迟挂起时间一般情况下默认值为3分钟,低电量时默认值为1分钟。 | | getRemainingDelayTime(requestId: number): Promise<number> | 获取应用程序进入挂起状态前的剩余时间。
使用Promise形式返回。 | | cancelSuspendDelay(requestId: number): void | 取消延迟挂起。 | diff --git a/zh-cn/application-dev/ui/figures/CoreSpec_figures_state-mgmt-overview.png b/zh-cn/application-dev/ui/figures/CoreSpec_figures_state-mgmt-overview.png deleted file mode 100644 index 37ae5324808a0ab50f210907ca65a09e4456a371..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/CoreSpec_figures_state-mgmt-overview.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/column.png b/zh-cn/application-dev/ui/figures/column.png deleted file mode 100644 index 27321b5a24798d6d423cbf76eab974f4ebc2d0fb..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/column.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/row.png b/zh-cn/application-dev/ui/figures/row.png deleted file mode 100644 index d7fced9fe4a9fc618dee88ae95cc2f04a34bb3c3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/row.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png deleted file mode 100644 index 3be38a7df454954c455b44bb1fbb6b2158be3785..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001148858818.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png deleted file mode 100644 index 57d18b7b7d9333d85824623169fc2f3943568214..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001158896538.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png deleted file mode 100644 index e53f6d7e1c8b3060ae000d78555ea0b33ffc97bf..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001167746622.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png deleted file mode 100644 index 205d18f50424811f04dcecc1b6a95c52530c6527..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168059158.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png deleted file mode 100644 index 8c145a2fe59fef14f46b8da08c60b705d6fa366a..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168728272.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png deleted file mode 100644 index e2b4a1b1ce009bec2c798eb1c353ebc7790ac9d9..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168888822.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png deleted file mode 100644 index adb255e05d2f54161e79e0f0a21ddc6b04552793..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001168956332.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174104404.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174104404.png deleted file mode 100644 index e370a44cf043fc34bd8891f57faad2cd2ca05707..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174104404.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174264376.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174264376.png deleted file mode 100644 index dfcb0c5e259b3f8d7375c21712249c1e847edd67..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174264376.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174422914.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174422914.png deleted file mode 100644 index bc28f5056c679e189543c8ad6fba67fb56db7655..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174422914.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582864.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582864.png deleted file mode 100644 index b54dbc2391d1a8f16312dd02dc3d65a35ea2626f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582864.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582866.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582866.png deleted file mode 100644 index 56d32d4cd371c5374b133cb81c9c077aaf7b110d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001174582866.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001182200571.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001182200571.png deleted file mode 100644 index a1bd96de03ca927b9d168cdbe99fa7f3f96472f3..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001182200571.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001189744672.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001189744672.png deleted file mode 100644 index 926b023516156e8daa94afee4b9d2769d0e2547e..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001189744672.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190463780.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190463780.png deleted file mode 100644 index 30b7d2bb30c9f9a2cd8b3419285267b6be4f0143..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190463780.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190466492.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190466492.png deleted file mode 100644 index aebc1b5e3afbc74a161bdc481b1578ef79105a87..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001190466492.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png deleted file mode 100644 index 60160d18d66fef9a5b65a4c5675fe91873e95582..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001204537865.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png deleted file mode 100644 index 2782851bba344dd8afc82943603e52ab6b452e0a..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001214595111.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215645452.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215645452.png deleted file mode 100644 index 21478ddee0ac2a56230eb67406ba7ddb4600ee74..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215645452.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215796030.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215796030.png deleted file mode 100644 index a449a54d3ebbb0fe35754a0b6191e090a9f57fb6..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215796030.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215965420.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215965420.png deleted file mode 100644 index 69ab2b53dc50fbe5f146b336993f86bf1e4a5f24..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001215965420.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217236574.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217236574.png deleted file mode 100644 index 0b45eda696b180bb917b10db8eb803e7babd1538..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001217236574.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108718.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108718.png deleted file mode 100644 index 2fd6c145acd07026766c368d2e20724b0d1f8a04..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108718.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108719.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108719.png deleted file mode 100644 index bf89500815be29bf77bc1c50f56106bfbc010e19..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218108719.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218259634.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218259634.png deleted file mode 100644 index a54bd7cd05accb496c691b2527b08b0a11cd8c66..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218259634.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218579608.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218579608.png deleted file mode 100644 index 74526d5efee72c20ce09c731842c0d1c56159a97..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218579608.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739568.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739568.png deleted file mode 100644 index a66ff857ba7629951a39a1c2cc19c7b6fb43b9e1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001218739568.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662661.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662661.png deleted file mode 100644 index 9c43caf5fdfd466eafc37b793f509a6bde2b885d..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662661.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662663.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662663.png deleted file mode 100644 index 5c5e360f249a2002ba68ad9b94bd7f66f5d6aab1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662663.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662665.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662665.png deleted file mode 100644 index 309d1c46f8bc396df5eaed381a5ffa2f0389d602..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219662665.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219744201.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219744201.png deleted file mode 100644 index 0d22570503febc7a7dcba0d1e870f49f32fe489a..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219744201.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219864153.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219864153.png deleted file mode 100644 index 58293d5e874f2aa36ecaf7282ca9e4736318092f..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219864153.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219982719.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219982719.png deleted file mode 100644 index fde616c73000d3f58fd98eea59088177221127a5..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001219982719.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001224173302.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001224173302.png deleted file mode 100644 index 68b537c0afc28896fc8d14d36a5d7190fcfa256c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001224173302.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235146483.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235146483.png deleted file mode 100644 index 0bebd24640b896d465c3f130dcf69f10abab3def..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235146483.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235626467.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235626467.png deleted file mode 100644 index 189cc8a1e959a162f22d1b9b0dd9573614cb0673..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001235626467.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260373911.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260373911.png deleted file mode 100644 index 223fab73b7c40f7b1bdc5cc05d2d8a91589b88d4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260373911.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260555857.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260555857.png deleted file mode 100644 index e63baa89d7b6f4c816ca6e4386851498d47eac36..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001260555857.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001261605867.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001261605867.png deleted file mode 100644 index 096d7f530cc2d82391be453a7a5dbe659ba15513..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001261605867.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001262748569.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001262748569.png deleted file mode 100644 index 7af6c8cc92db32d22b3f2022ab567ca9c8978b63..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001262748569.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263019461.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263019461.png deleted file mode 100644 index b79b7923adca0d6e2a211c29ef0d34b70bf02583..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263019461.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263139411.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263139411.png deleted file mode 100644 index 3e481248c0e16f3311644a35fa3c71269a3e7877..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263139411.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263339461.png b/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263339461.png deleted file mode 100644 index 183d9468ca3901183b3fa55facbc976418e7a5f1..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/ui/figures/zh-cn_image_0000001263339461.png and /dev/null differ diff --git a/zh-cn/application-dev/ui/js-framework-syntax-js.md b/zh-cn/application-dev/ui/js-framework-syntax-js.md index 6a1484b0d9d49c295ff7c99390d547d4bc589c81..f2dd1f51f3f802d66ce2811b4585ef57fd4e7f89 100644 --- a/zh-cn/application-dev/ui/js-framework-syntax-js.md +++ b/zh-cn/application-dev/ui/js-framework-syntax-js.md @@ -248,7 +248,7 @@ export default {
parent component click - hello parent component! + hello parent component!
``` @@ -257,11 +257,11 @@ export default { // parent.js export default { data: { - show: false, + showValue: false, text: 'I am parent component!', }, parentClicked () { - this.show = !this.show; + this.showValue = !this.showValue; console.info('parent component get parent text'); console.info(`${this.$parent().text}`); console.info("parent component get child function"); diff --git a/zh-cn/application-dev/ui/ui-js-animate-svg.md b/zh-cn/application-dev/ui/ui-js-animate-svg.md index beed6f9df285dc966a03ea46f63085d962fc16be..fee61aa781b123426fbbc5bc20324725fb99952b 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-svg.md +++ b/zh-cn/application-dev/ui/ui-js-animate-svg.md @@ -65,7 +65,7 @@ ## animateTransform动画 -在Svg的子组件[animateMotion](../reference/arkui-js/js-components-svg-animatetransform.md)中,通过attributeName绑定transform属性,type设置动画类型,from设置开始值,to设置结束值。 +在Svg的子组件[animateTransform](../reference/arkui-js/js-components-svg-animatetransform.md)中,通过attributeName绑定transform属性,type设置动画类型,from设置开始值,to设置结束值。 ```html diff --git a/zh-cn/application-dev/ui/ui-js-animate-transform.md b/zh-cn/application-dev/ui/ui-js-animate-transform.md index c07c524558072b7206186c1e4a961b42b466c98f..18e1b65108dddef9fc99caabbf0feffe2f4b131d 100644 --- a/zh-cn/application-dev/ui/ui-js-animate-transform.md +++ b/zh-cn/application-dev/ui/ui-js-animate-transform.md @@ -38,8 +38,8 @@ height: 428px; background-color: #860303; transform: rotate(45deg); - margin-top: 230px; - margin-left: 266px; + margin-top: 284px; + margin-left: 148px; } .content{ margin-top: 500px; @@ -52,7 +52,7 @@ width: 100px; height: 150px; background-color: #1033d9; - transform: translate(150px,-150px); + transform: translate(150px,-137px); } .window{ z-index: 1; @@ -85,7 +85,7 @@ height: 100px; border-radius: 15px; background-color: #9a7404; - transform: translate(200px,-830px) skewX(-5deg); + transform: translate(200px,-710px) skewX(-5deg); } ``` @@ -254,13 +254,13 @@ .rect4 { width: 100px; height: 100px; - animation: rotate3d1 17ms infinite; + animation: rotate3d1 1000ms infinite; background: linear-gradient(#e6c4ec, #be15d9) } .rect5 { width: 100px; height: 100px; - animation: rotate3d1 17ms infinite; + animation: rotate3d1 1000ms infinite; margin-left: 100px; background: linear-gradient(#e6c4ec, #be15d9) } @@ -270,7 +270,7 @@ height: 100px; border-radius: 50px; border: 1px solid #e70303; - animation: rotate3d2 17ms infinite; + animation: rotate3d2 1000ms infinite; } /* 眼睛的动效 */ @keyframes rotate3d1 { @@ -483,6 +483,8 @@ transform可以设置多个值并且多个值可同时设置,下面案例中 ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction:column; background-color:#F1F3F5; padding:50px; diff --git a/zh-cn/application-dev/ui/ui-js-component-tabs.md b/zh-cn/application-dev/ui/ui-js-component-tabs.md index 69b08d7edb002f75dadb8631e1d1a447444ca882..78a71ea6ded6be188e0c8b042d34ed29d04470aa 100644 --- a/zh-cn/application-dev/ui/ui-js-component-tabs.md +++ b/zh-cn/application-dev/ui/ui-js-component-tabs.md @@ -15,7 +15,7 @@ tabs是一种常见的界面导航结构。通过页签容器,用户可以快 item1 item2 - +
content1
@@ -35,6 +35,10 @@ tabs是一种常见的界面导航结构。通过页签容器,用户可以快 align-items: center; background-color: #F1F3F5; } +.tabContent{ + width: 100%; + height: 100%; +} .text{ width: 100%; height: 100%; diff --git a/zh-cn/application-dev/ui/ui-js-components-canvas.md b/zh-cn/application-dev/ui/ui-js-components-canvas.md index 9410a9d4ceda10a4fd7cb2169ca71afe7ec51a6c..06bc9dc1885d03d75e4b0acd345874aaadc4d4e0 100644 --- a/zh-cn/application-dev/ui/ui-js-components-canvas.md +++ b/zh-cn/application-dev/ui/ui-js-components-canvas.md @@ -20,6 +20,8 @@ Canvas组件提供画布,用于自定义绘制图形。具体用法请参考[C ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md b/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md index 85a737f4d78f8e9ec6aa60130dadf788c06090bc..dc01f3b2b906e931dada6c436f06a95344bf2fb7 100644 --- a/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/ui/ui-js-components-canvasrenderingcontext2d.md @@ -27,6 +27,8 @@ ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -227,6 +229,8 @@ export default { ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -324,6 +328,8 @@ export default { ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -448,6 +454,8 @@ export default { ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -591,6 +599,8 @@ export default { ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; @@ -760,6 +770,8 @@ save方法可对画笔样式进行存储,restore可对存储的画笔进行恢 ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; background-color: #F1F3F5; align-items: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-form.md b/zh-cn/application-dev/ui/ui-js-components-form.md index e00ca0ea9bbc88eb8fe9bd8182f027baccffd4c0..836f46f8fbbfce291ccd8144f8f6098526d0c925 100644 --- a/zh-cn/application-dev/ui/ui-js-components-form.md +++ b/zh-cn/application-dev/ui/ui-js-components-form.md @@ -183,6 +183,8 @@ export default{ ```css /* index.css */ .container { + width: 100%; + height: 100%; flex-direction:column; align-items:center; background-color:#F1F3F5; diff --git a/zh-cn/application-dev/ui/ui-js-components-grid.md b/zh-cn/application-dev/ui/ui-js-components-grid.md index fcaaef6774c02e2fe0857c78291d4de066f1eabf..1d74d0cb6541165ddf74b309ad4fbaed8ef4a212 100644 --- a/zh-cn/application-dev/ui/ui-js-components-grid.md +++ b/zh-cn/application-dev/ui/ui-js-components-grid.md @@ -28,6 +28,7 @@ flex-direction: column; background-color: #F1F3F5; width: 100%; + height: 100%; justify-content: center; align-items: center; } @@ -67,6 +68,7 @@ grid-container点击组件调用getColumns、getColumnWidth、getGutterWidth方 flex-direction: column; background-color: #F1F3F5; width: 100%; + height: 100%; justify-content: center; align-items: center; } @@ -154,6 +156,7 @@ export default { flex-direction: column; background-color: #F1F3F5; width: 100%; + height: 100%; justify-content: center; align-items: center; } @@ -203,6 +206,7 @@ text{ flex-direction: column; background-color: #F1F3F5; width: 100%; + height: 100%; } text{ color: #0a0aef; diff --git a/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md b/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md index 21eb77734b4209734968bc7f73c8f99a40b865a8..03a50a6e2c1c4a133779f0ae31c5623c976ac832 100644 --- a/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md +++ b/zh-cn/application-dev/ui/ui-js-components-offscreencanvas.md @@ -26,6 +26,8 @@ ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; @@ -106,6 +108,8 @@ export default { ```css /* xxx.css */ .container{ + width: 100%; + height: 100%; flex-direction: column; justify-content: center; align-items: center; diff --git a/zh-cn/application-dev/ui/ui-js-components-path2d.md b/zh-cn/application-dev/ui/ui-js-components-path2d.md index 636c694e48377be4ca33691f314ef53c0806e498..b1f1bb0c68c88d0734bbdee94d9159982cc84ec0 100644 --- a/zh-cn/application-dev/ui/ui-js-components-path2d.md +++ b/zh-cn/application-dev/ui/ui-js-components-path2d.md @@ -23,6 +23,7 @@ align-items: center; justify-content: center; width: 100%; + height: 100%; } canvas { @@ -105,6 +106,7 @@ export default { align-items: center; justify-content: center; width: 100%; + height: 100%; } canvas { diff --git a/zh-cn/application-dev/ui/ui-js-components-switch.md b/zh-cn/application-dev/ui/ui-js-components-switch.md index e236251483a79026fdcc87663ead6d309a221329..a8554912f7467a7ff1e667833fbd4965a9490027 100644 --- a/zh-cn/application-dev/ui/ui-js-components-switch.md +++ b/zh-cn/application-dev/ui/ui-js-components-switch.md @@ -21,8 +21,6 @@ switch为开关选择器,切换开启或关闭状态。具体用法请参考[s /* xxx.css */ .container { flex-direction: column; - justify-content: center; - align-items: center; background-color: #F1F3F5; } ``` diff --git a/zh-cn/application-dev/ui/ui-ts-developing-intro.md b/zh-cn/application-dev/ui/ui-ts-developing-intro.md index d5bfbf46859bb2fe260f18d63eedf15aa7fb768f..62f4538cbe834025650e252f413ec7934b171cd4 100644 --- a/zh-cn/application-dev/ui/ui-ts-developing-intro.md +++ b/zh-cn/application-dev/ui/ui-ts-developing-intro.md @@ -2,15 +2,14 @@ ## 开发说明 -声明式UI的工程结构还请参考[OpenHarmony APP工程结构介绍](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section133380945818)。其中,.ets结尾的ArkTS文件用于描述UI布局、样式、事件交互和页面逻辑,支持导入TypeScript和JavaScript文件。资源目录resources文件夹位于src/main下,此目录下资源文件的详细规范以及子目录结构规范参看[资源分类与访问](../quick-start/resource-categories-and-access.md)。 - -在开发页面之前,请先[学习ArkTS语言](../quick-start/arkts-get-started.md)了解声明式UI的基本语法。 - -在开发页面时,可先根据使用场景,在[常见布局](ui-ts-layout-linear.md)中选择合适的布局。再根据页面需要实现的内容,为页面添加系统内置组件,更新组件状态。页面开发过程中请参考[自定义组件的生命周期](ui-ts-custom-component-lifecycle-callbacks.md)了解如何添加需要的生命周期回调方法。 - -也可在页面中添加[绘图](../reference/arkui-ts/ts-drawing-components-circle.md)和[动画](../reference/arkui-ts/ts-animatorproperty.md),丰富页面的展现形态。还可以使用[路由](../reference/apis/js-apis-router.md)实现多个页面之间的跳转和数据传递。 - -另外请参考[性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md),避免低性能代码对应用的性能造成负面影响。 +| 任务 | 简介 | 相关资源 | +| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| 准备开发环境 | 了解声明式UI的工程结构。
了解资源分类与访问。 | [OpenHarmony工程介绍](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650)
[资源分类与访问](../quick-start/resource-categories-and-access.md) | +| 学习ArkTS语言 | ArkTS是HarmonyOS优选的主力应用开发语言,当前,ArkTS在TS基础上主要扩展了声明式UI能力。 | [学习ArkTS语言](../quick-start/arkts-get-started.md) | +| 开发页面 | 根据页面的使用场景,选择合适的布局。
根据页面需要实现的内容,添加系统内置组件,并修改组件样式。
更新页面内容,丰富页面展现形式。 | [创建页面](#创建页面)
[常见布局开发指导](ui-ts-layout-linear.md)
[常见组件说明](ui-ts-components-intro.md)
[修改组件样式](#修改组件样式)
[更新页面内容](#更新页面内容) | +| (可选)页面多样化 | 绘图和动画。 | [绘图组件](../reference/arkui-ts/ts-drawing-components-circle.md)
[画布组件](../reference/arkui-ts/ts-components-canvas-canvas.md)
[动画](../reference/arkui-ts/ts-animatorproperty.md) | +| (可选)页面之间的跳转 | 使用页面路由实现多个页面之前的跳转。 | [页面路由](../reference/apis/js-apis-router.md) | +| (可选)性能提升 | 避免低性能代码对应用的性能造成负面影响。 | [性能提升的推荐方法](ui-ts-performance-improvement-recommendation.md) | ## 创建页面 @@ -33,19 +32,10 @@ ## 修改组件样式 -创建系统内置组件时,若不设置属性方法,则会显示其默认样式。通过更改组件的属性样式或者组件支持的[通用属性](../reference/arkui-ts/ts-universal-attributes-size.md)样式,设置可以改变组件的UI显示。 +在页面中添加系统内置组件时,若不设置属性方法,则会显示其默认样式。通过更改组件的属性样式或者组件支持的[通用属性](../reference/arkui-ts/ts-universal-attributes-size.md)样式,改变组件的UI显示。 1. 通过修改Text组件的构造参数,将Text组件的显示内容修改为“Tomato”。 - -2. 修改Text组件的fontSize属性更改组件的字体大小,将字体大小设置为26,通过fontWeight属性更改字体粗细,将其设置为500。fontWeight属性支持三种设置方式: - - a. number类型的取值范围为100到900,取值间隔为100,默认为400,取值越大,字体越粗。 - - b. FontWeight为内置枚举类型,取值支持FontWeight.Lighter、FontWeight.Normal、FontWeight.Regular、FontWeight.Medium、FontWeight.Bold、FontWeight.Bolder。FontWeight.Normal即为400数值的字体粗细。 - - c. string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。设置其他字符串则为无效,保持默认字体粗细显示。 - - 属性方法要紧随组件,通过“.”操作符连接,也可以通过链式调用的方式配置组件的多个属性。 +2. 修改Text组件的fontSize属性更改组件的字体大小,将字体大小设置为26,通过fontWeight属性更改字体粗细,将其设置为500。 ```ts // xxx.ets @@ -66,62 +56,13 @@ ![zh-cn_image_0000001168888224](figures/zh-cn_image_0000001168888224.png) -## 组件成员变量初始化 - -自定义组件的成员变量可以通过[本地初始化](../quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)和[在构造组件时通过构造参数初始化](../quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)两种方式实现,具体允许哪种方式取决于该变量所使用的装饰器: - - -**示例:** - -```ts -// xxx.ets -class ClassA { - public str: string - - constructor(str: string) { - this.str = str - } -} - -@Entry -@Component -struct Parent { - // Parent的变量parentState进行本地初始化 - @State parentState: ClassA = new ClassA('hello') - - build() { - Column() { - Row() { - CompA({ aState: new ClassA('Tomato'), aLink: $parentState }) - } - // aState在CompA中已进行初始化,因此可以缺省 - Row() { - CompA({ aLink: $parentState }) - } - }.width('100%') - } -} - -@Component -struct CompA { - // CompA中的变量aState进行本地初始化,aLink在Parent中使用时通过构造参数初始化 - @State aState: any = new ClassA('CompA') - @Link aLink: ClassA - - build() { - Row() { - Text(JSON.stringify(this.aState)).fontSize(20).margin(30) - Text(JSON.stringify(this.aLink)).fontSize(20).margin(30) - } - } -} -``` - -![component](figures/component.PNG) +## 更新页面内容 -## 组件的状态更新 +在创建基本的页面之后,可根据组件的状态来更新页面内容。以下示例展示了简单的更新页面方法。 -组件的状态可以通过动态修改组件成员变量的值来更新,下面以示例来进行说明。 +> **说明:** +> +> 更新组件的状态之前,请先初始化组件的成员变量。自定义组件的成员变量可以通过[本地初始化](../quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)和[在构造组件时通过构造参数初始化](../quick-start/arkts-restrictions-and-extensions.md#自定义组件成员变量初始化的方式与约束)两种方式实现,具体允许哪种方式取决于该变量所使用的装饰器。 **示例:** @@ -197,11 +138,6 @@ struct TimerComponent { 2. 判断if条件,创建true条件下的元素; 1. 创建Image组件,并设置其图片源地址; 2. 使用给定的构造函数创建TimerComponent; - 1. 创建TimerComponent对象; - 2. 本地初始化成员变量初始值; - 3. 使用TimerComponent构造函数提供的参数更新成员变量的值; - 4. 执行TimerComponent的aboutToAppear函数; - 5. 执行TimerComponent的build函数,创建相应的UI描述结构; 3. 创建Button内置组件,设置相应的内容。 **状态更新:** @@ -218,10 +154,5 @@ struct TimerComponent { 1. Text组件会被重用,但使用新的文本内容进行重新初始化; 2. 判断if条件,使用false条件下的元素; 1. 原来true条件的组件不再使用,将这些组件销毁; - 1. 销毁Image组件实例; - 2. 销毁TimerComponent组件实例,aboutToDisappear函数被调用; 2. 创建false条件下的组件; - 1. 创建Image组件,并设置其图片源地址; - 2. 使用给定的构造函数重新创建TimerComponent; - 3. 初始化TimerComponent,并调用aboutToAppear函数和build函数。 - 3. 重用Button组件,使用新的图片源地址。 + 3. 重用Button组件,使用新的图片源地址。 \ No newline at end of file diff --git a/zh-cn/contribute/template/js-template.md b/zh-cn/contribute/template/js-template.md index 127e95f17fb7f03c1c555ef6ef8a019cfd3ee788..d84ea6b990ab0e575e15d9226d1280812c15fac0 100644 --- a/zh-cn/contribute/template/js-template.md +++ b/zh-cn/contribute/template/js-template.md @@ -1,6 +1,7 @@ # API接口说明模板 ## 总体写作说明 + > **说明:**
所有的写作说明,在完成写作后,都要删除。 | | 说明项 | 细则 | @@ -8,10 +9,10 @@ | 1 | 客户化写作基本要求 | **写作中,请变身开发者,对于开发者使用该API时所需的使用场景、参数选取原则、开发建议/经验、示例等信息进行清晰描述,达到指导开发者顺利使用本API进行开发的目标。** | | 2 | 上传路径 | markdown文件:docs/zh-cn/application-dev/reference/apis
图片路径:docs/zh-cn/application-dev/reference/apis/figures,并在markdown文件中通过路径`![](figures/xxx.jpg)`或`![](figures/xxx.png)`引用。 | | 3 | 文件命名 | 一个d.ts对应一个js api文档,文件名称应与模块名称保持一致,格式为:**js-apis-模块名.md**。
示例:
媒体@ohos.multimedia.audio,文件命名为:js-apis-audio.md
电话@ohos.telephony.sms,文件命名为:js-apis-sms.md | -| 4 | 目录修改 | 新增文件,需要修改对应的Readme,即`docs/zh-cn/application-dev/reference/apis/Readme-CN.md`。 | -| 5 | 文档结构 | - 模块说明
- 起始版本说明
- 导入模块/使用说明
- 接口(属性、方法、枚举、自定义类型)
描述顺序和代码保持一致,如果某些接口具有逻辑顺序,请注意排列。 | +| 4 | 目录修改 | 新增文件,需要修改对应的Readme,即`docs/zh-cn/application-dev/reference/apis/Readme-CN.md`。
目录按字母顺序排列。 | +| 5 | 文档结构 | - 模块说明
- 起始版本说明
- 导入模块/使用说明
- 接口(属性、常量、方法、枚举、自定义类型)
描述顺序和代码保持一致,如果某些接口具有逻辑顺序,请注意排列。 | | 6 | 接口版本说明 | 1. 每个模块要有起始版本说明,使用引用语法“>”对接口的起始版本进行说明。接口没有标记的,默认与模块同一个起始版本。
2. 已有模块新增接口使用\标签标记对应版本号。写法:`版本号+`
例如`7+`
示例:API 6已有的模块,在API 7新增了一个属性字段,则在属性后加标记,即newAttribute7+
如果新增了一个方法,则在方法标题后增加标记,即 sim.getSimIccId7+,interface、class、枚举等同理。 | -| 7 | 废弃接口说明 | 废弃内容不能直接删去,在废弃内容后面加标注deprecated,并使用“>”引用语法建议使用的替代方式,加上对应的链接。
示例:abandonmentMethod(deprecated)
> 从API version 7 开始不再维护,建议使用[newMethod]\(#newmethod)替代。 | +| 7 | 废弃接口说明 | 1. 废弃内容不能直接删去,在废弃内容后面加标注deprecated,并使用“>”引用语法建议使用的替代方式,加上对应的链接。
示例:abandonmentMethod(deprecated)
> 从API version 7 开始不再维护,建议使用[newMethod]\(#newmethod)替代。
2. 当接口同时存在起始版本和废弃版本需要说明时,上标仅保留(deprecated),起始版本在“>”里说明。
示例:abandonmentMethod(deprecated)
> 从API version 4 开始支持,从API version 7 开始不再维护,建议使用[newMethod]\(#newmethod)替代。| | 8 | 权限说明 | 与代码保持一致,下沉到各个方法、枚举、属性字段中。
1. 如果仅系统应用可申请,格式:
**需要权限:** ohos.permission.xxxx,仅系统应用可用。
2. 如果该权限所有应用可申请,格式:
**需要权限:** ohos.permission.xxxx
3. 如果该接口涉及多个权限,则采用“和、或”进行分割,格式:
**需要权限:** ohos.permission.A 和 ohos.permission.B
**需要权限:** ohos.permission.A 或 ohos.permission.B | | 9 | @syscap | 1. 每个方法都需要进行描述,格式:
**系统能力**:SystemCapability.xxx.xxx
2. 每个表格(属性、枚举、常量、变量)可统一进行说明,分两种情况:
1)每个表格下系统能力无差异的,同方法的写法:
**系统能力**:SystemCapability.xxx.xxx
2)有差异的:在每一个表格项里进行描述。 | | 10 | @system api | 1. 如果某个模块全部接口均为system api,则在模块开头的版本说明下一行,增加:
- 本模块接口为系统接口。
2. 如果某个接口为system api,仅供OEM厂商使用,则需要在描述中增加:
**系统接口:** 此接口为系统接口。 | @@ -108,6 +109,21 @@ import call from '@ohos.telephony.call'; | pluggedType | [BatteryPluggedType](#batterypluggedtype) | 是 | 否 | 表示当前设备连接的充电器类型。 | | isBatteryPresent | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 | +## 常量 + +> *写作说明* +> +> 1. 可选,如果没有常量可删除此二级标题,对应d.ts中的const。 +> +> 2. 类型如果为自定义类型,需要建立链接到对应的interface或enum中。 + +**系统能力:** SystemCapability.xxx.xxx。(必选) + +| 名称 | 类型 | 说明 | +| ---------------- | ----------------------------------------- | ------------------------------------------ | +| uid | number | 进程的用户标识。 | +| pid | number | 当前进程的pid。 | + ## 方法 > *写作说明* @@ -282,17 +298,43 @@ import call from '@ohos.telephony.call'; ## CustomType +> *写作说明* +> +> 可选,如果没有可删除此二级标题,对应d.ts中无方法的Interface。 + 仅有k-v键值对的自定义类型示例。 + +**系统能力:** SystemCapability.xxx.xxx(必选) + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ------------------- | ---- | ------------------------------------------------------------ | +| parameterUrl | string | 是 | 媒体输出URI。支持:
1. 协议类型为“internal”的相对路径,示例如下: 临时目录:internal://cache/test.mp4
2. 文件的绝对路径,示例如下: file:///data/data/ohos.xxx.xxx/files/test.mp4 | +| parameterOne | [CustomEnum](#枚举) | 否 | 属性描述,要求与参数说明类似。 | + +## Type + +> *写作说明* +> +> 1. 可选,如果没有可删除此二级标题,对应d.ts中的type联合类型。 +> +> 2. 默认第一列为“类型”。如果全部为具体字符串,可将第一列修改为“取值”。 +> +> 3. 类型如果为自定义类型,需要建立链接到对应的interface或enum中。 + +在此处给出该联合类型的简要描述。如:表示允许的数据字段类型。 + **系统能力:** SystemCapability.xxx.xxx(必选) -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | -| parameterUrl | string | 是 | 是 | 媒体输出URI。支持:
1. 协议类型为“internal”的相对路径,示例如下: 临时目录:internal://cache/test.mp4
2. 文件的绝对路径,示例如下: file:///data/data/ohos.xxx.xxx/files/test.mp4 | -| parameterOne | [CustomEnum](#枚举) | 是 | 是 | 属性描述,要求与参数说明类似。 | +| 类型 | 说明 | +| -----------| ---------------------------- | +| number | 表示值类型为数字。 | +| string | 表示值类型为字符。 | ## 变更日志 -| 变更说明 | 日期 | -| -------- | ---- | -| 1. 总体写作说明整理为表格。
2. “图片路径”中,增加图片的引用方式说明。
3. 增加“文档结构”,对文档各节点顺序进行说明。
4. “权限说明”中,增加多权限的描述方式。
5. 增加@FAModelOnly/@StageModelOnly标记在文档的描述方式。
6. 增加异步接口说明(callback、Promise)。
7. 增加示例代码语言的标准和规范。
8. 增加文档链接的标准写法。
9. 增加模块描述的固定句式、示例。
10. 增加“on/off”等订阅方法的说明。
11. 修改@syscap的描述方式,除表格内的差异项,其余保持一致。
12. 修改@systemapi的描述方式,仅保留“该系统为系统接口。”。
13. 删除MR版本说明。 |2022/6/24| +| 变更说明 | 日期 | +| ----------------------------------------------------------------------- | ------------ | +| 1. 总体写作说明整理为表格。
2. “图片路径”中,增加图片的引用方式说明。
3. 增加“文档结构”,对文档各节点顺序进行说明。
4. “权限说明”中,增加多权限的描述方式。
5. 增加@FAModelOnly/@StageModelOnly标记在文档的描述方式。
6. 增加异步接口说明(callback、Promise)。
7. 增加示例代码语言的标准和规范。
8. 增加文档链接的标准写法。
9. 增加模块描述的固定句式、示例。
10. 增加“on/off”等订阅方法的说明。
11. 修改@syscap的描述方式,除表格内的差异项,其余保持一致。
12. 修改@systemapi的描述方式,仅保留“该系统为系统接口。”。
13. 删除MR版本说明。 | 2022/6/24 | +| 增加错误码说明。 | 2022/10/11 | +| 1. 增加**常量const**、**类型type**的模板。
2. 修改自定义类型interface的表格,去除“可读、可写”,与d.ts保持一致,增加“必填”。
3. 针对同时存在起始版本和废弃版本的接口,增加废弃说明的模板。 |2022/11/22 | \ No newline at end of file diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index 146d5484f274750a806173175d7d628cb7c68cb6..677035cc831d7956b4a79354aaf2a9139775bde1 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -54,10 +54,8 @@ - [轻量和小型系统设备开发示例](guide/device-wlan-led-control.md) - [标准系统设备开发示例](guide/device-clock-guide.md) - 调测 - - [测试用例开发](subsystems/subsys-testguide-test.md) + - [设备测试](device-test/Readme-CN.md) - [调测工具](subsystems/subsys-toolchain-hdc-guide.md) -- XTS认证 - - [XTS认证](subsystems/subsys-xts-guide.md) - 工具 - [Docker编译环境](get-code/gettools-acquire.md) - [IDE集成开发环境](get-code/gettools-ide.md) diff --git a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md index 8fddafeda91cdbea167912c57ad3a991b1d6b980..d817ef48a6a1796bdf5dd9e33743d23d84d2a6d6 100755 --- a/zh-cn/device-dev/driver/driver-peripherals-camera-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-camera-des.md @@ -47,7 +47,8 @@ Camera模块主要针对相机预览、拍照、视频流等场景,对这些 ### 接口说明 -注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/camera/v1_0/)。 +注:以下接口列举的为IDL接口描述生成的对应C++语言函数接口,接口声明见idl文件(/drivers/interface/camera/v1_0/)。 +在HDI使用中下发的配置参数不能超出GetCameraAbility上报的能力范围。即使通过UpdateSettings、CommitStreams、Capture等接口可以下发超出该范围的配置参数,且接口调用不会返回失败,但设置后的行为是不确定的。 - icamera_device.h | 功能描述 | 接口名称 | @@ -634,7 +635,7 @@ Camera驱动的开发过程主要包含以下步骤: 在/drivers/peripheral/camera/hal/init目录下有一个关于Camera的demo,开机后会在/vendor/bin下生成可执行文件ohos_camera_demo,该demo可以完成Camera的预览,拍照等基础功能。下面我们就以此demo为例讲述怎样用HDI接口去编写预览PreviewOn()和拍照CaptureON()的用例,可参考[ohos_camera_demo](https://gitee.com/openharmony/drivers_peripheral/tree/master/camera/hal/init)。 -1. 在main函数中构造一个CameraDemo 对象,该对象中有对Camera初始化、启停流、释放等控制的方法。下面mainDemo->InitSensors()函数为初始化CameraHost,mainDemo->InitCameraDevice()函数为初始化CameraDevice。 +1. 在main函数中构造一个CameraDemo 对象,该对象中有对Camera初始化、启停流、释放等控制的方法。下面mainDemo->InitSensors()函数为初始化CameraHost,mainDemo->InitCameraDevice()函数为初始化CameraDevice。 ```c++ int main(int argc, char** argv) @@ -849,7 +850,7 @@ Camera驱动的开发过程主要包含以下步骤: } ``` - CaptureON()接口调用streamOperator的Capture()方法获取Camera数据并轮转buffer,拉起一个线程接收相应类型的数据。 + CaptureON()接口调用streamOperator的Capture()方法获取Camera数据并轮转buffer,拉起一个线程接收相应类型的数据。 ```c++ RetCode OhosCameraDemo::CaptureON(const int streamId, diff --git a/zh-cn/device-dev/porting/Readme-CN.md b/zh-cn/device-dev/porting/Readme-CN.md index 10ab78d4c3459f5816c4b9d6a9401fb273f71313..ce5b474e48144b84d7b14854c3920359c1141ea0 100644 --- a/zh-cn/device-dev/porting/Readme-CN.md +++ b/zh-cn/device-dev/porting/Readme-CN.md @@ -67,3 +67,4 @@ repo init -u https://gitee.com/openharmony-sig/manifest.git -b master -m devboar - 标准系统芯片移植案例 - [标准系统方案之瑞芯微RK3568移植案例](porting-dayu200-on_standard-demo.md) - [标准系统方案之瑞芯微RK3566移植案例](https://gitee.com/openharmony/vendor_kaihong/blob/master/khdvk_3566b/porting-khdvk_3566b-on_standard-demo.md) + - [标准系统方案之扬帆移植案例](porting-yangfan-on_standard-demo.md) diff --git a/zh-cn/device-dev/porting/figures/isoftstone/yangfan-camera-01.png b/zh-cn/device-dev/porting/figures/isoftstone/yangfan-camera-01.png deleted file mode 100644 index 444898b86792d8ee4ebcbd61b1223c44faa2bee6..0000000000000000000000000000000000000000 Binary files a/zh-cn/device-dev/porting/figures/isoftstone/yangfan-camera-01.png and /dev/null differ diff --git a/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md b/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md index 49a9a80a4852e2975095672f55e898fb2ba0ca8b..5ace73eff617d18cbbc8a984feb668f92748ee6d 100755 --- a/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md +++ b/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md @@ -2278,7 +2278,7 @@ PanelSimpleUnprepare负责灭屏的硬件时序初始化 实例化后使用RegisterPanel接口向display模型注册该panel驱动即可 -需要说明的是,dauy200上的这款lcd 使用的时候DRM显示框架 +需要说明的是,dayu200上的这款lcd 使用的是DRM显示框架 ### hcs配置 diff --git a/zh-cn/device-dev/porting/porting-stm32f407-on-minisystem-eth.md b/zh-cn/device-dev/porting/porting-stm32f407-on-minisystem-eth.md index 2c737a460b35f81ad954e496a21467a42c8f53da..6324fd3087ba4ca5b0fa9973c6edaac7bc2ea939 100644 --- a/zh-cn/device-dev/porting/porting-stm32f407-on-minisystem-eth.md +++ b/zh-cn/device-dev/porting/porting-stm32f407-on-minisystem-eth.md @@ -1185,7 +1185,7 @@ _hdf_drivers_end = .; #### 添加XTS子系统 -`XTS`测试参考资料见[xts参考资料](../subsystems/subsys-xts-guide.md),进行`XTS`子系统适配需要添加`xts_acts`与`xts_tools`组件,直接在`config.json`配置即可,配置如下: +`XTS`测试参考资料见[xts参考资料](../device-test/xts.md),进行`XTS`子系统适配需要添加`xts_acts`与`xts_tools`组件,直接在`config.json`配置即可,配置如下: { "subsystem": "xts", diff --git a/zh-cn/device-dev/quick-start/figures/Phoenix-upload.png b/zh-cn/device-dev/quick-start/figures/Phoenix-upload.png index 5702f209752edc74d687e5e8ce7e210428f4551e..d5762ecd3ed51a29bf1645808626b64bc4d747a1 100644 Binary files a/zh-cn/device-dev/quick-start/figures/Phoenix-upload.png and b/zh-cn/device-dev/quick-start/figures/Phoenix-upload.png differ diff --git a/zh-cn/device-dev/quick-start/figures/install-fail.png b/zh-cn/device-dev/quick-start/figures/install-fail.png new file mode 100644 index 0000000000000000000000000000000000000000..75f5419935587ad23d01f637830594ce0535bb3a Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/install-fail.png differ diff --git a/zh-cn/device-dev/quick-start/figures/select-vscode-path.png b/zh-cn/device-dev/quick-start/figures/select-vscode-path.png new file mode 100644 index 0000000000000000000000000000000000000000..66500f56ddcdd48695b9abe22bdc56241e9bef85 Binary files /dev/null and b/zh-cn/device-dev/quick-start/figures/select-vscode-path.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png index 93be7d7b91882bc5d372fe465a0d3a8b2972371f..e6818fac6fb62329dbced2c523cda71d60590ce0 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001265516901.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png index db92b0181a48b56990633058e3a4efce7ca5be82..b85eaee5ce796ab0741943933fcb657033e2a6f7 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276281922.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276354454.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276354454.png index 2419d79327a7a13df83fe637916b9abeb180a2b0..db62f3f7def3c12b5b5d14d6eb44b9043d4de327 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276354454.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001276354454.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png index 560240a18a081d50201d6185d25da46cc1c7a0eb..8f61b550a1131f3f5520a7db84c5e11376551ed9 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001280147358.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png index da90fa7c0cd0da44ab6aff877eb8e11550dc7871..7b9807183c09f952bc2ce2874d1cc358f47e568b 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281221352.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png index 86501f030f57eea30b724f8b7d32736a8ddc7f21..d3a70a4e845cd0943d71601b73d9a730a86008e0 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001281378224.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png index 6d567bf69106c8bb266c7f7f445a317b5405c6a5..c5790475513c9927892b047a750f5beb45295302 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531806.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png index df66ac7a87d293ae8500eae978fbe5bcbc23e214..3a1a8b113d000bbc3684882505b9daa43a86bef9 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292531862.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png index d430a7534a65f96de3f90fc37e279ba116fdf43c..106109e14e08bebcd4423af2966786f6a59d3f5e 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001292849062.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png index dea8677bfd7c9ba3f7b82f00c8422d695f85b86b..61486549943cf0badf606b6379c256dacdba1e31 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001296270098.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png index d1992b49a9805cd0823c98c2d6f1500a10c5f249..c0d61708ad9cb2db0c1336a73e9ce6fcc2f364fe 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001307160958.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png index d1992b49a9805cd0823c98c2d6f1500a10c5f249..4633dadcbc9365d9873505d91b8fcfefd9f1b66b 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001325269477.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png index e17047264d181b73e48e96a54c60517b57f42fb5..13afaeecab462d7c6efe1c4ba5e38467bfb2e9e0 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001326234609.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327429541.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327429541.png index cc19b0a8e8f97ec07b29eab8b01f387c5c81903c..2c29e7a69d2a87f9c2f888949457ba98374ec9ee 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327429541.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001327429541.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png index f0d3cfc874effae73aad01dd26961ef4946c8f81..1ccaa6d5225520181903e86a88907a53a89094d2 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333256741.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png index d6dbd5d63c55c135dd8121d4ca1b4d11d5438897..d607ced0b457e1899bf2b67fa7bac7d5fcd067f7 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001333581089.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png index 61536a53597991971c997481624f1aedbc232c6d..7848b0336d1c8fb4e9b8f38e94b8308453b2b464 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338012765.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png index e83dad0b26392f009564d2e4014e374187ac1d7f..bfa493ec2ea2c43f5dea668079d23169696443ee 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001338622229.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png index f467c1b45f84730fd3fc45158004d9a03dec2551..41fa3ad3a958d3acf43fc68946f8bd7897e1c8af 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001349388493.png differ diff --git a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png index ab85672164a7efca486295641c5ec15e40eda432..bc10279c9de8e1f380a368593a5f0b7b97fd772c 100644 Binary files a/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png and b/zh-cn/device-dev/quick-start/figures/zh-cn_image_0000001360439881.png differ diff --git a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md index de97f5472490b9078fc78b4868b679e567d4f9ab..2c9334c0823392f9944e3ad07df1a024c5b8e85c 100644 --- a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md @@ -1,5 +1,10 @@ # Hi3516标准系统入门(IDE方式) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> 从3.2版本起,标准系统不再针对Hi3516DV300进行适配验证,建议您使用RK3568进行标准系统的设备开发。 +> +> 如您仍然需要使用Hi3516DV300进行标准系统相关开发操作,则可能会出现无法适配的现象,此时请联系芯片供应商获取相关适配指导,或自行完成适配。 除小型系统外,Hi3516DV300开发板还支持标准系统。此章节简要介绍如何使用IDE在Hi3516DV300开发板上进行标准系统的开发。 @@ -157,7 +162,7 @@ applications/sample/hello 在productdefine/common/products/Hi3516DV300.json中添加对应的hello部件,直接添加到原有部件后即可。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,Hi3516的配置文件为productdefine/common/products/Hi3516DV300.json;若源码版本大于OpenHarmony-v3.1-Release时,Hi3516的配置文件为vendor/hisilicon/Hi3516DV300/config.json。 + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,Hi3516的配置文件为productdefine/common/products/Hi3516DV300.json;从OpenHarmony-v3.2-Beta2版本开始,Hi3516的配置文件为vendor/hisilicon/Hi3516DV300/config.json。 ``` @@ -184,8 +189,11 @@ DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供 ![zh-cn_image_0000001292531862](figures/zh-cn_image_0000001292531862.png) 3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在**TERMINAL**窗口输入用户密码进行安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > + > - 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > - 若出现安装apt组件失败,可参考[修改apt源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/faq-toolchain-install-0000001301623822)进行修改,完成后尝试重新安装。 ![zh-cn_image_0000001274748606](figures/zh-cn_image_0000001274748606.png) @@ -193,7 +201,7 @@ DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供 ![zh-cn_image_0000001296270098](figures/zh-cn_image_0000001296270098.png) -4. 在**hi3516dv300**配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。修改完成后,点击**Save**进行保存。 +4. 在**hispark_taurus_standard**配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。 ![zh-cn_image_0000001325269477](figures/zh-cn_image_0000001325269477.png) @@ -242,9 +250,11 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 ![Phoenix-upload](figures/Phoenix-upload.png) -5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions_profile、upload_port和upload_protocol。 +5. 在“hispark_taurus_standard”页签,设置烧录选项,包括upload_partitions_profile、upload_port和upload_protocol。配置完成后工程将自动保存。 + - upload_partitions_profile:选择待烧录程序的配置文件(已预置默认的配置文件),该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 > > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 @@ -253,9 +263,7 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 ![zh-cn_image_0000001338622229](figures/zh-cn_image_0000001338622229.png) -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -7. 点击hi3516dv300下的**Upload**按钮。 +6. 单击hispark_taurus_standard下的**Upload**按钮。 ![zh-cn_image_0000001276281922](figures/zh-cn_image_0000001276281922.png) @@ -263,7 +271,7 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 ![zh-cn_image_0000001326201857](figures/zh-cn_image_0000001326201857.png) -8. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 +7. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 ![zh-cn_image_0000001276122010](figures/zh-cn_image_0000001276122010.png) @@ -271,7 +279,7 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 ![zh-cn_image_0000001275802150](figures/zh-cn_image_0000001275802150.png) -9. 烧录成功后,请根据运行章节进行操作,启动系统。 +8. 烧录成功后,请根据运行章节进行操作,启动系统。 ## 运行 @@ -294,12 +302,12 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 3. 通过以下两条命令设置启动参数。 - ``` + ```shell setenv bootargs 'mem=640M console=ttyAMA0,115200 mmz=anonymous,0,0xA8000000,384M clk_ignore_unused rootdelay=10 hardware=Hi3516DV300 init=/init root=/dev/ram0 rw blkdevparts=mmcblk0:1M(boot),15M(kernel),20M(updater),2M(misc),3307M(system),256M(vendor),-(userdata)'; ``` - ``` + ```shell setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800; bootm 0x82000000' ``` @@ -307,7 +315,7 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 4. 保存参数设置。 - ``` + ```shell save ``` @@ -315,7 +323,7 @@ Hi3516DV300开发板标准系统的烧录方式包括USB烧录、网口烧录两 5. 重启开发板,完成系统启动。 - ``` + ```shell reset ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md index 838d824279bd88f0c3e33a1284dba93a3a18c74e..421632d684ea5db1f682f54e49ca711877ddb7fc 100644 --- a/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md +++ b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-pkg.md @@ -1,5 +1,12 @@ # Hi3516标准系统入门(命令行方式) +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> 从3.2版本起,标准系统不再针对Hi3516DV300进行适配验证,建议您使用RK3568进行标准系统的设备开发。 +> +> 如您仍然需要使用Hi3516DV300进行标准系统相关开发操作,则可能会出现无法适配的现象,此时请联系芯片供应商获取相关适配指导,或自行完成适配。 + + 除小型系统外,Hi3516DV300开发板还支持标准系统。此章节简要介绍如何使用命令行在Hi3516DV300开发板上进行标准系统的开发。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md index 58f0db0f1884e541ae936562633e125cbf460172..472be7bd3efa0ea241356892aa91c64044dd7c0f 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-build.md @@ -17,8 +17,11 @@ DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供 ![zh-cn_image_0000001307480750](figures/zh-cn_image_0000001307480750.png) 3. 安装Hi3516DV300相关工具链,部分工具安装需要使用root权限,请在“TERMINAL”窗口输入用户密码进行安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > + > - 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > - 若出现安装apt组件失败,可参考[修改apt源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/faq-toolchain-install-0000001301623822)进行修改,完成后尝试重新安装。 ![zh-cn_image_0000001360080305](figures/zh-cn_image_0000001360080305.png) @@ -26,7 +29,7 @@ DevEco Device Tool支持Hi3516DV300开发板的源码一键编译功能,提供 ![zh-cn_image_0000001307320918](figures/zh-cn_image_0000001307320918.png) -4. 在“hi3516dv300”配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。修改完成后,单击**Save**进行保存。 +4. 在**ipcamera_hispark_taurus**配置页签中,设置源码的编译类型**build_type**,默认为“debug”类型,请根据需要进行修改。 ![zh-cn_image_0000001307160958](figures/zh-cn_image_0000001307160958.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md index 75eb1d896ca2158da0a636055841bdd8f7d5dbb4..3ded9acf977fbabb7e9f4984b959c3fc83f72afb 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-burn.md @@ -37,7 +37,7 @@ Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两 ![Phoenix-upload](figures/Phoenix-upload.png) -5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。 +5. 在“hi3516dv300”页签,设置烧录选项,包括upload_partitions、upload_port和upload_protocol。配置完成后工程将自动保存。 - upload_partitions:选择待烧录的文件,默认情况下会同时烧录fastboot、kernel、rootfs和userfs。DevEco Device Tool已预置默认的烧录文件信息,包括起始地址、分区大小、待烧录文件地址等,开发者可根据实际情况进行调整,点击每个待烧录文件后的![zh-cn_image_0000001275592884](figures/zh-cn_image_0000001275592884.png)按钮进行修改。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 @@ -49,9 +49,7 @@ Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两 ![3516-small-usb](figures/3516-small-usb.png) -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -7. 点击hi3516dv300下的**Upload**按钮。 +6. 点击hi3516dv300下的**Upload**按钮。 ![zh-cn_image_0000001326234609](figures/zh-cn_image_0000001326234609.png) @@ -59,7 +57,7 @@ Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两 ![zh-cn_image_0000001275835836](figures/zh-cn_image_0000001275835836.png) -8. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 +7. 在终端窗口显示如下提示信息时,请在15秒内,按住Update键,插拔USB线,最后松开Update键启动烧录。 ![zh-cn_image_0000001326412233](figures/zh-cn_image_0000001326412233.png) @@ -67,4 +65,4 @@ Hi3516DV300开发板小型系统的烧录方式包括USB烧录、网口烧录两 ![zh-cn_image_0000001276317464](figures/zh-cn_image_0000001276317464.png) -9. 烧录成功后,请根据运行章节进行操作,启动系统。 +8. 烧录成功后,请根据运行章节进行操作,启动系统。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md b/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md index de3a6b16bbd43a75f31f6688cf742ac5e28f8185..7641917305337e206d4dd3046348686ed63afac0 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3516-running.md @@ -30,13 +30,13 @@ 1. 在启动界面进入bin目录。 - ``` + ```shell cd bin ``` 2. 进入bin目录后可以看到helloworld文件,通过以下命令运行helloworld程序。 - ``` + ```shell ./helloworld ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md index 923fe7bbaf0ee4ebcd696de0e14a21cc020fe7d1..a7065bb9355f2ea1463f49dc41f7b7626c9b48b7 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-build.md @@ -13,8 +13,11 @@ DevEco Device Tool支持Rockchip RK3568开发板的源码一键编译功能, ![zh-cn_image_0000001327669509](figures/zh-cn_image_0000001327669509.png) 2. 在**Tool Chain**页签中,DevEco Device Tool会自动检测依赖的编译工具链是否完备,如果提示部分工具缺失,可点击**Install**,自动安装所需工具链。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > + > - 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > - 若出现安装apt组件失败,可参考[修改apt源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/faq-toolchain-install-0000001301623822)进行修改,完成后尝试重新安装。 ![zh-cn_image_0000001292531806](figures/zh-cn_image_0000001292531806.png) @@ -26,7 +29,7 @@ DevEco Device Tool支持Rockchip RK3568开发板的源码一键编译功能, ![zh-cn_image_0000001349388493](figures/zh-cn_image_0000001349388493.png) -3. 在**hh_scdy200**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**进行保存。 +3. 在**rk3568**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。 ![zh-cn_image_0000001276354454](figures/zh-cn_image_0000001276354454.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md index a8a3a5267de371fbe6189fdd0a7f215554edbaaf..dd249431214ac91d52aa9622418bd771f4fb1323 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md @@ -20,6 +20,7 @@ RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操 1. 请连接好电脑和待烧录开发板,连接USB接口,具体可参考[RK3568开发板介绍](quickstart-appendix-rk3568.md)。 2. 在DevEco Device Tool中,选择**REMOTE DEVELOPMENT > Local PC**,查看远程计算机(Ubuntu开发环境)与本地计算机(Windows开发环境)的连接状态。 + - 如果Local PC右边连接按钮为![zh-cn_image_0000001326512673](figures/zh-cn_image_0000001326512673.png),则远程计算机与本地计算机为已连接状态,不需要执行其他操作。 - 如果Local PC右边连接按钮为![zh-cn_image_0000001275432904](figures/zh-cn_image_0000001275432904.png),则点击绿色按钮进行连接。连接时DevEco Device Tool会重启服务,因此请不要在下载源码或源码编译过程中进行连接,否则会中断任务。 @@ -33,9 +34,11 @@ RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操 ![3865-uploader](figures/3865-uploader.png) -5. 在**hh_scdy200**页签,设置烧录选项,包括upload_partitions和upload_protocol。 +5. 在**rk3568**页签,设置烧录选项,包括upload_partitions和upload_protocol。配置完成后工程将自动保存。 + - **upload_partitions_profile**:选择待烧录程序的配置文件,该配置文件会指定烧录文件名称、起始烧录地址、地址长度等信息;同时请勾选**Enable to use upload_partitions_profile for upload**选项。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > > 如需修改烧录profile文件,在设置烧录分区起始地址和分区长度时,应根据实际待烧录文件的大小进行设置,要求设置的烧录分区大小,要大于待烧录文件的大小;同时,各烧录文件的分区地址设置不能出现重叠。 > > 首次烧录,请勾选**Enable to use upload_partitions_profile for upload**选项,会自动生成upload_partitions文件。再次烧录时,可根据实际情况选择生成upload_partitions文件进行自定义烧录,也可以再勾选**Enable to use upload_partitions_profile for upload**选项,使用upload_partitions_profile重新生成upload_partitions文件用于烧录。 @@ -43,13 +46,11 @@ RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操 ![zh-cn_image_0000001338663697](figures/zh-cn_image_0000001338663697.png) -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -7. 在**PROJECT TASKS**中,点击hh_scdy200下的**Upload**按钮启动烧录。 +6. 在**PROJECT TASKS**中,点击rk3568下的**Upload**按钮启动烧录。 ![zh-cn_image_0000001280147358](figures/zh-cn_image_0000001280147358.png) -8. 当屏幕提示“Operation paused,Please press Enter key to continue”,请按**回车键**继续。 +7. 当屏幕提示“Operation paused,Please press Enter key to continue”,请按**回车键**继续。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击**RESET**键,然后再过3秒放开音量+键,使开发板进入烧录模式。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md b/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md index cbd93e684bfcff79a1e518114b4d21af9e6cdd18..518228c24abd54f22ecb318ed117c903b33b6bee 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3568-helloworld.md @@ -156,7 +156,7 @@ productdefine/common 在productdefine/common/products/rk3568.json中添加对应的hello部件,直接添加到原有部件后即可。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,RK3568的配置文件为productdefine/common/products/rk3568.json;若源码版本大于OpenHarmony-v3.1-Release时,RK3568的配置文件为vendor/hihope/rk3568/config.json。 + > 本章节操作是以OpenHarmony-v3.1-Release版本为例进行操作的,该版本中,RK3568的配置文件为productdefine/common/products/rk3568.json;从OpenHarmony-v3.2-Beta2版本开始,RK3568的配置文件为vendor/hihope/rk3568/config.json。 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md index fe688893ece0b4c486cb58c4fe08ea9cb5234d89..2e03e588f52cecfc1855950c0d1f9affdfd73ee0 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-build.md @@ -18,7 +18,9 @@ DevEco Device Tool支持Hi3861V100开发板的源码一键编译功能,提供 3. 安装Hi3861V100相关工具链,部分工具安装需要使用root权限,请在**TERMINAL**窗口输入用户密码进行安装。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > + > - 如果出现安装pip组件失败,可参考[修改Python源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/ide-set-python-source-0000001227639986)进行修改,完成尝试重新安装。 + > - 若出现安装apt组件失败,可参考[修改apt源的方法](https://device.harmonyos.com/cn/docs/documentation/guide/faq-toolchain-install-0000001301623822)进行修改,完成后尝试重新安装。 ![zh-cn_image_0000001280938208](figures/zh-cn_image_0000001280938208.png) @@ -26,7 +28,7 @@ DevEco Device Tool支持Hi3861V100开发板的源码一键编译功能,提供 ![zh-cn_image_0000001281378224](figures/zh-cn_image_0000001281378224.png) -4. 在**hi3861**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。然后点击**Save**进行保存。 +4. 在**wifiiot_hispark_pegasus**配置页签中,设置源码的编译类型**build_type**,默认为"debug"类型,请根据需要进行修改。 ![zh-cn_image_0000001333581089](figures/zh-cn_image_0000001333581089.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md b/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md index 607463264e079110e64934138b7a805dabcc5d67..672de391335f484d975367393c2b393458651269 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-3861-burn.md @@ -30,22 +30,23 @@ Hi3861V100的镜像烧录通过Windows环境进行烧录,开发者启动烧录 4. 在“Tool Chain”页签,设置Uploader烧录器工具,可以通过Tool Chain页签中的Install按钮在线安装。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 若烧录器存在新版本或需要使用其它烧录器,您可以在**Uploader > Use Custom Burn Tool**指定本地的烧录器。 + ![Phoenix-upload](figures/Phoenix-upload.png) -5. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。 +5. 在“hi3861”页签,设置烧录选项,包括upload_port、upload_protocol和upload_partitions。配置完成后工程将自动保存。 - upload_port:选择已查询的串口号。 - upload_protocol:选择烧录协议,选择“hiburn-serial”。 - upload_partitions:选择待烧录的文件名称。DevEco Device Tool已预置默认的烧录文件信息,如果需要修改待烧录文件地址,可点击每个待烧录文件后的![zh-cn_image_0000001333642545](figures/zh-cn_image_0000001333642545.png)按钮进行修改。 ![zh-cn_image_0000001345770181](figures/zh-cn_image_0000001345770181.png) -6. 所有的配置都修改完成后,在工程配置页签的顶部,点击**Save**进行保存。 - -7. 在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 +6. 在“PROJECT TASKS”中,点击hi3861下的**Upload**按钮,启动烧录。 ![zh-cn_image_0000001333322693](figures/zh-cn_image_0000001333322693.png) -8. 启动烧录后,显示如下提示信息时,请在15秒内,按下开发板上的RST按钮重启开发板。 +7. 启动烧录后,显示如下提示信息时,请在15秒内,按下开发板上的RST按钮重启开发板。 ![hi3861-upload-restart](figures/hi3861-upload-restart.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md b/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md index 055d303163bd564fdc49e6f66765bda88de1eef8..e408e6d3b38ed718132517c284ad5a07cedf9c24 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md @@ -10,27 +10,31 @@ - Windows 10 64位系统。 -- Windows系统上安装的DevEco Device Tool为3.0 Release版本。 +- Windows系统上安装的DevEco Device Tool为3.1 Beta1版本。 ## 操作步骤 -1. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Windows版。 +1. 下载[DevEco Device Tool 3.1 Beta1](https://device.harmonyos.com/cn/ide#download) Windows版。 2. 解压DevEco Device Tool压缩包,双击安装包程序,单击**Next**进行安装。 3. 设置DevEco Device Tool的安装路径,请注意安装路径不能包含中文字符,**不建议安装到C盘目录**,单击**Next**。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 如果您已安装DevEco Device Tool 3.0 Beta2及以前的版本,则在安装新版本时,会先卸载旧版本,卸载过程中出现错误提示“Error during uninstallation process: Cannot remove directory...”时,请单击**Ignore**继续安装,该错误不影响新版本的安装。 ![zh-cn_image_0000001326386753](figures/zh-cn_image_0000001326386753.png) 4. 根据安装向导提示,勾选要自动安装的软件。 - 1. 在弹出**VS Code installation confirm**页面,勾选“Install VS Code 1.62.2automatically”,单击**Next**。 + + 1. 在弹出**VSCode installation confirm**页面,勾选“Install VS Code 1.62.2 automatically”,单击**Next**。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 如果检测到Visual Studio Code已安装,且版本为1.62及以上,则会跳过该步骤。 ![zh-cn_image_0000001285965546](figures/zh-cn_image_0000001285965546.png) + + 2. 选择Visual Studio Code的安装路径,单击**Next**。 + + ![select-vscode-path](figures/select-vscode-path.png) + 2. 在弹出的**Python select page**选择“Download from Huawei mirror”,单击**Next**。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 如果系统已安装可兼容的Python版本(Python 3.8~3.9版本),可选择“Use one of compatible on your PC”。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md b/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md index a6c260e917f5b49cb1f04cd4b7f9ae3bd78d9e50..1c82b6759dc6040c34802bdc23c8fe49ed54b5eb 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env-remote.md @@ -11,19 +11,19 @@ > 如果执行该命令失败,提示openssh-server和openssh-client依赖版本不同,请根据CLI界面提示信息,安装openssh-client相应版本后(例如:sudo apt-get install openssh-client=1:8.2p1-4),再重新执行该命令安装openssh-server。 - ``` + ```shell sudo apt-get install openssh-server ``` 2. 执行如下命令,启动SSH服务。 - ``` + ```shell sudo systemctl start ssh ``` 3. 执行如下命令,获取当前用户的IP地址,用于Windows系统远程访问Ubuntu环境。 - ``` + ```shell ifconfig ``` @@ -62,12 +62,19 @@ ![zh-cn_image_0000001215720398](figures/zh-cn_image_0000001215720398.png) -5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机 。 +5. 在弹出的输入框中,选择**Linux**,然后在选择**Continue**,然后输入登录远程计算机的密码,连接远程计算机。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 在Windows系统远程访问Ubuntu过程中,需要频繁的输入密码进行连接,为解决该问题,您可以使用SSH公钥来进行设置,设置方法请参考[注册远程访问Ubuntu环境的公钥](https://device.harmonyos.com/cn/docs/documentation/guide/ide-registering-public-key-0000001247162706)。 ![zh-cn_image_0000001215897530](figures/zh-cn_image_0000001215897530.png) - 连接成功后,等待在远程计算机用户目录下的.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。至此,环境搭建完成,如下图所示,左下角显示远程连接计算机的IP地址。 + 连接成功后,等待在远程计算机用户目录下的.vscode-server文件夹下自动安装插件,安装完成后,根据界面提示在Windows系统下重新加载Visual Studio Code,便可以在Windows的DevEco Device Tool界面进行源码开发、编译、烧录等操作。 + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 如果您之前安装过DevEco Device Tool 3.0 Release及以前的版本,可能出现插件安装失败的情况,Visual Studio Code右下角一直处于如下界面,请参考[DevEco Device Tool插件安装失败处理办法](https://device.harmonyos.com/cn/docs/documentation/guide/faq-device-tool-install-failed-0000001437806813)进行处理。 + + ![install-fail](figures/install-fail.png) + + 至此,环境搭建完成,如下图所示,左下角显示远程连接计算机的IP地址。 ![zh-cn_image_0000001338102621](figures/zh-cn_image_0000001338102621.png) diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md b/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md index 30db89994cb54da88c8d8a0a0aaa0f088426640a..f79c4b7b14c8e95de76d147333c295ea236cdec0 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-env-ubuntu.md @@ -12,7 +12,7 @@ ## 系统要求 -- Ubuntu系统要求:Ubuntu18.04~21.10版本,内存推荐16 GB及以上。 +- Ubuntu系统要求:Ubuntu18.04~21.10版本。推荐使用20.04版本,内存16 GB及以上。 - Ubuntu系统的用户名不能包含中文字符。 @@ -22,37 +22,37 @@ 1. 将Ubuntu Shell环境修改为bash。 1. 执行如下命令,确认输出结果为bash。如果输出结果不是bash,请根据子步骤2,将Ubuntu shell修改为bash。 - ``` + ```shell ls -l /bin/sh ``` ![zh-cn_image_0000001226764302](figures/zh-cn_image_0000001226764302.png) 2. 打开终端工具,执行如下命令,输入密码,然后选择**No**,将Ubuntu shell由dash修改为bash。 - ``` + ```shell sudo dpkg-reconfigure dash ``` ![ubuntu-dash-to-bash](figures/ubuntu-dash-to-bash.png) -2. 下载[DevEco Device Tool 3.0 Release](https://device.harmonyos.com/cn/ide#download) Linux版本。 +2. 下载[DevEco Device Tool 3.1 Beta1](https://device.harmonyos.com/cn/ide#download) Linux版本。 3. 解压DevEco Device Tool软件包并对解压后的文件夹进行赋权。 - 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.1.0.200.zip为软件包名称,请根据实际进行修改。 + 1. 进入DevEco Device Tool软件包目录,执行如下命令解压软件包,其中devicetool-linux-tool-3.1.0.300.zip为软件包名称,请根据实际进行修改。 + ```shell + unzip devicetool-linux-tool-3.1.0.300.zip ``` - unzip devicetool-linux-tool-3.1.0.200.zip - ``` - 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.1.0.200.sh请根据实际进行修改。 + 2. 进入解压后的文件夹,执行如下命令,赋予安装文件可执行权限,其中devicetool-linux-tool-3.1.0.300.sh请根据实际进行修改。 - ``` - chmod u+x devicetool-linux-tool-3.1.0.200.sh + ```shell + chmod u+x devicetool-linux-tool-3.1.0.300.sh ``` -4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.1.0.200.sh请根据实际进行修改。 +4. 执行如下命令,安装DevEco Device Tool,其中devicetool-linux-tool-3.1.0.300.sh请根据实际进行修改。 - ``` - sudo ./devicetool-linux-tool-3.1.0.200.sh + ```shell + sudo ./devicetool-linux-tool-3.1.0.300.sh ``` 5. 在用户协议和隐私声明签署界面,请详细阅读用户协议和隐私声明,需签署同意用户协议和隐私声明才能进行下一步的安装,可通过键盘的上下按键进行选择。 @@ -66,7 +66,7 @@ 6. 使用如下apt-get命令安装后续操作所需的库和工具。 - ``` + ```shell sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales libxinerama-dev libxcursor-dev libxrandr-dev libxi-dev ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-env.md b/zh-cn/device-dev/quick-start/quickstart-ide-env.md deleted file mode 100644 index 3cb3ffb46bf738617f74bbc0a651a3d641db4d2a..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-env.md +++ /dev/null @@ -1,7 +0,0 @@ -# 搭建开发环境 - - -在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。 - - -在以上的设备开发场景中,可以搭建一套Windows+Ubuntu混合开发的环境,其中使用Windows平台的DevEco Device Tool可视化界面进行相关操作,通过远程连接的方式对接Ubuntu下的DevEco Device Tool(可以不安装Visual Studio Code),然后对Ubuntu下的源码进行开发、编译、烧录等操作。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md b/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md index 4692ddf4862e7397586a9abd19f00caed050a1f0..443f44e9196a79f9b3af07017702336ba51a93ae 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-import-project.md @@ -15,7 +15,10 @@ OpenHarmony Stable Version源码为OpenHarmony稳定版本源码,通过镜像 ## 前提条件 -只有在Windows环境通过Remote SSH远程连接上Ubuntu环境的情况下,才可以创建OpenHarmony新工程,具体请参考[搭建开发环境](quickstart-ide-env--win.md)。否则,在DevEco Device Tool的Home界面没有“**New Project**”按钮。 +只有在Windows环境通过Remote SSH远程连接上Ubuntu环境的情况下,才可以创建OpenHarmony新工程,具体请参考[搭建开发环境](quickstart-ide-env--win.md)。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 若Windows环境未远程连接Ubuntu环境,New Project功能仅针对海思企业用户,不支持创建OpenHarmony工程。 ## 操作步骤 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md b/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md deleted file mode 100644 index 37735011da2235266fe5a6397df0cca595609111..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide-lite-appendix.md +++ /dev/null @@ -1,11 +0,0 @@ -# 附录 - - - -- **[Hi3516开发板介绍](quickstart-appendix-hi3516.md)** - -- **[Hi3861开发板介绍](quickstart-appendix-hi3861.md)** - -- **[RK3568开发板介绍](quickstart-appendix-rk3568.md)** - -- **[编译形态整体说明](quickstart-appendix-compiledform.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-ide.md b/zh-cn/device-dev/quick-start/quickstart-ide.md deleted file mode 100644 index 71922baa6fda1c56abffed4f57542990f2ac6701..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-ide.md +++ /dev/null @@ -1,25 +0,0 @@ -# 使用IDE快速入门 - - -- 基于IDE入门 - - 搭建开发环境 - - [搭建Windows环境](quickstart-ide-env--win.md) - - [搭建Ubuntu环境](quickstart-ide-env-ubuntu.md) - - [配置远程访问环境](quickstart-ide-env-remote.md) - - [创建工程并获取源码](quickstart-ide-import-project.md) - - 轻量系统(基于Hi3861开发板) - - [编写“Hello World”程序](quickstart-ide-3861-helloworld.md) - - [编译](quickstart-ide-3861-build.md) - - [烧录](quickstart-ide-3861-burn.md) - - [运行](quickstart-ide-3861-running.md) - - 小型系统(基于Hi3516开发板) - - [编写“Hello World”程序](quickstart-ide-3516-helloworld.md) - - [编译](quickstart-ide-3516-build.md) - - [烧录](quickstart-ide-3516-burn.md) - - [运行](quickstart-ide-3516-running.md) - - 标准系统(基于RK3568开发板) - - [编写“Hello World”程序](quickstart-ide-3568-helloworld.md) - - [编译](quickstart-ide-3568-build.md) - - [烧录](quickstart-ide-3568-burn.md) - - [运行](quickstart-ide-3568-running.md) - diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-env.md b/zh-cn/device-dev/quick-start/quickstart-pkg-env.md deleted file mode 100644 index 313c291e3e917767472787f90f4b74cb68de948f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-pkg-env.md +++ /dev/null @@ -1,4 +0,0 @@ -# 搭建开发环境 - - -在嵌入式开发中,很多开发者习惯于使用Windows进行代码的编辑,比如使用Windows的Visual Studio Code进行OpenHarmony代码的开发。但当前阶段,大部分的开发板源码还不支持在Windows环境下进行编译,如Hi3861、Hi3516系列开发板。因此,建议使用Ubuntu的编译环境对源码进行编译。同时,开发板的烧录需要在Windows环境中进行。 diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg-info.md b/zh-cn/device-dev/quick-start/quickstart-pkg-info.md deleted file mode 100644 index aa2bd522a5e6f8487e5bf0b38a881d6069f2286f..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-pkg-info.md +++ /dev/null @@ -1,13 +0,0 @@ -# 常用信息 - - - -- **[配置代理](quickstart-pkg-common-proxy.md)** - -- **[使用build.sh脚本编译源码](quickstart-pkg-common-build.md)** - -- **[hb安装异常处理](quickstart-pkg-common-hberr.md)** - -- **[编译异常处理](quickstart-pkg-common-builderr.md)** - -- **[烧录异常处理](quickstart-pkg-common-burnerr.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/quick-start/quickstart-pkg.md b/zh-cn/device-dev/quick-start/quickstart-pkg.md deleted file mode 100644 index b13f806e0f01e594a5393aeb13a7dd60c59a36a8..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/quick-start/quickstart-pkg.md +++ /dev/null @@ -1,31 +0,0 @@ -# 使用命令行快速入门 - - -- 基于命令行入门 - - 搭建开发环境 - - [准备开发环境](quickstart-pkg-prepare.md) - - [安装库和工具集](quickstart-pkg-install_package.md) - - [获取源码](quickstart-pkg-sourcecode.md) - - [安装编译工具](quickstart-pkg-install_tool.md) - - 轻量系统(基于Hi3861开发板) - - [安装Hi3861开发板特有环境](quickstart-pkg-3861-tool.md) - - [编写“Hello World”程序](quickstart-pkg-3861-helloworld.md) - - [编译](quickstart-pkg-3861-build.md) - - [烧录](quickstart-pkg-3861-burn.md) - - [运行](quickstart-pkg-3861-running.md) - - 小型系统(基于Hi3516开发板) - - [编写“Hello World”程序](quickstart-pkg-3516-helloworld.md) - - [编译](quickstart-pkg-3516-build.md) - - [烧录](quickstart-pkg-3516-burn.md) - - [运行](quickstart-pkg-3516-running.md) - - 标准系统(基于RK3568开发板) - - [编写“Hello World”程序](quickstart-pkg-3568-helloworld.md) - - [编译](quickstart-pkg-3568-build.md) - - [烧录](quickstart-pkg-3568-burn.md) - - [运行](quickstart-pkg-3568-running.md) - - 常用信息 - - [配置代理](quickstart-pkg-common-proxy.md) - - [使用build.sh脚本编译源码](quickstart-pkg-common-build.md) - - [hb安装异常处理](quickstart-pkg-common-hberr.md) - - [编译异常处理](quickstart-pkg-common-builderr.md) - - [烧录异常处理](quickstart-pkg-common-burnerr.md) \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/annotated.md b/zh-cn/device-dev/reference/hdi-apis/annotated.md deleted file mode 100644 index e415acf8378b78b8e569253222748e5404e3f36b..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/annotated.md +++ /dev/null @@ -1,365 +0,0 @@ -# 结构体 - - - -- **[YUVDescInfo](_yun_desc_info_.md)** - -- **[ExtDataHandle](_ext_data_handle.md)** - -- **[ActRecognitionEvent](_act_recognition_event.md)** - -- **[AllocInfo](_alloc_info.md)** - -- **[Alignment](_alignment.md)** - -- **[AudioAdapter](_audio_adapter.md)** - -- **[AudioAdapterDescriptor](_audio_adapter_descriptor.md)** - -- **[AudioAttribute](_audio_attribute.md)** - -- **[AudioCapture](_audio_capture.md)** - -- **[AudioControl](_audio_control.md)** - -- **[AudioDevExtInfo](_audio_dev_ext_info.md)** - -- **[AudioDeviceDescriptor](_audio_device_descriptor.md)** - -- **[AudioManager](_audio_manager.md)** - -- **[AudioMixExtInfo](_audio_mix_ext_info.md)** - -- **[AudioMmapBufferDescriptor](_audio_mmap_buffer_descriptor.md)** - -- **[AudioPort](_audio_port.md)** - -- **[AudioPortCap](audio_portcap.md)** - -- **[AudioPortCapability](_audio_port_capability.md)** - -- **[AudioRender](_audio_render.md)** - -- **[AudioRoute](_audio_route.md)** - -- **[AudioRouteNode](_audio_route_node.md)** - -- **[AudioSampleAttributes](_audio_sample_attributes.md)** - -- **[AudioScene](_audio_scene.md)** - -- **[AudioSceneDescriptor](_audio_scene_descriptor.md)** - -- **[AudioSceneDescriptor::SceneDesc](union_audio_scene_descriptor_1_1_scene_desc.md)** - -- **[AudioSessionExtInfo](_audio_session_ext_info.md)** - -- **[AudioSubPortCapability](_audio_sub_port_capability.md)** - -- **[AudioTimeStamp](_audio_time_stamp.md)** - -- **[AudioVolume](_audio_volume.md)** - -- **[AuthResultInfo](_auth_result_info.md)** - -- **[AuthSolution](_auth_solution.md)** - -- **[BufferData](_buffer_data.md)** - -- **[BatteryInfo](_battery_info.md)** - -- **[CaptureEndedInfo](_capture_ended_info.md)** - -- **[CaptureErrorInfo](_capture_error_info.md)** - -- **[CaptureInfo](_capture_info.md)** - -- **[CodecCallbackType](_codec_callback_type.md)** - -- **[CodecCompCapability](_codec_comp_capability.md)** - -- **[CodecComponentManager](_codec_component_manager.md)** - -- **[CodecComponentType](_codec_component_type.md)** - -- **[ColorValue](union_color_value.md)** - -- **[CompVerInfo](_comp_ver_info.md)** - -- **[CredentialInfo](_credential_info.md)** - -- **[DeviceFuncs](_device_funcs.md)** - -- **[DisplayCapability](_display_capability.md)** - -- **[DisplayInfo](_display_info.md)** - -- **[DisplayModeInfo](_display_mode_info.md)** - -- **[EnrolledInfo](_enrolled_info.md)** - -- **[EnrollParam](_enroll_param.md)** - -- **[EnrollResultInfo](_enroll_resultinfo.md)** - -- **[EventInfo](_event_info.md)** - -- **[ExecutorInfo](_executor_info.md)** - -- **[ExecutorInfo](_user_executor_info.md)** - -- **[ExecutorRegisterInfo](_executor_register_info.md)** - -- **[ExecutorSendMsg](_executor_send_msg.md)** - -- **[GetBufferHandleUsageParams](_get_buffer_handle_usage_params.md)** - -- **[GfxFuncs](_gfx_funcs.md)** - -- **[GfxOpt](_gfx_opt.md)** - -- **[GrallocFuncs](_gralloc_funcs.md)** - -- **[HdfFeatureInfo](_hdf_feature_info.md)** - -- **[HdfLightColor](_hdf_light_color.md)** - -- **[HdfLightEffect](_hdf_light_effect.md)** - -- **[HdfLightFlashEffect](_hdf_light_flash_effect.md)** - -- **[HdfLightInfo](_hdf_light_info.md)** - -- **[HdfMotionEvent](_hdf_motion_event.md)** - -- **[HdfNetDeviceInfo](_hdf_net_device_info.md)** - -- **[HdfNetDeviceInfoResult](_hdf_net_device_info_result.md)** - -- **[HdfSensorEvents](_hdf_sensor_events.md)** - -- **[HdfSensorInformation](_hdf_sensor_information.md)** - -- **[HdfStaInfo](_hdf_sta_info.md)** - -- **[HdfThermalCallbackInfo](_hdf_thermal_callback_info.md)** - -- **[HdfVibratorInfo](_hdf_vibrator_info.md)** - -- **[HdfWifiDriverScanSsid](_hdf_wifi_driver_scan_ssid.md)** - -- **[HdfWifiInfo](_hdf_wifi_info.md)** - -- **[HdfWifiScan](_hdf_wifi_scan.md)** - -- **[HdfWifiScanResult](_hdf_wifi_scan_result.md)** - -- **[HDRCapability](_h_d_r_capability.md)** - -- **[HDRMetaData](_h_d_r_meta_data.md)** - -- **[IActivityChangedCallback](interface_i_activity_changed_callback.md)** - -- **[IActivityInterface](interface_i_activity_interface.md)** - -- **[IBatteryCallback](interface_i_battery_callback.md)** - -- **[IBatteryInterface](interface_i_battery_interface.md)** - -- **[ICameraDevice](interface_i_camera_device.md)** - -- **[ICameraDeviceCallback](interface_i_camera_device_callback.md)** - -- **[ICameraHost](interface_i_camera_host.md)** - -- **[ICameraHostCallback](interface_i_camera_host_callback.md)** - -- **[ICircle](_i_circle.md)** - -- **[IdentifyResultInfo](_identify_result_info.md)** - -- **[IExecutor](interface_i_executor.md)** - -- **[IExecutor](interface_pin_i_executor.md)** - -- **[IExecutorCallback](interface_i_executor_callback.md)** - -- **[IExecutorCallback](interface_pin_i_executor_callback.md)** - -- **[IFaceAuthInterface](interface_i_face_auth_interface.md)** - -- **[ILine](_i_line.md)** - -- **[IInputInterface](_i_input_interface.md)** - -- **[ILightInterface](interface_i_light_interface.md)** - -- **[IMotionCallback](interface_i_motion_callback.md)** - -- **[IMotionInterface](interface_i_motion_interface.md)** - -- **[InputController](_input_controller.md)** - -- **[InputDevAbility](_input_dev_ability.md)** - -- **[InputDevAttr](_input_dev_attr.md)** - -- **[InputDevDesc](_input_dev_desc.md)** - -- **[InputDeviceInfo](_input_device_info.md)** - -- **[InputDevIdentify](_input_dev_identify.md)** - -- **[InputDimensionInfo](_input_dimension_info.md)** - -- **[InputEventCb](_input_event_cb.md)** - -- **[InputEventPackage](_input_event_package.md)** - -- **[IPowerHdiCallback](interface_i_power_hdi_callback.md)** - -- **[InputExtraCmd](_input_extra_cmd.md)** - -- **[InputHostCb](_input_host_cb.md)** - -- **[InputHotPlugEvent](_input_hot_plug_event.md)** - -- **[InputManager](_input_manager.md)** - -- **[InputReporter](_input_reporter.md)** - -- **[IOfflineStreamOperator](interface_i_offline_stream_operator.md)** - -- **[IPinAuthInterface](interface_i_pin_auth_interface.md)** - -- **[IPowerInterface](interface_i_power_interface.md)** - -- **[IRect](_i_rect.md)** - -- **[ISensorCallback](interface_i_sensor_callback.md)** - -- **[ISensorInterface](interface_i_sensor_interface.md)** - -- **[IStreamOperator](interface_i_stream_operator.md)** - -- **[IStreamOperatorCallback](interface_i_stream_operator_callback.md)** - -- **[ISurface](_i_surface.md)** - -- **[IThermalCallback](interface_i_thermal_callback.md)** - -- **[IThermalInterface](interface_i_thermal_interface.md)** - -- **[IUsbdBulkCallback](interface_i_usbd_bulk_callback.md)** - -- **[IUsbdSubscriber](interface_i_usbd_subscriber.md)** - -- **[IUsbInterface](interface_i_usb_interface.md)** - -- **[IUserAuthInterface](interface_i_user_auth_interface.md)** - -- **[IVibratorInterface](interface_i_vibrator_interface.md)** - -- **[IWlanCallback](interface_i_wlan_callback.md)** - -- **[IWlanInterface](interface_i_wlan_interface.md)** - -- **[LayerAlpha](_layer_alpha.md)** - -- **[LayerBuffer](_layer_buffer.md)** - -- **[LayerFuncs](_layer_funcs.md)** - -- **[LayerInfo](_layer_info.md)** - -- **[MeasChannelParam](_meas_channel_param.md)** - -- **[MeasChannelResult](_meas_channel_result.md)** - -- **[OmxCodecBuffer](_omx_codec_buffer.md)** - -- **[PortCap](union_port_cap.md)** - -- **[PortInfo](_port_info.md)** - -- **[PresentTimestamp](_present_timestamp.md)** - -- **[PropertyObject](_property_object.md)** - -- **[ProjectionScreenCmdParam](_projection_screen_cmd_param.md)** - -- **[RangeValue](_range_value.md)** - -- **[Rect](_rect.md)** - -- **[Rectangle](_rectangle.md)** - -- **[RGBColor](_r_g_b_color.md)** - -- **[ScheduleInfo](_schedule_info.md)** - -- **[StreamAttribute](_stream_attribute.md)** - -- **[StreamInfo](_stream_info.md)** - -- **[SupportBufferType](_support_buffer_type.md)** - -- **[TemplateInfo](_template_info.md)** - -- **[ThermalZoneInfo](_thermal_zone_info.md)** - -- **[UsbCtrlTransfer](_usb_ctrl_transfer.md)** - -- **[UsbDev](_usb_dev.md)** - -- **[USBDeviceInfo](_u_s_b_device_info.md)** - -- **[UsbPipe](_usb_pipe.md)** - -- **[UseBufferType](_use_buffer_type.md)** - -- **[VerifyAllocInfo](_verify_alloc_info.md)** - -- **[VGUBuffer](_v_g_u_buffer.md)** - -- **[VGUColorStop](_v_g_u_color_stop.md)** - -- **[VGUConic](_v_g_u_conic.md)** - -- **[VGUFillAttr](_v_g_u_fill_attr.md)** - -- **[VGUFuncs](_v_g_u_funcs.md)** - -- **[VGUGradient](_v_g_u_gradient.md)** - -- **[VGUImage](_v_g_u_image.md)** - -- **[VGULinear](_v_g_u_linear.md)** - -- **[VGUMaskLayer](_v_g_u_mask_layer.md)** - -- **[VGUMatrix3](_v_g_u_matrix3.md)** - -- **[VGUPaintStyle](_v_g_u_paint_style.md)** - -- **[VGUPath](_v_g_u_path.md)** - -- **[VGUPattern](_v_g_u_pattern.md)** - -- **[VGUPoint](_v_g_u_point.md)** - -- **[VGURadial](_v_g_u_radial.md)** - -- **[VGURect](_v_g_u_rect.md)** - -- **[VGUSolid](_v_g_u_solid.md)** - -- **[VGUStrokeAttr](_v_g_u_stroke_attr.md)** - -- **[VGUSurface](_v_g_u_surface.md)** - -- **[VideoPortCap](_video_port_cap.md)** - -- **[WifiStationInfo](_wifi_station_info.md)** - -- **[WRGBColor](_w_r_g_b_color.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/files.md b/zh-cn/device-dev/reference/hdi-apis/files.md deleted file mode 100644 index c4c4f5171e25975eb0c0e29c0c73ed189c29a62d..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/files.md +++ /dev/null @@ -1,145 +0,0 @@ -# 头文件 - - - -- **[audio_adapter.h](audio__adapter_8h.md)** - -- **[audio_attribute.h](audio__attribute_8h.md)** - -- **[audio_capture.h](audio__capture_8h.md)** - -- **[audio_control.h](audio__control_8h.md)** - -- **[audio_manager.h](audio__manager_8h.md)** - -- **[audio_render.h](audio__render_8h.md)** - -- **[audio_scene.h](audio__scene_8h.md)** - -- **[audio_types.h](audio__types_8h.md)** - -- **[audio_volume.h](audio__volume_8h.md)** - -- **[codec_callback_if.h](codec_callback_if_h.md)** - -- **[codec_common_type.h](codec_common_type_h.md)** - -- **[codec_component_if.h](codec_component_if_h.md)** - -- **[codec_component_manager.h](codec__component__manager_h.md)** - -- **[codec_component_type.h](codec__component__type_h.md)** - -- **[display_device.h](display__device_8h.md)** - -- **[display_gfx.h](display__gfx_8h.md)** - -- **[display_gralloc.h](display__gralloc_8h.md)** - -- **[display_layer.h](display__layer_8h.md)** - -- **[display_type.h](display__type_8h.md)** - -- **[display_vgu.h](display__vgu_8h.md)** - -- **[input_controller.h](input__controller_8h.md)** - -- **[input_manager.h](input__manager_8h.md)** - -- **[input_reporter.h](input__reporter_8h.md)** - -- **[input_type.h](input__type_8h.md)** - -- **[ActivityRecognitionTypes.idl](activity_recognition_types_idl.md)** - -- **[Types.idl](battery_types_idl.md)** - -- **[IExecutor.idl](face__auth_2_i_executor_8idl.md)** - -- **[IExecutorCallback.idl](face__auth_2_i_executor_callback_8idl.md)** - -- **[FaceAuthTypes.idl](_face_auth_types_8idl.md)** - -- **[PinAuthTypes.idl](_pin_auth_types_8idl.md)** - -- **[IExecutor.idl](pin__auth_2_i_executor_8idl.md)** - -- **[IExecutorCallback.idl](pin__auth_2_i_executor_callback_8idl.md)** - -- **[IFaceAuthInterface.idl](_i_face_auth_interface_8idl.md)** - -- **[IPinAuthInterface.idl](_i_pin_auth_interface_8idl.md)** - -- **[IUserAuthInterface.idl](_i_user_auth_interface_8idl.md)** - -- **[UserAuthTypes.idl](_user_auth_types_8idl.md)** - -- **[IActivityChangedCallback.idl](_i_activity_changed_callback_8idl.md)** - -- **[IActivityInterface.idl](_i_activity_interface_8idl.md)** - -- **[IBatteryCallback.idl](_i_battery_callback_8idl.md)** - -- **[IBatteryInterface.idl](_i_battery_interface_8idl.md)** - -- **[ICameraDevice.idl](_i_camera_device_8idl.md)** - -- **[ICameraDeviceCallback.idl](_i_camera_device_callback_8idl.md)** - -- **[ICameraHostCallback.idl](_i_camera_host_callback_8idl.md)** - -- **[ICameraHost.idl](_i_camera_host_8idl.md)** - -- **[ILightInterface.idl](_i_light_interface_8idl.md)** - -- **[IMotionCallback.idl](_i_motion_callback_8idl.md)** - -- **[IMotionInterface.idl](_i_motion_interface_8idl.md)** - -- **[IOfflineStreamOperator.idl](_i_offline_stream_operator_8idl.md)** - -- **[IPowerHdiCallback.idl](_i_power_hdi_callback_8idl.md)** - -- **[IPowerInterface.idl](_i_power_interface_8idl.md)** - -- **[ISensorCallback.idl](_i_sensor_callback_8idl.md)** - -- **[ISensorInterface.idl](_i_sensor_interface_8idl.md)** - -- **[IStreamOperator.idl](_i_stream_operator_8idl.md)** - -- **[IStreamOperatorCallback.idl](_i_stream_operator_callback_8idl.md)** - -- **[IThermalCallback.idl](_i_thermal_callback_8idl.md)** - -- **[IThermalInterface.idl](_i_thermal_interface_8idl.md)** - -- **[IUsbdBulkCallback.idl](_i_usbd_bulk_callback_8idl.md)** - -- **[IUsbInterface.idl](_i_usb_interface_8idl.md)** - -- **[IUsbdSubscriber.idl](_i_usbd_subscriber_8idl.md)** - -- **[IVibratorInterface.idl](_i_vibrator_interface_8idl.md)** - -- **[IWlanCallback.idl](_i_wlan_callback_8idl.md)** - -- **[IWlanInterface.idl](_i_wlan_interface_8idl.md)** - -- **[LightTypes.idl](_light_types_8idl.md)** - -- **[MotionTypes.idl](_motion_types_8idl.md)** - -- **[PowerTypes.idl](_power_types_8idl.md)** - -- **[SensorTypes.idl](_sensor_types_8idl.md)** - -- **[ThermalTypes.idl](_thermal_types_8idl.md)** - -- **[Types.idl](camera_2v1__0_2_types_8idl.md)** - -- **[UsbTypes.idl](_usb_types_8idl.md)** - -- **[VibratorTypes.idl](_vibrator_types_8idl.md)** - -- **[WlanTypes.idl](_wlan_types_8idl.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md index b5b3b5b1702c0cb94e109fd84c07108ea230689a..dbf4350cce0b2562e5e73e933ec224b062dcffc2 100644 --- a/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md +++ b/zh-cn/device-dev/reference/hdi-apis/interface_i_executor.md @@ -34,6 +34,7 @@ | [Delete](#delete)([in] unsigned long[] templateIdList) | 删除人脸特征模版。 | | [Cancel](#cancel)([in] unsigned long scheduleId) | 取消操作请求。 | | [SendCommand](#sendcommand)([in] int commandId, [in] unsigned char[] extraInfo, [in] IExecutorCallback callbackObj) | 发送人脸认证功能相关操作命令。 | +| [SetBufferProducer](#setbufferproducer) ([in] BufferProducerSequenceable bufferProducer) | 设置可用缓冲区生成器。 | ## **成员函数说明** @@ -291,3 +292,26 @@ IExecutor::SendCommand ([in] int commandId, [in] unsigned char[] extraInfo, [in] 0 表示操作成功。 非0 表示操作失败。 + +### SetBufferProducer() + + +``` +IExecutor::SetBufferProducer ([in] BufferProducerSequenceable bufferProducer ) +``` + +**描述:** + +设置可用缓冲区生成器。用于传递相机预览流,开始录入前设置为有效值,结束录入后设置为空指针。 + +**参数:** + + | 名称 | 描述 | +| -------- | -------- | +| bufferProducer | 可用缓冲区生成器。 | + +**返回:** + +0 表示操作成功。 + +非0 表示操作失败。 diff --git a/zh-cn/device-dev/reference/hdi-apis/modulelist.md b/zh-cn/device-dev/reference/hdi-apis/modulelist.md deleted file mode 100644 index a0969df08272de3d04f006ea7643d30eec42deed..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/modulelist.md +++ /dev/null @@ -1,39 +0,0 @@ -# 模块 - - - -- **[Audio](_audio.md)** - -- **[Battery](battery.md)** - -- **[Camera](camera.md)** - -- **[Codec](codec.md)** - -- **[Display](_display.md)** - -- **[HdfFaceAuth](_hdf_face_auth.md)** - -- **[HdfPinAuth](_hdf_pin_auth.md)** - -- **[HdfUserAuth](_hdf_user_auth.md)** - -- **[HdiActivityRecognition](activity_recognition.md)** - -- **[Input](input.md)** - -- **[Light](light.md)** - -- **[Motion](motion.md)** - -- **[Power](power.md)** - -- **[Sensor](sensor.md)** - -- **[Thermal](thermal.md)** - -- **[USB](usb.md)** - -- **[Vibrator](vibrator.md)** - -- **[WLAN](wlan.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/reference/hdi-apis/total.md b/zh-cn/device-dev/reference/hdi-apis/total.md deleted file mode 100644 index bac50766065bf942c00fe3d98e89e1772b2b5087..0000000000000000000000000000000000000000 --- a/zh-cn/device-dev/reference/hdi-apis/total.md +++ /dev/null @@ -1,7 +0,0 @@ -# 头文件和结构体 - - - -- **[头文件](files.md)** - -- **[结构体](annotated.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index acd1c7b4da051bbc6736ed35ffa32f92f2d00f8f..9f7d8e47a86f06a2ec8df38a2142c70614251a1c 100644 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -5,18 +5,18 @@ - [构建系统编码规范与最佳实践](subsys-build-gn-coding-style-and-best-practice.md) - [编译构建Kconfig可视化配置指导](subsys-build-gn-kconfig-visual-config-guide.md) - 编译构建相关操作 - - [产品配置规则](subsys-build-product.md#产品配置规则) - - [子系统配置规则](subsys-build-subsystem.md#子系统配置规则) - - [部件配置规则](subsys-build-component.md#部件配置规则) - - [部件编译构建规范](subsys-build-component-building-rules.md#部件编译构建规范) - - [模块配置规则](subsys-build-module.md#模块配置规则) - - [芯片解决方案配置规则](subsys-build-chip_solution.md#芯片解决方案配置规则) - - [特性配置规则](subsys-build-feature.md#特性配置规则) - - [系统能力配置规则](subsys-build-syscap.md#如何按需配置部件的系统能力) - - [关于deps、external_deps的使用](subsys-build-reference.md#关于deps、external_deps的使用) - - [开源软件Notice收集策略说明](subsys-build-reference.md#开源软件notice收集策略说明) - - [加快本地编译的一些参数](subsys-build-reference.md#加快本地编译的一些参数) - - [查看NinjaTrace](subsys-build-reference.md#查看ninjatrace) + - [产品配置规则](subsys-build-product.md) + - [子系统配置规则](subsys-build-subsystem.md) + - [部件配置规则](subsys-build-component.md) + - [部件编译构建规范](subsys-build-component-building-rules.md) + - [模块配置规则](subsys-build-module.md) + - [芯片解决方案配置规则](subsys-build-chip_solution.md) + - [特性配置规则](subsys-build-feature.md) + - [系统能力配置规则](subsys-build-syscap.md) + - [关于deps、external_deps的使用](subsys-build-reference.md) + - [开源软件Notice收集策略说明](subsys-build-reference.md) + - [加快本地编译的一些参数](subsys-build-reference.md) + - [查看NinjaTrace](subsys-build-reference.md) - [HAP编译构建指导](subsys-build-gn-hap-compilation-guide.md) - [ 常见问题](subsys-build-FAQ.md) - [ArkCompiler](subsys-arkcompiler-guide.md) diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md index 4c8ed67988e5d30c5adcc5532fef02e2b376c0ea..8c871f3957bc0bb8f8ba3c962b7c7e63f5711050 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @@ -4,82 +4,191 @@ ### 功能简介 -HiSysEvent打点提供了事件埋点功能,开发者可以通过在关键路径埋点来记录系统在运行过程中的重要信息。同时,HiSysEvent打点也提供了以事件领域为单位的HiSysEvent打点屏蔽机制,方便开发者评估及调试HiSysEvent打点操作的影响。 +HiSysEvent打点提供了事件打点功能,开发者可以通过在关键路径打点来记录系统在运行过程中的重要信息。同时,HiSysEvent打点也提供了以事件领域为单位的HiSysEvent打点屏蔽机制,方便开发者评估及调试HiSysEvent打点操作的影响。 ### 运作机制 -在进行HiSysEvent事件埋点之前,需要先完成HiSysEvent打点配置,具体配置方法请参考[HiSysEvent打点配置指导](subsys-dfx-hisysevent-logging-config.md)。 +在进行HiSysEvent事件打点之前,需要先完成HiSysEvent打点配置,具体配置方法请参考[HiSysEvent打点配置指导](subsys-dfx-hisysevent-logging-config.md)。 ## 开发指导 ### 场景介绍 -事件埋点的主要工作是将打点数据进行落盘。 +事件打点的主要工作是将打点数据进行落盘。 ### 接口说明 #### C++接口说明 -C++事件埋点开发能力如下:HiSysEvent类,具体的API详见接口文档 。 +C++事件打点开发能力如下:HiSysEvent类,具体API详见接口目录(/base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/)。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> 在OpenHarmony-3.2-Beta3版本中,为避免打点风暴事件引发性能问题,对HiSysEvent打点进行了管控。表1中的HiSysEvent::Write打点API接口被表2中的HiSysEventWrite宏接口取代。HiSysEvent::Write接口已废弃,请使用HiSysEventWrite宏完成HiSysEvent事件打点。 +> 从OpenHarmony-3.2-Beta3版本开始,为避免打点风暴事件引发性能问题,对HiSysEvent打点进行了管控。表1中的HiSysEvent::Write打点接口被表2中的HiSysEventWrite宏接口取代。HiSysEvent::Write接口已废弃,请使用HiSysEventWrite宏接口完成HiSysEvent事件打点。 -**表1** C++事件埋点API接口功能介绍(已废弃) +**表1** 事件打点接口(已废弃) | 接口名 | 描述 | | ------------------------------------------------------------ | --------------------- | -| template<typename... Types> 
static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | 将打点事件数据进行落盘 | +| template<typename... Types> 
static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | 将打点事件数据进行落盘。 | + +**表2** 事件打点宏接口 -**表2** C++事件埋点API接口功能介绍 | 接口名 | 描述 | | ------------------------------------------------------------ | --------------------- | -| HiSysEventWrite(domain, eventName, type, ...) | 将打点事件数据进行落盘 | +| HiSysEventWrite(domain, eventName, type, ...) | 将打点事件数据进行落盘。 | - **表3** C++事件类型介绍 + **表3** EventType事件类型枚举 | 事件类型 | 描述 | | --------- | ----------- | -| FAULT | 故障类型事件 | -| STATISTIC | 统计类型事件 | -| SECURITY | 安全类型事件 | -| BEHAVIOR | 行为类型事件 | +| FAULT | 故障类型事件。 | +| STATISTIC | 统计类型事件。 | +| SECURITY | 安全类型事件。 | +| BEHAVIOR | 行为类型事件。 | + +#### C接口说明 + +C事件打点开发能力如下:具体API详见接口目录(/base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include/)。 + +**表4** 事件打点接口 + +| 接口名 | 描述 | +| ------------------------------------------------------------ | ------------------------ | +| int OH_HiSysEvent_Write(const char\* domain, const char\* name, HiSysEventEventType type, HiSysEventParam params[], size_t size); | 将打点事件数据进行落盘。 | + +**表5** HiSysEventEventType事件类型枚举 + +| 事件类型 | 描述 | +| -------------------- | -------------- | +| HISYSEVENT_FAULT | 故障类型事件。 | +| HISYSEVENT_STATISTIC | 统计类型事件。 | +| HISYSEVENT_SECURITY | 安全类型事件。 | +| HISYSEVENT_BEHAVIOR | 行为类型事件。 | + +**表6** HiSysEventParam事件参数结构体 + +| 属性名称 | 属性类型 | 描述 | +| --------- | -------------------- | ---------------------------------- | +| name | char name[] | 事件参数名称。 | +| t | HiSysEventParamType | 事件参数类型。 | +| v | HiSysEventParamValue | 事件参数值。 | +| arraySize | size_t | 事件参数值为数组类型时的数组长度。 | + +**表7** HiSysEventParamType事件参数类型枚举 + +| 参数类型 | 描述 | +| ----------------------- | -------------------------- | +| HISYSEVENT_INVALID | 无效类型事件参数。 | +| HISYSEVENT_BOOL | bool类型事件参数。 | +| HISYSEVENT_INT8 | int8_t类型事件参数。 | +| HISYSEVENT_UINT8 | uint8_t类型事件参数。 | +| HISYSEVENT_INT16 | int16_t类型事件参数。 | +| HISYSEVENT_UINT16 | uint16_t类型事件参数。 | +| HISYSEVENT_INT32 | int32_t类型事件参数。 | +| HISYSEVENT_UINT32 | uint32_t类型事件参数。 | +| HISYSEVENT_INT64 | int64_t类型事件参数。 | +| HISYSEVENT_UINT64 | uint64_t类型事件参数。 | +| HISYSEVENT_FLOAT | float类型事件参数。 | +| HISYSEVENT_DOUBLE | double类型事件参数。 | +| HISYSEVENT_STRING | char*类型事件参数。 | +| HISYSEVENT_BOOL_ARRAY | bool数组类型事件参数。 | +| HISYSEVENT_INT8_ARRAY | int8_t数组类型事件参数。 | +| HISYSEVENT_UINT8_ARRAY | uint8_t数组类型事件参数。 | +| HISYSEVENT_INT16_ARRAY | int16_t数组类型事件参数。 | +| HISYSEVENT_UINT16_ARRAY | uint16_t数组类型事件参数。 | +| HISYSEVENT_INT32_ARRAY | int32_t数组类型事件参数。 | +| HISYSEVENT_UINT32_ARRAY | uint32_t数组类型事件参数。 | +| HISYSEVENT_INT64_ARRAY | int64_t数组类型事件参数。 | +| HISYSEVENT_UINT64_ARRAY | uint64_t数组类型事件参数。 | +| HISYSEVENT_FLOAT_ARRAY | float数组类型事件参数。 | +| HISYSEVENT_DOUBLE_ARRAY | double数组类型事件参数。 | +| HISYSEVENT_STRING_ARRAY | char*数组类型事件参数。 | + +**表8** HiSysEventParamValue事件参数值联合体 + +| 属性名称 | 属性类型 | 描述 | +| -------- | -------- | ------------------------ | +| b | bool | bool类型事件参数值。 | +| i8 | int8_t | int8_t类型事件参数值。 | +| ui8 | uint8_t | uint8_t类型事件参数值。 | +| i16 | int16_t | int16_t类型事件参数值。 | +| ui16 | uint16_t | uint16_t类型事件参数值。 | +| i32 | int32_t | int32_t类型事件参数值。 | +| ui32 | uint32_t | uint32_t类型事件参数值。 | +| i64 | int64_t | int64_t类型事件参数值。 | +| ui64 | uint64_t | uint64_t类型事件参数值。 | +| f | float | float类型事件参数值。 | +| d | double | double类型事件参数值。 | +| s | char* | char*类型事件参数值。 | +| array | void* | 数组类型事件参数值。 | #### kernel接口说明 -kernel事件埋点开发能力如下: +kernel事件打点开发能力如下:具体API详见接口文件(/kernel/linux/linux-5.10/include/dfx/hiview_hisysevent.h)。 -**表4** kernel事件埋点API接口功能介绍 +**表9** 事件打点接口 | 接口名 | 描述 | | ------------------------------------------------------------ | ----------------------------------- | -| struct hiview_hisysevent *hisysevent_create(const char *domain, const char *name, enum hisysevent_type type); | 创建一个事件对象 | -| void hisysevent_destroy(struct hiview_hisysevent *event); | 销毁一个事件对象 | -| int hisysevent_put_integer(struct hiview_hisysevent *event, const char *key, long long value); | 将整数类型的事件参数添加到事件对象 | -| int hisysevent_put_string(struct hiview_hisysevent *event, const char *key, const char *value); | 将字符串类型的事件参数添加到事件对象 | -| int hisysevent_write(struct hiview_hisysevent *event); | 将事件对象数据进行落盘 | +| struct hiview_hisysevent *hisysevent_create(const char *domain, const char *name, enum hisysevent_type type); | 创建一个事件对象。 | +| void hisysevent_destroy(struct hiview_hisysevent *event); | 销毁一个事件对象。 | +| int hisysevent_put_integer(struct hiview_hisysevent *event, const char *key, long long value); | 将整数类型的事件参数添加到事件对象。 | +| int hisysevent_put_string(struct hiview_hisysevent *event, const char *key, const char *value); | 将字符串类型的事件参数添加到事件对象。 | +| int hisysevent_write(struct hiview_hisysevent *event); | 将事件对象数据进行落盘。 | -**表5** kernel事件类型介绍 +**表10** hisysevent_type事件类型枚举 | 事件类型 | 描述 | | --------- | ----------- | -| FAULT | 故障类型事件 | -| STATISTIC | 统计类型事件 | -| SECURITY | 安全类型事件 | -| BEHAVIOR | 行为类型事件 | +| FAULT | 故障类型事件。 | +| STATISTIC | 统计类型事件。 | +| SECURITY | 安全类型事件。 | +| BEHAVIOR | 行为类型事件。 | ### 开发步骤 -#### C++埋点开发步骤 +#### C++打点开发步骤 -1. 在需要埋点的地方直接调用埋点接口,并传入相应事件参数。 +在需要打点的地方直接调用打点接口,并传入相应事件参数。 ```c++ HiSysEventWrite(HiSysEvent::Domain::AAFWK, "START_APP", HiSysEvent::EventType::BEHAVIOR, "APP_NAME", "com.ohos.demo"); ``` -#### kernel埋点开发步骤 +#### C打点开发步骤 + +1. 如果需要在打点时传入自定义事件参数,先要根据事件参数类型创建对应的事件参数对象,再将其放入到事件参数数组中。 + + ```c + // 创建一个int32_t类型的事件参数 + HiSysEventParam param1 = { + .name = "KEY_INT32", + .t = HISYSEVENT_INT32, + .v = { .i32 = 1 }, + .arraySize = 0, + }; + + // 创建一个int32_t数组类型的事件参数 + int32_t int32Arr[] = { 1, 2, 3 }; + HiSysEventParam param2 = { + .name = "KEY_INT32_ARR", + .t = HISYSEVENT_INT32_ARRAY, + .v = { .array = int32Arr }, + .arraySize = sizeof(int32Arr) / sizeof(int32Arr[0]), + }; + + // 将事件参数对象放入创建的事件参数数组中 + HiSysEventParam params[] = { param1, param2 }; + ``` + +2. 在需要打点的地方调用打点接口,并传入相应事件参数。 + + ```c + OH_HiSysEvent_Write("TEST_DOMAIN", "TEST_NAME", HISYSEVENT_BEHAVIOR, params, sizeof(params) / sizeof(params[0])); + ``` + +#### kernel打点开发步骤 1. 根据事件领域、事件名称、事件类型参数,创建一个基础的事件对象。 @@ -141,9 +250,9 @@ kernel事件埋点开发能力如下: ### 开发实例 -#### C++埋点开发实例 +#### C++打点开发实例 -假设业务模块需要在应用启动时进行埋点来记录应用启动事件,且需要记录应用的包名信息,完整使用示例如下所示: +假设业务模块需要在应用启动时进行打点来记录应用启动事件,且需要记录应用的包名信息,完整使用示例如下所示: 1. 首先,需要在业务模块的在BUILD.gn里增加HiSysEvent部件依赖。 @@ -151,7 +260,7 @@ kernel事件埋点开发能力如下: external_deps = [ "hisysevent_native:libhisysevent" ] ``` -2. 在业务模块的应用启动函数StartAbility()中,调用埋点接口并传入对应事件参数。 +2. 在业务模块的应用启动函数StartAbility()中,调用打点接口并传入对应事件参数。 ```c++ #include "hisysevent.h" @@ -164,9 +273,40 @@ kernel事件埋点开发能力如下: } ``` -#### kernel埋点开发实例 +#### C打点开发实例 + +假设业务模块需要在应用启动时进行打点来记录应用启动事件,且需要记录应用的包名信息,完整使用示例如下所示: + +1. 首先,需要在业务模块的在BUILD.gn里增加HiSysEvent部件依赖。 + + ```c++ + external_deps = [ "hisysevent_native:libhisysevent" ] + ``` + +2. 在业务模块的应用启动函数StartAbility()中,调用打点接口并传入对应事件参数。 + + ```c + #include "hisysevent_c.h" + + int StartAbility() + { + ... // 其他业务逻辑 + char packageName[] = "com.ohos.demo"; + HiSysEventParam param = { + .name = "APP_NAME", + .t = HISYSEVENT_STRING, + .v = { .s = packageName }, + .arraySize = 0, + }; + HiSysEventParam params[] = { param }; + int ret = OH_HiSysEvent_Write("AAFWK", "START_APP", HISYSEVENT_BEHAVIOR, params, sizeof(params) / sizeof(params[0])); + ... // 其他业务逻辑 + } + ``` + +#### kernel打点开发实例 -假设内核业务模块需要在设备启动时进行埋点来记录设备启动事件,完整使用示例如下所示: +假设内核业务模块需要在设备启动时进行打点来记录设备启动事件,完整使用示例如下所示: 1. 在设备启动函数device_boot()中,构建一个启动事件对象,然后将事件进行上报,最后销毁事件对象。 @@ -204,7 +344,6 @@ kernel事件埋点开发能力如下: - 假设业务模块中,需要在某个cpp文件中屏蔽名称分别为AAFWK和POWER的事件领域的打点,在该cpp文件引入hisysevent.h头文件之前,定义名称为DOMAIN_MASKS的宏: ```c++ - #define DOMAIN_MASKS "AAFWK|POWER" #include "hisysevent.h" @@ -212,14 +351,13 @@ kernel事件埋点开发能力如下: HiSysEventWrite(OHOS:HiviewDFX::HiSysEvent::Domain::AAFWK, "JS_ERROR", OHOS:HiviewDFX::HiSysEvent::EventType::FAULT, "MODULE", "com.ohos.module"); // 该HiSysEvent打点操作不会执行 ... // 其他业务逻辑 HiSysEventWrite(OHOS:HiviewDFX::HiSysEvent::Domain::POWER, "POWER_RUNNINGLOCK", OHOS:HiviewDFX::HiSysEvent::EventType::FAULT, "NAME", "com.ohos.module"); // 该HiSysEvent打点操作不会执行 - ``` - 假设需要在整个业务模块中屏蔽名称分别为AAFWK和POWER的事件领域的打点,在模块的BUILG.gn文件中定义名称为DOMAIN_MASKS的宏: ```gn config("module_a") { - ... // 其他配置项 - cflags_cc += ["-DDOMAIN_MASKS=\"AAFWK|POWER\""] + ... // 其他配置项 + cflags_cc += ["-DDOMAIN_MASKS=\"AAFWK|POWER\""] } ``` @@ -231,4 +369,4 @@ kernel事件埋点开发能力如下: # 参考 -HiSysEvent模块会将埋点数据写入到节点文件中,而埋点数据的解析处理会在Hiview模块中统一进行,详细处理过程可参考[Hiview开发指导](subsys-dfx-hiview.md)。 +HiSysEvent模块会将打点数据写入到节点文件中,而打点数据的解析处理会在Hiview模块中统一进行,详细处理过程可参考[Hiview开发指导](subsys-dfx-hiview.md)。 diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 180706d7e409c2fed9046ce5d0402c2c969e9192..9ea8b3859494f92ee72d5d291bfa13b45ebf4854 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -8,105 +8,380 @@ HiSysEvent提供了查询接口,支持开发者设置条件查询HiSysEvent事 ## 开发指导 - ### 接口说明 +#### C++接口说明 + +C++ HiSysEvent查询开发能力如下:HiSysEventManager类,具体API详见接口目录(/base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent_manager/include/)。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > -> HiSysEventQueryCallback查询回调对象OnQuery方法中的形参类型HiSysEventRecord请参考[HiSysEvent订阅](subsys-dfx-hisysevent-listening.md)中的**表5**HiSysEventRecord系统事件对象说明 +> HiSysEventQueryCallback查询回调对象OnQuery方法中的形参类型HiSysEventRecord请参考[HiSysEvent订阅](subsys-dfx-hisysevent-listening.md)中的“表5 HiSysEventRecord系统事件对象”说明。 **表1** HiSysEvent查询接口 -| 接口名 | 描述 | +| 接口名称 | 描述 | | -------- | -------- | -| int32_t HiSysEventManager::Query(struct QueryArg& arg,
 std::vector<QueryRule>& rules,
 std::shared_ptr<HiSysEventQueryCallback> callback) | 接口功能:支持设置时间段,事件领域,事件名称等,查询满足条件的HiSysEvent事件。
输入参数:
- arg:查询参数。
- rules:事件过滤规则。
- callback:查询接口回调对象。
返回值:
- 0:查询成功。
- 负值:查询失败。 | +| int32_t Query(struct QueryArg& arg,
std::vector<QueryRule>& rules,
std::shared_ptr<HiSysEventQueryCallback> callback) | 接口功能:支持根据时间段、事件领域、事件名称等条件,查询满足条件的HiSysEvent事件。
输入参数:
- arg:查询参数。
- rules:事件过滤规则。
- callback:查询接口回调对象。
返回值:
- 0:查询成功。
- 负值:查询失败。 | **表2** QueryArg查询参数对象 -| 属性名称 | 描述 | -| -------- | -------- | -| beginTime | long long int类型,用于指定查询事件的开始时间。 | -| endTime | long long int类型,用于指定查询事件的结束时间。 | -| maxEvents | int类型,用于指定查询返回事件查询的最多条数。 | +| 属性名称 | 属性类型 | 描述 | +| -------- | -------- | -------- | +| beginTime | long long | 用于指定查询事件的开始时间,格式为Unix毫秒级时间戳。 | +| endTime | long long | 用于指定查询事件的结束时间,格式为Unix毫秒级时间戳。 | +| maxEvents | int | 用于指定查询返回事件的最多条数。 | **表3** QueryRule查询规则对象 | 接口名称 | 描述 | | -------- | -------- | -| QueryRule(const std::string& domain,
 const std::vector<std::string>& eventList) | 接口功能:查询规则构造函数,创建查询规则对象。
输入参数:
- domain:string类型,用来标识查询规则对象的事件所属领域,如果传入的是空字符串,则默认事件领域字段匹配成功。
- eventList:std::vector<std::string>类型,事件名称的列表,如果传入的是空字符串,则默认事件名称字段匹配成功。 | +| QueryRule(const std::string& domain,
const std::vector<std::string>& eventList) | 接口功能:查询规则构造函数,创建查询规则对象。
输入参数:
- domain:string类型,用来标识查询规则对象的事件所属领域,如果传入的是空字符串,则默认事件领域字段匹配成功。
- eventList:std::vector<std::string>类型,事件名称的列表,如果传入的是空字符串,则默认事件名称字段匹配成功。 | **表4** HiSysEventQueryCallback查询回调对象 | 接口名称 | 描述 | | -------- | -------- | -| void HiSysEventQueryCallback::OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents) | 接口功能:事件查询的回调。
输入参数:
- sysEvents:返回的事件集合。
返回值:
无。 | -| void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) | 接口功能:事件查询完成的回调。
输入参数:
- reason:查询结束返回原因,目前默认是0。
- total:本次查询总共返回的事件总数量。
返回值:
无。 | +| void HiSysEventQueryCallback::OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents) | 接口功能:事件查询的回调。
输入参数:
- sysEvents:返回的事件集合。 | +| void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) | 接口功能:事件查询完成的回调。
输入参数:
- reason:查询结束的返回原因,0表示查询正常结束,其他值表示查询异常结束。
- total:本次查询返回的事件的总数量。 | -### 开发实例 +#### C接口说明 -C++接口实例。 +C HiSysEvent查询开发能力如下:具体API详见接口目录(/base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent_manager/include/)。 -1. 源代码开发: - 引入对应的头文件: + **表5** HiSysEvent查询接口 - ``` +| 接口名称 | 描述 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| int OH_HiSysEvent_Query(const HiSysEventQueryArg& arg, HiSysEventQueryRule rules[], size_t ruleSize, HiSysEventQueryCallback& callback); | 接口功能:支持根据时间段、事件领域、事件名称、事件参数等条件,查询满足条件的HiSysEvent事件。
输入参数:
- arg:查询参数。
- rules:事件过滤规则。
- ruleSize:事件过滤规则数量。
- callback:查询接口回调。
返回值:
- 0:查询成功。
- 负值:查询失败。 | + + **表6** HiSysEventQueryArg查询参数结构体 + +| 属性名称 | 属性类型 | 描述 | +| --------- | -------- | ---------------------------------------------------- | +| beginTime | int64_t | 用于指定查询事件的开始时间,格式为Unix毫秒级时间戳。 | +| endTime | int64_t | 用于指定查询事件的结束时间,格式为Unix毫秒级时间戳。 | +| maxEvents | int32_t | 用于指定查询返回事件的最多条数。 | + +**表7** HiSysEventQueryRule查询规则结构体 + +| 属性名称 | 属性类型 | 描述 | +| ------------- | --------- | ---------------------------------- | +| domain | char[] | 用来指定查询的事件领域。 | +| eventList | char\[][] | 用于指定查询的事件名称列表。 | +| eventListSize | size_t | 用于指定查询的事件名称列表大小。 | +| condition | char* | 用于指定查询的自定义事件参数条件。 | + +对于condition参数需要按照指定的JSON字符串格式传入,使用实例如下: + +```json +{ + "version":"V1", + "condition":{ + "and":[ + {"param":"type_","op":">","value":0}, + {"param":"uid_","op":"=","value":1201} + ], + "or":[ + {"param":"NAME","op":"=","value":"SysEventService"}, + {"param":"NAME","op":"=","value":"SysEventSource"} + ] + } +} +``` + +- version字段是必选字段,表示传入条件的支持版本,当前只支持V1版本。 +- condition字段是必选字段,表示传入条件的具体内容。 + - and字段是可选字段,表示条件之间是与的关系。 + - or字段是可选字段,表示条件之间是或的关系。 + - param字段是必选字段,表示条件匹配的参数名称,必须为字符串类型。 + - op字段是必选字段,表示条件匹配的参数比较符,必须为字符串类型,支持的比较符包括=、>、<、>=、<=。 + - value字段是必选字段,表示条件匹配的参数值,必须为字符串类型或整型。 + +**表8** HiSysEventQueryCallback查询回调结构体 + +| 属性名称 | 属性类型 | 描述 | +| ---------- | -------------------------------------------------- | ------------------------------------------------------------ | +| OnQuery | void (*)(HiSysEventRecord records[], size_t size); | 接口功能:事件查询的回调。
输入参数:
- records:返回的事件集合。
- size:返回的事件集合大小。 | +| OnComplete | void (*)(int32_t reason, int32_t total); | 接口功能:事件查询完成的回调。
输入参数:
- reason:查询结束的返回原因,0表示查询正常结束,其他值表示查询异常结束。
- total:本次查询返回的事件的总数量。 | + +**表9** HiSysEventRecord事件结构体 + +| 属性名称 | 属性类型 | 描述 | +| --------- | ------------------- | -------------------------- | +| domain | char[] | 事件的领域名称。 | +| eventName | char\[] | 事件的名称。 | +| type | HiSysEventEventType | 事件的类型。 | +| time | uint64_t | 事件的时间戳。 | +| tz | char\[] | 事件的时区。 | +| pid | int64_t | 事件的进程ID。 | +| tid | int64_t | 事件的线程ID。 | +| uid | int64_t | 事件的用户ID。 | +| traceId | uint64_t | 事件的分布式跟踪链ID。 | +| spandId | uint64_t | 事件的分布式跟踪分支ID。 | +| pspanId | uint64_t | 事件的分布式跟踪父分支ID。 | +| traceFlag | int | 事件的分布式跟踪标志位。 | +| level | char* | 事件的级别。 | +| tag | char* | 事件的标签。 | +| jsonStr | char* | 事件的内容。 | + +**表10** HiSysEventRecord解析接口 + +| 接口名称 | | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| void OH_HiSysEvent_GetParamNames(const HiSysEventRecord& record, char*** params, size_t& len); | 接口功能:获取该事件的所有的参数名。
输入参数:
- record:事件结构体。
- params:参数名数组。
- len:数组大小。 | +| int OH_HiSysEvent_GetParamInt64Value(const HiSysEventRecord& record, const char* name, int64_t& value); | 接口功能:将该事件中参数名为name的参数值,解析为int64_t类型并赋值到value。
输入参数:
- record:事件结构体。
- name:参数名。
- value:int64_t类型的参数值。 | +| int OH_HiSysEvent_GetParamUint64Value(const HiSysEventRecord& record, const char* name, uint64_t& value); | 接口功能:将该事件中参数名为name的参数值,解析为uint64_t类型并赋值到value。
输入参数:
- record:事件结构体。
- name:参数名。
- value:uint64_t类型的参数值。 | +| int OH_HiSysEvent_GetParamDoubleValue(const HiSysEventRecord& record, const char* name, double& value); | 接口功能:将该事件中参数名为name的参数值,解析为double类型并赋值到value。
输入参数:
- record:事件结构体。
- name:参数名。
- value:double类型的参数值。 | +| int OH_HiSysEvent_GetParamStringValue(const HiSysEventRecord& record, const char* name, char** value); | 接口功能:将该事件中参数名为name的参数值,解析为char数组类型并赋值到value,value在使用完成后需要手动释放内存。
输入参数:
- record:事件结构体。
- name:参数名。
- value:char\*类型引用。 | +| int OH_HiSysEvent_GetParamInt64Values(const HiSysEventRecord& record, const char* name, int64_t** value, size_t& len); | 接口功能:将该事件中参数名为name的参数值,解析为int64_t数组类型并赋值到value,value在使用完成后需要手动释放内存。
输入参数:
- record:事件结构体。
- name:参数名。
- value:int64_t\*类型引用。
- len:数组大小。 | +| int OH_HiSysEvent_GetParamUint64Values(const HiSysEventRecord& record, const char* name, uint64_t** value, size_t& len); | 接口功能:将该事件中参数名为name的参数值,解析为uint64_t数组类型并赋值到value,value在使用完成后需要手动释放内存。
输入参数:
- record:事件结构体。
- name:参数名。
- value:uint64_t\*类型引用。
- len:数组大小。 | +| int OH_HiSysEvent_GetParamDoubleValues(const HiSysEventRecord& record, const char* name, double** value, size_t& len); | 接口功能:将该事件中参数名为name的参数值,解析为double数组类型并赋值到value,value在使用完成后需要手动释放内存。
输入参数:
- record:事件结构体。
- name:参数名。
- value:double\*类型引用。
- len:数组大小。 | +| int OH_HiSysEvent_GetParamStringValues(const HiSysEventRecord& record, const char* name, char*** value, size_t& len); | 接口功能:将该事件中参数名为name的参数值,解析为char*数组类型并赋值到value,value在使用完成后需要手动释放内存。
输入参数:
- record:事件结构体。
- name:参数名。
- value:char\*\*类型引用。
- len:数组大小。 | + +HiSysEventRecord解析接口的返回值说明如下: + +- 0,表示解析成功; +- -1,表示该事件初始化失败; +- -2,表示参数名不存在; +- -3,表示要解析的参数值类型与传入的参数值类型不匹配。 + +### 开发步骤 + +#### C++ HiSysEvent查询开发步骤 + +1. 首先,需要引入对应的头文件。 + + ```c++ #include "hisysevent_manager.h" ``` - 实现对应的查询回调接口: +2. 然后,业务领域需要实现对应的查询回调接口。 - ``` - void HiSysEventQueryCallback::OnQuery(std::shared_ptr> sysEvents) - void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) + ```c++ + class TestQueryCallback : public HiSysEventQueryCallback { + public: + void OnQuery(std::shared_ptr> sysEvents) override + { + if (sysEvents == nullptr) { + return; + } + for_each((*sysEvents).cbegin(), (*sysEvents).cend(), [](const HiSysEventRecord& event) { + std::cout << event.AsJson() << std::endl; + }); + } + + void OnComplete(int32_t reason, int32_t total) override + { + std::cout << "Query completed" << std::endl; + return; + } + }; ``` - 在相应的业务逻辑里面调用查询接口: +3. 最后,在需要查询的地方调用查询接口,并传入相应的查询参数、查询规则、查询回调参数。 + ```c++ + // 创建查询参数对象 + long long startTime = 0; + long long endTime = 1668245644000; //2022-11-12 09:34:04 + int queryCount = 10; + QueryArg arg(startTime, endTime, queryCount); + + // 创建查询规则对象 + QueryRule rule("HIVIEWDFX", { "PLUGIN_LOAD" }); + std::vector queryRules = { rule }; + + // 创建查询回调对象 + auto queryCallback = std::make_shared(); + + // 调用查询接口 + HiSysEventManager::Query(arg, queryRules, queryCallback); ``` - HiSysEventManager::Query(struct QueryArg& queryArg, - std::vector& queryRules, std::shared_ptr queryCallBack) - ``` - 以下是查询所有系统事件的应用例子: +#### C HiSysEvent查询开发步骤 + +1. 首先,需要引入对应的头文件。 + ```c++ + #include "hisysevent_manager_c.h" ``` - #include "hisysevent_manager.h" - #include - namespace OHOS { - namespace HiviewDFX { - // 实现查询回调的接口 - void HiSysEventToolQuery::OnQuery(std::shared_ptr> sysEvents) +2. 然后,业务领域需要实现对应的查询回调接口。 + + ```c++ + void OnQueryTest(HiSysEventRecord records[], size_t size) { - if (sysEvents == nullptr) { - return; + for (size_t i = 0; i < size; i++) { + printf("OnQuery: event=%s", records[i].jsonStr); } - for_each((*sysEvents).cbegin(), (*sysEvents).cend(), [](const HiSysEventRecord& event) { - std::cout << event.AsJson() << std::endl; - }); } - - void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total) + + void OnCompleteTest(int32_t reason, int32_t total) { - return; + printf("OnCompleted, res=%d, total=%d\n", reason, total); } - } // namespace HiviewDFX - } // namespace OHOS - - // 调用查询接口获取HiSysEvent事件 - auto queryCallBack = std::make_shared(); - struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector rules; - HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack); ``` -2. 编译设置: - 在BUILD.gn编译文件中,需要添加依赖hisysevent_native部件的libhisysevent及libhisyseventmanager库。 - +3. 最后,在需要查询的地方调用查询接口,并传入相应的查询参数、查询规则、查询回调参数。 + + ```c++ + // 创建查询参数对象 + HiSysEventQueryArg arg; + arg.beginTime = 0; + arg.endTime = 1668245644000; //2022-11-12 09:34:04 + arg.maxEvents = 10; + + // 创建查询规则对象 + constexpr char TEST_DOMAIN[] = "HIVIEWDFX"; + constexpr char TEST_NAME[] = "PLUGIN_LOAD"; + HiSysEventQueryRule rule; + (void)strcpy_s(rule.domain, strlen(TEST_DOMAIN) + 1, TEST_DOMAIN); + (void)strcpy_s(rule.eventList[0], strlen(TEST_NAME) + 1, TEST_NAME); + rule.eventListSize = 1; + rule.condition = nullptr; + HiSysEventQueryRule rules[] = { rule }; + + // 创建查询回调对象 + HiSysEventQueryCallback callback; + callback.OnQuery = OnQueryTest; + callback.OnComplete = OnCompleteTest; + + // 调用查询接口 + OH_HiSysEvent_Query(arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), callback); ``` + +### 开发实例 + +#### C++ HiSysEvent查询开发实例 + +假设业务模块需要查询截止至当前时间、事件领域为HIVIEWDFX、事件名称为PLUGIN_LOAD的所有事件,其完整使用示例如下所示: + +1. 首先,需要在业务模块的在BUILD.gn里增加hisysevent_native部件的libhisysevent及libhisyseventmanager依赖。 + + ```c++ external_deps = [ "hisysevent_native:libhisysevent", "hisysevent_native:libhisyseventmanager", ] ``` +2. 在业务模块的TestQuery()函数中,调用查询接口去查询事件。 + + ```c++ + #include "hisysevent_manager.h" + #include + #include + + using namespace OHOS::HiviewDFX; + + class TestQueryCallback : public HiSysEventQueryCallback { + public: + void OnQuery(std::shared_ptr> sysEvents) override + { + if (sysEvents == nullptr) { + return; + } + for_each((*sysEvents).cbegin(), (*sysEvents).cend(), [](const HiSysEventRecord& event) { + std::cout << event.AsJson() << std::endl; + }); + } + + void OnComplete(int32_t reason, int32_t total) override + { + std::cout << "Query completed" << std::endl; + return; + } + }; + + int64_t GetMilliseconds() + { + auto now = std::chrono::system_clock::now(); + auto millisecs = std::chrono::duration_cast(now.time_since_epoch()); + return millisecs.count(); + } + + void TestQuery() + { + // 创建查询参数对象 + long long startTime = 0; + long long endTime = GetMilliseconds(); + int maxEvents = 100; + QueryArg arg(startTime, endTime, maxEvents); + + // 创建查询规则对象 + QueryRule rule("HIVIEWDFX", { "PLUGIN_LOAD" }); + std::vector queryRules = { rule }; + + // 创建查询回调对象 + auto queryCallback = std::make_shared(); + + // 调用查询接口 + int ret = HiSysEventManager::Query(arg, queryRules, queryCallback); + } + ``` + +#### C HiSysEvent查询开发实例 + +假设业务模块需要查询截止至当前时间、事件领域为HIVIEWDFX、事件名称为PLUGIN_LOAD的所有事件,其完整使用示例如下所示: + +1. 首先,需要在业务模块的在BUILD.gn里增加hisysevent_native部件的libhisyseventmanager依赖。 + + ```c++ + external_deps = [ "hisysevent_native:libhisyseventmanager" ] + + // for strcpy_s + deps = [ "//third_party/bounds_checking_function:libsec_shared" ] + ``` + +2. 在业务模块的TestQuery()函数中,调用查询接口去查询事件。 + + ```c++ + #include "hisysevent_manager_c.h" + #include + #include + + void OnQueryTest(HiSysEventRecord records[], size_t size) + { + for (size_t i = 0; i < size; i++) { + printf("OnQuery: event=%s", records[i].jsonStr); + } + } + + void OnCompleteTest(int32_t reason, int32_t total) + { + printf("OnCompleted, res=%d, total=%d\n", reason, total); + } + + int64_t GetMilliseconds() + { + return time(NULL); + } + + void TestQuery() + { + // 创建查询参数对象 + HiSysEventQueryArg arg; + arg.beginTime = 0; + arg.endTime = GetMilliseconds(); + arg.maxEvents = 100; + + // 创建查询规则对象 + constexpr char TEST_DOMAIN[] = "HIVIEWDFX"; + constexpr char TEST_NAME[] = "PLUGIN_LOAD"; + HiSysEventQueryRule rule; + (void)strcpy_s(rule.domain, strlen(TEST_DOMAIN) + 1, TEST_DOMAIN); + (void)strcpy_s(rule.eventList[0], strlen(TEST_NAME) + 1, TEST_NAME); + rule.eventListSize = 1; + rule.condition = nullptr; + HiSysEventQueryRule rules[] = { rule }; + + // 创建查询回调对象 + HiSysEventQueryCallback callback; + callback.OnQuery = OnQueryTest; + callback.OnComplete = OnCompleteTest; + + // 调用查询接口 + int ret = OH_HiSysEvent_Query(arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), callback); + } + ``` diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 181e52c7768c353051b8e2780a125d79a4dd9128..84d2960c20fa39e0820acd66d26d6afcb6090acf 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -60,8 +60,6 @@ - [Hi3516标准系统入门(命令行方式)](quick-start/quickstart-appendix-hi3516-pkg.md) - [获取源码](get-code/sourcecode-acquire.md) - - [隐私保护](security/security-privacy-protection.md) - - [安全指南](security/security-guidelines-overall.md) - 隐私和安全 - [隐私保护](security/security-privacy-protection.md) - [安全指南](security/security-guidelines-overall.md) @@ -155,6 +153,7 @@ - 子系统开发 - 内核 + - [内核概述](kernel/kernel-overview.md) - 轻量系统内核(LiteOS-M) - [轻量系统内核概述](kernel/kernel-mini-overview.md) - 基础内核 @@ -380,18 +379,18 @@ - [构建系统编码规范与最佳实践](subsystems/subsys-build-gn-coding-style-and-best-practice.md) - [编译构建Kconfig可视化配置指导](subsystems/subsys-build-gn-kconfig-visual-config-guide.md) - 编译构建参考 - - [子系统配置规则](subsystems/subsys-build-subsystem.md#子系统配置规则) - - [产品配置规则](subsystems/subsys-build-product.md#产品配置规则) - - [子系统配置规则](subsystems/subsys-build-subsystem.md#子系统配置规则) - - [部件配置规则](subsystems/subsys-build-component.md#部件配置规则) - - [模块配置规则](subsystems/subsys-build-module.md#模块配置规则) - - [芯片解决方案配置规则](subsystems/subsys-build-chip_solution.md#芯片解决方案配置规则) - - [特性配置规则](subsystems/subsys-build-feature.md#特性配置规则) - - [系统能力配置规则](subsystems/subsys-build-syscap.md#如何按需配置部件的系统能力) - - [关于deps、external_deps的使用](subsystems/subsys-build-reference.md#关于deps、external_deps的使用) - - [开源软件Notice收集策略说明](subsystems/subsys-build-reference.md#开源软件notice收集策略说明) - - [加快本地编译的一些参数](subsystems/subsys-build-reference.md#加快本地编译的一些参数) - - [查看NinjaTrace](subsystems/subsys-build-reference.md#查看ninjatrace) + - [子系统配置规则](subsystems/subsys-build-subsystem.md) + - [产品配置规则](subsystems/subsys-build-product.md) + - [子系统配置规则](subsystems/subsys-build-subsystem.md) + - [部件配置规则](subsystems/subsys-build-component.md) + - [模块配置规则](subsystems/subsys-build-module.md) + - [芯片解决方案配置规则](subsystems/subsys-build-chip_solution.md) + - [特性配置规则](subsystems/subsys-build-feature.md) + - [系统能力配置规则](subsystems/subsys-build-syscap.md) + - [关于deps、external_deps的使用](subsystems/subsys-build-reference.md) + - [开源软件Notice收集策略说明](subsystems/subsys-build-reference.md) + - [加快本地编译的一些参数](subsystems/subsys-build-reference.md) + - [查看NinjaTrace](subsystems/subsys-build-reference.md) - [HAP编译构建指导](subsystems/subsys-build-gn-hap-compilation-guide.md) - [常见问题](subsystems/subsys-build-FAQ.md) - [分布式远程启动](subsystems/subsys-remote-start.md) @@ -517,12 +516,13 @@ - 调测 - - [测试用例开发](subsystems/subsys-testguide-test.md) + - [developer_test开发者自测试执行框架使用指导](device-test/developer_test.md) + - [xdevice测试调度框架使用指导](device-test/xdevice.md) - 调测工具 - [bytrace使用指导](subsystems/subsys-toolchain-bytrace-guide.md) - [hdc\_std 使用指导](subsystems/subsys-toolchain-hdc-guide.md) - [hiperf 使用指南](subsystems/subsys-toolchain-hiperf.md) -- [XTS认证](subsystems/subsys-xts-guide.md) +- [XTS认证](device-test/xts.md) - 工具 - [Docker编译环境](get-code/gettools-acquire.md) - [IDE集成开发环境](get-code/gettools-ide.md) diff --git a/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md b/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md new file mode 100644 index 0000000000000000000000000000000000000000..7e9748a27e1dbcb15a64d5c9b872738e0292de5c --- /dev/null +++ b/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md @@ -0,0 +1,219 @@ +# 元能力子系统ChangeLog + +## cl.ability.1 应用组件启动规则变更 + +元能力子系统应用组件启动规则在如下场景中存在变更: + + - 应用位于后台启动应用组件 + - 跨应用启动invisible应用组件 + - 跨应用启动FA模型的serviceAbility与dataAbility + - 使用startAbilityByCall接口 + +开发者需要根据以下说明对应用进行适配。 + + +**变更影响** + +若未适配新规则,在上述场景下将无法启动应用组件 +> **注意,启动应用组件是指一切启动或连接Ability的行为:** +
1. 启动Ability,如使用startAbility、startServiceExtensionAbility、startAbilityByCall等接口。 +
2. 连接Ability,如使用connectAbility、connectServiceExtensionAbility、acquireDataAbilityHelper、createDataShareHelper等接口。 + +**关键的接口/组件变更** + + - 涉及的应用组件 + - Stage模型 + - Ability + - ServiceExtension + - DataShareExtension + - FA模型 + - PageAbility + - ServiceAbility + - DataAbility + - 涉及接口 + - Stage模型 + - startAbility(want: Want, callback: AsyncCallback): void; + - startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + - startAbility(want: Want, options?: StartOptions): Promise; + - startAbilityByCall(want: Want): Promise; + - startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + - startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + - startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + - startAbilityForResult(want: Want, callback: AsyncCallback): void; + - startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; + - startAbilityForResult(want: Want, options?: StartOptions): Promise; + - startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + - startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + - startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + - startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + - startServiceExtensionAbility(want: Want): Promise; + - startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + - startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + - stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + - stopServiceExtensionAbility(want: Want): Promise; + - stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + - stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + - connectAbility(want: Want, options: ConnectOptions): number; + - connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + - createDataShareHelper(context: Context, uri: string, callback: AsyncCallback): void + - FA模型 + - startAbility(parameter: StartAbilityParameter, callback: AsyncCallback): void; + - startAbility(parameter: StartAbilityParameter): Promise; + - startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback): void; + - startAbilityForResult(parameter: StartAbilityParameter): Promise; + - acquireDataAbilityHelper(uri: string): DataAbilityHelper; + - connectAbility(request: Want, options:ConnectOptions ): number; + +**适配指导** + +不同场景下的启动规则说明如下: + - **应用后台启动应用组件** + - OpenHarmony 3.2-beta3 版本规则: + - 应用位于后台时,启动应用组件不受任何限制。 + - OpenHarmony 3.2-beta4 版本新规则: + - 当应用位于后台时,启动应用组件需鉴权,需申请的权限如下: + - ```json + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "grantMode": "system_grant", + "availableLevel": "system_basic", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + > **注:** +
1. 即使启动同应用的组件,也受该规则限制。 +
2. 对于API8以及之前的SDK,启动serviceAbility和dataAbility不受此规则限制。 + + - **跨应用启动invisible应用组件** + - OpenHarmony 3.2-beta3 版本规则: + - 对于APL为normal的应用,无法跨应用启动invisible的应用组件 + - OpenHarmony 3.2-beta4 版本新规则: + - 所有应用,若需要跨应用启动invisible的应用组件,需鉴权,需申请的权限如下: + - ```json + { + "name": "ohos.permission.START_INVISIBLE_ABILITY", + "grantMode": "system_grant", + "availableLevel": "system_core", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + + - **跨应用启动FA模型的serviceAbility与dataAbility** + + - OpenHarmony 3.2-beta3 版本规则: + - 可任意跨应用启动serviceAbility与dataAbility + - OpenHarmony 3.2-beta4 版本新规则: + - serviceAbility与dataAbility的提供方应用需配置关联启动,否则无法被跨应用拉起。(普通应用无法配置关联启动) + + + - **startAbilityByCall接口** + - OpenHarmony 3.2-beta3 版本规则: + - 可任意进行Call调用 + - OpenHarmony 3.2-beta4 版本新规则: + - 不支持同应用startAbilityByCall调用 + - 跨应用startAbilityByCall调用需鉴权,需申请的权限如下: + + - ```json + { + "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", + "grantMode": "system_grant", + "availableLevel": "system_basic", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + > **注:** +
使用startAbilityByCall接口同时也受上述后台启动、跨应用启动invisible规则的限制。 + +## cl.ability.2 跨设备应用组件启动规则变更(仅支持系统应用) + +元能力子系统跨设备应用组件启动规则在如下场景中存在变更: + + - 应用位于后台启动应用组件 + - 跨应用启动invisible应用组件 + - 跨应用启动FA模型的serviceAbility + +开发者需要根据以下说明对应用进行适配。 + + +**变更影响** + +若未适配新规则,在上述场景下将无法启动应用组件 +> **注意,启动应用组件是指一切启动或连接Ability的行为:** +
1. 启动Ability,如使用startAbility、startAbilityForResult、startAbilityByCall等接口。 +
2. 连接Ability,如使用connectAbility等接口。 + +**关键的接口/组件变更** + + - 涉及的应用组件 + - Stage模型 + - Ability + - ServiceExtension + - FA模型 + - PageAbility + - ServiceAbility + - 涉及接口 + - Stage模型 + - startAbility(want: Want, callback: AsyncCallback): void; + - startAbilityByCall(want: Want): Promise; + - startAbilityForResult(want: Want, callback: AsyncCallback): void; + - connectAbility(want: Want, options: ConnectOptions): number; + - FA模型 + - startAbility(parameter: StartAbilityParameter, callback: AsyncCallback): void; + - startAbility(parameter: StartAbilityParameter): Promise; + - startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback): void; + - startAbilityForResult(parameter: StartAbilityParameter): Promise; + - connectAbility(request: Want, options:ConnectOptions ): number; + +**适配指导** + +不同场景下的启动规则说明如下: + - **应用后台启动应用组件** + - OpenHarmony 3.2-beta3 版本规则: + - 应用位于后台时,启动应用组件不受任何限制。 + - OpenHarmony 3.2-beta4 版本新规则: + - 当应用位于后台时,启动应用组件需鉴权,需申请的权限如下: + - ```json + { + "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + "grantMode": "system_grant", + "availableLevel": "system_basic", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + > **注:** +
1. 即使启动同应用的组件,也受该规则限制。 +
2. 对于API8以及之前的SDK,启动serviceAbility不受此规则限制。 + + - **跨应用启动invisible应用组件** + - OpenHarmony 3.2-beta3 版本规则: + - 无法跨应用启动invisible的应用组件 + - OpenHarmony 3.2-beta4 版本新规则: + - 若需要跨应用启动invisible的应用组件,需鉴权,需申请的权限如下: + - ```json + { + "name": "ohos.permission.START_INVISIBLE_ABILITY", + "grantMode": "system_grant", + "availableLevel": "system_core", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + + - **跨应用启动FA模型的serviceAbility** + + - OpenHarmony 3.2-beta3 版本规则: + - 可任意跨应用启动serviceAbility + - OpenHarmony 3.2-beta4 版本新规则: + - serviceAbility的提供方应用需配置关联启动,否则无法被跨应用拉起。(普通应用无法配置关联启动) + - 关联启动配置 + - ```json + { + "bundleName": "", + "app_signature": ["xxxxxxxxxxxxxxxxxxx"], + "associatedWakeUp": true + } + ``` \ No newline at end of file