提交 dd1eccbc 编写于 作者: L LiAn 提交者: Gitee

Merge branch 'OpenHarmony-3.2-Beta1' of gitee.com:openharmony/docs into OpenHarmony-3.2-Beta1

......@@ -18,15 +18,17 @@ The table below describes the ability call APIs. For details, see [Ability](../r
**Table 1** Ability call APIs
|API|Description|
|:------|:------|
|Promise<Caller> startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
|void on(method: string, callback: CalleeCallBack)|Callee.on: callback invoked when the callee registers a method.|
|void off(method: string)|Callee.off: callback invoked when the callee deregisters a method.|
|Promise<void> call(method: string, data: rpc.Sequenceable)|Caller.call: sends agreed sequenceable data to the callee.|
|Promise<rpc.MessageParcel> callWithResult(method: string, data: rpc.Sequenceable)|Caller.callWithResult: sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
|void release()|Caller.release: releases the caller interface.|
|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease: registers a callback that is invoked when the caller is disconnected.|
|startAbilityByCall(want: Want): Promise\<Caller>|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.|
|on(method: string, callback: CaleeCallBack): void|Callback invoked when the callee registers a method.|
|off(method: string): void|Callback invoked when the callee deregisters a method.|
|call(method: string, data: rpc.Sequenceable): Promise\<void>|Sends agreed sequenceable data to the callee.|
|callWithResult(method: string, data: rpc.Sequenceable): Promise\<rpc.MessageParcel>|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.|
|release(): void|Releases the caller interface.|
|onRelease(callback: OnReleaseCallBack): void|Registers a callback that is invoked when the caller is disconnected.|
## How to Develop
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. For details about the complete project code, see [Samples](#samples).
### Creating a Callee
For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener.
1. Configure the ability startup mode.
......@@ -55,7 +57,7 @@ import Ability from '@ohos.application.Ability'
```
3. Define the agreed sequenceable data.
The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code is as follows:
The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code snippet is as follows:
```ts
export default class MySequenceable {
num: number = 0
......@@ -81,7 +83,7 @@ export default class MySequenceable {
```
4. Implement **Callee.on** and **Callee.off**.
The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows:
The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows:
```ts
const TAG: string = '[CalleeAbility]'
const MSG_SEND_METHOD: string = 'CallSendMsg'
......@@ -125,7 +127,7 @@ import Ability from '@ohos.application.Ability'
```
2. Obtain the caller interface.
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code is as follows:
The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code snippet is as follows:
```ts
async onButtonGetCaller() {
try {
......@@ -146,7 +148,7 @@ async onButtonGetCaller() {
console.error(TAG + 'get caller failed with ' + error)
})
```
In the cross-device scenario, you need to specify the ID of the peer device. The sample code is as follows:
In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows:
```ts
let TAG = '[MainAbility] '
var caller = undefined
......@@ -170,7 +172,7 @@ context.startAbilityByCall({
console.error(TAG + 'get remote caller failed with ' + error)
})
```
Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code is as follows:
Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows:
```ts
import deviceManager from '@ohos.distributedHardware.deviceManager';
var dmClass;
......@@ -188,7 +190,7 @@ function getRemoteDeviceId() {
}
}
```
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows:
In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows:
```ts
let context = this.context
let permissions: Array<string> = ['ohos.permission.DISTRIBUTED_DATASYNC']
......@@ -200,7 +202,7 @@ context.requestPermissionsFromUser(permissions).then((data) => {
```
3. Send agreed sequenceable data.
The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows:
The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
async onButtonCall() {
......@@ -213,7 +215,7 @@ async onButtonCall() {
}
```
In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code is as follows:
In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows:
```ts
const MSG_SEND_METHOD: string = 'CallSendMsg'
originMsg: string = ''
......@@ -235,7 +237,7 @@ async onButtonCallWithResult(originMsg, backMsg) {
```
4. Release the caller interface.
When the caller interface is no longer required, call the **release** API to release it. The sample code is as follows:
When the caller interface is no longer required, call the **release** API to release it. The sample code snippet is as follows:
```ts
try {
this.caller.release()
......@@ -248,4 +250,4 @@ try {
## Samples
The following sample is provided to help you better understand how to develop an ability call in the stage model:
- [`StageCallAbility`: Stage Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
......@@ -204,7 +204,7 @@ You can obtain the distributed table name for a remote device based on the local
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",}
data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
rdbStore.executeSql(SQL_CREATE_TABLE)
rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
})
```
......
......@@ -15,7 +15,7 @@ You can develop applications or services in the low-code approach using either o
- Create a project that supports low-code development. This method is used as an example in this topic.
- In an existing project, create a .visual file for development.
- In an existing project, create a .visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page).
## Creating a Project That Supports Low-Code Development
......@@ -52,7 +52,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
Open the **index.visual** file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif)
![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif)
2. Add a **Column** component and set its styles and attributes.<a name="add_container"></a>
......@@ -70,7 +70,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations.
![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif)
![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif)
5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
......@@ -85,7 +85,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png)
![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png)
2. [Delete the existing template components from the canvas.](#delete_origin_content)
......
......@@ -13,7 +13,7 @@ You can develop applications or services in the low-code approach using either o
- Create a project that supports low-code development. This method is used as an example in this topic.
- In an existing project, create a Visual file for development.
- In an existing project, create a Visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page).
## Creating a Project That Supports Low-Code Development
......@@ -53,15 +53,15 @@ Add **Div**, **Text**, and **Button** components to the first page.
1. Delete the existing template components from the canvas.<a name= delete_origin_content></a>
Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif)
![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif)
2. Add a **Div** component and set its styles and attributes.<a name = add_container></a>
Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations.
![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif)
![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif)
3. Add a **Text** component.
......@@ -88,7 +88,7 @@ Open the index.visual file, right-click the existing template components on the
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png)
![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png)
2. [Delete the existing template components from the canvas.](#delete_origin_content)
......
......@@ -320,10 +320,10 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.replaceAllElements((value, index) => {
arrayList.replaceAllElements((value: number, index: number)=> {
return value = 2 * value;
});
arrayList.replaceAllElements((value, index) => {
arrayList.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
```
......@@ -394,8 +394,8 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.sort((a, b) => a - b);
arrayList.sort((a, b) => b - a);
arrayList.sort((a: number, b: number) => a - b);
arrayList.sort((a: number, b: number) => b - a);
arrayList.sort();
```
......
......@@ -1322,7 +1322,7 @@ Sets a device to the active state. This API uses an asynchronous callback to ret
**Example**
```
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err) => {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => {
if (err) {
console.error('Failed to set the active status of the device. ${err.message}');
return;
......@@ -1356,7 +1356,7 @@ Sets a device to the active state. This API uses a promise to return the result.
```
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(() => {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => {
console.log('Promise returned to indicate that the device is set to the active status.');
});
```
......@@ -1379,7 +1379,7 @@ Checks whether a device is active. This API uses an asynchronous callback to ret
**Example**
```
audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => {
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the device. ${err.message}');
return;
......@@ -1412,7 +1412,7 @@ Checks whether a device is active. This API uses a promise to return the result.
**Example**
```
audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => {
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => {
console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
});
```
......@@ -1646,7 +1646,7 @@ var interAudioInterrupt = {
contentType:0,
pauseWhenDucked:true
};
this.audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to gain the audio focus starts.");
console.log("Focus gain event:" + JSON.stringify(InterruptAction));
......@@ -1682,7 +1682,7 @@ var interAudioInterrupt = {
contentType:0,
pauseWhenDucked:true
};
this.audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => {
if (InterruptAction.actionType === 0) {
console.log("An event to release the audio focus starts.");
console.log("Focus release event:" + JSON.stringify(InterruptAction));
......@@ -1744,7 +1744,7 @@ This is a system API and cannot be called by third-party applications.
**Example**
```
audioManager.setAudioScene(audio.AudioSceneMode.AUDIO_SCENE_PHONE_CALL).then(() => {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.log('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
console.log('Failed to set the audio scene mode');
......@@ -1903,6 +1903,7 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us
**Example**
```
var resultFlag = true;
audioRenderer.getRendererInfo().then((rendererInfo) => {
console.log('Renderer GetRendererInfo:');
console.log('Renderer content:' + rendererInfo.content);
......@@ -2349,13 +2350,11 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Example**
```
audioRenderer.getBufferSize((err, bufferSize) => {
var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
if (err) {
console.error('getBufferSize error');
}
});
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
```
### getBufferSize<sup>8+</sup>
......@@ -2375,11 +2374,12 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a
**Example**
```
audioRenderer.getBufferSize().then((bufferSize) => {
let buf = new ArrayBuffer(bufferSize);
ss.readSync(buf);
var bufferSize;
await audioRenderer.getBufferSize().then(async function (data) => {
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data);
bufferSize=data;
}).catch((err) => {
console.log('ERROR: '+err.message);
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message);
});
```
......@@ -2504,7 +2504,9 @@ Subscribes to audio interruption events. This API uses a callback to get interru
**Example**
```
audioRenderer.on('interrupt', (interruptEvent) => {
var isPlay;
var started;
audioRenderer.on('interrupt', async(interruptEvent) => {
if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
......@@ -2517,14 +2519,33 @@ audioRenderer.on('interrupt', (interruptEvent) => {
break;
}
} else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) {
switch (interruptEvent.hintType) {
switch (interruptEvent.hintType) {
case audio.InterruptHint.INTERRUPT_HINT_RESUME:
console.log('Resume force paused renderer or ignore');
startRenderer();
await audioRenderer.start().then(async function () {
console.info('AudioInterruptMusic: renderInstant started :SUCCESS ');
started = true;
}).catch((err) => {
console.info('AudioInterruptMusic: renderInstant start :ERROR : '+err.message);
started = false;
});
if (started) {
isPlay = true;
console.info('AudioInterruptMusic Renderer started : isPlay : '+isPlay);
} else {
console.error('AudioInterruptMusic Renderer start failed');
}
break;
case audio.InterruptHint.INTERRUPT_HINT_PAUSE:
console.log('Choose to pause or ignore');
pauseRenderer();
if (isPlay == true) {
isPlay == false;
console.info('AudioInterruptMusic: Media PAUSE : TRUE');
}
else {
isPlay = true;
console.info('AudioInterruptMusic: Media PLAY : TRUE');
}
break;
}
}
......@@ -2985,7 +3006,7 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
if (!err) {
console.log("Success in reading the buffer data");
}
};
});
```
......
......@@ -128,6 +128,7 @@ Cancels the suspension delay.
**Example**
```js
let id = 1;
backgroundTaskManager.cancelSuspendDelay(id);
```
......@@ -313,14 +314,14 @@ Provides the information about the suspension delay.
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
| Name | Value| Description |
| ----------------------- | ------ | ---------------------------- |
| DATA_TRANSFER | 1 | Data transfer. |
| AUDIO_PLAYBACK | 2 | Audio playback. |
| AUDIO_RECORDING | 3 | Audio recording. |
| LOCATION | 4 | Positioning and navigation. |
| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
| WIFI_INTERACTION | 7 | WLAN-related (reserved). |
| VOIP | 8 | Voice and video call (reserved). |
| TASK_KEEPING | 9 | Computing task (effective only for specific devices).|
| Name | Value| Description |
| ----------------------- | ------ | ------------------------------------------------------------ |
| DATA_TRANSFER | 1 | Data transfer. |
| AUDIO_PLAYBACK | 2 | Audio playback. |
| AUDIO_RECORDING | 3 | Audio recording. |
| LOCATION | 4 | Positioning and navigation. |
| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. |
| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. |
| WIFI_INTERACTION | 7 | WLAN-related.<br>This is a system API and cannot be called by third-party applications.|
| VOIP | 8 | Audio and video calls.<br>This is a system API and cannot be called by third-party applications.|
| TASK_KEEPING | 9 | Computing task (effective only for specific devices). |
# Bluetooth
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
> 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.
>
> The Bluetooth module provides Classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
Provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
## Modules to Import
......@@ -201,7 +201,7 @@ Obtains the connection state of a profile.
| Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- |
| ProfileId | profileId | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value**
......@@ -212,7 +212,7 @@ Obtains the connection state of a profile.
**Example**
```js
let result = bluetooth.getProfileConnState(PROFILE_A2DP_SOURCE);
let result = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
......@@ -355,7 +355,7 @@ Sets the Bluetooth scan mode so that the device can be discovered by a remote de
```js
// The device can be discovered and connected only when the discoverable and connectable mode is used.
let result = bluetooth.setBluetoothScanMode(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
let result = bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
```
......@@ -720,7 +720,7 @@ bluetooth.off('stateChange', onReceiveEvent);
```
## bluetooth.sppListen<sup>8+</sup><a name="sppListen<"></a>
## bluetooth.sppListen<sup>8+</sup><a name="sppListen"></a>
sppListen(name: string, option: SppOption, callback: AsyncCallback&lt;number&gt;): void
......@@ -773,6 +773,14 @@ Listens for a connection to be made to this socket from the client and accepts i
**Example**
```js
let serverNumber = -1;
function serverSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
if (code.code == 0) {
console.log('bluetooth serverSocket Number: ' + number);
serverNumber = number;
}
}
let clientNumber = -1;
function acceptClientSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
......@@ -807,6 +815,7 @@ Initiates an SPP connection to a remote device from the client.
**Example**
```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
......@@ -838,6 +847,14 @@ Closes the listening socket of the server.
**Example**
```js
let serverNumber = -1;
function serverSocket(code, number) {
console.log('bluetooth error code: ' + code.code);
if (code.code == 0) {
console.log('bluetooth serverSocket Number: ' + number);
serverNumber = number;
}
}
bluetooth.sppCloseServerSocket(serverNumber);
```
......@@ -860,6 +877,15 @@ Closes the client socket.
**Example**
```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
return;
}
console.log('bluetooth serverSocket Number: ' + number);
// The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
clientNumber = number;
}
bluetooth.sppCloseClientSocket(clientNumber);
```
......@@ -888,6 +914,15 @@ Writes data to the remote device through the socket.
**Example**
```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
return;
}
console.log('bluetooth serverSocket Number: ' + number);
// The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
clientNumber = number;
}
let arrayBuffer = new ArrayBuffer(8);
let data = new Uint8Array(arrayBuffer);
data[0] = 123;
......@@ -923,6 +958,15 @@ No value is returned.
**Example**
```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
return;
}
console.log('bluetooth serverSocket Number: ' + number);
// The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
clientNumber = number;
}
function dataRead(dataBuffer) {
let data = new Uint8Array(dataBuffer);
console.log('bluetooth data is: ' + data[0]);
......@@ -954,6 +998,15 @@ No value is returned.
**Example**
```js
let clientNumber = -1;
function clientSocket(code, number) {
if (code.code != 0) {
return;
}
console.log('bluetooth serverSocket Number: ' + number);
// The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
clientNumber = number;
}
bluetooth.off('sppRead', clientNumber);
```
......@@ -981,14 +1034,14 @@ Obtains a profile object.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
## bluetooth.getProfile<sup>9+</sup><a name="getProfile"></a>
getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile
Obtains the profile object instance based on **ProfileId**. API version 9 is added with **HidHostProfile**.
Obtains a profile instance. **HidHostProfile** is added in API version 9.
**System capability**: SystemCapability.Communication.Bluetooth.Core
......@@ -996,7 +1049,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add
| Name | Type | Mandatory | Description |
| --------- | --------- | ---- | ------------------------------------- |
| profileId | [ProfileId](#ProfileId) | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.|
| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
**Return value**
......@@ -1007,7 +1060,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add
**Example**
```js
let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
```
......@@ -1239,7 +1292,7 @@ No value is returned.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let retArray = a2dpSrc.getConnectionDevices();
```
......@@ -1257,7 +1310,7 @@ Obtains the connection state of the profile.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1268,7 +1321,7 @@ Obtains the connection state of the profile.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
```
......@@ -1302,7 +1355,7 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE)
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE)
let ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1332,7 +1385,7 @@ Disconnects an A2DP connection.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1362,7 +1415,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
a2dpSrc.on('connectionStateChange', onReceiveEvent);
```
......@@ -1392,7 +1445,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('a2dp state = '+ JSON.stringify(data));
}
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
a2dpSrc.on('connectionStateChange', onReceiveEvent);
a2dpSrc.off('connectionStateChange', onReceiveEvent);
```
......@@ -1410,7 +1463,7 @@ Obtains the playing state of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1421,7 +1474,7 @@ Obtains the playing state of a device.
**Example**
```js
let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE);
let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
```
......@@ -1445,7 +1498,7 @@ Sets up a Hands-free Profile (HFP) connection of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1456,7 +1509,7 @@ Sets up a Hands-free Profile (HFP) connection of a device.
**Example**
```js
let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let ret = hfpAg.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1475,7 +1528,7 @@ Disconnects the HFP connection of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1486,7 +1539,7 @@ Disconnects the HFP connection of a device.
**Example**
```js
let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1516,7 +1569,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpAg.on('connectionStateChange', onReceiveEvent);
```
......@@ -1546,7 +1599,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hfp state = '+ JSON.stringify(data));
}
let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY);
let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
hfpAg.on('connectionStateChange', onReceiveEvent);
hfpAg.off('connectionStateChange', onReceiveEvent);
```
......@@ -1573,7 +1626,7 @@ Connects to the HidHost service of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1584,7 +1637,7 @@ Connects to the HidHost service of a device.
**Example**
```js
let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST);
let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
```
......@@ -1605,7 +1658,7 @@ Disconnects from the HidHost service of a device.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the remote device.|
| device | string | Yes | Address of the target device.|
**Return value**
......@@ -1616,7 +1669,7 @@ Disconnects from the HidHost service of a device.
**Example**
```js
let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST);
let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
```
......@@ -1646,7 +1699,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
hidHost.on('connectionStateChange', onReceiveEvent);
```
......@@ -1676,7 +1729,7 @@ No value is returned.
function onReceiveEvent(data) {
console.info('hidHost state = '+ JSON.stringify(data));
}
let hidHost = bluetooth.getProfile(PROFILE_HID_HOST);
let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST);
hidHost.on('connectionStateChange', onReceiveEvent);
hidHost.off('connectionStateChange', onReceiveEvent);
```
......@@ -1819,7 +1872,7 @@ cccV[0] = 1;
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptorsN};
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
characteristics[0] = characteristic;
// Create a gattService instance.
......@@ -1911,8 +1964,11 @@ Notifies the connected client device when a characteristic value changes.
**Example**
```js
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: notifyCcc.characteristicValue, confirm: false};
characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false};
let server = bluetooth.BLE.createGattServer();
server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
```
......@@ -2138,7 +2194,7 @@ Subscribes to the descriptor read request events.
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event.|
| callback | Callback&lt;[DescriptorReadReq](#descriptorreadreq)&gt; | Yes | Callback invoked to return a descriptor read request from the GATT client. |
| callback | Callback&lt;[DescriptorReadReq](#descriptorreadreq)&gt; | Yes | Callback invoked to return a descriptor read request event from the GATT client. |
**Return value**
......@@ -2279,7 +2335,6 @@ let gattServer = bluetooth.BLE.createGattServer();
gattServer.off("descriptorWrite");
```
### on('connectStateChange')
on(type: "connectStateChange", callback: Callback&lt;BLEConnectChangedState&gt;): void
......@@ -2488,7 +2543,7 @@ Obtains all services of the remote BLE device. This API uses a promise to return
// Promise
let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.connect();
let services = device.getServices();
var services = device.getServices();
console.log("bluetooth services size is ", services.length);
for (let i = 0; i < services.length; i++) {
......@@ -2826,8 +2881,11 @@ Sets the function of notifying the GATT client when the characteristic value of
**Example**
```js
let arrayBufferC = new ArrayBuffer(8);
let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
device.setNotifyCharacteristicChanged(notifyCcc, false);
device.setNotifyCharacteristicChanged(characteristic, false);
```
......@@ -3296,11 +3354,11 @@ Defines the scan filter parameters.
**System capability**: SystemCapability.Communication.Bluetooth.Core
| Name | Type | Readable | Writable | Description |
| ----------- | ------ | ---- | ---- | ---------------------------------------- |
| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
| name | string | Yes | Yes | Name of the BLE device to filter. |
| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
| Name | Type | Readable| Writable| Description |
| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ |
| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. |
| name | string | Yes | Yes | Name of the BLE device to filter. |
| serviceUuid | string | Yes | Yes | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
## ScanOptions
......
# Display
Provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays.
> **NOTE**<br/>
> **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.
## Modules to Import
......@@ -139,7 +141,7 @@ Obtains all the display objects.
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return all the display objects.|
**Example**
......@@ -163,7 +165,7 @@ Enables listening.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>- **add**: listening for whether a display is added<br>- **remove**: listening for whether a display is removed<br>- **change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
**Example**
......@@ -186,7 +188,7 @@ Disables listening.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>- **add**: listening for whether a display is added<br>- **remove**: listening for whether a display is removed<br>- **change**: listening for whether a display is changed|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
**Example**
......
......@@ -575,13 +575,12 @@ Provides KV store configuration.
Defines the KV store types.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
| Name | Default Value| Description |
| --- | ---- | ----------------------- |
| DEVICE_COLLABORATION | 0 | Device KV store. |
| SINGLE_VERSION | 1 | Single KV store. |
| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. |
| DEVICE_COLLABORATION | 0 | Device KV store. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| SINGLE_VERSION | 1 | Single KV store.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. <br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
## SecurityLevel
......
......@@ -6,7 +6,7 @@
## Modules to Import
```
```js
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
```
......@@ -36,7 +36,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -50,7 +50,7 @@ enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDevice
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -84,7 +84,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -95,7 +95,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -124,17 +124,17 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: elementName.bundleName,
abilityName: elementName.abilityName,
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -168,13 +168,13 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -199,14 +199,14 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -234,10 +234,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -262,17 +262,17 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: elementName.bundleName,
abilityName: elementName.abilityName,
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -302,13 +302,13 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -333,14 +333,14 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
if (error != null) {
console.log("error occurs" + error);
return;
}
console.log(result);
console.log("result is " + result);
});
```
......@@ -370,10 +370,10 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -397,7 +397,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
......@@ -436,7 +436,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "bundleName",
abilityName: "abilityName",
......@@ -472,7 +472,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -483,7 +483,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -515,7 +515,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -526,7 +526,7 @@ let enterpriseInfo = {
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
console.log(result);
console.log("result is " + result);
}).catch(error => {
console.log("error occurs" + error);
});
......@@ -551,7 +551,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......@@ -591,7 +591,7 @@ SystemCapability.Customation.EnterpriseDeviceManager
**Example**
```
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility",
......
# HiAppEvent
This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
......
# Distributed Call Chain Tracing
This module implements call chain tracing throughout a service process. It provides functions such as starting and stopping call chain tracing and configuring trace points.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# Performance Tracing
This module provides the functions of tracing service processes and monitoring the system performance. It provides the data needed for hiTraceMeter to carry out performance analysis.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
......@@ -15,6 +15,70 @@ The input device management module is used to listen for the connection, disconn
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
## inputDevice.on<sup>9+</sup>
on(type: "change", listener: Callback&lt;DeviceListener&gt;): void
Enables listening for hot swap events of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | Yes | Listener for events of the input device.|
**Example**
```js
let isPhysicalKeyboardExist = true;
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;
}
});
});
// Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist.
```
## inputDevice.off<sup>9+</sup>
off(type: "change", listener?: Callback&lt;DeviceListener&gt;): void
Disables listening for hot swap events of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------- |
| type | string | Yes | Event type of the input device. |
| listener | Callback&lt;[DeviceListener](#devicelistener<sup>9+</sup>)&gt; | No | Listener for events of the input device.|
**Example**
```js
function listener(data) {
console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}
// Disable this listener.
inputDevice.off("change", listener);
// Disable all listeners.
inputDevice.off("change");
// By default, the soft keyboard is closed when listening is disabled.
```
## inputDevice.getDeviceIds
......@@ -30,28 +94,17 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the result.|
**Example**
```js
export default {
data: {
deviceIds: Array,
},
callback: function(ids) {
this.deviceIds = ids;
},
testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds");
inputDevice.getDeviceIds(this.callback);
console.info("InputDeviceJsTest---end---testGetDeviceIds");
}
}
inputDevice.getDeviceIds((ids)=>{
console.log("The device ID list is: " + ids);
});
```
## inputDevice.getDeviceIds
function getDeviceIds(): Promise<Array\<number>>
getDeviceIds(): Promise&lt;Array&lt;number&gt;&gt;
Obtains the IDs of all input devices. This API uses a promise to return the result.
......@@ -59,35 +112,23 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu
**Return value**
| Parameter | Description |
| ---------------------- | ------------------ |
| Promise<Array\<number>> | Promise used to return the result.|
| Parameter | Description |
| ---------------------------------- | ------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
**Example**
```js
export default {
testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds");
let promise = inputDevice.getDeviceIds();
promise.then((data)=> {
console.info('GetDeviceIds successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceIds. Cause: ' + JSON.stringify(err));
});
}
}
inputDevice.getDeviceIds().then((ids)=>{
console.log("The device ID list is: " + ids);
});
```
## inputDevice.getDevice
getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains the information about an input device. This API uses an asynchronous callback to return the result.
Obtains information about an input device. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
......@@ -95,107 +136,212 @@ Obtains the information about an input device. This API uses an asynchronous cal
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------------------------- |
| deviceId | number | Yes | ID of the input device whose information is to be obtained. |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes | Callback used to return the **InputDeviceData** object.|
| 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
export default {
InputDeviceData: {
deviceId : 0,
name : "NA",
sources : Array,
axisRanges : Array,
},
callback: function(deviceData) {
this.InputDeviceData = deviceData;
},
testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1.
console.info("InputDeviceJsTest---start---testGetDevice");
inputDevice.getDevice(1, this.callback);
console.info("InputDeviceJsTest---end---testGetDevice");
}
}
// Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1, (inputDevice)=>{
console.log("The device name is: " + inputDevice.name);
});
```
## inputDevice.getDevice
function getDevice(deviceId: number): Promise\<InputDeviceData>
getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
Obtains the information about an input device. This API uses a promise to return the result.
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**
| Parameter | Description |
| ------------------------ | ------------------ |
| Promise\<InputDeviceData> | Promise used to return the result.|
| Parameter | Description |
| ---------------------------------------- | ------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
**Example**
```js
export default {
InputDeviceData: {
deviceId : 0,
name : "NA",
sources : Array,
axisRanges : Array,
},
testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1.
console.info("InputDeviceJsTest---start---testGetDevice");
let promise = inputDevice.getDevice(1);
promise.then((data)=> {
console.info('GetDeviceId successed, Data: ' + JSON.stringify(data))
}).catch((err)=>{
console.error('Failed GetDeviceId. Cause: ' + JSON.stringify(err));
});
}
}
// Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1).then((inputDevice)=>{
console.log("The device name is: " + inputDevice.name);
});
```
## inputDevice.supportKeys<sup>9+</sup>
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: Callback&lt;Array&lt;boolean&gt;&gt;): void;
## InputDeviceData
Obtains the key codes supported by the 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 | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys | Array&lt;KeyCode&gt; | Yes | Key codes to be queried. A maximum of five key codes can be specified. |
| callback | Callback&lt;Array&lt;boolean&gt;&gt; | Yes | Callback used to return the result. |
**Example**
```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{
console.log("The query result is as follows: " + ret);
});
```
## inputDevice.supportKeys<sup>9+</sup>
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;boolean&gt;&gt;;
Obtains the key codes supported by the 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 | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys | Array&lt;KeyCode&gt; | Yes | Key codes to be queried. A maximum of five key codes can be specified. |
**Return value**
| Parameter | Description |
| ----------------------------------- | ------------------- |
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise used to return the result.|
**Example**
```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)=>{
console.log("The query result is as follows: " + ret);
})
```
## inputDevice.getKeyboardType<sup>9+</sup>
getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): void;
Obtains the keyboard type of 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 | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype)&gt; | Yes | Callback used to return the result. |
**Example**
```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);
});
```
## inputDevice.getKeyboardType<sup>9+</sup>
getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;;
Obtains the keyboard type of an input device. This API uses a promise to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Return value**
| Parameter | Description |
| ---------------------------------------- | ------------------- |
| Promise&lt;[KeyboardType](#keyboardtype)&gt; | Promise used to return the result.|
**Example**
```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);
})
```
## DeviceListener<sup>9+</sup>
Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ---------- | -------------------------- | ---------------------------------------------------- |
| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. |
| axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | Axis information of the input device. |
| bus | number | Bus type of the input device. |
| product | number | Product information of the input device. |
| vendor | number | Vendor information of the input device. |
| version | number | Version information of the input device. |
| phys | string | Physical address of the input device. |
| uniq | string | Unique ID of the input device. |
| Name | Type | Description |
| -------- | ------------------------- | --------------------------------- |
| type | [ChangeType](#changetype) | Device change type, which indicates whether an input device is inserted or removed. |
| deviceId | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
## AxisType
## InputDeviceData
Defines the axis type of an input device, which is **NULL**.
Defines the information about an input device.
## AxisRange
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------------------- | -------------------------------------- | ---------------------------------------- |
| id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source type of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| axisRanges | Array&lt;[axisRanges](#axisrange)&gt; | Axis information of the input device. |
| bus<sup>9+</sup> | number | Bus type of the input device. |
| product<sup>9+</sup> | number | Product information of the input device. |
| vendor<sup>9+</sup> | number | Vendor information of the input device. |
| version<sup>9+</sup> | number | Version information of the input device. |
| phys<sup>9+</sup> | string | Physical address of the input device. |
| uniq<sup>9+</sup> | string | Unique ID of the input device. |
## AxisType<sup>9+</sup>
Defines the axis information of an input device.
Defines the axis type of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ------ | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](axistype) | Axis type. |
| max | number | Maximum value reported by the axis. |
| min | number | Minimum value reported by the axis. |
| Name | Type | Description |
| ----------- | ------ | --------------- |
| touchMajor | string | touchMajor axis. |
| touchMinor | string | touchMinor axis. |
| toolMinor | string | toolMinor axis. |
| toolMajor | string | toolMajor axis. |
| orientation | string | Orientation axis.|
| pressure | string | Pressure axis. |
| x | string | X axis. |
| y | string | Y axis. |
| NULL | string | None. |
## AxisRange
Defines the axis range of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ----------------------- | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](#axistype) | Axis type. |
| max | number | Maximum value of the axis. |
| min | number | Minimum value of the axis. |
| fuzz<sup>9+</sup> | number | Fuzzy value of the axis. |
| flat<sup>9+</sup> | number | Benchmark value of the axis. |
| resolution<sup>9+</sup> | number | Resolution of the axis. |
## SourceType
......@@ -211,3 +357,29 @@ Enumerates the input source types. For example, if a mouse reports an x-axis eve
| trackball | string | The input device is a trackball.|
| touchpad | string | The input device is a touchpad.|
| joystick | string | The input device is a joystick.|
## ChangeType
Defines the change type for the hot swap event of an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| ------ | ------ | --------- |
| add | string | An input device is inserted.|
| remove | string | An input device is removed.|
## KeyboardType<sup>9+</sup>
Enumerates the keyboard types.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Value | Description |
| ------------------- | ------ | ---- | --------- |
| NONE | number | 0 | Keyboard without keys. |
| UNKNOWN | number | 1 | Keyboard with unknown keys.|
| ALPHABETIC_KEYBOARD | number | 2 | Full keyboard. |
| DIGITAL_KEYBOARD | number | 3 | Keypad. |
| HANDWRITING_PEN | number | 4 | Stylus. |
| REMOTE_CONTROL | number | 5 | Remote control. |
......@@ -364,10 +364,10 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
list.replaceAllElements((value, index) => {
list.replaceAllElements((value: number, index: number) => {
return value = 2 * value;
});
list.replaceAllElements((value, index) => {
list.replaceAllElements((value: number, index: number) => {
return value = value - 2;
});
```
......@@ -439,8 +439,8 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
list.sort((a, b) => a - b);
list.sort((a, b) => b - a);
list.sort((a: number, b: number) => a - b);
list.sort((a: number, b: number) => b - a);
```
### getSubList
......@@ -472,9 +472,9 @@ list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.subList(2, 4);
let result1 = list.subList(4, 3);
let result2 = list.subList(2, 6);
let result = list.getSubList(2, 4);
let result1 = list.getSubList(4, 3);
let result2 = list.getSubList(2, 6);
```
### clear
......
# Page Routing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase.
......@@ -190,6 +190,8 @@ getLength(): string
Obtains the number of pages in the current stack.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type| Description|
| -------- | -------- |
......@@ -275,7 +277,7 @@ Enables the display of a confirm dialog box before returning to the previous pag
Describes the confirm dialog box.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
......
......@@ -3,6 +3,7 @@
- Access Control
- [Access Control Overview](accesstoken-overview.md)
- [Access Control Development](accesstoken-guidelines.md)
- [Permission List](permission-list.md)
- User Authentication
- [User Authentication Overview](userauth-overview.md)
- [User Authentication Development](userauth-guidelines.md)
......@@ -10,5 +11,5 @@
- [HUKS Overview](huks-overview.md)
- [HUKS Development](huks-guidelines.md)
- hapsigner
- [hapsigner Overview](hapsigntool-overview.md)
- [hapsigner Guide](hapsigntool-guidelines.md)
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册