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/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/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/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-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/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/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 6e564f2518cf3ce6f083da66d8d72c0b8310f650..6c2b77d3f903657f7a64bef17799d5ebebd2d88b 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -146,6 +146,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) 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-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-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-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/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-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-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/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/website.md b/en/device-dev/website.md index 79d0a83eeffa334cd7f82bf141e201fd731c9fa7..9463578e645cb0c4aa816dac2bd47ef8d3faf5c2 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -202,6 +202,23 @@ - [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 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/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/website.md b/en/website.md index 4165d8468ba31e9d420f14dfec9fb3fefa5199d6..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 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-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/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/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/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/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/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 index dd0fb019c7241ea9b66dc1ef79d5d8812acb0f4a..0d58b674eeada7347da187882d6f8f5f5ee1534b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-Want.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-Want.md @@ -1,7 +1,11 @@ -# Want6+ +# Want Want是对象间信息传递的载体, 可以用于应用组件间的信息传递。 Want的使用场景之一是作为startAbility的参数, 其包含了指定的启动目标, 以及启动时需携带的相关数据, 如bundleName和abilityName字段分别指明目标Ability所在应用的包名以及对应包内的Ability名称。当Ability A需要启动Ability B并传入一些数据时, 可使用Want作为载体将这些数据传递给Ability B。 +> **说明:** +> +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -61,5 +65,3 @@ Want是对象间信息传递的载体, 可以用于应用组件间的信息传 }) ``` - - 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 d22d8041b6e7b65857880d58423d02439a4eb57a..15895ab2b64d8b76e8e5c1c928e812f37aeeff19 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -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) { 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 e2a83d75a2b15810ca6afc19cf1f3ec8ec60601b..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,7 +37,7 @@ constructor(durationTime: number); **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | durationTime | number | 是 | 手势总耗时,单位为毫秒。 | 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 0639e6939b1cf40624385e039195a7f564d0503e..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坐标。 | 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 e4c42fbf76f3f226625d33223e8fa11e7c482aa5..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,6 +64,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>): **示例:** ```ts +import accessibility from '@ohos.accessibility'; let name = 'com.ohos.example/axExtension'; let capability : accessibility.Capability[] = ['retrieve']; try { @@ -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,6 +106,7 @@ enableAbility(name: string, capability: Array<accessibility.Capability>, c **示例:** ```ts +import accessibility from '@ohos.accessibility'; let name = 'com.ohos.example/axExtension'; let capability : accessibility.Capability[] = ['retrieve']; try { @@ -130,7 +132,7 @@ disableAbility(name: string): Promise<void>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 辅助应用的名称,格式为:'bundleName/abilityName'。 | @@ -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> | 是 | 回调函数,在启用的辅助扩展的列表变化时通过此函数进行通知。 | @@ -241,9 +243,9 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback<void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| type | string | 否 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 | +| type | string | 是 | 参数固定为enabledAccessibilityExtensionListChange,监听启用的辅助扩展的列表变化。 | | callback | Callback<void> | 否 | 要取消的监听回调函数。 | **示例:** @@ -273,7 +275,7 @@ set(value: T): Promise<void>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | T | 是 | 设置的属性值。 | @@ -308,7 +310,7 @@ set(value: T, callback: AsyncCallback<void>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | value | T | 是 | 设置的属性值。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | @@ -366,9 +368,9 @@ get(callback: AsyncCallback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | 是 | 回调函数,返回属性值。 | +| callback | AsyncCallback<T> | 是 | 回调函数,返回属性值。 | **示例:** @@ -394,7 +396,7 @@ on(callback: Callback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | Callback<T> | 是 | 回调函数,在属性变化时通过此函数进行通知。 | @@ -420,7 +422,7 @@ off(callback?: Callback<T>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | Callback<T> | 否 | 要取消的监听回调函数。 | 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..b01dfdc5f486c6accfe80de31d9fc691010010ad 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 +267,7 @@ getWindowRootElement(windowId?: number): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | windowId | number | 否 | 指定窗口的编号,未指定则从当前活跃窗口获取。 | @@ -309,7 +311,7 @@ getWindowRootElement(callback: AsyncCallback\): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<AccessibilityElement> | 是 | 回调函数,返回指定窗口的根节点元素。 | @@ -324,6 +326,7 @@ getWindowRootElement(callback: AsyncCallback\): void; **示例:** ```ts +let rootElement; try { axContext.getWindowRootElement((err, data) => { if (err) { @@ -348,7 +351,7 @@ getWindowRootElement(windowId: number, callback: AsyncCallback\ { if (err) { @@ -388,7 +392,7 @@ getWindows(displayId?: number): Promise\>; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------------------- | ------- | ---- | ------------------- | | displayId | number | 否 | 指定的屏幕编号,未指定则从默认主屏幕获取。 | @@ -432,7 +436,7 @@ getWindows(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<Array<AccessibilityElement>> | 是 | 回调函数,返回指定屏幕的所有窗口。 | @@ -472,7 +476,7 @@ getWindows(displayId: number, callback: AsyncCallback\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | @@ -536,10 +540,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 +566,7 @@ injectGesture(gesturePath: GesturePath, callback: AsyncCallback\): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | gesturePath | [GesturePath](js-apis-accessibility-GesturePath.md#gesturepath) | 是 | 表示手势的路径信息。 | | callback | AsyncCallback<void> | 是 | 回调函数,表示注入手势执行结果的回调。 | @@ -578,10 +583,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 +643,7 @@ attributeNames\(callback: AsyncCallback\ **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback<Array<T>> | 是 | 回调函数,返回节点元素的所有属性名称。 | @@ -665,7 +671,7 @@ attributeValue\(attributeName: T): Promi **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | attributeName | T | 是 | 表示属性的名称。 | @@ -687,6 +693,8 @@ 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'); @@ -709,7 +717,7 @@ attributeValue\(attributeName: T, **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | attributeName | T | 是 | 表示属性的名称。 | | callback | AsyncCallback<ElementAttributeValues[T]> | 是 | 回调函数,返回根据节点属性名称获取的属性值。 | @@ -777,7 +785,7 @@ actionNames(callback: AsyncCallback\>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | callback | AsyncCallback<Array<string>> | 是 | 回调函数,返回节点元素支持的所有操作名称。 | @@ -805,7 +813,7 @@ performAction(actionName: string, parameters?: object): Promise\; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | actionName | string | 是 | 表示属性的名称。 | | parameters | object | 否 | 表示执行操作时所需要的参数。 | @@ -848,7 +856,7 @@ performAction(actionName: string, callback: AsyncCallback\): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ---------------------------------------- | ---- | -------------- | | actionName | string | 是 | 表示属性的名称。 | | callback | AsyncCallback<void> | 是 | 回调函数,表示执行指定操作的回调。| @@ -887,7 +895,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> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | @@ -189,7 +189,7 @@ on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | @@ -217,7 +217,7 @@ off(type: 'enableChange', callback?: Callback<boolean>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消监听的事件名,固定为‘enableChange’,即字幕配置启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在字幕配置启用状态变化时将状态通过此函数进行通知。 | @@ -243,7 +243,7 @@ off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 取消监听的事件名,固定为‘styleChange’,即字幕风格变化事件。 | | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | @@ -271,7 +271,7 @@ try { ### 属性 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| 名称 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | | windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | @@ -298,7 +298,7 @@ constructor(jsonObject) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | jsonObject | string | 是 | 创建对象所需要的 JSON 格式字符串。 | @@ -375,7 +375,7 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<A **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -425,7 +425,7 @@ getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: Asyn **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -469,7 +469,7 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState) **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -514,7 +514,7 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | @@ -576,7 +576,7 @@ on(type: 'accessibilityStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | | callback | Callback<boolean> | 是 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | @@ -603,7 +603,7 @@ on(type: 'touchGuideStateChange', callback: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 是 | 监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | | callback | Callback<boolean> | 是 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | @@ -630,7 +630,7 @@ off(type: 'accessibilityStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 否 | 取消监听的事件名,固定为‘accessibilityStateChange’,即辅助应用启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在辅助应用启用状态变化时将状态通过此函数进行通知。 | @@ -657,7 +657,7 @@ off(type: 'touchGuideStateChange', callback?: Callback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | type | string | 否 | 取消监听的事件名,固定为‘touchGuideStateChange’,即触摸浏览启用状态变化事件。 | | callback | Callback<boolean> | 否 | 回调函数,在触摸浏览启用状态变化时将状态通过此函数进行通知。 | @@ -708,7 +708,7 @@ isOpenAccessibility(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | @@ -758,7 +758,7 @@ isOpenTouchGuide(callback: AsyncCallback<boolean>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | @@ -789,7 +789,7 @@ sendEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | @@ -829,7 +829,7 @@ sendEvent(event: EventInfo, callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | | callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件失败,则 AsyncCallback中err有数据返回。 | @@ -861,7 +861,7 @@ sendAccessibilityEvent(event: EventInfo): Promise<void> **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | @@ -900,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-appControl.md b/zh-cn/application-dev/reference/apis/js-apis-appControl.md index 71058a3a8c86c7c6c54067cd6f9ea7c2705de741..ac29892f18b8291a40a445b7471ace833f264694 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,40 +79,24 @@ 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 { @@ -137,7 +105,7 @@ try { 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,38 +175,23 @@ 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) => { @@ -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,39 +269,23 @@ 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' -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, (err, data) => { if (err) { @@ -392,3 +299,26 @@ try { } ``` +## 获取应用的appId + +appId是应用的唯一标识,由应用的包名和签名信息决定,可以通过[getBundleInfo](js-apis-bundleManager.md#bundlemanagergetbundleinfo)接口获取。 + +**示例:** + +```ts +import bundleManager from '@ohos.bundle.bundleManager'; + +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; + console.info("appId is " + appId); + }).catch((error) => { + console.error("getBundleInfo failed " + error.message); + }); +} catch (error) { + console.error("getBundleInfo 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-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..759d35fcee934925e33ed2a7409bb8bd2a263a3b 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 @@ - # 媒体会话管理 +# 媒体会话管理 媒体会话管理提供媒体播控相关功能的接口,目的是让应用接入播控中心。 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 b4c6f557599e3617bd94282366b0d41f03261933..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 | @@ -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 | @@ -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 | 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-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 dc0a2d34093370ec0f36c32db957d5d50edd250a..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 **参数**: @@ -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 **参数**: @@ -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 bc6162d6d793754139104299d0f5f3623dea6972..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)。 | 类型 | 说明 | | -------- | -------- | 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 bad1f5f21c498bf8b14d6b5c22448c638945561a..9c2722a2201949b7b1dbe11bc1eea6228844c542 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-defaultAppManager.md @@ -17,7 +17,7 @@ import defaultAppMgr from '@ohos.bundle.defaultAppManager'; **系统能力:** SystemCapability.BundleManager.BundleFramework.DefaultApp -| 名称 | 类型 | 值 | 说明 | +| 参数名 | 类型 | 值 | 说明 | | -------- | -------- | -------------------------------------- | -------------------------------------- | | BROWSER | string | Web Browser | 默认浏览器。 | | IMAGE | string | Image Gallery | 默认图片查看器。 | @@ -38,7 +38,7 @@ isDefaultApplication(type: string): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 | @@ -70,7 +70,7 @@ isDefaultApplication(type: string, callback: AsyncCallback\): void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------------------------------- | ---- | --------------------------------------- | | type | string | 是 | 要查询的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值。 | | callback | AsyncCallback\ | 是 | 程序启动作为入参的回调函数,返回当前应用是否是默认应用,true表示是默认应用,false表示不是默认应用。 | @@ -102,7 +102,7 @@ getDefaultApplication(type: string, userId?: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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. | @@ -156,7 +156,7 @@ getDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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. | @@ -259,7 +259,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId?: number): **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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. | @@ -329,7 +329,7 @@ setDefaultApplication(type: string, elementName: ElementName, userId: number, ca **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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. | @@ -388,7 +388,7 @@ setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCal **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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. | @@ -445,14 +445,14 @@ resetDefaultApplication(type: string, userId?: number): Promise\ **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | type | string | 是 | 要重置的应用类型,取[ApplicationType](#defaultappmgrapplicationtype)中的值,或者符合媒体类型格式的文件类型。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户。 | **错误码:** -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ----------------------------------- | | 17700004 | The specified user id is not found. | | 17700025 | The specified type is invalid. | @@ -493,7 +493,7 @@ resetDefaultApplication(type: string, userId: number, callback: AsyncCallback\) : void; **参数:** -| 名称 | 类型 | 必填 | 描述 | +| 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | --------------------------------------- | | 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-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 c835160acbbd11c07a24985a49fb4887d67690e9..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, @@ -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+ @@ -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,7 +598,7 @@ var connId = featureAbility.connectAbility( onFailed: onFailedCallback, }, ); -var result = featureAbility.disconnectAbility(connId, +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 7a3d08fbd358af5a3d91672125854554fc5db1a8..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。 | **返回值:** @@ -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 b3ef0bd3551af1d94ab8fc12c8e57306eb9d4be9..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. | @@ -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. | @@ -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-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 aa6d25ec0cd7d5f234d36895b749b883ccb64844..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 @@ -16,9 +16,9 @@ import InputMethodExtensionAbility from '@ohos.inputmethodextensionability'; **系统能力:** SystemCapability.MiscServices.InputMethodFramework -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------- | -----------------| --- | ---- | -------------------- | -| context | [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md) | 是 | 否 | InputMethodExtension的上下文环境,继承自ExtensionContext。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| context | [InputMethodExtensionContext](js-apis-inputmethod-extension-context.md) | 是 | 否 | InputMethodExtension的上下文环境,继承自ExtensionContext。 | ## InputMethodExtensionAbility.onCreate 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 3a82fbdbae70fc44f158e06df7eaa463d351dbd0..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替代。 | @@ -58,14 +58,14 @@ getController(): InputMethodController 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800006 | Input method controller error. | **示例:** ```js -let InputMethodController = inputMethod.getController(); +let inputMethodController = inputMethod.getController(); ``` ## inputMethod.getSetting9+ @@ -86,14 +86,14 @@ getSetting(): InputMethodSetting 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800007 | Input method settings extension error. | **示例:** ```js -let InputMethodSetting = inputMethod.getSetting(); +let inputMethodSetting = inputMethod.getSetting(); ``` ## inputMethod.switchInputMethod9+ @@ -117,7 +117,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback<boolea 以下错误码的详细介绍请参见[输入法框架错误码](../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)| 是 | 传入要切换的目标输入法。 | **返回值:** @@ -166,7 +166,7 @@ switchInputMethod(target: InputMethodProperty): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../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) | 返回当前输入法属性对象。 | **示例:** @@ -230,7 +230,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb 以下错误码的详细介绍请参见[输入法框架错误码](../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", @@ -292,7 +292,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise<boolean& 以下错误码的详细介绍请参见[输入法框架错误码](../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", @@ -368,7 +368,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp 以下错误码的详细介绍请参见[输入法框架错误码](../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", @@ -436,7 +436,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp 以下错误码的详细介绍请参见[输入法框架错误码](../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 @@ -539,7 +543,7 @@ stopInputSession(callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -582,7 +586,7 @@ stopInputSession(): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -617,7 +621,7 @@ showSoftKeyboard(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。当软键盘显示成功。err为undefined,否则为错误对象。 | @@ -625,7 +629,7 @@ showSoftKeyboard(callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -662,7 +666,7 @@ showSoftKeyboard(): Promise<void> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -689,7 +693,7 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | ---------- | | callback | AsyncCallback<void> | 是 | 回调函数。当软键盘隐藏成功。err为undefined,否则为错误对象。 | @@ -697,7 +701,7 @@ hideSoftKeyboard(callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------------------- | | 12800003 | Input method client error. | | 12800008 | Input method settings extension error. | @@ -734,7 +738,7 @@ hideSoftKeyboard(): Promise<void> 以下错误码的详细介绍请参见[输入法框架错误码](../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/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; @@ -935,7 +936,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise<Arr 以下错误码的详细介绍请参见[输入法框架错误码](../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/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; @@ -1016,7 +1017,7 @@ listCurrentInputMethodSubtype(): Promise<Array<InputMethodSubtype>> 以下错误码的详细介绍请参见[输入法框架错误码](../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/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; @@ -1093,7 +1094,7 @@ getInputMethods(enable: boolean): Promise<Array<InputMethodProperty>> 以下错误码的详细介绍请参见[输入法框架错误码](../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)); @@ -1138,7 +1139,7 @@ showOptionalInputMethods(callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../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; @@ -1178,14 +1179,14 @@ showOptionalInputMethods(): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../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 21a731926282a8f66412a5e7fec8de00c91bfb60..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/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -748,7 +748,7 @@ hide(): Promise<void> 以下错误码的详细介绍请参见[输入法框架错误码](../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,否则为错误对象。 | **示例:** @@ -843,7 +843,7 @@ sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -891,7 +891,7 @@ sendKeyFunction(action:number): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -932,7 +932,7 @@ getForward(length:number, callback: AsyncCallback<string>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -978,7 +978,7 @@ getForward(length:number): Promise<string> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1017,7 +1017,7 @@ getBackward(length:number, callback: AsyncCallback<string>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1063,7 +1063,7 @@ getBackward(length:number): Promise<string> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | ------------------------------ | | 12800003 | Input method client error. | | 12800006 | Input method controller error. | @@ -1102,7 +1102,7 @@ deleteForward(length:number, callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1152,7 +1152,7 @@ deleteForward(length:number): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1195,7 +1195,7 @@ deleteBackward(length:number, callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1245,7 +1245,7 @@ deleteBackward(length:number): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1284,7 +1284,7 @@ insertText(text:string, callback: AsyncCallback<boolean>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1329,7 +1329,7 @@ insertText(text:string): Promise<boolean> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800002 | Input method engine error. | | 12800003 | Input method client error. | @@ -1370,7 +1370,7 @@ getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1405,7 +1405,7 @@ getEditorAttribute(): Promise<EditorAttribute> 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1439,7 +1439,7 @@ moveCursor(direction: number, callback: AsyncCallback<void>): void 以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)。 -| 错误码ID | 错误码信息 | +| 错误码ID | 错误信息 | | -------- | -------------------------- | | 12800003 | Input method client error. | @@ -1483,7 +1483,7 @@ moveCursor(direction: number): Promise<void> 以下错误码的详细介绍请参见[输入法框架错误码](../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..96dc07d812c0ac9a3c87e143254752ef98064865 --- /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.errCode} message:${errData.message}`); + } + console.log("data is " + JSON.Stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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.errCode} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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.errCode} message:${errData.message}`); + } + console.log("data is " + JSON.Stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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.errCode} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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.errCode} message:${errData.message}`); + } + console.log("data is " + JSON.Stringify(data)); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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.errCode} message:${errData.message}`); + }) +} catch (errData) { + console.log(`errData is errCode:${errData.errCode} 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-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-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..404c4eb3f3d506203a4f6a758b8a7b9bffbc7a4e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md +++ b/zh-cn/application-dev/reference/apis/js-apis-pasteboard.md @@ -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(); }); ``` @@ -1226,6 +1226,7 @@ off(type: 'update', callback?: () =>void ): void **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); let listener = () => { console.info('The system pasteboard has changed.'); }; @@ -1249,6 +1250,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 +1277,7 @@ clearData(): Promise<void> **示例:** ```js +let systemPasteboard = pasteboard.getSystemPasteboard(); systemPasteboard.clearData().then((data) => { console.info('Succeeded in clearing the pasteboard.'); }).catch((err) => { @@ -1442,6 +1445,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 +1472,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 cb945909331f089d2f98f384d7bfc9de65b28a5d..60e03b6967b89bafdccd0b1cde63a34462353bad 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -39,7 +39,7 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number& | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700001 | Notification does not enable. | +| 1700001 | Notification is not enabled. | | 1700002 | The number of reminders exceeds the limit. | **示例**: @@ -88,7 +88,7 @@ publishReminder(reminderReq: ReminderRequest): Promise<number> | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700001 | Notification does not enable. | +| 1700001 | Notification is not enabled. | | 1700002 | The number of reminders exceeds the limit. | **示例**: @@ -131,7 +131,7 @@ cancelReminder(reminderId: number, callback: AsyncCallback<void>): void | 错误码ID | 错误码信息 | | --------- | ------- | | 1700003 | The reminder does not exist. | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -177,7 +177,7 @@ cancelReminder(reminderId: number): Promise<void> | 错误码ID | 错误码信息 | | --------- | ------- | | 1700003 | The reminder does not exist. | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -214,7 +214,7 @@ getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -274,7 +274,7 @@ getValidReminders(): Promise<Array<ReminderRequest>> | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -332,7 +332,7 @@ cancelAllReminders(callback: AsyncCallback<void>): void | 错误码ID | 错误码信息 | | --------- | ------- | -| 1700004 | The package name does not exist. | +| 1700004 | The bundle name does not exist. | **示例**: @@ -371,7 +371,7 @@ cancelAllReminders(): Promise<void> | 错误码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 74dead2958ab76019eeea847595d14c3648d074e..fb3b971d29373fdadac3722b130b6a73c3b00945 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-request.md +++ b/zh-cn/application-dev/reference/apis/js-apis-request.md @@ -264,7 +264,7 @@ uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask> | Promise<[UploadTask](#uploadtask)> | 返回上传任务。 | **错误码:** -以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcodes-request.md)。 +以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)。 | 错误码ID | 错误码信息 | | -------- | -------- | @@ -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-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..08ae7b8d57ced84b0be4699d4f6a4fcbcbd7a71b 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开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 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-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index 1053f4629197be91c60382da5239cc8eeb6c08b5..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 @@ -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 @@ -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,6 +1549,14 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\ | Promise对象。无返回结果的Promise对象。 | +**错误码**: + +以下的错误码的详细介绍请参见[升级错误码](../errorcodes/errorcode-update.md) + +| 类型 | 说明 | +| ------- | ---------------------------------------------------- | +| 11500104 | BusinessError 11500104: IPC error. | + **示例:** ```ts @@ -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-userFileManager.md b/zh-cn/application-dev/reference/apis/js-apis-userFileManager.md index 6edfa75fd310669a9e9b4cb05114f13995ecd636..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,14 +3,13 @@ 该模块提供用户数据管理能力,包括访问、修改用户等用户公共媒体数据信息等常用功能。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 该模块从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -> 本模块下的接口均为系统接口 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块接口为系统接口。 ## 导入模块 ```ts import userFileManager from '@ohos.filemanagement.userFileManager'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; ``` ## userFileManager.getUserFileMgr @@ -27,7 +26,7 @@ getUserFileMgr(context: Context): UserFileManager | 参数名 | 类型 | 必填 | 说明 | | ------- | ------- | ---- | -------------------------- | -| context | [Context](#../apis/js-apis-Context.md) | 是 | 传入Ability实例的Context。 | +| context | [Context](js-apis-Context.md) | 是 | 传入Ability实例的Context。 | **返回值:** @@ -91,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(); @@ -139,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(); @@ -181,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(); @@ -292,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(); @@ -341,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(); @@ -451,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(); @@ -499,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(); @@ -541,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(); @@ -593,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(); @@ -935,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 { @@ -971,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 { @@ -1009,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(); @@ -1052,6 +1077,8 @@ commitModify(): Promise<void> **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('commitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1174,6 +1201,8 @@ close(fd: number, callback: AsyncCallback<void>): void **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('closeDemo') try { @@ -1222,6 +1251,8 @@ close(fd: number): Promise<void> **示例:** ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('closeDemo') try { @@ -1256,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(); @@ -1296,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(); @@ -1342,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(); @@ -1386,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(); @@ -1430,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(); @@ -1468,6 +1509,8 @@ getCount(): number **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getCountDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1498,6 +1541,8 @@ isAfterLast(): boolean **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { let predicates = new dataSharePredicates.DataSharePredicates(); let fetchOption = { @@ -1527,6 +1572,8 @@ close(): void **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('fetchResultCloseDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1557,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(); @@ -1592,6 +1641,8 @@ getFirstObject(): Promise<T> **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getFirstObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1622,6 +1673,8 @@ async function example() { **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getNextObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1660,6 +1713,8 @@ async function example() { **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getNextObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1693,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(); @@ -1728,6 +1785,8 @@ getLastObject(): Promise<T> **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('getLastObjectDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -1759,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(); @@ -1800,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(); @@ -1849,6 +1912,8 @@ getPhotoAssets(options: FetchOptions, callback: AsyncCallback<FetchResult< **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumGetFileAssetsDemoCallback') @@ -1891,6 +1956,8 @@ getPhotoAssets(options: FetchOptions): Promise<FetchResult<FileAsset>&g **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumGetFileAssetsDemoPromise') @@ -1931,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(); @@ -1969,6 +2038,8 @@ commitModify(): Promise<void>; **示例**: ```ts +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + async function example() { console.info('albumCommitModifyDemo') let predicates = new dataSharePredicates.DataSharePredicates(); @@ -2025,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); @@ -2070,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); @@ -2104,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); @@ -2150,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); @@ -2190,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); @@ -2236,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); @@ -2384,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 @@ -2394,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 a22163a78c646bedab2ff1ec36df7797f7562b42..c0383e0497ec0e53e0e02da382adeac1405e8f9b 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 @@ -70,13 +70,3 @@ setSurfaceId(surfaceId: string): void; console.error("set surface id failed, error = " + e); } ``` - -## ResultCode - - 表示执行结果的枚举。 - - **系统能力:** SystemCapability.UserIAM.UserAuth.FaceAuth - -| 名称 | 默认值 | 描述 | -| ----------------------- | ------ | -------------------- | -| FAIL | 12700001 | 执行失败。 | 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 78824946b90c2e74190506e9273551d68e580145..5eb839a2e10eb986132ad007bb9afdffef298de0 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 @@ -903,7 +903,6 @@ onAcquireInfo ?: (module : number, acquire : number, extraInfo : any) => void | TYPE_NOT_SUPPORT | 5 | 不支持的认证类型。 | | TRUST_LEVEL_NOT_SUPPORT | 6 | 不支持的认证等级。 | | BUSY | 7 | 忙碌状态。 | -| INVALID_PARAMETERS | 8 | 无效参数。 | | LOCKED | 9 | 认证器已锁定。 | | NOT_ENROLLED | 10 | 用户未录入认证信息。 | 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..26b3b7dc24b4d813d390891eaf06840f9a64a8a1 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版本,仅供试用,不保证接口可稳定调用。 > - 本模块接口为系统接口,三方应用不支持调用。 ## 导入模块 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 a31ccc4a1efba63bc781319c0873dfbaa4948a52..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 | 是 | 接收消息的回调函数。 | **错误码**: @@ -196,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请求头。 | **错误码**: @@ -248,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为空时,此属性无效。 | **错误码**: @@ -263,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. | **示例:** @@ -619,9 +620,9 @@ accessStep(step: number): boolean **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ------------------------------------------ | -| step | number | 是 | - | 要跳转的步数,正数代表前进,负数代表后退。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ------------------------------------------ | +| step | number | 是 | 要跳转的步数,正数代表前进,负数代表后退。 | **返回值:** @@ -769,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对象的方法。 | **错误码:** @@ -829,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。 | **错误码:** @@ -892,9 +893,9 @@ runJavaScript(script: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ---------------- | -| script | string | 是 | - | JavaScript脚本。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---------------- | +| script | string | 是 | JavaScript脚本。 | **返回值:** @@ -956,9 +957,9 @@ deleteJavaScriptRegister(name: string): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ------------------------------------------------------------ | -| name | string | 是 | - | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---- | +| name | string | 是 | 注册对象的名称,可在网页侧JavaScript中通过此名称调用应用侧JavaScript对象。 | **错误码:** @@ -1007,7 +1008,7 @@ zoom(factor: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | +| 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------------------------------------------------------------ | | factor | number | 是 | 基于当前网页所需调整的相对缩放比例,正值为放大,负值为缩小。 | @@ -1155,9 +1156,9 @@ searchNext(forward: boolean): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------- | -------- | ---- | ------ | ---------------------- | -| forward | boolean | 是 | - | 从前向后或者逆向查找。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | -------- | ---- | ---------------------- | +| forward | boolean | 是 | 从前向后或者逆向查找。 | **错误码:** @@ -1341,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。 | **错误码**: @@ -1855,7 +1856,7 @@ storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback\ **参数:** -| 参数名 | 参数类型 | 必填 | 说明 | +| 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | ---- | ------------------------------------------------------------ | | baseName | string | 是 | 文件存储路径,该值不能为空。 | | autoName | boolean | 是 | 决定是否自动生成文件名。 如果为false,则将baseName作为文件存储路径。 如果为true,则假定baseName是一个目录,将根据当前页的Url自动生成文件名。 | @@ -2073,9 +2074,9 @@ backOrForward(step: number): void **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | ---------------------- | -| step | number | 是 | - | 需要前进或后退的步长。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------- | ---- | ---------------------- | +| step | number | 是 | 需要前进或后退的步长。 | **错误码**: @@ -2127,9 +2128,9 @@ static getCookie(url: string): string **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | :------------------------ | -| url | string | 是 | - | 要获取的cookie所属的url。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | :------------------------ | +| url | string | 是 | 要获取的cookie所属的url。 | **返回值:** @@ -2140,6 +2141,7 @@ static getCookie(url: string): string **错误码**: 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) + | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------ | | 17100002 | Invalid url. | @@ -2182,10 +2184,10 @@ static setCookie(url: string, value: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | :------------------------ | -| url | string | 是 | - | 要设置的cookie所属的url。 | -| value | string | 是 | - | 要设置的cookie的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | :------------------------ | +| url | string | 是 | 要设置的cookie所属的url。 | +| value | string | 是 | 要设置的cookie的值。 | **错误码**: @@ -2233,9 +2235,9 @@ static saveCookieAsync(callback: AsyncCallback\): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | ---------------------- | ---- | ------ | :------------------------------------------------- | -| callback | AsyncCallback\ | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | :------------------------------------------------- | +| callback | AsyncCallback\ | 是 | 返回cookie是否成功保存的布尔值作为回调函数的入参。 | **示例:** @@ -2326,9 +2328,9 @@ static putAcceptCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------- | ---- | ------ | :----------------------------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | :----------------------------------- | +| accept | boolean | 是 | 设置是否拥有发送和接收cookie的权限。 | **示例:** @@ -2405,9 +2407,9 @@ static putAcceptThirdPartyCookieEnabled(accept: boolean): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------- | ---- | ------ | :----------------------------------------- | -| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | :----------------------------------------- | +| accept | boolean | 是 | 设置是否拥有发送和接收第三方cookie的权限。 | **示例:** @@ -2588,9 +2590,9 @@ static deleteOrigin(origin : string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------------ | -| origin | string | 是 | - | 指定源的字符串索引. | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| origin | string | 是 | 指定源的字符串索引. | **错误码:** @@ -2640,9 +2642,9 @@ static getOrigins(callback: AsyncCallback\>) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | -------------------------------------- | ---- | ------ | ------------------------------------------------------ | -| callback | AsyncCallback\> | 是 | - | 以数组方式返回源的信息,信息内容参考[WebStorageOrigin](#webstorageorigin)。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback\> | 是 | 以数组方式返回源的信息,信息内容参考[WebStorageOrigin](#webstorageorigin)。 | **错误码:** @@ -2762,10 +2764,10 @@ static getOriginQuota(origin : string, callback : AsyncCallback\) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | --------------------- | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | -| callback | AsyncCallback\ | 是 | - | 指定源的存储配额 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 指定源的存储配额 | **错误码:** @@ -2821,9 +2823,9 @@ static getOriginQuota(origin : string) : Promise\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **返回值:** @@ -2885,10 +2887,10 @@ static getOriginUsage(origin : string, callback : AsyncCallback\) : void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | --------------------- | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | -| callback | AsyncCallback\ | 是 | - | 指定源的存储量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 指定源的存储量。 | **错误码:** @@ -2944,9 +2946,9 @@ static getOriginUsage(origin : string) : Promise\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **返回值:** @@ -3048,10 +3050,10 @@ static getHttpAuthCredentials(host: string, realm: string): Array\ **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ---------------------------- | -| host | string | 是 | - | HTTP身份验证凭据应用的主机。 | -| realm | string | 是 | - | HTTP身份验证凭据应用的域。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------- | +| host | string | 是 | HTTP身份验证凭据应用的主机。 | +| realm | string | 是 | HTTP身份验证凭据应用的域。 | **返回值:** @@ -3103,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 | 是 | 密码。 | **示例:** @@ -3229,13 +3231,14 @@ static allowGeolocation(origin: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 说明 | +| ------ | ------ | ------------------ | +| origin | string | 指定源的字符串索引 | **错误码:** 以下错误码的详细介绍请参见 [webview错误码](../errorcodes/errorcode-webview.md) + | 错误码ID | 错误信息 | | -------- | ------------------------------------------------------ | | 17100011 | Invalid origin. | @@ -3278,9 +3281,9 @@ static deleteGeolocation(origin: string): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| ------ | ------ | ---- | ------ | ------------------ | -| origin | string | 是 | - | 指定源的字符串索引 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| origin | string | 是 | 指定源的字符串索引 | **错误码:** @@ -3328,10 +3331,10 @@ static getAccessibleGeolocation(origin: string, callback: AsyncCallback\ | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| origin | string | 是 | 指定源的字符串索引 | +| callback | AsyncCallback\ | 是 | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 | **错误码:** @@ -3385,9 +3388,9 @@ static getAccessibleGeolocation(origin: string): Promise\ **参数:** -| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | -| ------ | -------- | ---- | ------ | -------------------- | -| origin | string | 是 | - | 指定源的字符串索引。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | -------- | ---- | -------------------- | +| origin | string | 是 | 指定源的字符串索引。 | **返回值:** @@ -3446,9 +3449,9 @@ static getStoredGeolocation(callback: AsyncCallback\>): void **参数:** -| 参数名 | 类型 | 必填 | 默认值 | 说明 | -| -------- | ---------------------------- | ---- | ------ | ---------------------------------------- | -| callback | AsyncCallback\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback\> | 是 | 返回已存储地理位置权限状态的所有源信息。 | **示例:** @@ -3570,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 @@ -3596,10 +3599,10 @@ Web组件返回的请求/响应头对象。 **系统能力:** SystemCapability.Web.Webview.Core -| 名称 | 类型 | 说明 | -| ----- | ------------- | :----------------------------------------------------------- | -| type | [HitTestTypeV9](#hittesttypev9) | 当前被点击区域的元素类型。 | -| extra | string | 点击区域的附加参数信息。若被点击区域为图片或链接,则附加参数信息为其url地址。 | +| 名称 | 类型 | 可读 | 可写 | 说明| +| ---- | ---- | ---- | ---- |---- | +| type | [HitTestTypeV9](#hittesttypev9) | 是 | 否 | 当前被点击区域的元素类型。| +| extra | string | 是 | 否 |点击区域的附加参数信息。若被点击区域为图片或链接,则附加参数信息为其url地址。 | ## WebStorageOrigin @@ -3607,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..a0a82cbf7ff47911534159971440dd6df3823450 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -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+ @@ -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+ @@ -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+ @@ -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 cb6128d2e14a590c3c244e9e31983640fe22465f..d3c071445b5c412cf1182d76c9b5a1bd491509df 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @@ -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 84b3499495eba387eea6c99683c21506144be1d8..ad29bc2f88977a389b8c7c19fcfce583c486b9a4 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. | **示例** @@ -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】 @@ -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. | **示例** @@ -274,7 +274,7 @@ decompressFile(inFile: string, outFile: string, options: Options): Promise\
-
``` ```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-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/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_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/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 4319811e77cdc23654087d8127b8057c055041f2..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 @@ -402,4 +402,4 @@ struct LoadImageExample { .width('100%').height('100%') } } -``` \ No newline at end of file +``` 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-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-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-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-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-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-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/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 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-Account.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-account.md 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 100% rename from zh-cn/application-dev/reference/errorcodes/errcode-bundle.md rename to zh-cn/application-dev/reference/errorcodes/errorcode-bundle.md 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-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/errorcode-reminderAgentManager.md b/zh-cn/application-dev/reference/errorcodes/errorcode-reminderAgentManager.md index 6087eb0f9bd03b8befc8d516ad174d58eaa61854..faeac6fddca8d11815797258e7a44a1fa9a87edd 100644 --- a/zh-cn/application-dev/reference/errorcodes/errorcode-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..9ce15b0692b5bea93f3b82932dd3a5290a0ef8a9 --- /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/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/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/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/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/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/quick-start/quickstart-appendix-hi3516-ide.md b/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516-ide.md index eacb6fcc14080bdab991b4e8343ea8a63932d156..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。 ``` 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-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/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/website.md b/zh-cn/device-dev/website.md index 416a41d518cb60de85619d9bbcd09ff59a1a4b91..84d2960c20fa39e0820acd66d26d6afcb6090acf 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -153,6 +153,7 @@ - 子系统开发 - 内核 + - [内核概述](kernel/kernel-overview.md) - 轻量系统内核(LiteOS-M) - [轻量系统内核概述](kernel/kernel-mini-overview.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..5d2efae259ce81f686f324053750ef89ac5205b5 --- /dev/null +++ b/zh-cn/release-notes/changelogs/weekly-20221025/changelogs-ability.md @@ -0,0 +1,128 @@ +# 元能力子系统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-Release 版本新规则: + - 当应用位于后台时,启动应用组件需鉴权,需申请的权限如下: + - ```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-Release 版本新规则: + - 所有应用,若需要跨应用启动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-Release 版本新规则: + - serviceAbility与dataAbility的提供方应用需配置关联启动,否则无法被跨应用拉起。(普通应用无法配置关联启动) + + + - **startAbilityByCall接口** + - OpenHarmony 3.2.beta3 版本规则: + - 可任意进行Call调用 + - OpenHarmony 3.2-Release 版本新规则: + - 不支持同应用startAbilityByCall调用 + - 跨应用startAbilityByCall调用需鉴权,需申请的权限如下: + + - ```json + { + "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", + "grantMode": "system_grant", + "availableLevel": "system_basic", + "provisionEnable": true, + "distributedSceneEnable": false + } + ``` + > **注:** +
使用startAbilityByCall接口同时也受上述后台启动、跨应用启动invisible规则的限制。 \ No newline at end of file