提交 f3221206 编写于 作者: A Austin 提交者: Gitee

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

Signed-off-by: NAustin <liaozhiqi7@huawei.com>
......@@ -7,7 +7,7 @@ To ensure successful communications between the client and server, interfaces re
![IDL-interface-description](./figures/IDL-interface-description.png)
IDL provides the following functions:
**IDL provides the following functions:**
- Declares interfaces provided by system services for external systems, and based on the interface declaration, generates C, C++, JS, or TS code for inter-process communication (IPC) or remote procedure call (RPC) proxies and stubs during compilation.
......@@ -17,7 +17,7 @@ IDL provides the following functions:
![IPC-RPC-communication-model](./figures/IPC-RPC-communication-model.png)
IDL has the following advantages:
**IDL has the following advantages:**
- Services are defined in the form of interfaces in IDL. Therefore, you do not need to focus on implementation details.
......@@ -433,7 +433,7 @@ export default {
console.log('ServiceAbility want:' + JSON.stringify(want));
console.log('ServiceAbility want name:' + want.bundleName)
} catch(err) {
console.log("ServiceAbility error:" + err)
console.log('ServiceAbility error:' + err)
}
console.info('ServiceAbility onConnect end');
return new IdlTestImp('connect');
......@@ -455,13 +455,13 @@ import featureAbility from '@ohos.ability.featureAbility';
function callbackTestIntTransaction(result: number, ret: number): void {
if (result == 0 && ret == 124) {
console.log("case 1 success ");
console.log('case 1 success');
}
}
function callbackTestStringTransaction(result: number): void {
if (result == 0) {
console.log("case 2 success ");
console.log('case 2 success');
}
}
......@@ -472,17 +472,17 @@ var onAbilityConnectDone = {
testProxy.testStringTransaction('hello', callbackTestStringTransaction);
},
onDisconnect:function (elementName) {
console.log("onDisconnectService onDisconnect");
console.log('onDisconnectService onDisconnect');
},
onFailed:function (code) {
console.log("onDisconnectService onFailed");
console.log('onDisconnectService onFailed');
}
};
function connectAbility: void {
let want = {
"bundleName":"com.example.myapplicationidl",
"abilityName": "com.example.myapplicationidl.ServiceAbility"
bundleName: 'com.example.myapplicationidl',
abilityName: 'com.example.myapplicationidl.ServiceAbility'
};
let connectionId = -1;
connectionId = featureAbility.connectAbility(want, onAbilityConnectDone);
......@@ -495,7 +495,7 @@ function connectAbility: void {
You can send a class from one process to another through IPC interfaces. However, you must ensure that the peer can use the code of this class and this class supports the **marshalling** and **unmarshalling** methods. OpenHarmony uses **marshalling** and **unmarshalling** to serialize and deserialize objects into objects that can be identified by each process.
To create a class that supports the sequenceable type, perform the following operations:
**To create a class that supports the sequenceable type, perform the following operations:**
1. Implement the **marshalling** method, which obtains the current state of the object and serializes the object into a **Parcel** object.
2. Implement the **unmarshalling** method, which deserializes the object from a **Parcel** object.
......@@ -595,7 +595,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel();
_data.writeInt(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_INT_TRANSACTION, _data, _reply, _option).then(function(result) {
if (result.errCode === 0) {
if (result.errCode == 0) {
let _errCode = result.reply.readInt();
if (_errCode != 0) {
let _returnValue = undefined;
......@@ -605,7 +605,7 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _returnValue = result.reply.readInt();
callback(_errCode, _returnValue);
} else {
console.log("sendRequest failed, errCode: " + result.errCode);
console.log('sendRequest failed, errCode: ' + result.errCode);
}
})
}
......@@ -617,11 +617,11 @@ export default class IdlTestServiceProxy implements IIdlTestService {
let _reply = new rpc.MessageParcel();
_data.writeString(data);
this.proxy.sendRequest(IdlTestServiceProxy.COMMAND_TEST_STRING_TRANSACTION, _data, _reply, _option).then(function(result) {
if (result.errCode === 0) {
if (result.errCode == 0) {
let _errCode = result.reply.readInt();
callback(_errCode);
} else {
console.log("sendRequest failed, errCode: " + result.errCode);
console.log('sendRequest failed, errCode: ' + result.errCode);
}
})
}
......@@ -644,12 +644,12 @@ import nativeMgr from 'nativeManager';
function testIntTransactionCallback(errCode: number, returnValue: number)
{
console.log("errCode: " + errCode + " returnValue: " + returnValue);
console.log('errCode: ' + errCode + ' returnValue: ' + returnValue);
}
function testStringTransactionCallback(errCode: number)
{
console.log("errCode: " + errCode);
console.log('errCode: ' + errCode);
}
function jsProxyTriggerCppStub()
......@@ -660,6 +660,6 @@ function jsProxyTriggerCppStub()
tsProxy.testIntTransaction(10, testIntTransactionCallback);
// Call testStringTransaction.
tsProxy.testStringTransaction("test", testIntTransactionCallback);
tsProxy.testStringTransaction('test', testIntTransactionCallback);
}
```
......@@ -66,7 +66,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
You can declare the required permission in your application's configuration file. For details, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../security/accesstoken-guidelines.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......
# Audio Playback Development
## When to Use
## Introduction
You can use audio playback APIs to convert audio data into audible analog signals, play the signals using output devices, and manage playback tasks.
You can use audio playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, and obtain track information.
**Figure 1** Playback status
## Working Principles
The following figures show the audio playback status changes and the interaction with external modules for audio playback.
**Figure 1** Audio playback state transition
![en-us_image_audio_state_machine](figures/en-us_image_audio_state_machine.png)
**Note**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value.
**NOTE**: If the status is **Idle**, setting the **src** attribute does not change the status. In addition, after the **src** attribute is set successfully, you must call **reset()** before setting it to another value.
**Figure 2** Layer 0 diagram of audio playback
**Figure 2** Interaction with external modules for audio playback
![en-us_image_audio_player](figures/en-us_image_audio_player.png)
**NOTE**: When a third-party application calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework and outputs the audio data decoded by the software to the audio HDI of the hardware interface layer to implement audio playback.
## How to Develop
For details about the APIs, see [AudioPlayer in the Media API](../reference/apis/js-apis-media.md#audioplayer).
> **NOTE**
>
> The method for obtaining the path in the FA model is different from that in the stage model. **pathDir** used in the sample code below is an example. You need to obtain the path based on project requirements. For details about how to obtain the path, see [Application Sandbox Path Guidelines](../reference/apis/js-apis-fileio.md#guidelines).
### Full-Process Scenario
The full audio playback process includes creating an instance, setting the URI, playing audio, seeking to the playback position, setting the volume, pausing playback, obtaining track information, stopping playback, resetting the player, and releasing resources.
......@@ -99,8 +109,9 @@ async function audioPlayerDemo() {
setCallBack(audioPlayer); // Set the event callbacks.
// 2. Set the URI of the audio file.
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
......@@ -118,6 +129,7 @@ async function audioPlayerDemo() {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
......@@ -139,8 +151,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
......@@ -159,6 +172,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
export class AudioDemo {
// Set the player callbacks.
private isNextMusic = false;
......@@ -185,8 +199,9 @@ export class AudioDemo {
async nextMusic(audioPlayer) {
this.isNextMusic = true;
let nextFdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let nextpath = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/02.mp3';
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let nextpath = pathDir + '/02.mp3'
await fileIO.open(nextpath).then((fdNumber) => {
nextFdPath = nextFdPath + '' + fdNumber;
console.info('open fd success fd is' + nextFdPath);
......@@ -202,8 +217,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
......@@ -222,6 +238,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio'
export class AudioDemo {
// Set the player callbacks.
setCallBack(audioPlayer) {
......@@ -239,8 +256,9 @@ export class AudioDemo {
let audioPlayer = media.createAudioPlayer(); // Create an AudioPlayer instance.
this.setCallBack(audioPlayer); // Set the event callbacks.
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/01.mp3';
let pathDir = "/data/storage/el2/base/haps/entry/files" // The method for obtaining pathDir in the FA model is different from that in the stage model. For details, see NOTE just below How to Develop. You need to obtain pathDir based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
await fileIO.open(path).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
console.info('open fd success fd is' + fdPath);
......
# Audio Recording Development
## When to Use
## Introduction
During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and file path for audio recording.
During audio recording, audio signals are captured, encoded, and saved to files. You can specify parameters such as the sampling rate, number of audio channels, encoding format, encapsulation format, and output file path for audio recording.
## Working Principles
The following figures show the audio recording state transition and the interaction with external modules for audio recording.
**Figure 1** Audio recording state transition
......@@ -10,10 +14,16 @@ During audio recording, audio signals are captured, encoded, and saved to files.
**Figure 2** Layer 0 diagram of audio recording
**Figure 2** Interaction with external modules for audio recording
![en-us_image_audio_recorder_zero](figures/en-us_image_audio_recorder_zero.png)
**NOTE**: When a third-party recording application or recorder calls the JS interface provided by the JS interface layer to implement a feature, the framework layer invokes the audio component through the media service of the native framework to obtain the audio data captured through the audio HDI. The framework layer then encodes the audio data through software and saves the encoded and encapsulated audio data to a file to implement audio recording.
## Constraints
Before developing audio recording, configure the **ohos.permission.MICROPHONE** permission for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
## How to Develop
For details about the APIs, see [AudioRecorder in the Media API](../reference/apis/js-apis-media.md#audiorecorder).
......
# Video Playback Development
## When to Use
## Introduction
You can use video playback APIs to convert video data into visible signals, play the signals using output devices, and manage playback tasks. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback.
You can use video playback APIs to convert audio data into audible analog signals and play the signals using output devices. You can also manage playback tasks. For example, you can start, suspend, stop playback, release resources, set the volume, seek to a playback position, set the playback speed, and obtain track information. This document describes development for the following video playback scenarios: full-process, normal playback, video switching, and loop playback.
## Working Principles
The following figures show the video playback state transition and the interaction with external modules for video playback.
**Figure 1** Video playback state transition
![en-us_image_video_state_machine](figures/en-us_image_video_state_machine.png)
**Figure 2** Layer 0 diagram of video playback
**Figure 2** Interaction with external modules for video playback
![en-us_image_video_player](figures/en-us_image_video_player.png)
**NOTE**: When a third-party application calls a JS interface provided by the JS interface layer, the framework layer invokes the audio component through the media service of the native framework to output the audio data decoded by the software to the audio HDI. The graphics subsystem outputs the image data decoded by the codec HDI at the hardware interface layer to the display HDI. In this way, video playback is implemented.
*Note: Video playback requires hardware capabilities such as display, audio, and codec.*
1. A third-party application obtains a surface ID from the XComponent.
......
# Video Recording Development
## When to Use
## Introduction
During video recording, audio and video signals are captured, encoded, and saved to files. You can specify parameters such as the encoding format, encapsulation format, and file path for video recording.
You can use video recording APIs to capture audio and video signals, encode them, and save them to files. You can start, suspend, resume, and stop recording, and release resources. You can also specify parameters such as the encoding format, encapsulation format, and file path for video recording.
## Working Principles
The following figures show the video recording state transition and the interaction with external modules for video recording.
**Figure 1** Video recording state transition
![en-us_image_video_recorder_state_machine](figures/en-us_image_video_recorder_state_machine.png)
**Figure 2** Layer 0 diagram of video recording
**Figure 2** Interaction with external modules for video recording
![en-us_image_video_recorder_zero](figures/en-us_image_video_recorder_zero.png)
**NOTE**: When a third-party camera application or system camera calls a JS interface provided by the JS interface layer, the framework layer uses the media service of the native framework to invoke the audio component. Through the audio HDI, the audio component captures audio data, encodes the audio data through software, and saves the encoded audio data to a file. The graphics subsystem captures image data through the video HDI, encodes the image data through the video codec HDI, and saves the encoded image data to a file. In this way, video recording is implemented.
## Constraints
Before developing video recording, configure the permissions **ohos.permission.MICROPHONE** and **ohos.permission.CAMERA** for your application. For details about the configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
## How to Develop
For details about the APIs, see [VideoRecorder in the Media API](../reference/apis/js-apis-media.md#videorecorder9).
......@@ -147,3 +157,4 @@ export class VideoRecorderDemo {
}
}
```
......@@ -215,6 +215,7 @@
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputDeviceCooperate](js-apis-cooperate.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md)
......
......@@ -796,7 +796,7 @@ call.reject(rejectMessageOptions, (err, data) => {
## call.reject<sup>7+</sup>
reject(callId: number, callback: AsyncCallback<void\>): <void\>
reject(callId: number, callback: AsyncCallback\<void>): void
Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result.
......@@ -811,16 +811,11 @@ This is a system API.
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
call.reject(1, (error, data) => {
call.reject(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......@@ -1621,8 +1616,8 @@ This is a system API.
**Example**
```js
call.on('callDetailsChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.on('callDetailsChange', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1646,8 +1641,8 @@ This is a system API.
**Example**
```js
call.on('callEventChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.on('callEventChange', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1671,8 +1666,8 @@ This is a system API.
**Example**
```js
call.on('callDisconnectedCause', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.on('callDisconnectedCause', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1696,8 +1691,8 @@ This is a system API.
**Example**
```js
call.on('mmiCodeResult', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.on('mmiCodeResult', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1721,8 +1716,8 @@ This is a system API.
**Example**
```js
call.off('callDetailsChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.off('callDetailsChange', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1746,8 +1741,8 @@ This is a system API.
**Example**
```js
call.off('callEventChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.off('callEventChange', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1771,8 +1766,8 @@ This is a system API.
**Example**
```js
call.off('callDisconnectedCause', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.off('callDisconnectedCause', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -1796,8 +1791,8 @@ This is a system API.
**Example**
```js
call.off('mmiCodeResult', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
call.off('mmiCodeResult', data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
```
......@@ -2386,7 +2381,7 @@ This is a system API.
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
call.setAudioDevice(1, audioDeviceOptions, (err, value) => {
call.setAudioDevice(1, audioDeviceOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
......
# Screen Hopping
The Screen Hopping module enables two or more networked devices to share the keyboard and mouse for collaborative operations.
> **Description**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import inputDeviceCooperate from '@ohos.multimodalInput.inputDeviceCooperate'
```
## inputDeviceCooperate.enable
enable(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
Specifies whether to enable screen hopping. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | --------------------------- |
| enable | boolean | Yes | Whether to enable screen hopping.|
| callback | AsyncCallback&lt;void&gt; | Yes |Callback used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.enable(true, (error) => {
if (error) {
console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Keyboard mouse crossing enable success.`);
});
} catch (error) {
console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.enable
enable(enable: boolean): Promise&lt;void&gt;
Specifies whether to enable screen hopping. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------- | ---- | ------------------------------------------------------------------- |
| enable | boolean | Yes | Whether to enable screen hopping. |
**Return value**
| Name | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.enable(true).then(() => {
console.log(`Keyboard mouse crossing enable success.`);
}, (error) => {
console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
});
} catch (error) {
console.log(`Keyboard mouse crossing enable failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.start
start(sinkDeviceDescriptor: string, srcInputDeviceId: number, callback: AsyncCallback\<void>): void
Starts screen hopping. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| sinkDeviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. |
| srcInputDeviceId | number | Yes | ID of the target device for screen hopping. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Screen Hopping Error Codes](../errorcodes/errorcodes-multimodalinput.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. |
| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
**Example**
```js
try {
inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId, (error) => {
if (error) {
console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Start Keyboard mouse crossing success.`);
});
} catch (error) {
console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.start
start(sinkDeviceDescriptor: string, srcInputDeviceId: number): Promise\<void>
Starts screen hopping. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| sinkDeviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. |
| srcInputDeviceId | number | Yes | ID of the target device for screen hopping. |
**Return value**
| Name | Description |
| ---------------------- | ------------------------------- |
| Promise\<void> | Promise used to return the result. |
**Error codes**
For details about the error codes, see [Screen Hopping Error Codes](../errorcodes/errorcodes-multimodalinput.md).
| ID| Error Message|
| -------- | ---------------------------------------- |
| 4400001 | This error code is reported if an invalid device descriptor is passed to the screen hopping API. |
| 4400002 | This error code is reported if the screen hopping status is abnormal when the screen hopping API is called. |
**Example**
```js
try {
inputDeviceCooperate.start(sinkDeviceDescriptor, srcInputDeviceId).then(() => {
console.log(`Start Keyboard mouse crossing success.`);
}, (error) => {
console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
});
} catch (error) {
console.log(`Start Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.stop
stop(callback: AsyncCallback\<void>): void
Stops screen hopping. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.stop((error) => {
if (error) {
console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Stop Keyboard mouse crossing success.`);
});
} catch (error) {
console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.stop
stop(): Promise\<void>
Stops screen hopping. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Description |
| -------- | ---------------------------- |
| Promise\<void> | Promise used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.stop().then(() => {
console.log(`Stop Keyboard mouse crossing success.`);
}, (error) => {
console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
});
} catch (error) {
console.log(`Stop Keyboard mouse crossing failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.getState
getState(deviceDescriptor: string, callback: AsyncCallback<{ state: boolean }>): void
Checks whether screen hopping is enabled. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------- | ---- | ---------------------------- |
| deviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. |
| callback | AsyncCallback<{ state: boolean }> | Yes | Callback used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.getState(deviceDescriptor, (error, data) => {
if (error) {
console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get the status success, data: ${JSON.stringify(data)}`);
});
} catch (error) {
console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputDeviceCooperate.getState
getState(deviceDescriptor: string): Promise<{ state: boolean }>
Checks whether screen hopping is enabled. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------- | ---- | ---------------------------- |
| deviceDescriptor | string | Yes | Descriptor of the target device for screen hopping. |
**Return value**
| Name | Description |
| ------------------- | ------------------------------- |
| Promise<{ state: boolean }>| Promise used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.getState(deviceDescriptor).then((data) => {
console.log(`Get the status success, data: ${JSON.stringify(data)}`);
}, (error) => {
console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
});
} catch (error) {
console.log(`Get the status failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## on('cooperation')
on(type: 'cooperation', callback: AsyncCallback<{ deviceDescriptor: string, eventMsg: EventMsg }>): void
Enables listening for screen hopping events.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. The value is **cooperation**. |
| callback | AsyncCallback<{ deviceDescriptor: string, eventMsg: [EventMsg](#eventmsg) }> | Yes | Callback used to return the result. |
**Example**
```js
try {
inputDeviceCooperate.on('cooperation', (data) => {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(data)}`);
});
} catch (err) {
console.log(`Register failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## off('cooperation')
off(type: 'cooperation', callback?: AsyncCallback\<void>): void
Disables listening for screen hopping events.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| type | string | Yes | Event type. The value is **cooperation**. |
| callback | AsyncCallback<void> | No | Callback to be unregistered. If this parameter is not specified, all callbacks registered by the current application will be unregistered.|
**Example**
```js
// Unregister a single callback.
callback: function(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.off("cooperation", this.callback);
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// Unregister all callbacks.
callback: function(event) {
console.log(`Keyboard mouse crossing event: ${JSON.stringify(event)}`);
return false;
},
try {
inputDeviceCooperate.on('cooperation', this.callback);
inputDeviceCooperate.off("cooperation");
} catch (error) {
console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## EventMsg
Enumerates screen hopping event.
**System capability**: SystemCapability.MultimodalInput.Input.InputDeviceCooperate
| Name | Value | Description |
| -------- | --------- | ----------------- |
| MSG_COOPERATE_INFO_START | 200 | Screen hopping starts. |
| MSG_COOPERATE_INFO_SUCCESS | 201 | Screen hopping succeeds. |
| MSG_COOPERATE_INFO_FAIL | 202 | Screen hopping fails. |
| MSG_COOPERATE_STATE_ON | 500 | Screen hopping is enabled. |
| MSG_COOPERATE_STATE_OFF | 501 | Screen hopping is disabled. |
......@@ -38,12 +38,16 @@ This is a system API.
**Example**
```
let keyOptions = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
try {
inputConsumer.on(inputConsumer.SubscribeType.KEY, keyOptions, callback);
} catch (error) {
console.info(`inputConsumer.on, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
}
inputConsumer.on('key', keyOptions, callback);
```
......@@ -68,12 +72,16 @@ This is a system API.
**Example**
```
let keyOptions = {preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
let keyOptions = { preKeys: [], finalKey: 18, isFinalKeyDown: true, finalKeyDownDuration: 0 }
let callback = function (keyOptions) {
console.info("preKeys: " + keyOptions.preKeys, "finalKey: " + keyOptions.finalKey,
"isFinalKeyDown: " + keyOptions.isFinalKeyDown, "finalKeyDownDuration: " + keyOptions.finalKeyDownDuration)
}
try {
inputConsumer.off(inputConsumer.SubscribeType.KEY, keyOptions, callback);
} catch (error) {
console.info(`inputConsumer.off, error.code=${JSON.stringify(error.code)}, error.msg=${JSON.stringify(error.message)}`);
}
inputConsumer.off('key', keyOptions, callback);
```
......
......@@ -15,6 +15,130 @@ The Input Device module implements listening for connection, disconnection, and
```js
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
## inputDevice.getDeviceList<sup>9+</sup>
getDeviceList(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
inputDevice.getDeviceList((error, ids) => {
if (error) {
console.log(`Failed to get device list.
error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
return;
}
this.data = ids;
console.log("The device ID list is: " + ids);
});
} catch (error) {
console.info("getDeviceList " + error.code + " " + error.message);
}
```
## inputDevice.getDeviceList<sup>9+</sup>
getDeviceList(): Promise&lt;Array&lt;number&gt;&gt;
Obtains the IDs of all input devices. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Return value**
| Name | Description |
| ---------------------------------- | ------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
**Example**
```js
try {
inputDevice.getDeviceList().then((ids) => {
console.log("The device ID list is: " + ids);
});
} catch (error) {
console.info("getDeviceList " + error.code + " " + error.message);
}
```
## inputDevice.getDeviceInfo<sup>9+</sup>
getDeviceInfo(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains information about an input device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | --------------------------------------- |
| deviceId | number | Yes | ID of the input device. |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes | Callback used to return the result, which is an **InputDeviceData** object.|
**Example**
```js
// Obtain the name of the device whose ID is 1.
try {
inputDevice.getDeviceInfo(1, (error, inputDevice) => {
if (error) {
console.log(`Failed to get device information.
error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
return;
}
console.log("The device name is: " + inputDevice.name);
});
} catch (error) {
console.info("getDeviceInfo " + error.code + " " + error.message);
}
```
## inputDevice.getDeviceInfo<sup>9+</sup>
getDeviceInfo(deviceId: number): Promise&lt;InputDeviceData&gt;
Obtains information about an input device. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------- |
| deviceId | number | Yes | ID of the input device.|
**Return value**
| Name | Description |
| -------------------------------------------------- | ------------------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
**Example**
```js
// Obtain the name of the device whose ID is 1.
try {
inputDevice.getDeviceInfo(id).then((inputDevice) => {
console.log("The device name is: " + inputDevice.name);
});
} catch (error) {
console.info("getDeviceInfo " + error.code + " " + error.message);
}
```
## inputDevice.on<sup>9+</sup>
......@@ -35,20 +159,24 @@ Enables listening for hot swap events of an input device.
```js
let isPhysicalKeyboardExist = true;
inputDevice.on("change", (data) => {
try {
inputDevice.on("change", (data) => {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
inputDevice.getKeyboardType(data.deviceId, (err, ret) => {
console.log("The keyboard type of the device is: " + ret);
if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
// The physical keyboard is connected.
isPhysicalKeyboardExist = true;
} else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') {
// The physical keyboard is disconnected.
isPhysicalKeyboardExist = false;
}
console.log("The keyboard type of the device is: " + ret);
if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
// The physical keyboard is connected.
isPhysicalKeyboardExist = true;
} else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') {
// The physical keyboard is disconnected.
isPhysicalKeyboardExist = false;
}
});
});
// Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist.
});
// Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist.
} catch (error) {
console.info("oninputdevcie " + error.code + " " + error.message);
}
```
## inputDevice.off<sup>9+</sup>
......@@ -69,24 +197,43 @@ Disables listening for hot swap events of an input device.
**Example**
```js
function listener(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
callback: function(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}
try {
inputDevice.on("change", this.callback);
} catch (error) {
console.info("oninputdevcie " + error.code + " " + error.message)
}
// Enable listening for hot swap events of an input device.
inputDevice.on("change", listener);
// Disable this listener.
inputDevice.off("change", listener);
try {
inputDevice.off("change", this.callback);
} catch (error) {
console.info("offinputdevcie " + error.code + " " + error.message)
}
// Disable all listeners.
inputDevice.off("change");
try {
inputDevice.off("change");
} catch (error) {
console.info("offinputdevcie " + error.code + " " + error.message);
}
// By default, the soft keyboard is closed when listening is disabled.
```
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds<sup>(deprecated)</sup>
getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
......@@ -103,12 +250,14 @@ inputDevice.getDeviceIds((ids)=>{
});
```
## inputDevice.getDeviceIds
## inputDevice.getDeviceIds<sup>(deprecated)</sup>
getDeviceIds(): Promise&lt;Array&lt;number&gt;&gt;
Obtains the IDs of all input devices. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Return value**
......@@ -125,12 +274,14 @@ inputDevice.getDeviceIds().then((ids)=>{
});
```
## inputDevice.getDevice
## inputDevice.getDevice<sup>(deprecated)</sup>
getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains information about an input device. This API uses an asynchronous callback to return the result.
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
......@@ -149,12 +300,14 @@ inputDevice.getDevice(1, (inputDevice)=>{
});
```
## inputDevice.getDevice
## inputDevice.getDevice<sup>(deprecated)</sup>
getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
Obtains information about an input device. This API uses a promise to return the result.
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
......@@ -198,9 +351,13 @@ Obtains the key codes supported by the input device. This API uses an asynchrono
```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
try {
inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => {
console.log("The query result is as follows: " + ret);
});
});
} catch (error) {
console.info("supportKeys " + error.code + " " + error.message);
}
```
## inputDevice.supportKeys<sup>9+</sup>
......@@ -228,9 +385,13 @@ Obtains the key codes supported by the input device. This API uses a promise to
```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{
try {
inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => {
console.log("The query result is as follows: " + ret);
})
});
} catch (error) {
console.info("supportKeys " + error.code + " " + error.message);
}
```
## inputDevice.getKeyboardType<sup>9+</sup>
......@@ -252,9 +413,18 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call
```js
// Query the keyboard type of the input device whose ID is 1.
inputDevice.getKeyboardType(1, (ret)=>{
console.log("The keyboard type of the device is: " + ret);
});
try {
inputDevice.getKeyboardType(1, (error, number) => {
if (error) {
console.log(`Failed to get keyboardtype.
error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
return;
}
console.log("The keyboard type of the device is: " + number);
});
} catch (error) {
console.info("getKeyboardType " + error.code + " " + error.message);
}
```
## inputDevice.getKeyboardType<sup>9+</sup>
......@@ -275,14 +445,18 @@ Obtains the keyboard type of an input device. This API uses a promise to return
```js
// Query the keyboard type of the input device whose ID is 1.
inputDevice.getKeyboardType(1).then((ret)=>{
console.log("The keyboard type of the device is: " + ret);
})
try {
inputDevice.getKeyboardType(1).then((number) => {
console.log("The keyboard type of the device is: " + number);
});
} catch (error) {
console.info("getKeyboardType " + error.code + " " + error.message);
}
```
## DeviceListener<sup>9+</sup>
Defines the information about an input device.
Defines the listener for hot swap events of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
......
......@@ -36,13 +36,24 @@ This is a system API.
**Example**
```js
let keyEvent = {
try {
var keyEvent = {
isPressed: true,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
}
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent });
var keyEvent1 = {
isPressed: false,
keyCode: 2,
keyDownDuration: 0,
isIntercepted: false
};
inputEventClient.injectKeyEvent({ KeyEvent: keyEvent1 });
} catch (error) {
console.info("injectKeyEvent " + error.code + " " + error.message);
}
let res = inputEventClient.injectEvent({KeyEvent: keyEvent});
```
......
......@@ -43,10 +43,14 @@ This is a system API.
**Example**
```js
inputMonitor.off("touch", (event) => {
// A touch event is consumed.
return false;
});
try {
inputMonitor.on("touch", (data)=> {
console.info(`monitorOnTouchEvent success ${JSON.stringify(data)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
}
```
on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
......@@ -69,13 +73,16 @@ This is a system API.
**Example**
```js
inputMonitor.off("mouse", (event) => {
// A mouse event is consumed.
});
try {
inputMonitor.on("mouse", (data)=> {
console.info(`monitorOnMouseEvent success ${JSON.stringify(data)}`);
return false;
});
} catch (error) {
console.info("onMonitor " + error.code + " " + error.message)
}
```
## inputMonitor.off
off(type: "touch", receiver?: TouchEventReceiver): void
......@@ -98,7 +105,26 @@ This is a system API.
**Example**
```js
inputMonitor.off("touch");
// Disable listening globally.
try {
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("touch", this.callback);
} catch (error) {
console.info("onTouchMonitor " + error.code + " " + error.message)
},
try {
inputMonitor.off("touch",this.callback);
} catch (error) {
console.info("offTouchMonitor " + error.code + " " + error.message)
}
```
off(type: "mouse", receiver?:Callback\<MouseEvent>):void
......@@ -121,7 +147,26 @@ This is a system API.
**Example**
```js
inputMonitor.off("mouse");
// Disable listening globally.
try {
inputMonitor.off("mouse");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
}
// Disable listening for this receiver.
callback:function(data) {
console.info(`call success ${JSON.stringify(data)}`);
},
try {
inputMonitor.on("mouse", this.callback);
} catch (error) {
console.info("onMouseMonitor " + error.code + " " + error.message)
},
try {
inputMonitor.off("mouse", this.callback);
} catch (error) {
console.info("offMouseMonitor " + error.code + " " + error.message)
}
```
......@@ -149,9 +194,13 @@ This is a system API.
**Example**
```js
inputMonitor.on("touch", (event) => {
// A touch event is consumed.
return false;
});
inputMonitor.off("touch");
try {
inputMonitor.on("touch", (event) => {
// If true is returned, all subsequent events of this operation will be consumed by the listener, instead of being distributed to the window.
return false;
});
inputMonitor.off("touch");
} catch (error) {
console.info("offMonitor " + error.code + " " + error.message)
}
```
# Media
> **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The multimedia subsystem provides a set of simple and easy-to-use APIs for you to access the system and use media resources.
......@@ -53,7 +52,7 @@ Creates a **VideoPlayer** instance. This API uses an asynchronous callback to re
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the **VideoPlayer** instance, which can be used to manage and play video media.|
| callback | AsyncCallback<[VideoPlayer](#videoplayer8)> | Yes | Callback used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.|
**Example**
......@@ -80,9 +79,9 @@ Creates a **VideoPlayer** instance. This API uses a promise to return the result
**Return value**
| Type | Description |
| ------------------------------------- | ----------------------------------- |
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the **VideoPlayer** instance, which can be used to manage and play video media.|
| Type | Description |
| ------------------------------------- | ------------------------------------------------------------ |
| Promise<[VideoPlayer](#videoplayer8)> | Promise used to return the result. If the operation is successful, the **VideoPlayer** instance is returned; otherwise, **null** is returned. The instance can be used to manage and play video media.|
**Example**
......@@ -112,9 +111,9 @@ Only one **AudioRecorder** instance can be created per device.
**Return value**
| Type | Description |
| ------------------------------- | ----------------------------------------- |
| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise.|
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ |
| [AudioRecorder](#audiorecorder) | Returns the **AudioRecorder** instance if the operation is successful; returns **null** otherwise. The instance can be used to record audio media.|
**Example**
......@@ -135,7 +134,7 @@ Only one **AudioRecorder** instance can be created per device.
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ------------------------------ |
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the **VideoRecorder** instance, which can be used to record video media.|
| callback | AsyncCallback<[VideoRecorder](#videorecorder9)> | Yes | Callback used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.|
**Example**
......@@ -163,9 +162,9 @@ Only one **AudioRecorder** instance can be created per device.
**Return value**
| Type | Description |
| ----------------------------------------- | ----------------------------------- |
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the **VideoRecorder** instance, which can be used to record video media.|
| Type | Description |
| ----------------------------------------- | ------------------------------------------------------------ |
| Promise<[VideoRecorder](#videorecorder9)> | Promise used to return the result. If the operation is successful, the **VideoRecorder** instance is returned; otherwise, **null** is returned. The instance can be used to record video media.|
**Example**
......@@ -263,7 +262,7 @@ Enumerates the buffering event types.
| BUFFERING_START | 1 | Buffering starts. |
| BUFFERING_END | 2 | Buffering ends. |
| BUFFERING_PERCENT | 3 | Buffering progress, in percent. |
| CACHED_DURATION | 4 | Cache duration, in milliseconds.|
| CACHED_DURATION | 4 | Cache duration, in ms.|
## AudioPlayer
......@@ -362,9 +361,9 @@ Seeks to the specified playback position.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------------- |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
**Example**
......@@ -427,9 +426,9 @@ Obtains the audio track information. This API uses an asynchronous callback to r
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback<Array<[MediaDescription](#mediadescription8)>> | Yes | Callback used to return the audio track information obtained.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ |
| callback | AsyncCallback<Array<[MediaDescription](#mediadescription8)>> | Yes | Callback used to return a **MediaDescription** array, which records the audio track information.|
**Example**
......@@ -463,9 +462,9 @@ Obtains the audio track information. This API uses a promise to return the resul
**Return value**
| Type | Description |
| ------------------------------------------------------ | ------------------------------- |
| Promise<Array<[MediaDescription](#mediadescription8)>> | Promise used to return the audio track information obtained.|
| Type | Description |
| ------------------------------------------------------ | ----------------------------------------------- |
| Promise<Array<[MediaDescription](#mediadescription8)>> | Promise used to return a **MediaDescription** array, which records the audio track information.|
**Example**
......@@ -497,7 +496,7 @@ for (let i = 0; i < arrayDescription.length; i++) {
on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferinginfotype8), value: number) => void): void
Subscribes to the audio buffering update event.
Subscribes to the audio buffering update event. Only network playback supports this subscription.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -594,7 +593,7 @@ audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' e
on(type: 'timeUpdate', callback: Callback\<number>): void
Subscribes to the **'timeUpdate'** event.
Subscribes to the **'timeUpdate'** event. This event is reported every second when the audio playback is in progress.
**System capability**: SystemCapability.Multimedia.Media.AudioPlayer
......@@ -1014,10 +1013,10 @@ Seeks to the specified playback position. The next key frame at the specified po
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.|
| callback | function | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| callback | function | Yes | Callback used to return the result. |
**Example**
......@@ -1042,11 +1041,11 @@ Seeks to the specified playback position. This API uses an asynchronous callback
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.|
| mode | [SeekMode](#seekmode8) | Yes | Seek mode. |
| callback | function | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| mode | [SeekMode](#seekmode8) | Yes | Seek mode. |
| callback | function | Yes | Callback used to return the result. |
**Example**
......@@ -1072,16 +1071,16 @@ Seeks to the specified playback position. If **mode** is not specified, the next
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | ------------------------------------ |
| timeMs | number | Yes | Position to seek to, in milliseconds.|
| mode | [SeekMode](#seekmode8) | No | Seek mode. |
| Name| Type | Mandatory| Description |
| ------ | ---------------------- | ---- | ------------------------------------------------------------ |
| timeMs | number | Yes | Position to seek to, in ms. The value range is [0, duration].|
| mode | [SeekMode](#seekmode8) | No | Seek mode. |
**Return value**
| Type | Description |
| -------------- | ----------------------------------- |
| Promise\<void> | Promise used to return the result.|
| Type | Description |
| -------------- | ------------------------------------------- |
| Promise\<number> | Promise used to return the playback position, in ms.|
**Example**
......@@ -1220,9 +1219,9 @@ Obtains the video track information. This API uses an asynchronous callback to r
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback<Array<[MediaDescription](#mediadescription8)>> | Yes | Callback used to return the video track information obtained.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------ |
| callback | AsyncCallback<Array<[MediaDescription](#mediadescription8)>> | Yes | Callback used to return a **MediaDescription** array, which records the video track information.|
**Example**
......@@ -1256,9 +1255,9 @@ Obtains the video track information. This API uses a promise to return the resul
**Return value**
| Type | Description |
| ------------------------------------------------------ | ------------------------------- |
| Promise<Array<[MediaDescription](#mediadescription8)>> | Promise used to return the video track information obtained.|
| Type | Description |
| ------------------------------------------------------ | ----------------------------------------------- |
| Promise<Array<[MediaDescription](#mediadescription8)>> | Promise used to return a **MediaDescription** array, which records the video track information.|
**Example**
......@@ -1332,9 +1331,9 @@ Sets the video playback speed. This API uses a promise to return the result.
**Return value**
| Type | Description |
| ---------------- | ------------------------- |
| Promise\<number> | Promise used to return the result.|
| Type | Description |
| ---------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return playback speed. For details, see [PlaybackSpeed](#playbackspeed8).|
**Example**
......@@ -1389,13 +1388,13 @@ Selects a bit rate from available ones, which can be obtained by calling [availa
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | -------------------------------------------- |
| bitrate | number | Yes | Bit rate to select, which is used in the HLS multi-bit rate scenario. The unit is bit/s.|
| bitrate | number | Yes | Bit rate, which is used in the HLS multi-bit rate scenario. The unit is bit/s.|
**Return value**
| Type | Description |
| ---------------- | ------------------------- |
| Promise\<number> | Promise used to return the result.|
| Type | Description |
| ---------------- | --------------------------- |
| Promise\<number> | Promise used to return the bit rate.|
**Example**
......@@ -1435,7 +1434,7 @@ videoPlayer.on('playbackCompleted', () => {
on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: number) => void): void
Subscribes to the video buffering update event.
Subscribes to the video buffering update event. Only network playback supports this subscription.
**System capability**: SystemCapability.Multimedia.Media.VideoPlayer
......
......@@ -309,6 +309,8 @@ reportNetConnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;): v
Reports connection of the data network. This API uses an asynchronous callback to return the result.
If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module.
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -337,6 +339,8 @@ reportNetConnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports connection of the data network. This API uses a promise to return the result.
If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module.
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -351,7 +355,7 @@ Reports connection of the data network. This API uses a promise to return the re
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......@@ -370,6 +374,8 @@ reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback&lt;void&gt;)
Reports disconnection of the data network. This API uses an asynchronous callback to return the result.
If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module.
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -398,6 +404,8 @@ reportNetDisconnected(netHandle: NetHandle): Promise&lt;void&gt;
Reports disconnection of the data network. This API uses a promise to return the result.
If this API is called, the application considers that the network connection state (**ohos.net.connection.NetCap.NET_CAPABILITY_VAILDATED**) is inconsistent with that in the network management module.
**Permission required**: ohos.permission.GET_NETWORK_INFO and ohos.permission.INTERNET
**System capability**: SystemCapability.Communication.NetManager.Core
......@@ -412,7 +420,7 @@ Reports disconnection of the data network. This API uses a promise to return the
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise that returns no value.|
**Example**
......@@ -521,7 +529,7 @@ This is a system API.
| Type | Description |
| ------------------------------------------- | ----------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Example**
......@@ -570,7 +578,7 @@ This is a system API.
| Type | Description |
| ------------------------------------------- | ----------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Example**
......@@ -888,7 +896,7 @@ Binds a **TCPSocket** or **UDPSocket** object to the data network. This API uses
| Type | Description |
| -------------- | ---------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise that returns no value.|
**Example**
......
......@@ -12,7 +12,7 @@ The mouse pointer module provides APIs related to pointer attribute management.
import pointer from '@ohos.multimodalInput.pointer';
```
## pointer.setPointerVisibele
## pointer.setPointerVisible<sup>9+</sup>
setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
......@@ -22,24 +22,28 @@ Sets the visible status of the mouse pointer. This API uses an asynchronous call
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------------- |
| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.|
| callback | AysncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| visible | boolean | Yes | Whether the mouse pointer is visible.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
pointer.setPointerVisible(true, (err, data) => {
if (err) {
console.log(`set pointer visible failed. err=${JSON.stringify(err)}`);
return;
try {
pointer.setPointerVisible(true, (error) => {
if (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`set pointer visible success.`);
);
console.log(`Set pointer visible success`);
});
} catch (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerVisible
## pointer.setPointerVisible<sup>9+</sup>
setPointerVisible(visible: boolean): Promise&lt;void&gt;
......@@ -49,66 +53,400 @@ Sets the visible status of the mouse pointer. This API uses a promise to return
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------- | ---- | ------------------------------------------------------------------- |
| visible | boolean | Yes | Whether the mouse pointer is visible. The value **true** indicates that the mouse pointer is visible, and the value **false** indicates the opposite.|
| Name | Type | Mandatory | Description |
| ------- | ------- | ---- | ---------------------------------------- |
| visible | boolean | Yes | Whether the mouse pointer is visible.|
**Return value**
| Parameter | Description |
| ------------------- | ------------------------------- |
| Name | Description |
| ------------------- | ------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
pointer.setPointerVisible(false).then( data => {
console.log(`set mouse pointer visible success`);
}, data => {
console.log(`set mouse pointer visible failed err=${JSON.stringify(data)}`);
});
try {
pointer.setPointerVisible(false).then(() => {
console.log(`Set pointer visible success`);
});
} catch (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.isPointerVisible
## pointer.isPointerVisible<sup>9+</sup>
isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result.
Checks the visible status of the mouse pointer. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Example**
```js
pointer.isPointerVisible((visible)=>{
console.log("The mouse pointer visible attributes is " + visible);
});
try {
pointer.isPointerVisible((error, visible) => {
if (error) {
console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
});
} catch (error) {
console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.isPointerVisible
## pointer.isPointerVisible<sup>9+</sup>
isPointerVisible(): Promise&lt;boolean&gt;
Checks the visible status of the mouse pointer. This API uses a promise to return the result.
Checks the visible status of the mouse pointer. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Return value**
| Parameter | Description |
| ---------------------- | ------------------------------- |
| Name | Description |
| ---------------------- | ------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
```js
pointer.isPointerVisible().then( data => {
console.log(`isPointerThen success data=${JSON.stringify(data)}`);
pointer.isPointerVisible().then((visible) => {
console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
});
```
## pointer.setPointerSpeed<sup>9+</sup>
setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
Sets the mouse movement speed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ------------------------------------- |
| speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**. |
| callback | AysncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
pointer.setPointerSpeed(5, (error) => {
if (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set pointer speed success`);
});
} catch (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.setPointerSpeed<sup>9+</sup>
setPointerSpeed(speed: number): Promise&lt;void&gt;
Sets the mouse movement speed. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----------------------------------- |
| speed | number | Yes | Mouse movement speed. The value ranges from **1** to **11**. The default value is **5**.|
**Return value**
| Name | Description |
| ------------------- | ---------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
try {
pointer.setPointerSpeed(5).then(() => {
console.log(`Set pointer speed success`);
});
} catch (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerSpeed<sup>9+</sup>
getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void
Obtains the mouse movement speed. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result.|
**Example**
```js
try {
pointer.getPointerSpeed((error, speed) => {
if (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
});
} catch (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerSpeed<sup>9+</sup>
getPointerSpeed(): Promise&lt;number&gt;
Obtains the mouse movement speed. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Return value**
| Name | Description |
| --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise used to return the result.|
**Example**
```js
try {
pointer.getPointerSpeed().then(speed => {
console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
});
} catch (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## pointer.getPointerStyle<sup>9+</sup>
getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void
Obtains the mouse pointer style. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | -------------- |
| windowId | number | Yes | Window ID. |
| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | Yes | Callback used to return the result.|
**Example**
```js
import window from '@ohos.window';
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.getPointerStyle(windowId, (error, style) => {
console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
});
} catch (error) {
console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
```
## pointer.getPointerStyle<sup>9+</sup>
getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
Obtains the mouse pointer style. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | -------- |
| windowId | number | Yes | Window ID.|
**Return value**
| Name | Description |
| ---------------------------------------- | ------------------- |
| Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise used to return the result.|
**Example**
```js
import window from '@ohos.window';
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.getPointerStyle(windowId).then((style) => {
console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
});
} catch (error) {
console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
```
## pointer.setPointerStyle<sup>9+</sup>
setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void
Sets the mouse pointer style. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------------------------------ | ---- | ----------------------------------- |
| windowId | number | Yes | Window ID. |
| pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. |
| callback | AysncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
import window from '@ohos.window';
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
console.log(`Set pointer style success`);
});
} catch (error) {
console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
```
## pointer.setPointerStyle<sup>9+</sup>
setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt;
Sets the mouse pointer style. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
**Parameters**
| Name | Type | Mandatory | Description |
| ------------------- | ------------------------------ | ---- | ---------------- |
| windowId | number | Yes | Window ID. |
| pointerStyle | [PointerStyle](#pointerstyle9) | Yes | Mouse pointer style ID. |
| Promise&lt;void&gt; | void | Yes | Promise used to return the result.|
**Example**
```js
import window from '@ohos.window';
window.getTopWindow((error, win) => {
win.getProperties((error, properties) => {
var windowId = properties.id;
if (windowId < 0) {
console.log(`Invalid windowId`);
return;
}
try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
console.log(`Set pointer style success`);
});
} catch (error) {
console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
});
});
```
## PointerStyle<sup>9+</sup>
Enumerates mouse pointer styles.
**System capability**: SystemCapability.MultimodalInput.Input.Pointer
| Name | Value | Description |
| -------------------------------- | ---- | ------ |
| DEFAULT | 0 | Default |
| EAST | 1 | East arrow |
| WEST | 2 | West arrow |
| SOUTH | 3 | South arrow |
| NORTH | 4 | North arrow |
| WEST_EAST | 5 | West-east arrow |
| NORTH_SOUTH | 6 | North-south arrow |
| NORTH_EAST | 7 | North-east arrow |
| NORTH_WEST | 8 | North-west arrow |
| SOUTH_EAST | 9 | South-east arrow |
| SOUTH_WEST | 10 | South-west arrow |
| NORTH_EAST_SOUTH_WEST | 11 | North-east and south-west adjustment|
| NORTH_WEST_SOUTH_EAST | 12 | North-west and south-east adjustment|
| CROSS | 13 | Cross (accurate selection) |
| CURSOR_COPY | 14 | Copy cursor |
| CURSOR_FORBID | 15 | Forbid cursor |
| COLOR_SUCKER | 16 | Sucker |
| HAND_GRABBING | 17 | Grabbing hand |
| HAND_OPEN | 18 | Opening hand |
| HAND_POINTING | 19 | Hand-shaped pointer |
| HELP | 20 | Help |
| MOVE | 21 | Move |
| RESIZE_LEFT_RIGHT | 22 | Left and right resizing|
| RESIZE_UP_DOWN | 23 | Up and down resizing|
| SCREENSHOT_CHOOSE | 24 | Screenshot crosshair|
| SCREENSHOT_CURSOR | 25 | Screenshot cursor |
| TEXT_CURSOR | 26 | Text cursor |
| ZOOM_IN | 27 | Zoom in |
| ZOOM_OUT | 28 | Zoom out |
| MIDDLE_BTN_EAST | 29 | Scrolling east |
| MIDDLE_BTN_WEST | 30 | Scrolling west |
| MIDDLE_BTN_SOUTH | 31 | Scrolling south |
| MIDDLE_BTN_NORTH | 32 | Scrolling north |
| MIDDLE_BTN_NORTH_SOUTH | 33 | Scrolling north-south |
| MIDDLE_BTN_NORTH_EAST | 34 | Scrolling north-east |
| MIDDLE_BTN_NORTH_WEST | 35 | Scrolling north-west |
| MIDDLE_BTN_SOUTH_EAST | 36 | Scrolling south-east |
| MIDDLE_BTN_SOUTH_WEST | 37 | Scrolling south-west |
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | Moving as a cone in four directions|
......@@ -710,7 +710,7 @@ Sets a display name for the SIM card in the specified slot. This API uses an asy
**Example**
```js
let name = "China Mobile";
let name = "ShowName";
sim.setShowName(0, name, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -744,7 +744,7 @@ Sets a display name for the SIM card in the specified slot. This API uses a prom
**Example**
```js
let name = "China Mobile";
let name = "ShowName";
let promise = sim.setShowName(0, name);
promise.then(data => {
console.log(`setShowName success, promise: data->${JSON.stringify(data)}`);
......
# Zip
# zlib
The **zlib** module provides APIs for file compression and decompression.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Constraints
None
## Modules to Import
```javascript
import zlib from '@ohos.zlib';
```
## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
## zlib.zipFile<sup>(deprecated)</sup>
zipFile(inFile: string, outFile: string, options: Options): Promise&lt;void&gt;
Zips a file. This API uses a promise to return the result.
> This API is deprecated since API version 9. You are advised to use [zlib.compressFile](#zlibcompressfile9) instead.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options) | No | Optional parameters for the zip operation. |
**Return value**
......@@ -36,59 +37,59 @@ Zips a file. This API uses a promise to return the result.
**Example 1**
```javascript
```typescript
// Zip a file.
import zlib from '@ohos.zlib'
var inFile = "/xxx/filename.xxx";
var outFile = "/xxx/xxx.zip";
var options = {
import zlib from '@ohos.zlib';
let inFile = '/xxx/filename.xxx';
let outFile = '/xxx/xxx.zip';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile, outFile, options).then((data) => {
console.log("zipFile result: " + data);
}).catch((err)=>{
console.log("catch((err)=>" + err);
console.log('zipFile result is ' + JSON.Stringify(data));
}).catch((err) => {
console.log('error is ' + JSON.Stringify(err));
});
```
**Example 2**
```
```typescript
// Zip a folder.
import zlib from '@ohos.zlib'
var inFile = "/xxx/xxx";
var outFile = "/xxx/xxx.zip";
var options = {
import zlib from '@ohos.zlib';
let inFile = '/xxx/xxx';
let outFile = '/xxx/xxx.zip';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.zipFile(inFile , outFile, options).then((data) => {
console.log("zipFile result: " + data);
console.log('zipFile result is ' + JSON.Stringify(data));
}).catch((err)=>{
console.log("catch((err)=>" + err);
console.log('error is ' + JSON.Stringify(err));
});
```
## zlib.unzipFile
## zlib.unzipFile<sup>(deprecated)</sup>
unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
Unzips a file. This API uses a promise to return the result.
> This API is deprecated since API version 9. You are advised to use [zlib.decompressFile](#zlibdecompressfile9) instead.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).|
| inFile | string | Yes | Path of the folder or file to unzip. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options) | No | Optional parameters for the unzip operation. |
......@@ -100,11 +101,11 @@ Unzips a file. This API uses a promise to return the result.
**Example**
```javascript
```typescript
// Unzip a file.
import zlib from '@ohos.zlib'
var inFile = "/xx/xxx.zip";
var outFile = "/xxx";
import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip';
let outFile = '/xxx';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
......@@ -112,11 +113,202 @@ let options = {
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
zlib.unzipFile(inFile, outFile, options).then((data) => {
console.log("unzipFile result: " + data);
console.log('unzipFile result is ' + JSON.Stringify(data));
}).catch((err)=>{
console.log("catch((err)=>" + err);
console.log('error is ' + JSON.Stringify(err));
})
```
## zlib.compressFile<sup>9+</sup>
compressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback\<void>): void;
Compresses a file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
**Error codes**
| ID| Error Message |
| ------ | -------------------------------------- |
| 401 | wrong param type |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
**Example**
```typescript
// Compress a file.
// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
import zlib from '@ohos.zlib';
let inFile = '/xxx/filename.xxx';
let outFile = '/xxx/xxx.zip';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
try {
zlib.compressFile(inFile, outFile, options, (errData) => {
if (erData !== null) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
})
} catch(errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
compressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Compresses a file. This API uses a promise to return the result.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to compress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the compressed file. |
| options | [Options](#options) | Yes | Compression parameters. |
**Error codes**
| ID| Error Message |
| ------ | -------------------------------------- |
| 401 | wrong param type |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
```typescript
// Compress a file.
// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
import zlib from '@ohos.zlib';
let inFile = '/xxx/filename.xxx';
let outFile = '/xxx/xxx.zip';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
try {
zlib.compressFile(inFile, outFile, options).then((data) => {
console.info('compressFile success');
}).catch((errData) => {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
})
} catch(errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
## zlib.decompressFile<sup>9+</sup>
decompressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback\<void>): void;
Decompresses a file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
| options | [Options](#options) | Yes | Decompression parameters. |
| AsyncCallback<**void**> | callback | No | Callback used to return the result. If the operation is successful, **null** is returned; otherwise, a specific error code is returned. |
**Error codes**
| ID| Error Message |
| ------ | -------------------------------------- |
| 401 | wrong param type |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
**Example**
```typescript
// Decompress a file.
// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip';
let outFile = '/xxx';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
try {
zlib.decompressFile(inFile, outFile, options, (errData) => {
if (erData !== null) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
})
} catch(errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
decompressFile(inFile: string, outFile: string, options: Options): Promise\<void>;
Decompress a file. This API uses a promise to return the result.
**System capability**: SystemCapability.BundleManager.Zlib
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the file to decompress. For details about the path, see [FA Model](js-apis-Context.md) or [Stage Model](js-apis-application-context.md).|
| outFile | string | Yes | Path of the decompressed file. |
| options | [Options](#options) | Yes | Decompression parameters. |
**Error codes**
| ID| Error Message |
| ------ | -------------------------------------- |
| 401 | wrong param type |
| 900001 | The Input source file is invalid. |
| 900002 | The Input destination file is invalid. |
```typescript
// Decompress a file.
// The path used in the code must be the application sandbox path, for example, /data/storage/el2/base/haps. You can obtain the path through context.
import zlib from '@ohos.zlib';
let inFile = '/xx/xxx.zip';
let outFile = '/xxx';
let options = {
level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION,
memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT,
strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY
};
try {
zlib.deCompressFile(inFile, outFile, options).then((data) => {
console.info('deCompressFile success');
}).catch((errData) => {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
})
} catch(errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
}
```
## Options
......@@ -129,16 +321,6 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
| memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). |
| strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).|
## zip.MemLevel
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Value | Description |
| ----------------- | ---- | -------------------------------- |
| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.|
| MEM_LEVEL_MAX | 9 | Maximum memory used by the **zip** API during compression.|
| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.|
## zip.CompressLevel
**System capability**: SystemCapability.BundleManager.Zlib
......@@ -150,6 +332,16 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. |
| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. |
## zip.MemLevel
**System capability**: SystemCapability.BundleManager.Zlib
| Name | Value | Description |
| ----------------- | ---- | -------------------------------- |
| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.|
| MEM_LEVEL_MAX | 9 | Maximum memory used by the **zip** API during compression.|
| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.|
## zip.CompressStrategy
**System capability**: SystemCapability.BundleManager.Zlib
......
# Access Token Error Codes
## 401 Parameter Error
### Error Message
Parameter error.${messageInfo}.
### Possible Causes
This error code is reported if an error occurs during JS parameter parsing. The possible causes are as follows:
1. The number of input parameters is insufficient.
2. The parameter type is incorrect.
### Solution
1. Add input parameters.
2. Correct parameter types.
## 201 Permission denied.
### Error Message
Permission denied.${messageInfo}.
### Possible Causes
This error code is reported if the application process that calls an API is not granted the required permission. The possible causes are as follows:
1. The application process is not granted the required permission.
2. The permission requires user authorization to take effect, but the application process does not obtain the user authorization.
### Solution
1. Check whether the application process is granted the required permission.
2. Check whether the application process has obtained the user authorization if the permission requires user authorization to take effect.
## 12100001 Invalid Parameters
### Error Message
Parameter invalid, message is ${messageInfo}.
### Possible Causes
This error code is reported if an error occurs during parameter verification. The possible causes are as follows:
1. The value of **tokenId** is **0**.
2. The specified permission name is empty or contains more than 256 characters.
3. The **flag** value in the permission authorization or revocation request is invalid.
4. The input parameters specified for registering a listener are incorrect.
### Solution
1. Correct the invalid parameter values.
## 12100002 TokenId does not exist.
### Error Message
TokenId does not exist.
### Possible Causes
1. The specified **tokenId** does not exist.
2. The process corresponding to the specified **tokenId** is not an application process.
### Solution
Set a correct **tokenId**, and make sure that the process corresponding to the specified **tokenId** is an application process.
## 12100003 Permission Not Exist
### Error Message
Permission does not exist.
### Possible Causes
1. The specified **permissionName** does not exist.
2. The specified **permissionName** does not match the specified **tokenId** in the permission authorization or revocation scenario.
3. The specified **permissionName** is not a sensitive permission that requires user authorization.
### Solution
Set the **permissionName** parameter correctly. For details, see [permission-list](../../security/permission-list.md).
## 12100004 Listener APIs Not Used in Pairs
### Error Message
The listener interface is not used together.
### Possible Causes
This error code is reported if listener APIs are not used in pairs. The possible causes are as follows:
1. The listener APIs that need to be used in pairs are repeatedly called.
2. The listener APIs that need to be used in pairs are independently called.
### Solution
1. Check whether the API needs to be used in pairs. That is, if an API is called to enable listening, an API with the same input parameters cannot be called unless an API is called to stop listening first.
2. Check whether the API needs to be used in pairs. That is, an API for disabling listening or unregistering a listener can only be called after the API for enabling listening or registering a listener is called.
## 12100005 Listener Overflow
### Error Message
The number of listeners exceeds the limit.
### Possible Causes
The number of listeners exceeds 200 (the upper limit).
### Solution
Abandon unused listeners in a timely manner.
## 12100006 Permission Granting or Revocation Not Supported for the Specified Application
### Error Message
The specified application does not support the permissions granted or ungranted as specified.
### Possible Causes
1. The specified **tokenId** is the identity of the remote device. Distributed granting and revocation are not yet supported.
2. The specified **tokenId** belongs to a sandbox application, which is not allowed to apply for the specified permission.
### Solution
1. Check whether the method of obtaining **tokenId** is correct.
2. Check whether the sandbox application works in restrictive mode. Most permissions cannot be granted to a sandbox application in restrictive mode.
## 12100007 System Services Not Working Properly
### Error Message
Service is abnormal.
### Possible Causes
This error code is reported if system services are not working properly. The possible causes are as follows:
1. The permission management service cannot be started properly.
2. An error occurs while reading or writing IPC data.
### Solution
System services do not work properly. Try again later or restart the device.
## 12100008 Out of Memory
### Error Message
Out of memory.
### Possible Causes
The system memory is insufficient.
### Solution
Try again later or restart the device.
# Pan-Sensor Error Codes
## 14500101 Service exception.
### Error information
Service exception.
### Description
This error code is reported if the HDI service is abnormal when the **on**, **once**, or **off** interface of the sensor module is called.
### Possible Causes
The HDI service is abnormal.
### Procedure
1. Retry the operation at a specified interval (for example, 1s) or at an exponential increase interval.
2. If the operation fails for three consecutive times, stop the attempt. You can also attempt to obtain the sensor list to check for device availability.
## 14600101 Device operation failed.
### Error Message
Device operation failed.
### Description
This error code is reported if the HDI service is abnormal or the device is occupied when the **startVibration** interface of the vibrator module is called.
### Possible Causes
1. The HDI service is abnormal.
2. The device is occupied.
### Procedure
1. Retry the operation at a specified interval or at an exponential increase interval. If the operation fails for three consecutive times, stop the retry. You can also obtain the vibrator list to check for device availability.
2. Set a higher priority for the vibrator.
# zlib Error Codes
## 900001 Invalid Source File
**Error Message**
The input source file is invalid.
**Description**
This error code is reported when the source file passed in the **compress** or **decompress** API is invalid.
**Possible Causes**
When the **compress** API is called, the file to compress does not exist. When the **decompress** API is called, the file to decompress does not exist.
**Procedure**
1. Check whether the source file exists.
2. Check whether the path of the source file exists and whether the path is the correct sandbox path.
## 900002 Invalid Destination File
**Error Message**
The input destination file is invalid.
**Description**
This error code is reported when the destination file passed in the **compress** or **decompress** API is invalid.
**Possible Causes**
1. When the **compress** API is called, the passed destination file path is invalid, for example, a non-exist sandbox path.
2. When the **decompress** API is called, the destination folder does not exist.
**Procedure**
1. Check whether the destination file path is correct. If not, enter the correct sandbox path.
2. Check whether the destination folder exists. If not, create the folder.
# Screen Hopping Error Codes
## 4400001 Incorrect Target Device Descriptor
**Error Message**
Incorrect descriptor for the target device.
**Description**
This error code is reported if an invalid device descriptor is passed to the screen hopping API.
**Possible Causes**
1. The target device does not exist, or the device is not networked.
2. The target device descriptor is empty.
**Solution**
1. Check whether the target device for screen hopping is correctly networked with the local device.
2. Set the target device descriptor correctly.
## 4400002 Input Device Operation Failed
**Error Message**
Failed to operate the input device.
**Description**
This error code is reported if the screen hopping status is abnormal when the screen hopping API is called.
**Possible Causes**
1. When screen hopping is initiated, the local device is in the hopped state.
2. When screen hopping is disabled, the local device is in the free state.
3. When screen hopping is disabled, the local device is in the hopping state.
**Solution**
1. When initiating screen hopping, make sure that the local device is not in the hopped state.
2. When disabling screen hopping, make sure that the local device is not in the free state.
3. When disabling screen hopping, make sure that the local device is not in the hopping state.
......@@ -180,14 +180,14 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| Hi3518 solution (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_aries.tar.gz.sha256)|
| Hi3516 solution-LiteOS (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus.tar.gz)|
| Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) |
| RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - |
| Release Notes | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - |
| **Source code of the Latest Release**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Full code base (for mini, small, and standard systems)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/code-v3.2-Beta2.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 solution (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_pegasus.tar.gz.sha256) |
| Hi3516 solution-LiteOS (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_LiteOS.tar.gz.sha256)|
| Hi3516 solution-Linux (binary)| 3.2 Beta2 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta2/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta2/hispark_taurus_Linux.tar.gz.sha256)|
| RELEASE-NOTES | 3.2 Beta2 | [Download](../../release-notes/OpenHarmony-v3.2-beta2.md)| - |
| Full code base (for mini, small, and standard systems)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/code-v3.2-Beta3.tar.gz.sha256)|
| RK3568 standard system solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/standard_rk3568.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.1.1/standard_rk3568.tar.gz.sha256)|
| Hi3861 solution (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_pegasus.tar.gz.sha256) |
| Hi3516 solution-LiteOS (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_LiteOS.tar.gz.sha256)|
| Hi3516 solution-Linux (binary)| 3.2 Beta3 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta3/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta3/hispark_taurus_Linux.tar.gz.sha256)|
| Release Notes | 3.2 Beta3 | [Download](../../release-notes/OpenHarmony-v3.2-beta3.md)| - |
| **Compiler Toolchain**| **Version Information**| **Site**| **SHA-256 Verification Code**|
| Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - |
......
......@@ -28,9 +28,8 @@ Location awareness helps determine where a mobile device locates. The system ide
WLAN or Bluetooth positioning estimates the current location of a mobile device based on the locations of WLANs and Bluetooth devices that can be discovered by the device. The location accuracy of this technology depends on the distribution of fixed WLAN access points (APs) and Bluetooth devices around the device. A high density of WLAN APs and Bluetooth devices can produce a more accurate location result than base station positioning. This technology also requires access to the network.
**Figure 1** ** Location subsystem architecture**<a name="fig4460722185514"></a>
**Figure 1** Location subsystem architecture**<a name="fig4460722185514"></a>
![](figures/location_En-1.png)
![](figures/location_En-1.png)
## Directory Structure<a name="section161941989596"></a>
......@@ -116,7 +115,7 @@ The following table describes APIs available for obtaining device location infor
If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background.
You can declare the required permission in your application's configuration file. For details, see [Application Package Structure Configuration File](../application-dev/quick-start/stage-structure.md).
You can declare the required permission in your application's configuration file. For details, see [Access Control (Permission) Development](../application-dev/security/accesstoken-guidelines.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......
......@@ -4,3 +4,4 @@ This directory records the API changes in OpenHarmony 3.1 Release over OpenHarmo
- [JS API Differences](js-apidiff-v3.1-release.md)
- [Native API Differences](native-apidiff-v3.1-release.md)
- [Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release)](changelog-v3.1-release.md)
# Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release)
### Added Validity Verification for Color Values in Color.json
Validity verification is added for color values in the **color.json** file. The verification rules are as follows:
- The hexadecimal color code is used in any of the following formats:
- #rgb: red(0-f) green(0-f) blue(0-f)
- #argb: transparency(0-f) red(0-f) green(0-f) blue(0-f)
- #rrggbb: red(00-ff) green(00-ff) blue(00-ff)
- #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff)
- The dollar sign ($) is used to reference resources defined in the application. The format is as follows:
- $color:xxx
**Change Impacts**
If the verification rules are not met, an error is reported during compilation.
**Key API/Component Changes**
None
### Restrictions on Declaring Multiple Data Types of State Variables
If a **@State**, **@Provide**, **@Link**, or **@Consume** decorated state variable supports multiple data types, they must be all simple data types or references at one time.
Example:
```ts
@Entry
@Component
struct Index {
// Incorrect: @State message: string | Resource = 'Hello World'
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(`${ this.message }`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
**Change Impacts**
When the defined state variable type contains both the simple data types and references, an error is reported during compilation.
**Key API/Component Changes**
If the defined state variable type contains both the simple data types and references, change the type to one of them, as shown in the preceding sample code.
......@@ -31,5 +31,6 @@ This directory records the API changes in OpenHarmony 3.2 Beta2 over OpenHarmony
- [Web subsystem](js-apidiff-web.md)
- [Window manager subsystem](js-apidiff-window.md)
- ChangeLog
- [Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1](changelog-v3.2-beta2.md)
- [Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2)](changelog-v3.2-beta2.md)
- [Adaptation Guide for the Application Sandbox](application-sandbox-adaptation-guide.md)
# Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1
# Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2)
## Introduced Application Sandbox
......
......@@ -30,3 +30,4 @@ This directory records the API changes in OpenHarmony 3.2 Beta3 over OpenHarmony
- [Update subsystem](js-apidiff-update.md)
- [Web subsystem](js-apidiff-web.md)
- [Window manager subsystem](js-apidiff-window.md)
- [Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3)](changelog-v3.2-beta3.md)
# Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3)
## Bundle Management Framework
The privilege control capability is added for preset applications. The capability can be divided into two parts: permission control for preset applications and configuration of preset applications.
Application privileges are high-level capabilities of an application, for example, restricting an application from being uninstalled or restricting application data from being deleted.
OpenHarmony provides both general and device-specific application privileges. The latter can be configured by device vendors for applications on different devices. OpenHarmony supports differentiated configuration of preset applications on different devices. In addition, OpenHarmony provides **GetCfgDirList** for your application to obtain the preset directories, such as **system**, **chipset**, **sys_prod**, and **chip_prod**, in ascending order of priority. For example, the priority of **chip_prod** is higher than that of **system**.
### Changed Installation Mode for Preset Applications
In earlier versions, preset applications are installed by automatically scanning and installing HAP files in the **/system/app** directory. From this version, preset applications are configured based on the trustlist. Specifically, only the HAP file configured with **app-dir** in the **install_list.json** file can be automatically installed as a preset application.
**Change Impacts**
JS and native APIs are not involved, and application development is not affected.
**Key API/Component Changes**
N/A
**Adaptation Guide**
Configure related fields in the [/system/etc/app/install_list.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list.json) file. The **app_dir** field specifies the directory where the HAP file is located, and **removable** specifies whether the HAP file can be uninstalled after being installed.
Example:
```json
{
"install_list" : [
{
"app_dir" : "/system/app/com.ohos.systemui",
"removable" : false
},
{
"app_dir" : "/system/app/demo.hap",
"removable" : true
}
]
}
```
### Changes in General Application Privilege Control
For a specific application, the general application privileges remain unchanged on all types of devices. The general application privileges are as follows:
| Permission| Description |
| ---------------- | ------------------------------------------------------------ |
| AllowAppDataNotCleared | Allows application data to be deleted.|
| AllowAppMultiProcess | Allows the application to run on multiple processes.|
| AllowAppDesktopIconHide | Allows the application icon to be hidden from the home screen.|
| AllowAbilityPriorityQueried | Allows an ability to configure and query the priority. |
| AllowAbilityExcludeFromMissions | Allows an ability to be hidden in the mission stack.|
| AllowAppUsePrivilegeExtension | Allows the application to use Service Extension and Data Extension abilities.|
| AllowFormVisibleNotify | Allows a widget to be visible on the home screen.|
In earlier versions, these privileges are configured in the **config.json** or **module.json** file and distinguished based on the application type (preset or system application). From this version, the privileges are configured based on the signing certificate and preset trustlist.
**Change Impacts**
JS and native APIs are not involved. If your application needs to use any of these privileges, apply for it. For details about how to apply for and configure the privileges, see [Application Privilege Configuration](../device-dev/subsystems/subsys-app-privilege-config-guide.md).
**Key API/Component Changes**
N/A
**Adaptation Guide**
See [Application Privilege Configuration](../device-dev/subsystems/subsys-app-privilege-config-guide.md).
```json
{
"version-name": "1.0.0",
...
"bundle-info": {
"developer-id": "OpenHarmony",
...
},
"issuer": "pki_internal",
"app-privilege-capabilities": ["AllowAppDataNotCleared", "AllowAppDesktopIconHide"] // The application data cannot be deleted, and the icon can be hidden on the home screen.
}
```
### Changes in Device-specific Application Privilege Control
In addition to general application privileges, device vendors can define device-specific privileges for an application, as described in the table below.
| Permission | Type | Default Value| Description |
| --------------------- | -------- | ------ | ------------------------------------------------- |
| removable | bool | true | Allows the application to be uninstalled. This permission takes effect only for preset applications. |
| keepAlive | bool | false | Allows the application to remain resident in the background. |
| singleton | bool | false | Allows the application to be installed for a single user (User 0). |
| allowCommonEvent | string[] | - | Allows the application to be started by a static broadcast. |
| associatedWakeUp | bool | false | Allows the application in the FA model to be woken up by an associated application. |
| runningResourcesApply | bool | false | Allows the application to request running resources, such as CPU, event notifications, and Bluetooth.|
In earlier versions, these privileges are configured in the **config.json** or **module.json** file and distinguished based on the application type (preset or system application). From this version, the privileges can be configured based on the preset trustlist. For details, see [install_list_capability.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_capability.json).
**Change Impacts**
JS and native APIs are not involved. If your application needs to use any of these privileges, apply for it. For details, see [Configuration Mode](../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-mode).
**Key API/Component Changes**
N/A
**Adaptation Guide**
See [Configuration Mode](../device-dev/subsystems/subsys-app-privilege-config-guide.md#configuration-mode).
```json
{
"install_list": [
{
"bundleName": "com.example.kikakeyboard",
"singleton": true, // The application is installed for a single user.
"keepAlive": true, // The application remains resident in the background.
"runningResourcesApply": true, // The application can apply for running resources such as CPU, event notifications, and Bluetooth.
"associatedWakeUp": true, // The application in the FA model can be woken up by an associated application.
"app_signature": ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC"], // The setting takes effect only when the configured certificate fingerprint is the same as the HAP certificate fingerprint.
"allowCommonEvent": ["usual.event.SCREEN_ON", "usual.event.THERMAL_LEVEL_CHANGED"]
}
}
```
### Fingerprint Verification for Pre-authorization Trustlist
The pre-authorization file [install_list_permissions.json](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/preinstall-config/install_list_permissions.json) is moved from **system/etc/permission** to **system/etc/app/** on the development board. The **app_signature** field is added to specify the fingerprint of the HAP file. Multiple fingerprints can be configured. Authorization can be performed only when the fingerprint is matched.
**Change Impacts**
JS and native APIs are not involved. If your application uses pre-authorization, add the fingerprint to the pre-authorization file.
**Key API/Component Changes**
N/A
**Adaptation Guide**
Refer to the following code:
```json
{
[
{
"bundleName" : "com.ohos.screenshot",
"app_signature" : ["8E93863FC32EE238060BF69A9B37E2608FFFB21F93C862DD511CBAC9F30024B5"],
"permissions" : [
{
"name" : "ohos.permission.MEDIA_LOCATION",
"userCancellable" : true
},
{
"name" : "ohos.permission.READ_MEDIA",
"userCancellable" : true
},
{
"name" : "ohos.permission.WRITE_MEDIA",
"userCancellable" : true
}
]
}
}
```
## ArkUI Development Framework
### Rectified Variable Sharing Issue of the Common Module in Release HAP Mode During Building in the FA Model
Assume that two pages depend on the same object (foodData) of a file. If page A modifies the object, page B obtains the new value when reading the object. This implements object sharing for the common module.
**Change Impacts**
Application compilation is not affected, and no interface adaptation is required.
**Key API/Component Changes**
N/A
### Restrictions on Declaring Multiple Data Types of State Variables
If a **@State**, **@Provide**, **@Link**, or **@Consume** decorated state variable supports multiple data types, they must be all simple data types or references at one time.
Example:
```ts
@Entry
@Component
struct Index {
// Incorrect: @State message: string | Resource = 'Hello World'
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(`${ this.message }`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
```
**Change Impacts**
When the defined state variable type contains both the simple data types and references, an error is reported during compilation.
**Key API/Component Changes**
If the defined state variable type contains both the simple data types and references, change the type to one of them, as shown in the preceding sample code.
## Globalization Subsystem
### Added Validity Verification for Color Values in Color.json
Validity verification is added for color values in the **color.json** file. The verification rules are as follows:
- The hexadecimal color code is used in any of the following formats:
- #rgb: red(0-f) green(0-f) blue(0-f)
- #argb: transparency(0-f) red(0-f) green(0-f) blue(0-f)
- #rrggbb: red(00-ff) green(00-ff) blue(00-ff)
- #aarrggbb: transparency(00-ff) red(00-ff) green(00-ff) blue(00-ff)
- The dollar sign ($) is used to reference resources defined in the application. The format is as follows:
- $color:xxx
**Change Impacts**
If the verification rules are not met, an error is reported during compilation.
**Key API/Component Changes**
N/A
<!--no_check-->
\ No newline at end of file
......@@ -58,6 +58,7 @@
- [Update subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-update.md)
- [Web subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-web.md)
- [Window manager subsystem](release-notes/api-change/v3.2-beta3/js-apidiff-window.md)
- [Updates (OpenHarmony 3.2 Beta2 -> OpenHarmony 3.2 Beta3)](release-notes/api-change/v3.2-beta3/changelog-v3.2-beta3.md)
- OpenHarmony 3.2 Beta2
- JS API Differences
- [Ability framework](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md)
......@@ -88,7 +89,7 @@
- [Web subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-web.md)
- [Window manager subsystem](release-notes/api-change/v3.2-beta2/js-apidiff-window.md)
- ChangeLog
- [Updates Between OpenHarmony 3.2 Beta2 and OpenHarmony 3.2 Beta1](release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md)
- [Updates (OpenHarmony 3.2 Beta1 -> OpenHarmony 3.2 Beta2)](release-notes/api-change/v3.2-beta2/changelog-v3.2-beta2.md)
- [Adaptation Guide for the Application Sandbox](release-notes/api-change/v3.2-beta2/application-sandbox-adaptation-guide.md)
- OpenHarmony 3.2 Beta1
- JS API Differences
......@@ -143,10 +144,11 @@
- [User IAM subsystem](release-notes/api-change/v3.1-Release/js-apidiff-user-authentication.md)
- [Window manager subsystem](release-notes/api-change/v3.1-Release/js-apidiff-window.md)
- [Native API Differences](release-notes/api-change/v3.1-Release/native-apidiff-v3.1-release.md)
- [Updates (OpenHarmony 3.1 Beta -> OpenHarmony 3.1 Release)](release-notes/api-change/v3.1-Release/changelog-v3.1-release.md)
- OpenHarmony 3.1 Beta
- [JS API Differences](release-notes/api-change/v3.1-beta/js-apidiff-v3.1-beta.md)
- [Native API Differences](release-notes/api-change/v3.1-beta/native-apidiff-v3.1-beta.md)
- [Updates Between OpenHarmony 3.1 Beta and OpenHarmony 3.0](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md)
- [Updates (OpenHarmony 3.0 -> OpenHarmony 3.1 Beta)](release-notes/api-change/v3.1-beta/changelog-v3.1-beta.md)
- OpenHarmony 3.0 LTS
- [JS API Differences](release-notes/api-change/v3.0-LTS/js-apidiff-v3.0-lts.md)
- OpenHarmony v2.2 Beta2
......
......@@ -114,7 +114,10 @@
### 设置分布式列表
>**注意:** 在使用RdbStore的setDistributedTables、obtainDistributedTableName、sync、on、off接口时,需要请求相应的权限:ohos.permission.DISTRIBUTED_DATASYNC。
> **说明:**
>
> - 在使用RdbStore的setDistributedTables、obtainDistributedTableName、sync、on、off接口时,需要请求相应的权限:ohos.permission.DISTRIBUTED_DATASYNC。
> - 使用分布式列表前,需要先建立设备间组网,具体接口及使用可见[设备管理](../reference/apis/js-apis-device-manager.md)。
**设置分布式列表**
......
......@@ -50,7 +50,7 @@
如此,既在各设备上体现了UX的一致性,也在各设备上体现了UX的差异性,从而既可以保障各设备上应用界面的体验,也可以最大程度复用界面代码。
在本文[应用UX设计章节](ux-design.md)中,将详细介绍应用的UX设计规则。
在本文[应用UX设计章节](design-principles.md)中,将详细介绍应用的UX设计规则。
## 工程管理及调试
......@@ -271,3 +271,5 @@ struct Home {
- 在使用特定系统能力前,通过canIUse接口判断系统能力是否存在,进而执行不同的逻辑。
在本文的[功能开发的一多能力介绍](development-intro.md)章节中,将详细展开介绍。
<!--no_check-->
\ No newline at end of file
......@@ -10,6 +10,8 @@
- [OpenSL ES播放开发指导](opensles-playback.md)
- [OpenSL ES录音开发指导](opensles-capture.md)
- [音频焦点模式开发指导](audio-interruptmode.md)
- [音量管理开发指导](audio-volume-manager.md)
- [路由、设备管理开发指导](audio-routing-manager.md)
- 视频
- [视频播放开发指导](video-playback.md)
......
......@@ -44,6 +44,5 @@ constructor(durationTime: number);
**示例:**
```ts
let durationTime = 20;
let gesturePath = new GesturePath(durationTime);
let gesturePath = new GesturePath.GesturePath(20);
```
......@@ -45,7 +45,5 @@ constructor(positionX: number, positionY: number);
**示例:**
```ts
let positionX = 1;
let positionY = 2;
let gesturePoint = new GesturePoint(positionX, positionY);
let gesturePoint = new GesturePoint.GesturePoint(1, 2);
```
......@@ -65,7 +65,7 @@ enableAbility(name: string, capability: Array&lt;accessibility.Capability&gt;):
```ts
let name = 'com.ohos.example/axExtension';
let capability = ['retrieve'];
let capability : accessibility.Capability[] = ['retrieve'];
try {
config.enableAbility(name, capability).then(() => {
console.info('enable ability succeed');
......@@ -75,7 +75,7 @@ try {
} catch (exception) {
console.error('failed to enable ability, because ' + JSON.stringify(exception));
};
```
```
## enableAbility
......@@ -106,9 +106,9 @@ enableAbility(name: string, capability: Array&lt;accessibility.Capability&gt;, c
```ts
let name = 'com.ohos.example/axExtension';
let capability = ['retrieve'];
let capability : accessibility.Capability[] = ['retrieve'];
try {
config.enableAbility(name, capability, (err, data) => {
config.enableAbility(name, capability, (err) => {
if (err) {
console.error('failed to enable ability, because ' + JSON.stringify(err));
return;
......@@ -153,7 +153,7 @@ disableAbility(name: string): Promise&lt;void&gt;;
```ts
let name = 'com.ohos.example/axExtension';
try {
config.enableAbility(name).then(() => {
config.disableAbility(name).then(() => {
console.info('disable ability succeed');
}).catch((err) => {
console.error('failed to disable ability, because ' + JSON.stringify(err));
......@@ -224,12 +224,9 @@ on(type: 'enabledAccessibilityExtensionListChange', callback: Callback&lt;void&g
try {
config.on('enabledAccessibilityExtensionListChange', () => {
console.info('subscribe enabled accessibility extension list change state success');
}).catch((err) => {
console.error('failed to subscribe enabled accessibility extension list change state, because ' +
JSON.stringify(err));
});
} catch (exception) {
console.error('failed to subscribe enabled accessibility extension list change state, because ' +
console.error('failed to subscribe enabled accessibility extension list change state, because ' +
JSON.stringify(exception));
};
```
......@@ -254,13 +251,10 @@ off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback&lt;void
```ts
try {
config.off('enabledAccessibilityExtensionListChange', () => {
console.info('unSubscribe enabled accessibility extension list change state success');
}).catch((err) => {
console.error('failed to unSubscribe enabled accessibility extension list change state, because ' +
JSON.stringify(err));
console.info('Unsubscribe enabled accessibility extension list change state success');
});
} catch (exception) {
console.error('failed to unSubscribe enabled accessibility extension list change state, because ' +
console.error('failed to Unsubscribe enabled accessibility extension list change state, because ' +
JSON.stringify(exception));
};
```
......@@ -408,12 +402,8 @@ on(callback: Callback&lt;T&gt;): void;
```ts
try {
config.highContrastText.on((err, data) => {
if (err) {
console.error('failed subscribe highContrastText, because ' + JSON.stringify(err));
return;
}
console.info('subscribe highContrastText success');
config.highContrastText.on((data) => {
console.info('subscribe highContrastText success, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed subscribe highContrastText, because ' + JSON.stringify(exception));
......@@ -437,12 +427,8 @@ off(callback?: Callback&lt;T&gt;): void;
**示例:**
```ts
config.highContrastText.off((err, data) => {
if (err) {
console.error('failed unSubscribe highContrastText, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe highContrastText success');
config.highContrastText.off((data) => {
console.info('Unsubscribe highContrastText success, result: ' + JSON.stringify(data));
});
```
......
......@@ -171,16 +171,10 @@ on(type: 'enableChange', callback: Callback&lt;boolean&gt;): void;
**示例:**
```ts
let result = false;
let captionsManager = accessibility.getCaptionsManager();
try {
captionsManager.on('enableChange', (err, data) => {
if (err) {
console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(err));
return;
}
result = data;
console.info('subscribe caption manager enable state change success');
captionsManager.on('enableChange', (data) => {
console.info('subscribe caption manager enable state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to subscribe caption manager enable state change, because ' + JSON.stringify(exception));
......@@ -206,13 +200,9 @@ on(type: 'styleChange', callback: Callback&lt;CaptionsStyle&gt;): void;
let captionStyle;
let captionsManager = accessibility.getCaptionsManager();
try {
captionsManager.on('styleChange', (err, data) => {
if (err) {
console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(err));
return;
}
captionsManager.on('styleChange', (data) => {
captionStyle = data;
console.info('subscribe caption manager style state change success');
console.info('subscribe caption manager style state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to subscribe caption manager style state change, because ' + JSON.stringify(exception));
......@@ -235,19 +225,13 @@ off(type: 'enableChange', callback?: Callback&lt;boolean&gt;): void;
**示例:**
```ts
let result = false;
let captionsManager = accessibility.getCaptionsManager();
try {
captionsManager.off('enableChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(err));
return;
}
result = data;
console.info('unSubscribe caption manager enable state change success');
captionsManager.off('enableChange', (data) => {
console.info('Unsubscribe caption manager enable state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to unSubscribe caption manager enable state change, because ' + JSON.stringify(exception));
console.error('failed to Unsubscribe caption manager enable state change, because ' + JSON.stringify(exception));
}
```
......@@ -270,16 +254,12 @@ off(type: 'styleChange', callback?: Callback&lt;CaptionsStyle&gt;): void;
let captionStyle;
let captionsManager = accessibility.getCaptionsManager();
try {
captionsManager.off('styleChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(err));
return;
}
captionsManager.off('styleChange', (data) => {
captionStyle = data;
console.info('unSubscribe caption manager style state change success');
console.info('Unsubscribe caption manager style state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to unSubscribe caption manager style state change, because ' + JSON.stringify(exception));
console.error('failed to Unsubscribe caption manager style state change, because ' + JSON.stringify(exception));
}
```
......@@ -503,9 +483,9 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState)
**示例:**
```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let extensionList: accessibility.AccessibilityInfo[];
let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState).then((data) => {
for (let item of data) {
......@@ -526,7 +506,7 @@ try {
## accessibility.getAccessibilityExtensionList<sup>9+</sup>
getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void
getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback&lt;Array&lt;AccessibilityAbilityInfo&gt;&gt;): void
查询辅助应用列表,使用callback异步回调。
......@@ -543,9 +523,9 @@ getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState,
**示例:**
```ts
let abilityType = 'spoken';
let abilityState = 'enable';
let extensionList: accessibility.AccessibilityInfo[];
let abilityType : accessibility.AbilityType = 'spoken';
let abilityState : accessibility.AbilityState = 'enable';
let extensionList: accessibility.AccessibilityAbilityInfo[] = [];
try {
accessibility.getAccessibilityExtensionList(abilityType, abilityState, (err, data) => {
if (err) {
......@@ -560,8 +540,6 @@ try {
extensionList.push(item);
}
console.info('get accessibility extension list success');
}).catch((err) => {
console.error('failed to get accessibility extension list because ' + JSON.stringify(err));
});
} catch (exception) {
console.error('failed to get accessibility extension list because ' + JSON.stringify(exception));
......@@ -607,12 +585,8 @@ on(type: 'accessibilityStateChange', callback: Callback&lt;boolean&gt;): void
```ts
try {
accessibility.on('accessibilityStateChange', (err, data) => {
if (err) {
console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(err));
return;
}
console.info('subscribe accessibility state change success');
accessibility.on('accessibilityStateChange', (data) => {
console.info('subscribe accessibility state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to subscribe accessibility state change, because ' + JSON.stringify(exception));
......@@ -638,12 +612,8 @@ on(type: 'touchGuideStateChange', callback: Callback&lt;boolean&gt;): void
```ts
try {
accessibility.on('touchGuideStateChange', (err, data) => {
if (err) {
console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(err));
return;
}
console.info('subscribe touch guide state change success');
accessibility.on('touchGuideStateChange', (data) => {
console.info('subscribe touch guide state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to subscribe touch guide state change, because ' + JSON.stringify(exception));
......@@ -669,15 +639,11 @@ off(type: 'accessibilityStateChange', callback?: Callback&lt;boolean&gt;): void
```ts
try {
accessibility.on('accessibilityStateChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe accessibility state change success');
accessibility.off('accessibilityStateChange', (data) => {
console.info('Unsubscribe accessibility state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to unSubscribe accessibility state change, because ' + JSON.stringify(exception));
console.error('failed to Unsubscribe accessibility state change, because ' + JSON.stringify(exception));
}
```
......@@ -700,15 +666,11 @@ off(type: 'touchGuideStateChange', callback?: Callback&lt;boolean&gt;): void
```ts
try {
accessibility.on('touchGuideStateChange', (err, data) => {
if (err) {
console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(err));
return;
}
console.info('unSubscribe touch guide state change success');
accessibility.off('touchGuideStateChange', (data) => {
console.info('Unsubscribe touch guide state change, result: ' + JSON.stringify(data));
});
} catch (exception) {
console.error('failed to unSubscribe touch guide state change, because ' + JSON.stringify(exception));
console.error('failed to Unsubscribe touch guide state change, because ' + JSON.stringify(exception));
}
```
......
......@@ -632,7 +632,7 @@ import distributedObject from '@ohos.data.distributedDataObject';
import featureAbility from '@ohos.ability.featureAbility';
// 获取context
let context = featureAbility.getContext();
let g_object = distributedObject.create({name:"Amy", age:18, isVis:false});
let g_object = distributedObject.create(context,{name:"Amy", age:18, isVis:false});
g_object.setSessionId("123456");
g_object.save("local").then((result) => {
console.log("save callback");
......@@ -654,7 +654,7 @@ class MainAbility extends Ability{
context = this.context
}
}
let g_object = distributedObject.create({name:"Amy", age:18, isVis:false});
let g_object = distributedObject.create(context,{name:"Amy", age:18, isVis:false});
g_object.setSessionId("123456");
g_object.save("local").then((result) => {
console.log("save callback");
......
......@@ -475,7 +475,7 @@ get(key: string, defValue: ValueType, callback: AsyncCallback&lt;ValueType&gt;):
```js
try {
data_preferences.get('startup', 'default', function (err, val) {
preferences.get('startup', 'default', function (err, val) {
if (err) {
console.info("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
return;
......
......@@ -1525,7 +1525,7 @@ lstat(path: string): Promise&lt;Stat&gt;
```js
let filePath = pathDir + "/test.txt";
fileio.lstat(filePath).then(function(stat){
console.info("get link status succeed, " + the size of file is + stat.size);
console.info("get link status succeed, the size of file is" + stat.size);
}).catch(function(err){
console.info("get link status failed with error:"+ err);
});
......
......@@ -56,7 +56,7 @@ getController(): InputMethodController
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
......@@ -84,7 +84,7 @@ getSetting(): InputMethodSetting
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -115,7 +115,7 @@ switchInputMethod(target: InputMethodProperty, callback: AsyncCallback&lt;boolea
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -164,7 +164,7 @@ switchInputMethod(target: InputMethodProperty): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -228,7 +228,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallb
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -290,7 +290,7 @@ switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise&lt;boolean&
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -366,7 +366,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -434,7 +434,7 @@ switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inp
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -537,7 +537,7 @@ stopInputSession(callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -580,7 +580,7 @@ stopInputSession(): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -623,7 +623,7 @@ showSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -660,7 +660,7 @@ showSoftKeyboard(): Promise&lt;void&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -695,7 +695,7 @@ hideSoftKeyboard(callback: AsyncCallback&lt;void&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -732,7 +732,7 @@ hideSoftKeyboard(): Promise&lt;void&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -883,7 +883,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: Async
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -933,7 +933,7 @@ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise&lt;Arr
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -975,7 +975,7 @@ listCurrentInputMethodSubtype(callback: AsyncCallback&lt;Array&lt;InputMethodSub
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -1014,7 +1014,7 @@ listCurrentInputMethodSubtype(): Promise&lt;Array&lt;InputMethodSubtype&gt;&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -1052,7 +1052,7 @@ getInputMethods(enable: boolean, callback: AsyncCallback&lt;Array&lt;InputMethod
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -1091,7 +1091,7 @@ getInputMethods(enable: boolean): Promise&lt;Array&lt;InputMethodProperty&gt;&gt
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -1136,7 +1136,7 @@ showOptionalInputMethods(callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......@@ -1176,7 +1176,7 @@ showOptionalInputMethods(): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------------------- |
......
......@@ -712,7 +712,7 @@ hide(callback: AsyncCallback&lt;void&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -746,7 +746,7 @@ hide(): Promise&lt;void&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -841,7 +841,7 @@ sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -889,7 +889,7 @@ sendKeyFunction(action:number): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -930,7 +930,7 @@ getForward(length:number, callback: AsyncCallback&lt;string&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
......@@ -976,7 +976,7 @@ getForward(length:number): Promise&lt;string&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
......@@ -1015,7 +1015,7 @@ getBackward(length:number, callback: AsyncCallback&lt;string&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
......@@ -1061,7 +1061,7 @@ getBackward(length:number): Promise&lt;string&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | ------------------------------ |
......@@ -1100,7 +1100,7 @@ deleteForward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1150,7 +1150,7 @@ deleteForward(length:number): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1193,7 +1193,7 @@ deleteBackward(length:number, callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1243,7 +1243,7 @@ deleteBackward(length:number): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1282,7 +1282,7 @@ insertText(text:string, callback: AsyncCallback&lt;boolean&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1327,7 +1327,7 @@ insertText(text:string): Promise&lt;boolean&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1368,7 +1368,7 @@ getEditorAttribute(callback: AsyncCallback&lt;EditorAttribute&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1403,7 +1403,7 @@ getEditorAttribute(): Promise&lt;EditorAttribute&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1437,7 +1437,7 @@ moveCursor(direction: number, callback: AsyncCallback&lt;void&gt;): void
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......@@ -1481,7 +1481,7 @@ moveCursor(direction: number): Promise&lt;void&gt;
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errcode-inputmethod-framework.md)
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误码信息 |
| -------- | -------------------------- |
......
......@@ -102,7 +102,7 @@ try {
let localUpdater = update.getLocalUpdater();
} catch(error) {
console.error(`Fail to get localUpdater error: ${error}`);
}
};
```
## Updater
......@@ -844,7 +844,7 @@ const versionDigestInfo = {
};
// 清除选项
lconstet clearOptions = {
const clearOptions = {
status: update.UpgradeStatus.UPGRADE_FAIL,
};
updater.clearError(versionDigestInfo, clearOptions).then(() => {
......@@ -1248,7 +1248,7 @@ applyNewVersion(upgradeFiles: Array<[UpgradeFile](#upgradefile)>): Promise\<void
**示例:**
```ts
localUpdater upgradeFiles = [{
const upgradeFiles = [{
fileType: update.ComponentType.OTA, // OTA包
filePath: "path" // 本地升级包路径
}];
......
......@@ -107,7 +107,7 @@ connectDevice(device: USBDevice): Readonly&lt;USBDevicePipe&gt;
**错误码:**
以下错误码的详细介绍参见[USB错误码](../errorcodes/errcode-usb.md)
以下错误码的详细介绍参见[USB错误码](../errorcodes/errorcode-usb.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
......
......@@ -10,6 +10,7 @@
```ts
import userFileManager from '@ohos.filemanagement.userFileManager';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
## userFileManager.getUserFileMgr
......@@ -38,7 +39,7 @@ getUserFileMgr(context: Context): UserFileManager
```ts
const context = getContext(this);
let mgr = userfilemanager.getUserFileMgr(context);
let mgr = userFileManager.getUserFileMgr(context);
```
## userFileManager.getUserFileMgr
......@@ -62,7 +63,7 @@ getUserFileMgr(): UserFileManager
**示例:**
```ts
let mgr = userfilemanager.getUserFileMgr();
let mgr = userFileManager.getUserFileMgr();
```
## UserFileManager
......
......@@ -101,26 +101,28 @@
headericon="/common/search.svg" placeholder="Please input text" onchange="change"
onenterkeyclick="enterkeyClick">
</input>
<input class="button" type="button" value="Submit" onclick="buttonClick"></input>
<input class="button" type="button" value="Submit" onclick="buttonClick" style="color: blue"></input>
</div>
```
```css
/* xxx.css */
.content {
width: 60%;
width: 100%;
flex-direction: column;
align-items: center;
}
.input {
width: 60%;
placeholder-color: gray;
}
.button {
width: 60%;
background-color: gray;
margin-top: 20px;
}
}
```
```js
// xxx.js
import prompt from '@system.prompt'
......@@ -142,9 +144,10 @@
error: 'error text'
});
},
}
}
```
![zh-cn_image_0000001252835901](figures/zh-cn_image_0000001252835901.png)
2. type为button
......
......@@ -82,7 +82,7 @@
/*xxx.css */
.container {
flex-direction: column;
align-items: center;
margin-left: 20px;
}
.row {
flex-direction: row;
......
......@@ -58,8 +58,6 @@
<div class="container">
<qrcode value="{{qr_value}}" type="{{qr_type}}"
style="color: {{qr_col}};background-color: {{qr_bcol}};width: {{qr_size}};height: {{qr_size}};margin-bottom: 70px;"></qrcode>
<text class="txt">Value</text>
<input onChange="setValue">123</input>
<text class="txt">Type</text>
<switch showtext="true" checked="true" texton="rect" textoff="circle" onchange="settype"></switch>
<text class="txt">Color</text>
......
......@@ -37,7 +37,7 @@
### getContext
getContext(type: '2d', options?: ContextAttrOptions): CanvasRendering2dContext
getContext(type: '2d', options?: ContextAttrOptions): CanvasRenderingContext2D
获取canvas绘图上下文。不支持在onInit和onReady中进行调用。
......
......@@ -319,7 +319,7 @@ Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2
<div class="container">
<text>transition</text>
<div class="move_page" onclick="jumpBack"></div>
</div
</div>
```
```js
......
......@@ -62,16 +62,16 @@
除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件:
| 名称 | 参数 | 描述 |
| -------------------------- | ---------------------------------------- | ---------------------------------------- |
| indexerchange<sup>5+</sup> | {&nbsp;local:&nbsp;booleanValue&nbsp;} | 多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:<br/>-&nbsp;true:&nbsp;当前展示本地索引。<br/>-&nbsp;false:&nbsp;当前展示字母索引。 |
| 名称 | 参数 | 描述 |
| -------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| indexerchange<sup>5+</sup> | {&nbsp;local:&nbsp;booleanValue&nbsp;} | 多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:<br/>-&nbsp;true:&nbsp;当前展示本地索引。<br/>-&nbsp;false:&nbsp;当前展示字母索引。 |
| scroll | {&nbsp;scrollX:&nbsp;scrollXValue,&nbsp;scrollY:&nbsp;scrollYValue,&nbsp;scrollState:&nbsp;stateValue&nbsp;} | 列表滑动的偏移量和状态回调。<br/>stateValue:&nbsp;0表示列表滑动已经停止。<br/>stateValue:&nbsp;1表示列表正在用户触摸状态下滑动。<br/>stateValue:&nbsp;2表示列表正在用户松手状态下滑动。 |
| scrollbottom | - | 当前列表已滑动到底部位置。 |
| scrolltop | - | 当前列表已滑动到顶部位置。 |
| scrollend | - | 列表滑动已经结束。 |
| scrolltouchup | - | 手指已经抬起且列表仍在惯性滑动。 |
| requestitem | - | 请求创建新的list-item。<br/>长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。 |
| rotate<sup>7+</sup> | {&nbsp;rotateValue:&nbsp;number&nbsp;} | 返回表冠旋转角度增量值,仅智能穿戴支持。 |
| scrollbottom | - | 当前列表已滑动到底部位置。 |
| scrolltop | - | 当前列表已滑动到顶部位置。 |
| scrollend | - | 列表滑动已经结束。 |
| scrolltouchup | - | 手指已经抬起且列表仍在惯性滑动。 |
| requestitem | - | 请求创建新的list-item。<br/>长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。 |
| rotation<sup>7+</sup> | {&nbsp;rotateValue:&nbsp;number&nbsp;} | 返回表冠旋转角度增量值,仅智能穿戴支持。 |
## 方法
......
......@@ -5,15 +5,6 @@
>
> - 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> - 需要在config.json对应的"abilities"中设置"configChanges"属性为"orientation"
> ```
> "abilities": [
> {
> "configChanges": ["orientation"],
> ...
> }
> ]
> ```
视频播放组件。
......
# 基于ArkTS的声明式开发范式
- [组件导读](ts-components-summary.md)
- 组件通用信息
- 通用事件
- [点击事件](ts-universal-events-click.md)
......@@ -65,6 +66,8 @@
- [LoadingProgress](ts-basic-components-loadingprogress.md)
- [Marquee](ts-basic-components-marquee.md)
- [Navigation](ts-basic-components-navigation.md)
- [NavRouter](ts-basic-components-navrouter.md)
- [NavDestination](ts-basic-components-navdestination.md)
- [PatternLock](ts-basic-components-patternlock.md)
- [PluginComponent](ts-basic-components-plugincomponent.md)
- [Progress](ts-basic-components-progress.md)
......@@ -140,8 +143,6 @@
- [OffscreenCanvasRenderingContext2D对象](ts-offscreencanvasrenderingcontext2d.md)
- [Path2D对象](ts-components-canvas-path2d.md)
- [Lottie](ts-components-canvas-lottie.md)
- 动画
- [属性动画](ts-animatorproperty.md)
- [显式动画](ts-explicit-animation.md)
......@@ -164,5 +165,4 @@
- [枚举说明](ts-appendix-enums.md)
- [类型说明](ts-types.md)
- 已停止维护的组件
- [GridContainer(栅格)](ts-container-gridcontainer.md)
- [GridContainer(栅格)](ts-container-gridcontainer.md)
\ No newline at end of file
# NavDestination
作为NavRouter组件的子组件,用于显示导航内容区。
> **说明:**
>
> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
可以包含子组件。
## 接口
NavDestination()
## 属性
仅支持[backgroundColor](ts-universal-attributes-background.md)通用属性。
| 名称 | 参数类型 | 描述 |
| -------------- | ---------------------------------------- | ---------------------------------------- |
| title | string&nbsp;\|&nbsp;[CustomBuilder](ts-types.md#custombuilder8)&nbsp;\|&nbsp;[NavigationCommonTitle](ts-basic-components-navigation.md#navigationcommontitle类型说明)&nbsp;\|&nbsp;[NavigationCustomTitle](ts-basic-components-navigation.md##navigationcustomtitle类型说明) | 页面标题。 |
| hideTitleBar | boolean | 是否显示标题栏。<br/>默认值:false<br/>true:&nbsp;隐藏标题栏。<br/>false:&nbsp;显示标题栏。 |
\ No newline at end of file
# Navigation
Navigation组件一般作为Page页面的根容器,通过属性设置来展示页面的标题、工具栏、菜单
Navigation组件一般作为Page页面的根容器,通过属性设置来展示页面的标题栏、工具栏、导航栏等
> **说明:**
>
......@@ -9,14 +9,13 @@ Navigation组件一般作为Page页面的根容器,通过属性设置来展示
## 子组件
可以包含子组件。
可以包含子组件。从API Version 9开始,推荐与[NavRouter](ts-basic-components-navrouter.md)组件搭配使用。
## 接口
Navigation()
创建可以根据属性设置,自动展示导航栏、标题、工具栏的组件。
## 属性
......@@ -24,14 +23,20 @@ Navigation()
| 名称 | 参数类型 | 描述 |
| -------------- | ---------------------------------------- | ---------------------------------------- |
| title | string&nbsp;\|&nbsp;[CustomBuilder](ts-types.md#custombuilder8)<sup>8+</sup> | 页面标题。 |
| subTitle | string | 页面副标题。 |
| title | string&nbsp;\|&nbsp;[CustomBuilder](ts-types.md#custombuilder8)<sup>8+</sup>&nbsp;\|&nbsp;[NavigationCommonTitle](#navigationcommontitle类型说明)<sup>9+</sup>&nbsp;\|&nbsp;[NavigationCustomTitle](#navigationcustomtitle类型说明)<sup>9+</sup> | 页面标题。 |
| subTitle<sup>deprecated</sup> | string | 页面副标题。从API Version 9开始废弃,建议使用title代替。 |
| menus | Array<[NavigationMenuItem](#navigationmenuitem类型说明)&gt;&nbsp;\|&nbsp;[CustomBuilder](ts-types.md#custombuilder8)<sup>8+</sup> | 页面右上角菜单。 |
| titleMode | [NavigationTitleMode](#navigationtitlemode枚举说明) | 页面标题栏显示模式。<br/>默认值:NavigationTitleMode.Free |
| toolBar | [object](#object类型说明)&nbsp;\|&nbsp;[CustomBuilder](ts-types.md#custombuilder8)<sup>8+</sup> | 设置工具栏内容。<br/>items:&nbsp;工具栏所有项。 |
| hideToolBar | boolean | 隐藏工具栏<br/>默认值:false<br/>true:&nbsp;隐藏工具栏。<br/>false:&nbsp;显示工具栏。 |
| hideToolBar | boolean | 隐藏工具栏<br/>默认值:false<br/>true:&nbsp;隐藏工具栏。<br/>false:&nbsp;显示工具栏。 |
| hideTitleBar | boolean | 隐藏标题栏。<br/>默认值:false<br/>true:&nbsp;隐藏标题栏。<br/>false:&nbsp;显示标题栏。 |
| hideBackButton | boolean | 隐藏返回键。<br/>默认值:false<br/>true:&nbsp;隐藏返回键。<br/>false:&nbsp;显示返回键。 |
| navBarWidth<sup>9+</sup> | [Length](ts-types.md#length) | 导航栏宽度。<br/>默认值:200vp |
| navBarPosition<sup>9+</sup> | [NavBarPosition](#navbarposition枚举说明) | 导航栏位置。<br/>默认值:NavBarPosition.Start |
| mode<sup>9+</sup> | [NavigationMode](#navigationmode枚举说明) | 导航栏的显示模式。<br/>默认值:NavigationMode.Auto |
| backButtonIcon<sup>9+</sup> | string&nbsp;\|&nbsp;[PixelMap](../apis/js-apis-image.md#pixelmap7)&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置导航栏返回图标。 |
| hideNavBar<sup>9+</sup> | boolean | 是否显示导航栏(仅在mode为NavigationMode.Split时生效)。 |
## NavigationMenuItem类型说明
......@@ -54,8 +59,45 @@ Navigation()
| 名称 | 描述 |
| ---- | ---------------------------------------- |
| Free | 当内容为可滚动组件时,标题随着内容向上滚动而缩小(子标题的大小不变、淡出)。向下滚动内容到顶时则恢复原样。 |
| Mini | 固定为小标题模式(图标+主副标题)。 |
| Full | 固定为大标题模式(主副标题)。 |
| Mini | 固定为小标题模式。 |
| Full | 固定为大标题模式。 |
## NavigationCommonTitle类型说明
| 名称 | 类型 | 必填 | 描述 |
| ------ | --------- | ---- | -------- |
| main | string | 是 | 设置主标题。 |
| sub | string | 是 | 设置副标题。 |
## NavigationCustomTitle类型说明
| 名称 | 类型 | 必填 | 描述 |
| ------ | ----------------------- | ---- | ------------------------------ |
| builder | [CustomBuilder](ts-types.md#custombuilder8) | 是 | 设置标题栏内容。 |
| height | [TitleHeight](#titleheight枚举说明)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 是 | 设置标题栏高度。 |
## NavBarPosition枚举说明
| 名称 | 描述 |
| ---- | ---------------------------------------- |
| Start | 双栏显示时,主列在主轴方向首部。 |
| End | 双栏显示时,主列在主轴方向尾部。 |
## NavigationMode枚举说明
| 名称 | 描述 |
| ---- | ---------------------------------------- |
| Stack | 导航栏与内容区独立显示,相当于两个页面。 |
| Split | 导航栏与内容区分两栏显示。 |
| Auto | 窗口宽度>=520vp时,采用Split模式显示;窗口宽度<520vp时,采用Stack模式显示。 |
## TitleHeight枚举说明
| 名称 | 描述 |
| ---- | ---------------------------------------- |
| MainOnly | 只有主标题时标题栏的推荐高度(56vp)。 |
| MainWithSub | 同时有主标题和副标题时标题栏的推荐高度(82vp)。 |
> **说明:**
> 目前可滚动组件只支持List。
......@@ -66,6 +108,7 @@ Navigation()
| 名称 | 功能描述 |
| ---------------------------------------- | ---------------------------------------- |
| onTitleModeChange(callback:&nbsp;(titleMode:&nbsp;NavigationTitleMode)&nbsp;=&gt;&nbsp;void) | 当titleMode为NavigationTitleMode.Free时,随着可滚动组件的滑动标题栏模式发生变化时触发此回调。 |
| onNavBarStateChange(callback:&nbsp;(isVisible:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) | 导航栏显示状态切换时触发该回调。返回值isVisible为true时表示显示,为false时表示隐藏。 |
## 示例
......
# NavRouter
导航组件,默认提供点击响应处理,不需要开发者自定义点击事件逻辑。
> **说明:**
>
> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
必须包含两个子组件,其中第二个子组件必须为[NavDestination](ts-basic-components-navdestination.md)
## 接口
NavRouter()
## 事件
| 名称 | 功能描述 |
| ---------------------------------------- | ---------------------------------------- |
| onStateChange(callback: (isActivated: boolean) => void) | 组件激活状态切换时触发该回调。返回值isActivated为true时表示激活,为false时表示未激活。</br> **说明:**用户点击NavRouter,激活NavRouter,加载对应的NavDestination子组件时,回调onStateChange(true);NavRouter对应的NavDestination子组件不再显示时,回调onStateChange(false)。 |
# 组件导读
## 行列与分栏
- [Column](ts-container-column.md)
沿垂直方向布局的容器组件。
- [ColumnSplit](ts-container-columnsplit.md)
垂直方向分隔布局容器组件,将子组件纵向布局,并在每个子组件之间插入一根横向的分割线。
- [Row](ts-container-row.md)
沿水平方向布局的容器组件。
- [RowSplit](ts-container-rowsplit.md)
水平方向分隔布局容器组件,将子组件横向布局,并在每个子组件之间插入一根纵向的分割线。
- [SideBarContainer](ts-container-sidebarcontainer.md)
提供侧边栏可以显示和隐藏的侧边栏容器组件,通过子组件定义侧边栏和内容区,第一个子组件表示侧边栏,第二个子组件表示内容区。
## 堆叠Flex与栅格
- [Stack](ts-container-stack.md)
堆叠容器组件,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。
- [Flex](ts-container-flex.md)
以弹性方式布局子组件的容器组件。
- [GridContainer](ts-container-gridcontainer.md)
纵向排布栅格布局容器组件,仅在栅格布局场景中使用。
- [GridRow](ts-container-gridrow.md)
栅格容器组件,仅可以和栅格子组件(GridCol)在栅格布局场景中使用。
- [GridCol](ts-container-gridcol.md)
栅格子组件,必须作为栅格容器组件(GridRow)的子组件使用。
- [RelativeContainer](ts-container-relativecontainer.md)
相对布局组件,用于复杂场景中元素对齐的布局。
## 列表与宫格
- [List](ts-container-list.md)
列表包含一系列相同宽度的列表项,适合连续、多行呈现同类数据,例如图片和文本。
- [ListItem](ts-container-listitem.md)
用来展示具体列表项,必须配合List来使用。
- [ListItemGroup](ts-container-listitemgroup.md)
用来展示分组列表项的组件,必须配合List组件来使用。
- [Grid](ts-container-grid.md)
网格容器组件,由“行”和“列”分割的单元格所组成,通过指定“项目”所在的单元格做出各种各样的布局。
- [GridItem](ts-container-griditem.md)
网格容器中单项内容容器。
## 滚动与滑动
- [Scroll](ts-container-scroll.md)
可滚动的容器组件,当子组件的布局尺寸超过父组件的尺寸时,内容可以滚动。
- [Swiper](ts-container-swiper.md)
滑块视图容器组件,提供子组件滑动轮播显示的能力。
- [WaterFlow](ts-container-waterflow.md)
瀑布流容器组件,由“行”和“列”分割的单元格所组成,通过容器自身的排列规则,将不同大小的“项目”自上而下,如瀑布般紧密布局。
- [FlowItem](ts-container-flowitem.md)
瀑布流组件WaterFlow的子组件,用来展示瀑布流具体item。
## 导航
- [Navigator](ts-container-navigator.md)
路由容器组件,提供路由跳转能力。
- [Navigation](ts-basic-components-navigation.md)
一般作为Page页面的根容器,通过属性设置来展示页面的标题栏、工具栏、导航栏等。
- [NavRouter](ts-basic-components-navrouter.md)
导航组件,默认提供点击响应处理,不需要开发者自定义点击事件逻辑。
- [NavDestination](ts-basic-components-navdestination.md)
作为NavRouter组件的子组件,用于显示导航内容区。
- [Stepper](ts-basic-components-stepper.md)
步骤导航器组件,适用于引导用户按照步骤完成任务的导航场景。
- [StepperItem](ts-basic-components-stepperitem.md)
Stepper组件的子组件。
- [Tabs](ts-container-tabs.md)
通过页签进行内容视图切换的容器组件,每个页签对应一个内容视图。
- [TabContent](ts-container-tabcontent.md)
仅在Tabs组件中使用,对应一个切换页签的内容视图。
## 按钮与选择
- [Button](ts-basic-components-button.md)
按钮组件,可快速创建不同样式的按钮。
- [Toggle](ts-basic-components-toggle.md)
组件提供勾选框样式、状态按钮样式及开关样式。
- [Checkbox](ts-basic-components-checkbox.md)
提供多选框组件,通常用于某选项的打开或关闭。
- [CheckboxGroup](ts-basic-components-checkboxgroup.md)
多选框群组,用于控制多选框全选或者不全选状态。
- [DatePicker](ts-basic-components-datepicker.md)
选择日期的滑动选择器组件。
- [TextPicker](ts-basic-components-textpicker.md)
滑动选择文本内容的组件。
- [TimePicker](ts-basic-components-timepicker.md)
滑动选择时间的组件。
- [Radio](ts-basic-components-radio.md)
单选框,提供相应的用户交互选择项。
- [Rating](ts-basic-components-rating.md)
提供在给定范围内选择评分的组件。
- [Select](ts-basic-components-select.md)
提供下拉选择菜单,可以让用户在多个选项之间选择。
- [Slider](ts-basic-components-slider.md)
滑动条组件,通常用于快速调节设置值,如音量调节、亮度调节等应用场景。
- [Counter](ts-container-counter.md)
计数器组件,提供相应的增加或者减少的计数操作。
## 文本与输入
- [Text](ts-basic-components-text.md)
显示一段文本的组件。
- [Span](ts-basic-components-span.md)
作为Text组件的子组件,用于显示行内文本片段的组件。
- [Search](ts-basic-components-search.md)
搜索框组件,适用于浏览器的搜索内容输入框等应用场景。
- [TextArea](ts-basic-components-textarea.md)
多行文本输入框组件,当输入的文本内容超过组件宽度时会自动换行显示。
- [TextInput](ts-basic-components-textinput.md)
单行文本输入框组件。
- [PatternLock](ts-basic-components-patternlock.md)
图案密码锁组件,以九宫格图案的方式输入密码,用于密码验证场景。手指在PatternLock组件区域按下时开始进入输入状态,手指离开屏幕时结束输入状态完成密码输入。
- [RichText](ts-basic-components-richtext.md)
富文本组件,解析并显示HTML格式文本。
## 图片视频与媒体
- [Image](ts-basic-components-image.md)
图片组件,支持本地图片和网络图片的渲染展示。
- [ImageAnimator](ts-basic-components-imageanimator.md)
提供逐帧播放图片能力的帧动画组件,可以配置需要播放的图片列表,每张图片可以配置时长。
- [Video](ts-media-components-video.md)
用于播放视频文件并控制其播放状态的组件。
- [PluginComponent](ts-basic-components-plugincomponent.md)
提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。
- [XComponent](ts-basic-components-xcomponent.md)
用于EGL/OpenGLES和媒体数据写入。
## 信息展示
- [DataPanel](ts-basic-components-datapanel.md)
数据面板组件,用于将多个数据占比情况使用占比图进行展示。
- [Gauge](ts-basic-components-gauge.md)
数据量规图表组件,用于将数据展示为环形图表。
- [LoadingProgress](ts-basic-components-loadingprogress.md)
用于显示加载动效的组件。
- [Marquee](ts-basic-components-marquee.md)
跑马灯组件,用于滚动展示一段单行文本,仅当文本内容宽度超过跑马灯组件宽度时滚动。
- [Progress](ts-basic-components-progress.md)
进度条组件,用于显示内容加载或操作处理等进度。
- [QRCode](ts-basic-components-qrcode.md)
用于显示单个二维码的组件。
- [TextClock](ts-basic-components-textclock.md)
通过文本将当前系统时间显示在设备上。支持不同时区的时间显示,最高精度到秒级。
- [TextTimer](ts-basic-components-texttimer.md)
通过文本显示计时信息并控制其计时器状态的组件。
## 空白与分隔
- [Blank](ts-basic-components-blank.md)
空白填充组件,在容器主轴方向上,空白填充组件具有自动填充容器空余部分的能力。仅当父组件为Row/Column时生效。
- [Divider](ts-basic-components-divider.md)
分隔器组件,分隔不同内容块/内容元素。
## 画布与图形绘制
- [Canvas](ts-components-canvas-canvas.md)
提供画布组件,用于自定义绘制图形。
- [Circle](ts-drawing-components-circle.md)
用于绘制圆形的组件。
- [Ellipse](ts-drawing-components-ellipse.md)
椭圆绘制组件。
- [Line](ts-drawing-components-line.md)
直线绘制组件。
- [Polyline](ts-drawing-components-polyline.md)
折线绘制组件。
- [Polygon](ts-drawing-components-polygon.md)
多边形绘制组件。
- [Path](ts-drawing-components-path.md)
路径绘制组件,根据绘制路径生成封闭的自定义形状。
- [Rect](ts-drawing-components-rect.md)
矩形绘制组件。
- [Shape](ts-drawing-components-shape.md)
作为绘制组件的父组件,实现类似SVG的效果,父组件中会描述所有绘制组件均支持的通用属性。
## 网络
- [Web](ts-basic-components-web.md)
提供具有网页显示能力的Web组件。
## 其他
- [ScrollBar](ts-basic-components-scrollbar.md)
滚动条组件,用于配合可滚动组件使用,如List、Grid、Scroll等。
- [Badge](ts-container-badge.md)
可以附加在单个组件上用于信息标记的容器组件。
- [AlphabetIndexer](ts-container-alphabet-indexer.md)
可以与容器组件联动用于按逻辑结构快速定位容器显示区域的索引条组件。
- [Panel](ts-container-panel.md)
可滑动面板,提供一种轻量的内容展示窗口,方便在不同尺寸中切换。
- [Refresh](ts-container-refresh.md)
可以进行页面下拉操作并显示刷新动效的容器组件。
- [AbilityComponent](ts-container-ability-component.md)
独立显示Ability的容器组件。
- [RemoteWindow](ts-basic-components-remotewindow.md)
远程控制窗口组件,可以通过此组件控制应用窗口,提供启动退出过程中控件动画和应用窗口联动动画的能力。
\ No newline at end of file
......@@ -133,17 +133,18 @@ onBreakpointChange(callback: (breakpoints: string) => void)
struct GridRowExample {
@State bgColors: Color[] = [Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Pink, Color.Grey, Color.Blue, Color.Brown]
@State currentBp: string = 'unknown'
build() {
Column() {
GridRow({
columns: 5,
gutter: {x:5, y:10},
breakpoints: {value:["400vp", "600vp", "800vp"],
reference: BreakpointsReference.WindowSize},
gutter: { x: 5, y: 10 },
breakpoints: { value: ["400vp", "600vp", "800vp"],
reference: BreakpointsReference.WindowSize },
direction: GridRowDirection.Row
}) {
ForEach(this.bgColors, (color)=>{
GridCol({ span: {xs:1, sm:2, md:3, lg:4}}) {
ForEach(this.bgColors, (color) => {
GridCol({ span: { xs: 1, sm: 2, md: 3, lg: 4 } }) {
Row().width("100%").height("20vp")
}.borderColor(color).borderWidth(2)
})
......@@ -151,8 +152,8 @@ struct GridRowExample {
.onBreakpointChange((breakpoint) => {
this.currentBp = breakpoint
})
}.width('80%').margin({ left: 10,top: 5, bottom:5 }).height(200)
.border({color:Color.Blue, width:2})
}.width('80%').margin({ left: 10, top: 5, bottom: 5 }).height(200)
.border({ color: '#880606', width: 2 })
}
}
```
......
......@@ -2,65 +2,81 @@
## 15100001 超过最大订阅数量
### 错误信息
**错误信息**
Over max subscribe limits.
### 错误描述
**错误描述**
该错误码表示在调用数据库变化订阅on接口时,订阅数量已超过最大限制。
### 可能原因
**可能原因**
在调用订阅数据库变化接口时,对数据库的订阅数量已超过最大限制。
### 处理步骤
**处理步骤**
取消对数据库的部分订阅后,再次尝试订阅。
## 15100002 打开已有数据库时参数配置发生变化
### 错误信息
**错误信息**
Open existed database with changed options.
### 错误描述
**错误描述**
该错误码表示在调用getKVStore接口打开已创建的数据库时,options配置参数发生变化。
### 可能原因
**可能原因**
打开已创建的数据库时,options参数配置发生了变化,可能原因如下:
1. 期望新建数据库时,使用了已创建过的数据库名称storeId。
2. 期望改变已创建数据库的options参数配置。
### 处理步骤
**处理步骤**
1. 新建数据库前,请检查数据库名称storeId不与已创建数据库的storeId重名。
2. 期望改变已创建数据库的options参数配置时,当前不支持该操作,请自行删除数据库后使用新的options参数重新创建。
## 15100003 数据库损坏
### 错误信息
**错误信息**
Database corrupted.
### 错误描述
**错误描述**
该错误码表示在调用数据库增、删、查、数据同步等接口时,数据库已损坏。
### 可能原因
**可能原因**
调用数据库增、删、查、数据同步等接口操作数据库时,数据库文件已损坏。
### 处理步骤
**处理步骤**
1. 如果之前备份过数据库,可尝试使用已备份的数据库文件恢复数据库。
2. 如果之前没有备份过数据库,可尝试删除数据库后重新创建。
## 15100004 未找到相关数据
### 错误信息
**错误信息**
Not found.
### 错误描述
**错误描述**
该错误码表示在调用数据库deleteKVStore、delete、deleteBatch、get等接口时,未找到相关数据。
### 可能原因
**可能原因**
在调用删除数据库、数据查询、数据删除等接口时未找到相关数据,可能原因如下。
1. 删除数据库操作时,数据库不存在或已删除。
2. 数据库数据查询操作时,相关数据不存在或已删除。
3. 数据库数据删除操作时,相关数据不存在或已删除。
### 处理步骤
**处理步骤**
1. 在删除数据库操作前,请检查数据库名称是否正确或是否重复删除。
2. 在数据库数据查询操作前,请检查查询关键字是否正确。
3. 在数据库数据删除操作前,请检查删除关键字是否正确或是否重复删除。
......@@ -68,29 +84,37 @@ Not found.
## 15100005 不支持当前操作
### 错误信息
**错误信息**
Not support the operation.
### 错误描述
**错误描述**
该错误码表示在调用数据库backup、restore等接口时,当前数据库不支持该操作。
### 可能原因
**可能原因**
在调用数据库备份、恢复等接口时,当前数据库不支持该操作。
### 处理步骤
**处理步骤**
检查当前数据库是否支持备份、恢复操作。
## 15100006 数据库或查询结果集已关闭
### 错误信息
**错误信息**
Database or result set already closed.
### 错误描述
**错误描述**
该错误码表示在调用数据库或查询结果集相关接口时,数据库或查询结果集为关闭状态。
### 可能原因
**可能原因**
在数据库或查询结果集操作前,已经手动关闭了数据库或查询结果集。
### 处理步骤
**处理步骤**
1. 在数据库相关操作前,请重新打开数据库之后再重试当前操作。
2. 在查询结果集相关操作前,请重新查询获取结果集之后再重试当前操作。
2. 在查询结果集相关操作前,请重新查询获取结果集之后再重试当前操作。
\ No newline at end of file
......@@ -54,10 +54,8 @@
- [轻量和小型系统设备开发示例](guide/device-wlan-led-control.md)
- [标准系统设备开发示例](guide/device-clock-guide.md)
- 调测
- [测试用例开发](subsystems/subsys-testguide-test.md)
- [设备测试](device-test/Readme-CN.md)
- [调测工具](subsystems/subsys-toolchain-hdc-guide.md)
- XTS认证
- [XTS认证](subsystems/subsys-xts-guide.md)
- 工具
- [Docker编译环境](get-code/gettools-acquire.md)
- [IDE集成开发环境](get-code/gettools-ide.md)
......
......@@ -1185,7 +1185,7 @@ _hdf_drivers_end = .;
#### 添加XTS子系统
`XTS`测试参考资料见[xts参考资料](../subsystems/subsys-xts-guide.md),进行`XTS`子系统适配需要添加`xts_acts``xts_tools`组件,直接在`config.json`配置即可,配置如下:
`XTS`测试参考资料见[xts参考资料](../device-test/xts.md),进行`XTS`子系统适配需要添加`xts_acts``xts_tools`组件,直接在`config.json`配置即可,配置如下:
{
"subsystem": "xts",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册