提交 01d35a8d 编写于 作者: S shawn_he 提交者: Gitee

Merge branch 'OpenHarmony-3.1-Release' of gitee.com:openharmony/docs into 5150-a

......@@ -20,23 +20,22 @@
- Development
- [Ability Development](ability/Readme-EN.md)
- [UI Development](ui/Readme-EN.md)
- Basic Feature Development
- [Common Event and Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
- [Security](security/Readme-EN.md)
- [Connectivity](connectivity/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
- [Telephony](telephony/Readme-EN.md)
- [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/Readme-EN.md)
- [Background Task Management](background-task-management/Readme-EN.md)
- [Work Scheduler](work-scheduler/Readme-EN.md)
- [Device Management](device/Readme-EN.md)
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- [DFX](dfx/Readme-EN.md)
- [Internationalization](internationalization/Readme-EN.md)
- [Native APIs](napi/Readme-EN.md)
- [Common Event and Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
- [Media](media/Readme-EN.md)
- [Security](security/Readme-EN.md)
- [Connectivity](connectivity/Readme-EN.md)
- [Data Management](database/Readme-EN.md)
- [Telephony](telephony/Readme-EN.md)
- [Agent-Powered Scheduled Reminders](background-agent-scheduled-reminder/Readme-EN.md)
- [Background Task Management](background-task-management/Readme-EN.md)
- [Work Scheduler](work-scheduler/Readme-EN.md)
- [Device Management](device/Readme-EN.md)
- [Device Usage Statistics](device-usage-statistics/Readme-EN.md)
- [DFX](dfx/Readme-EN.md)
- [Internationalization](internationalization/Readme-EN.md)
- [Native APIs](napi/Readme-EN.md)
- Tools
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- Hands-On Tutorials
......
......@@ -8,21 +8,27 @@ The following figure shows the ability call process.
![stage-call](figures/stage-call.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The startup mode of the callee must be **singleton**.
> Currently, only system applications and Service Extension abilities can use the **Call** APIs to access the callee.
## Available APIs
The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller).
**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 started, 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.
......@@ -51,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
......@@ -77,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 them. 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'
......@@ -121,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 {
......@@ -142,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
......@@ -166,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;
......@@ -184,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']
......@@ -196,7 +202,7 @@ context.requestPermissionsFromUser(permissions).then((data) => {
```
3. Send agreed sequenceable data.
The sequenceable data can be sent to the callee in either of the following ways: without a return value or obtaining data returned by the callee. 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() {
......@@ -209,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 = ''
......@@ -231,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()
......@@ -242,9 +248,6 @@ try {
}
```
## Development Example
## Samples
The following sample is provided to help you better understand how to develop an ability call in the stage model:
[StageCallAbility](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
In this sample, the **AbilityStage** APIs are implemented in the **AbilityStage.ts** file in the **Application** directory, the **Ability** APIs are implemented in the **MainAbility** directory, and **pages/index** is the pages of the ability. Another ability and callee are implemented in the **CalleeAbility** directory, and its pages are the content configured in **pages/second**. The **MainAbility** functions as the caller, and the **CalleeAbility** functions as the callee. After starting the **CalleeAbility**, the **MainAbility** obtains the caller interface, processes the string entered by the user, and transfers the processed string to the **CalleeAbility**. The **CalleeAbility** refreshes the page based on the received data and returns the result to the **MainAbility**.
- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility)
......@@ -54,7 +54,7 @@ They are organized as follows:
- [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md)
- [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md)
- APIs
- [JS and TS APIs](reference/apis/Readme-CN.md)
- [JS and TS APIs](reference/apis/Readme-EN.md)
- Native APIs
- [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
......
......@@ -8,7 +8,7 @@ In Host mode, you can obtain the list of connected devices, enable or disable th
The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management.
The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md).
The following table lists the USB APIs currently available. For details, see the [API Reference](../reference/apis/js-apis-usb.md).
**Table 1** Open USB APIs
......
# Context Module
# Context
## Modules to Import
......@@ -925,9 +925,9 @@ Describes the HAP module information.
| iconId | number | Yes | No | Module icon ID. |
| backgroundImg | string | Yes | No | Module background image. |
| supportedModes | number | Yes | No | Modes supported by the module. |
| reqCapabilities | Array<string> | Yes | No | Capabilities required for module running.|
| deviceTypes | Array<string> | Yes | No | An array of supported device types.|
| abilityInfo | Array\<AbilityInfo> | Yes | No | Ability information. |
| reqCapabilities | Array\<string> | Yes | No | Capabilities required for module running.|
| deviceTypes | Array\<string> | Yes | No | An array of supported device types.|
| abilityInfo | Array\\<AbilityInfo> | Yes | No | Ability information. |
| moduleName | string | Yes | No | Module name. |
| mainAbilityName | string | Yes | No | Name of the entrance ability. |
| installationFree | boolean | Yes | No | When installation-free is supported. |
......
# AbilityManager
> **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.
>
......@@ -18,13 +18,13 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
## updateConfiguration
......
# AbilityStageContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage
The ability stage context is obtained through an **AbilityStage** instance.
```js
import AbilityStage from '@ohos.application.AbilityStage';
class MyAbilityStage extends AbilityStage {
......@@ -28,7 +32,7 @@ class MyAbilityStage extends AbilityStage {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
# AbilityRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
Provides ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
......@@ -27,12 +31,12 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
| ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
......@@ -41,10 +45,10 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
# App Account Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![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.
......@@ -26,7 +26,7 @@ Creates an **AppAccountManager** instance.
**Example**
```js
var appAccountManager = account.createAppAccountManager();
const appAccountManager = account_appAccount.createAppAccountManager();
```
## AppAccountManager
......@@ -387,7 +387,7 @@ Checks whether an app account allows application data synchronization. This meth
### setAccountCredential
setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback&lt;void&gt;): void
setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback&lt;void&gt;): void
Sets a credential for an app account. This method uses an asynchronous callback to return the result.
......
# MissionInfo
> **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.
## Modules to Import
......
# appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
......@@ -25,9 +26,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -49,9 +50,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -75,9 +76,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -99,9 +100,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
**Example**
......@@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
**Example**
......@@ -160,7 +161,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array\<ProcessRunningInfo>>;
getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
......@@ -168,9 +169,9 @@ Obtains information about the running processes. This API uses a promise to retu
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array\<ProcessRunningInfo>> | Promise used to return the process information.|
| Type| Description|
| -------- | -------- |
| Promise\<Array\<ProcessRunningInfo>> | Promise used to return the process information.|
**Example**
......@@ -184,7 +185,7 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array\<ProcessRunningInfo>>): void;
getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
......@@ -192,9 +193,9 @@ Obtains information about the running processes. This API uses an asynchronous c
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array\<ProcessRunningInfo>> | No| Callback used to return the process information.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInfo>> | No| Callback used to return the process information.|
**Example**
......
# Audio Management
> **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.
>
> API version 9 is a canary release for trial use. The APIs of this version may be unstable.
......
# 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
......@@ -223,7 +223,7 @@ Obtains the connection status of a profile.
**Example**
```js
let result = bluetooth.getProfileConnState(PROFILE_A2DP_SOURCE);
let result = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
```
......@@ -364,7 +364,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);
```
......@@ -456,7 +456,7 @@ Sets the device pairing confirmation.
| Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------------------- |
| device | string | Yes | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
| device | string | Yes | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
| accept | boolean | Yes | Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite. |
**Return value**
......@@ -729,7 +729,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
......@@ -782,6 +782,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);
......@@ -847,6 +855,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);
```
......@@ -869,6 +885,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);
```
......@@ -897,6 +922,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;
......@@ -932,6 +966,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]);
......@@ -963,6 +1006,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);
```
......@@ -1218,7 +1270,7 @@ No value is returned.
| | |
| ------------------- | ------------- |
| Type | Description |
| Array&lt;string&gt; | List of addresses of the connected devices. |
| Array&lt;string&gt; | Addresses of the connected devices. |
### getDeviceState<sup>8+</sup><a name="getDeviceState"></a>
......@@ -1236,14 +1288,12 @@ Obtains the connection status of the profile.
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------- |
| device | string | Yes | Address of the target device.|
|
**Return value**
| | |
| ------------------------------------------------- | ----------------------- |
| Type | Description |
| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained. |
| [ProfileConnectionState](#profileconnectionState) | Profile connection state obtained. |
## A2dpSourceProfile
......@@ -1251,7 +1301,7 @@ Obtains the connection status of the profile.
Before using a method of **A2dpSourceProfile**, you need to create an instance of this class by using the **getProfile()** method.
### connect<sup>8+</sup><a name="connect"></a>
### connect<sup>8+</sup><a name="a2dp-connect"></a>
connect(device: string): boolean
......@@ -1278,12 +1328,12 @@ 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');
```
### disconnect<sup>8+</sup><a name="disconnect"></a>
### disconnect<sup>8+</sup><a name="a2dp-disconnect"></a>
disconnect(device: string): boolean
......@@ -1310,7 +1360,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');
```
......@@ -1397,7 +1447,7 @@ Obtains the playing status 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');
```
......@@ -1407,7 +1457,7 @@ let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
Before using a method of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using the **getProfile()** method.
### connect<sup>8+</sup><a name="connect"></a>
### connect<sup>8+</sup><a name="hfp-connect"></a>
connect(device: string): boolean
......@@ -1434,12 +1484,12 @@ 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');
```
### disconnect<sup>8+</sup><a name="disconnect"></a>
### disconnect<sup>8+</sup><a name="hfp-disconnect"></a>
disconnect(device: string): boolean
......@@ -1465,7 +1515,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');
```
......@@ -1665,7 +1715,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.
......@@ -1757,8 +1807,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);
```
......@@ -1984,7 +2037,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**
......@@ -2334,7 +2387,7 @@ Obtains all services of the remote BLE device. This method uses a promise to ret
// 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++) {
......@@ -2672,8 +2725,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);
```
......
# DataAbilityPredicates
> **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.
......@@ -17,7 +18,7 @@ import dataAbility from '@ohos.data.dataAbility';
createRdbPredicates(name: string, dataAbilityPredicates: DataAbilityPredicates): rdb.RdbPredicates
Creates an **RdbPredicates** object based on a **DataAabilityPredicates** object.
Creates an **RdbPredicates** object from a **DataAbilityPredicates** object.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -69,8 +70,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
dataAbilityPredicates.equalTo("NAME", "lisi")
```
......@@ -97,8 +97,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.notEqualTo("NAME", "lisi")
dataAbilityPredicates.notEqualTo("NAME", "lisi")
```
......@@ -119,8 +118,7 @@ Adds a left parenthesis to this **DataAbilityPredicates**.
**Example**
```js
let predicates = new dataAbilitylity.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
dataAbilityPredicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
.or()
......@@ -146,8 +144,7 @@ Adds a right parenthesis to this **DataAbilityPredicates**.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
dataAbilityPredicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
.or()
......@@ -173,8 +170,7 @@ Adds the OR condition to this **DataAbilityPredicates**.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
dataAbilityPredicates.equalTo("NAME", "Lisa")
.or()
.equalTo("NAME", "Rose")
```
......@@ -197,8 +193,7 @@ Adds the AND condition to this **DataAbilityPredicates**.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
dataAbilityPredicates.equalTo("NAME", "Lisa")
.and()
.equalTo("SALARY", 200.5)
```
......@@ -227,8 +222,7 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.contains("NAME", "os")
dataAbilityPredicates.contains("NAME", "os")
```
......@@ -255,8 +249,7 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.beginsWith("NAME", "os")
dataAbilityPredicates.beginsWith("NAME", "os")
```
......@@ -283,8 +276,7 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe
**Example**
```
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.endsWith("NAME", "se")
dataAbilityPredicates.endsWith("NAME", "se")
```
......@@ -310,8 +302,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.isNull("NAME")
dataAbilityPredicates.isNull("NAME")
```
......@@ -337,8 +328,7 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.isNotNull("NAME")
dataAbilityPredicates.isNotNull("NAME")
```
......@@ -365,8 +355,7 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.like("NAME", "%os%")
dataAbilityPredicates.like("NAME", "%os%")
```
......@@ -393,8 +382,7 @@ Sets a **DataAbilityPredicates** object to match the specified string.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.glob("NAME", "?h*g")
dataAbilityPredicates.glob("NAME", "?h*g")
```
......@@ -422,8 +410,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.between("AGE", 10, 50)
dataAbilityPredicates.between("AGE", 10, 50)
```
......@@ -451,8 +438,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.notBetween("AGE", 10, 50)
dataAbilityPredicates.notBetween("AGE", 10, 50)
```
......@@ -479,8 +465,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.greaterThan("AGE", 18)
dataAbilityPredicates.greaterThan("AGE", 18)
```
......@@ -507,8 +492,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.lessThan("AGE", 20)
dataAbilityPredicates.lessThan("AGE", 20)
```
......@@ -535,8 +519,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.greaterThanOrEqualTo("AGE", 18)
dataAbilityPredicates.greaterThanOrEqualTo("AGE", 18)
```
......@@ -563,8 +546,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.lessThanOrEqualTo("AGE", 20)
dataAbilityPredicates.lessThanOrEqualTo("AGE", 20)
```
......@@ -590,8 +572,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.orderByAsc("NAME")
dataAbilityPredicates.orderByAsc("NAME")
```
......@@ -617,8 +598,7 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.orderByDesc("AGE")
dataAbilityPredicates.orderByDesc("AGE")
```
......@@ -639,14 +619,7 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME")
let promiseDistinct = rdbStore.query(predicates, ["NAME"])
promiseDistinct.then((resultSet) => {
console.log("distinct")
}).catch((err) => {
expect(null).assertFail();
})
dataAbilityPredicates.equalTo("NAME", "Rose").distinct()
```
......@@ -672,8 +645,7 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").limitAs(3)
dataAbilityPredicates.equalTo("NAME", "Rose").limitAs(3)
```
......@@ -699,8 +671,7 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").offsetAs(3)
dataAbilityPredicates.equalTo("NAME", "Rose").offsetAs(3)
```
......@@ -726,8 +697,7 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.groupBy(["AGE", "NAME"])
dataAbilityPredicates.groupBy(["AGE", "NAME"])
```
### indexedBy
......@@ -751,8 +721,7 @@ Sets a **DataAbilityPredicates** object to specify the index column.
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.indexedBy("SALARY_INDEX")
dataAbilityPredicates.indexedBy("SALARY_INDEX")
```
......@@ -762,7 +731,7 @@ Sets a **DataAbilityPredicates** object to specify the index column.
in(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates
Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value within the specified range.
Sets a **DataAbilityPredicates** object to match the field with data type Array<ValueType> and value within the specified range.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -780,8 +749,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.in("AGE", [18, 20])
dataAbilityPredicates.in("AGE", [18, 20])
```
......@@ -791,7 +759,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
notIn(field: string, value: Array&lt;ValueType&gt;): DataAbilityPredicates
Sets a **DataAbilityPredicates** object to match the field with data type Array\<ValueType> and value out of the specified range.
Sets a **DataAbilityPredicates** object to match the field with data type Array<ValueType> and value out of the specified range.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
......@@ -809,8 +777,7 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Example**
```js
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.notIn("NAME", ["Lisa", "Rose"])
dataAbilityPredicates.notIn("NAME", ["Lisa", "Rose"])
```
## ValueType
......
# Distributed Data Object
Provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices.
> **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.
......@@ -31,14 +34,14 @@ Creates a distributed data object.
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
import distributedObject from '@ohos.data.distributedDataObject';
// Create a distributed data object, which contains attributes of four types, namely, string, number, boolean, and object.
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
```
## distributedObject.genSessionId()
## distributedObject.genSessionId
genSessionId(): string
......@@ -53,7 +56,7 @@ Creates a random session ID.
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
import distributedObject from '@ohos.data.distributedDataObject';
var sessionId = distributedObject.genSessionId();
```
......@@ -85,7 +88,7 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
// Add g_object to the distributed network.
......@@ -110,19 +113,19 @@ Subscribes to the changes of this distributed data object.
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback used to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("change", function (sessionId, changeData) {
console.info("change" + sessionId);
if (changeData != null && changeData != undefined) {
changeData.forEach(element => {
console.info("changed !" + element + " " + g_object[element]);
});
}
});
```
```js
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
globalThis.changeCallback = (sessionId, changeData) => {
console.info("change" + sessionId);
if (changeData != null && changeData != undefined) {
changeData.forEach(element => {
console.info("changed !" + element + " " + g_object[element]);
});
}
}
g_object.on("change", globalThis.changeCallback);
```
### off('change')
......@@ -136,24 +139,18 @@ Unsubscribes from the changes of this distributed data object.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback used to return the changes of the distributed data object. If this parameter is not specified, this API unsubscribes from all callbacks for data changes of this distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback to be unregistered. If this parameter is not specified, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("change", function (sessionId, changeData) {
console.info("change" + sessionId);
});
// Unsubscribe from the specified data change callback for the distributed data object.
g_object.off("change", function (sessionId, changeData) {
console.info("change" + sessionId);
});
// Unsubscribe from all data change callbacks for the distributed data object.
g_object.off("change");
```
```js
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
// Unregister the specified data change callback.
g_object.off("change", globalThis.changeCallback);
// Unregister all data change callbacks.
g_object.off("change");
```
### on('status')
......@@ -170,14 +167,14 @@ Subscribes to the status change (online or offline) of this distributed data obj
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.<br>**sessionId** indicates the session ID of the distributed data object.<br>**networkId** indicates the network ID of the device.<br>**status** indicates the status, which can be online or offline.|
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,
parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("status", function (sessionId, networkid, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
});
```
```js
import distributedObject from '@ohos.data.distributedDataObject';
globalThis.statusCallback = (sessionId, networkId, status) => {
globalThis.response += "status changed " + sessionId + " " + status + " " + networkId;
}
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
g_object.on("status", globalThis.statusCallback);
```
### off('status')
......@@ -196,15 +193,14 @@ Unsubscribes from the status change (online or offline) of this distributed data
**Example**
```js
import distributedObject from '@ohos.data.distributedDataObject'
g_object.on("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
});
// Unsubscribe from the specified status change callback for the distributed data object.
g_object.off("status", function (sessionId, networkId, status) {
this.response += "status changed " + sessionId + " " + status + " " + networkId;
});
// Unsubscribe from all status change callbacks for the distributed data object.
g_object.off("status");
```
```js
import distributedObject from '@ohos.data.distributedDataObject';
var g_object = distributedObject.createDistributedObject({name:"Amy", age:18, isVis:false,parent:{mother:"jack mom",father:"jack Dad"}});
globalThis.statusCallback = (sessionId, networkId, status) => {
globalThis.response += "status changed " + sessionId + " " + status + " " + networkId;
}
// Unsubscribe from the specified status change callback for the distributed data object.
g_object.off("status",globalThis.statusCallback);
// Unsubscribe from all status change callbacks for the distributed data object.
g_object.off("status");
```
......@@ -6,14 +6,12 @@ Lightweight storage provides applications with data processing capability and al
> **NOTE**<br/>
>
> 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.
>
## Modules to Import
```js
import dataStorage from '@ohos.data.storage';
import data_storage from '@ohos.data.storage';
```
## Constants
......@@ -26,7 +24,7 @@ import dataStorage from '@ohos.data.storage';
| MAX_VALUE_LENGTH | string | Yes| No| Maximum length of a value. It must be less than 8192 bytes.|
## dataStorage.getStorageSync
## data_storage.getStorageSync
getStorageSync(path: string): Storage
......@@ -46,24 +44,17 @@ Reads the specified file and loads its data to the **Storage** instance for data
**Example**
```js
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
import data_storage from '@ohos.data.storage'
var path = '/data/storage/el2/database/test_storage'
let storage = data_storage.getStorageSync(path + '/mystore')
storage.putSync('startup', 'auto')
storage.flushSync()
var context = featureAbility.getContext()
context.getFilesDir((err, path) => {
if (err) {
console.error('getFilesDir failed. err: ' + JSON.stringify(err));
return;
}
console.info('getFilesDir successful. path:' + JSON.stringify(path));
let storage = dataStorage.getStorageSync(path + '/mystore')
storage.putSync('startup', 'auto')
storage.flushSync()
});
```
## dataStorage.getStorage
## data_storage.getStorage
getStorage(path: string, callback: AsyncCallback&lt;Storage&gt;): void
......@@ -79,29 +70,21 @@ Reads the specified file and loads its data to the **Storage** instance for data
**Example**
```js
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
import data_storage from '@ohos.data.storage'
var context = featureAbility.getContext()
context.getFilesDir((err, path) => {
var path = '/data/storage/el2/database/test_storage'
data_storage.getStorage(path + '/mystore', function (err, storage) {
if (err) {
console.error('getFilesDir failed. err: ' + JSON.stringify(err));
console.info("Get the storage failed, path: " + path + '/mystore')
return;
}
console.info('getFilesDir successful. path:' + JSON.stringify(path));
dataStorage.getStorage(path + '/mystore', function (err, storage) {
if (err) {
console.info("Get the storage failed, path: " + path + '/mystore')
return;
}
storage.putSync('startup', 'auto')
storage.flushSync()
})
});
storage.putSync('startup', 'auto')
storage.flushSync()
})
```
## dataStorage.getStorage
## data_storage.getStorage
getStorage(path: string): Promise&lt;Storage&gt;
......@@ -121,28 +104,21 @@ Reads the specified file and loads its data to the **Storage** instance for data
**Example**
```js
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
import data_storage from '@ohos.data.storage'
var context = featureAbility.getContext()
context.getFilesDir((err, path) => {
if (err) {
console.info("Get the storage failed, path: " + path + '/mystore')
return;
}
console.info('getFilesDir successful. path:' + JSON.stringify(path));
let promisegetSt = dataStorage.getStorage(path + '/mystore')
promisegetSt.then((storage) => {
storage.putSync('startup', 'auto')
storage.flushSync()
}).catch((err) => {
console.info("Get the storage failed, path: " + path + '/mystore')
})
});
var path = '/data/storage/el2/database/test_storage'
let getPromise = data_storage.getStorage(path + '/mystore')
getPromise.then((storage) => {
storage.putSync('startup', 'auto')
storage.flushSync()
}).catch((err) => {
console.info("Get the storage failed, path: " + path + '/mystore')
})
```
## dataStorage.deleteStorageSync
## data_storage.deleteStorageSync
deleteStorageSync(path: string): void
......@@ -157,11 +133,11 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**Example**
```js
dataStorage.deleteStorageSync(path + '/mystore')
data_storage.deleteStorageSync(path + '/mystore')
```
## dataStorage.deleteStorage
## data_storage.deleteStorage
deleteStorage(path: string, callback: AsyncCallback&lt;void&gt;): void
......@@ -177,7 +153,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**Example**
```js
dataStorage.deleteStorage(path + '/mystore', function (err) {
data_storage.deleteStorage(path + '/mystore', function (err) {
if (err) {
console.info("Deleted failed with err: " + err)
return
......@@ -187,7 +163,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
```
## dataStorage.deleteStorage
## data_storage.deleteStorage
deleteStorage(path: string): Promise&lt;void&gt;
......@@ -207,7 +183,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
**Example**
```js
let promisedelSt = dataStorage.deleteStorage(path + '/mystore')
let promisedelSt = data_storage.deleteStorage(path + '/mystore')
promisedelSt.then(() => {
console.info("Deleted successfully.")
}).catch((err) => {
......@@ -216,7 +192,7 @@ Deletes the singleton **Storage** instance of a file from the memory, and delete
```
## dataStorage.removeStorageFromCacheSync
## data_storage.removeStorageFromCacheSync
removeStorageFromCacheSync(path: string): void
......@@ -231,11 +207,11 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**Example**
```js
dataStorage.removeStorageFromCacheSync(path + '/mystore')
data_storage.removeStorageFromCacheSync(path + '/mystore')
```
## dataStorage.removeStorageFromCache
## data_storage.removeStorageFromCache
removeStorageFromCache(path: string, callback: AsyncCallback&lt;void&gt;): void
......@@ -251,7 +227,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**Example**
```js
dataStorage.removeStorageFromCache(path + '/mystore', function (err) {
data_storage.removeStorageFromCache(path + '/mystore', function (err) {
if (err) {
console.info("Removed storage from cache failed with err: " + err)
return
......@@ -261,7 +237,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
```
## dataStorage.removeStorageFromCache
## data_storage.removeStorageFromCache
removeStorageFromCache(path: string): Promise&lt;void&gt;
......@@ -281,7 +257,7 @@ Removes the singleton **Storage** instance of a file from the cache. The removed
**Example**
```js
let promiserevSt = dataStorage.removeStorageFromCache(path + '/mystore')
let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore')
promiserevSt.then(() => {
console.info("Removed storage from cache successfully.")
}).catch((err) => {
......
# DataAbilityHelper Module (JavaScript SDK APIs)
# DataAbilityHelper
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
> **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
......@@ -553,7 +554,7 @@ DAHelper.insert(
## DataAbilityHelper.batchInsert
batchInsert(uri: string, valuesBuckets: Array\<rdb.ValuesBucket>, callback: AsyncCallback\<number>): void
batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback\<number>): void
Inserts multiple data records into the database. This API uses an asynchronous callback to return the result.
......@@ -881,7 +882,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th
| Type| Description|
|------ | ------- |
|Promise<[PacMap](#pacmap)> | Promise used to return the result.|
|Promise\<[PacMap](#pacmap)> | Promise used to return the result.|
**Example**
......
# EventHub
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
......@@ -34,10 +38,10 @@ Subscribes to an event.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
**Example**
......@@ -72,10 +76,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
**Example**
......@@ -110,10 +114,10 @@ Triggers an event.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
**Example**
......
# ExtensionAbilityInfo
> **NOTE**<br/>
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable.
## Modules to Import
```js
import bundle from "@ohos.bundle";
```
## AbilityInfo
Provides the ability information.
......
# ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
Provides extension running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
The extension running information is obtained through an **abilityManager** instance.
```
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
......@@ -43,15 +47,15 @@ Enumerates extension types.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name| Value| Description|
| Name| Value| Description|
| -------- | -------- | -------- |
| FORM | 0 | Extension information of the form type.< |
| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< |
| INPUT_METHOD | 2 | Extension information of the input method type.< |
| SERVICE | 3 | Extension information of the service type.< |
| ACCESSIBILITY | 4 | Extension information of the accessibility type.< |
| DATA_SHARE | 5 | Extension information of the data share type.< |
| FILE_SHARE | 6 | Extension information of the file share type.< |
| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< |
| WALLPAPER | 8 | Extension information of the wallpaper type.< |
| UNSPECIFIED | 9 | Extension information of the unspecified type.< |
| FORM | 0 | Extension information of the form type.< |
| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< |
| INPUT_METHOD | 2 | Extension information of the input method type.< |
| SERVICE | 3 | Extension information of the service type.< |
| ACCESSIBILITY | 4 | Extension information of the accessibility type.< |
| DATA_SHARE | 5 | Extension information of the data share type.< |
| FILE_SHARE | 6 | Extension information of the file share type.< |
| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< |
| WALLPAPER | 8 | Extension information of the wallpaper type.< |
| UNSPECIFIED | 9 | Extension information of the unspecified type.< |
......@@ -63,13 +63,19 @@ Obtains information about the root album or directory in asynchronous mode. This
- Example
```js
filemanager.getRoot((err, fileInfo) => {
let option = {
"dev":{
name:"",
}
};
filemanager.getRoot(option,(err, fileInfo)=>{
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
}
});
```
## filemanager.listFile
......@@ -105,7 +111,7 @@ Obtains information about the second-level album or files in asynchronous mode.
```js
// Obtain all files in the directory.
// Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri
let media_path = file.path
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
......@@ -114,10 +120,13 @@ Obtains information about the second-level album or files in asynchronous mode.
}
}
}).catch((err) => {
console.log(err)
});
console.log(err)
});
```
## filemanager.listFile
listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback&lt;FileInfo[]&gt;) : void
......@@ -130,8 +139,8 @@ Obtains information about the second-level album or files in asynchronous mode.
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | URI of the directory to query. |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| path | string | Yes | URI of the directory to query. |
| type | string | Yes | Type of the files to query. The file type can be **file**, **image**, **audio**, or **video**.|
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.<br>- &nbsp;**offset**: position to start the query. The value is a number.<br>- &nbsp;**count**: number of files to query.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
- Error
......@@ -145,14 +154,30 @@ Obtains information about the second-level album or files in asynchronous mode.
- Example
```js
// Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri
filemanager.listFile(media_path, "file", (err, fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
// Call listFile() and getRoot() to obtain the file path.
let fileInfos = await filemanager.getRoot();
let media_path = "";
for (let i = 0; i < fileInfos.length; i++) {
if (fileInfos[i].name == "image_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "audio_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "video_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "file_folder") {
media_path = fileInfos[i].path;
}
}
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
}).catch((err) => {
console.log(err)
});
```
......@@ -211,8 +236,8 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| filename | string | Yes | Name of the file to create. |
| path | string | Yes | URI of the file to create. |
| options | Object | No| The options are as follows:<br>- &nbsp;**dev**: See [DevInfo](#devinfo). It is **dev = {name: "local"}** by default if not specified. Currently, only 'local' is supported.|
| callback | AsyncCallback&lt;[FileInfo](#fileinfo)[]&gt; | Yes | Callback invoked to return the file information obtained. |
......@@ -230,7 +255,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a callb
```js
// Create a file.
// Call listFile() and getRoot() to obtain the file URI.
let media_path = file.uri
let media_path = file.path
// File to be saved.
let name = "xxx.jpg"
filemanager.createFile(media_path, name, (err, uri) => {
......
# FormExtensionContext
> ![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.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```js
import FormExtension from "@ohos.application.FormExtension";
```
## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
......
# FormHost
> **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.
Provides APIs related to the widget host.
......
# FormProvider
> **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.
Provides APIs related to the widget provider.
......@@ -27,11 +28,11 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -56,16 +57,16 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
**Return value**
| Type | Description |
| ------------- | ---------------------------------- |
| Promise\<void> |Promise used to return the result. |
| Type | Description |
| ------------- | ---------------------------------- |
| Promise\<void> |Promise used to return the result. |
**Example**
......@@ -80,7 +81,7 @@ SystemCapability.Ability.Form
## updateForm
updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback&lt;void&gt;): void;
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback&lt;void&gt;): void;
Updates a widget. This API uses an asynchronous callback to return the result.
......@@ -90,11 +91,11 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -111,7 +112,7 @@ SystemCapability.Ability.Form
## updateForm
updateForm(formId: string, formBindingData: FormBindingData): Promise&lt;void&gt;;
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise&lt;void&gt;;
Updates a widget. This API uses a promise to return the result.
......@@ -121,10 +122,10 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
**Return value**
......
# HiLog
The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs.
This document describes only API functions. For details about log printing requirements, see [Logging Guide](../../../contribute/OpenHarmony-Log-guide.md).
> **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.
......@@ -42,7 +41,7 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO);
## LogLevel
Log level.
Enumerates the log levels.
**System capability**: SystemCapability.HiviewDFX.HiLog
......@@ -70,7 +69,7 @@ DEBUG logs are not recorded in official versions by default. They are available
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -101,7 +100,7 @@ Prints INFO logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -132,7 +131,7 @@ Prints WARN logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -163,7 +162,7 @@ Prints ERROR logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......@@ -194,7 +193,7 @@ Prints FATAL logs.
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value as required.|
| tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by \<private>.|
| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.|
| args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.|
**Example**
......
......@@ -34,19 +34,9 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to
**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
......@@ -61,22 +51,14 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu
| Parameter | Description |
| ---------------------- | ------------------ |
| Promise<Array\<number>> | Promise used to return the result.|
| Promise\<Array\<number>> | 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);
});
```
......@@ -101,23 +83,10 @@ Obtains the information about an input device. This API uses an asynchronous cal
**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");
}
}
// This example obtains the information about the device whose ID is 1.
inputDevice.getDevice(1, (inputDevice)=>{
console.log("The device name is: " + inputDevice.name);
});
```
## inputDevice.getDevice
......@@ -137,24 +106,10 @@ Obtains the information about an input device. This API uses a promise to return
**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));
});
}
}
// This example obtains the information about the device whose ID is 1.
inputDevice.getDevice(1).then((inputDevice)=>{
console.log("The device name is: " + inputDevice.name);
});
```
......@@ -191,7 +146,7 @@ Defines the axis information of an input device.
| Name | Type | Description |
| ------ | ------------------------- | -------- |
| source | [SourceType](#sourcetype) | Input source type of the axis.|
| axis | [AxisType](axistype) | Axis type. |
| axis | [AxisType](#axistype) | Axis type. |
| max | number | Maximum value reported by the axis. |
| min | number | Minimum value reported by the axis. |
......
# Input Method Framework
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>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.
> **NOTE**<br>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.
>
......@@ -10,7 +10,7 @@
import inputMethod from '@ohos.inputMethod';
```
## inputMethod<sup>8+</sup>
## inputMethod<sup>6+</sup>
Provides the constants.
......@@ -21,7 +21,7 @@ Provides the constants.
| MAX_TYPE_NUM | number | Yes| No| Maximum number of supported input methods.|
## InputMethodProperty<sup>8+</sup><a name="InputMethodProperty"></a>
## InputMethodProperty<sup>6+</sup><a name="InputMethodProperty"></a>
Describes the input method application attributes.
......@@ -48,11 +48,11 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**Example**
```
var InputMethodController = inputMethod.getInputMethodController();
```
```js
var InputMethodController = inputMethod.getInputMethodController();
```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
## inputMethod.getInputMethodSetting<sup>6+</sup><a name="getInputMethodSetting"></a>
getInputMethodSetting(): InputMethodSetting
......@@ -120,7 +120,7 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
console.info('stopInput isSuccess = ' + isSuccess);
```
## InputMethodSetting<sup>8+</sup><a name="InputMethodSetting"></a>
## InputMethodSetting<sup>6+</sup><a name="InputMethodSetting"></a>
In the following API examples, you must first use [getInputMethodSetting](#getInputMethodSetting) to obtain an **InputMethodSetting** instance, and then call the APIs using the obtained instance.
......@@ -140,14 +140,14 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**Example**
```js
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
});
```
```js
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) {
var property = properties[i];
console.info(property.packageName + "/" + property.methodId);
}
});
```
### listInputMethod
......
......@@ -120,7 +120,7 @@ Creates an **AudioRecorder** instance to control audio recording.
**Example**
```js
let audiorecorder = media.createAudioRecorder();
let audioRecorder = media.createAudioRecorder();
```
## media.createVideoRecorder<sup>9+</sup>
......
# Media Library Management
# MediaLibrary
> **NOTE**<br>
> **NOTE**
>
> This component is supported since API version 6. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......
# Media Query
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
> **NOTE**
>
> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import mediaquery from '@ohos.mediaquery'
```
......@@ -22,19 +23,19 @@ matchMediaSync(condition: string): MediaQueryListener
Sets the media query criteria and returns the corresponding listening handle.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| condition | string | Yes| Matching condition of a media event.|
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------- |
| condition | string | Yes | Matching condition of a media event.|
- Return value
| Type| Description|
| -------- | -------- |
| MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.|
**Return value**
| Type | Description |
| ------------------ | ---------------------- |
| MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.|
- Example
```
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
**Example**
```js
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
```
......@@ -45,10 +46,10 @@ Media query handle, including the first query result when the handle is applied
### Attributes
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| matches | boolean | Yes| No| Whether the match condition is met.|
| media | string | Yes| No| Matching condition of a media event.|
| Name | Type | Readable | Writable | Description |
| ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes | No | Matching condition of a media event.|
### on
......@@ -57,13 +58,13 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void
Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Must enter the string **change**.|
| callback | Callback&lt;MediaQueryResult&gt; | Yes| Callback registered with media query.|
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ---- | ---------------- |
| type | string | Yes | Must enter the string **change**.|
| callback | Callback&lt;MediaQueryResult&gt; | Yes | Callback registered with media query. |
- Example
**Example**
For details, see [off Example](#off).
......@@ -72,14 +73,14 @@ Registers a callback with the corresponding query condition by using the handle.
off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | boolean | Yes| Must enter the string **change**.|
| callback | Callback&lt;MediaQueryResult&gt; | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
- Example
```
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ---- | ----------------------------- |
| type | boolean | Yes | Must enter the string **change**. |
| callback | Callback&lt;MediaQueryResult&gt; | No | Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.|
**Example**
```js
import mediaquery from '@ohos.mediaquery'
listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events.
......@@ -90,8 +91,8 @@ Unregisters a callback with the corresponding query condition by using the handl
// do something here
}
}
this.listener.on('change', this.onPortrait) // Registration callback.
this.listener.off('change', this.onPortrait) // Deregistration callback.
listener.on('change', onPortrait) // Register a callback.
listener.off('change', onPortrait) // Unregister a callback.
```
......@@ -100,15 +101,15 @@ Unregisters a callback with the corresponding query condition by using the handl
### Attributes
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| matches | boolean | Yes| No| Whether the match condition is met.|
| media | string | Yes| No| Matching condition of a media event.|
| Name | Type | Readable | Writable | Description |
| ------- | ------- | ---- | ---- | ---------- |
| matches | boolean | Yes | No | Whether the match condition is met. |
| media | string | Yes | No | Matching condition of a media event.|
### Example
```
```js
import mediaquery from '@ohos.mediaquery'
let portraitFunc = null
......
# missionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
......@@ -26,15 +27,15 @@ Registers a listener to observe the mission status.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | MissionListener | Yes| Listener to register.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | MissionListener | Yes| Listener to register.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.|
| Type| Description|
| -------- | -------- |
| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
**Example**
......@@ -55,16 +56,16 @@ Registers a listener to observe the mission status.
unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
Unregisters a mission status listener. This API uses an asynchronous callback to return the result.
Deregisters a mission status listener. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -88,21 +89,21 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
Unregisters a mission status listener. This API uses a promise to return the result.
Deregisters a mission status listener. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -126,17 +127,17 @@ Unregisters a mission status listener. This API uses a promise to return the res
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
Obtains the information of a given mission. This API uses an asynchronous callback to return the result.
Obtains the information about a given mission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionInfo](#missioninfo)&gt; | Yes| Callback used to return the mission information obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionInfo](#missioninfo)&gt; | Yes| Callback used to return the mission information obtained.|
**Example**
......@@ -159,22 +160,22 @@ Obtains the information of a given mission. This API uses an asynchronous callba
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
Obtains the information of a given mission. This API uses a promise to return the result.
Obtains the information about a given mission. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionInfo](#missioninfo)&gt; | Promise used to return the mission information obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionInfo](#missioninfo)&gt; | Promise used to return the mission information obtained.|
**Example**
......@@ -191,17 +192,17 @@ Obtains the information of a given mission. This API uses a promise to return th
getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void;
Obtains information of all missions. This API uses an asynchronous callback to return the result.
Obtains information about all missions. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| callback | AsyncCallback&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Yes| Callback used to return the array of mission information obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| callback | AsyncCallback&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Yes| Callback used to return the array of mission information obtained.|
**Example**
......@@ -220,22 +221,22 @@ Obtains information of all missions. This API uses an asynchronous callback to r
getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;;
Obtains information of all missions. This API uses a promise to return the result.
Obtains information about all missions. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Promise used to return the array of mission information obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Promise used to return the array of mission information obtained.|
**Example**
......@@ -258,11 +259,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
**Example**
......@@ -293,16 +294,16 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Promise used to return the snapshot information obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Promise used to return the snapshot information obtained.|
**Example**
......@@ -331,10 +332,10 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -364,15 +365,15 @@ Locks a given mission. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -435,15 +436,15 @@ Unlocks a given mission. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -476,10 +477,10 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -509,15 +510,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -566,9 +567,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -590,10 +591,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -623,11 +624,11 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -657,16 +658,16 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -684,20 +685,3 @@ Switches a given mission to the foreground, with the startup parameters for the
console.log(err);
});
```
## MissionInfo
Describes the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| missionId | number | Yes| Yes| Mission ID.|
| runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# PermissionRequestResult
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the permission request result.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| No| Permissions requested.|
| authResults | Array&lt;number&gt; | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
| permissions | Array&lt;string&gt; | Yes| No| Permissions requested.|
| authResults | Array&lt;number&gt; | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
# ProcessRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
Provides process running information.
## Modules to Import
```js
import appManager from '@ohos.application.appManager'
```
## Usage
The process running information is obtained through an **appManager** instance.
```js
import appManager from '@ohos.application.appManager';
appManager.getProcessRunningInfos((error,data) => {
......@@ -26,9 +30,9 @@ appManager.getProcessRunningInfos((error,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| bundleNames | Array&lt;string&gt; | Yes| No| Names of all bundles running in the process.|
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| bundleNames | Array&lt;string&gt; | Yes| No| Names of all bundles running in the process.|
# Prompt
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **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.
## Modules to Import
......
......@@ -7,7 +7,7 @@
## Modules to Import
```
```js
import radio from '@ohos.telephony.radio'
```
......@@ -30,7 +30,7 @@ Obtains the radio access technology (RAT) used by the CS and PS domains. This AP
**Example**
```
```js
let slotId = 0;
radio.getRadioTech(slotId, (err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -62,7 +62,7 @@ Obtains the RAT used by the CS and PS domains. This API uses a promise to return
**Example**
```
```js
let slotId = 0;
let promise = radio.getRadioTech(slotId);
promise.then(data => {
......@@ -91,7 +91,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
radio.getNetworkState((err, data) =>{
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -117,7 +117,7 @@ Obtains the network status. This API uses an asynchronous callback to return the
**Example**
```
```js
let slotId = 0;
radio.getNetworkState(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -149,7 +149,7 @@ Obtains the network status of the SIM card in the specified slot. This API uses
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkState(slotId);
promise.then(data => {
......@@ -177,7 +177,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
radio.getNetworkSelectionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -207,7 +207,7 @@ Obtains the network selection mode of the SIM card in the specified slot. This A
**Example**
```
```js
let slotId = 0;
let promise = radio.getNetworkSelectionMode(slotId);
promise.then(data => {
......@@ -235,7 +235,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
radio.getISOCountryCodeForNetwork(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -265,7 +265,7 @@ Obtains the ISO country code of the network with which the SIM card in the speci
**Example**
```
```js
let slotId = 0;
let promise = radio.getISOCountryCodeForNetwork(slotId);
promise.then(data => {
......@@ -292,7 +292,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
radio.getPrimarySlotId((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -315,7 +315,7 @@ Obtains the ID of the slot in which the primary card is located. This API uses a
**Example**
```
```js
let promise = radio.getPrimarySlotId();
promise.then(data => {
console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`);
......@@ -342,7 +342,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
radio.getSignalInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -372,7 +372,7 @@ Obtains a list of signal strengths of the network with which the SIM card in the
**Example**
```
```js
let slotId = 0;
let promise = radio.getSignalInformation(slotId);
promise.then(data => {
......@@ -405,10 +405,10 @@ Checks whether the current device supports 5G \(NR\).
**Example**
```
```js
let slotId = 0;
let result = radio.isNrSupported(slotId);
console.log(result);
console.log("Result: "+ result);
```
......@@ -430,7 +430,7 @@ Checks whether the radio service is enabled on the primary SIM card. This API us
**Example**
```
```js
radio.isRadioOn((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
......@@ -456,7 +456,7 @@ Checks whether the radio service is enabled on the SIM card in the specified slo
**Example**
```
```js
let slotId = 0;
radio.isRadioOn(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -488,7 +488,7 @@ Checks whether the radio service is enabled. This API uses a promise to return t
**Example**
```
```js
let slotId = 0;
let promise = radio.isRadioOn(slotId);
promise.then(data => {
......@@ -516,7 +516,7 @@ Obtains the carrier name. This API uses an asynchronous callback to return the r
**Example**
```
```js
let slotId = 0;
radio.getOperatorName(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
......@@ -546,7 +546,7 @@ Obtains the carrier name. This API uses a promise to return the result.
**Example**
```
```js
let slotId = 0;
let promise = radio.getOperatorName(slotId);
promise.then(data => {
......
......@@ -335,10 +335,10 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| url | string | Yes | Resource URL. |
| header | object | No | HTTP or HTTPS header added to an upload request. |
| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. |
| header | object | Yes | HTTP or HTTPS header added to an upload request. |
| method | string | Yes | Request methods available: **POST** and **PUT**. The default value is **POST**. |
| files | Array&lt;[File](#file)&gt; | Yes | List of files to upload, which is submitted through **multipart/form-data**. |
| data | Array&lt;[RequestData](#requestdata)&gt; | No | Form data in the request body. |
| data | Array&lt;[RequestData](#requestdata)&gt; | Yes | Form data in the request body. |
## File
......@@ -349,7 +349,7 @@ Removes this upload task. This API uses an asynchronous callback to return the r
| -------- | -------- | -------- | -------- |
| filename | string | No | File name in the header when **multipart** is used. |
| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
| uri | string | Yes | Local path for storing files.<br/>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example:<br/>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br/>internal://cache/path/to/file.txt |
| uri | string | Yes | Local path for storing files.<br/>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. Below are examples:<br>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br>internal://cache/path/to/file.txt |
| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. |
......
# statfs
> **NOTE**<br>
> **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.
This module provides information related to the file system. It provides JS APIs to obtain the total number of bytes and the number of idle bytes of the file system.
Obtains file system information, including the total number of bytes and the number of idle bytes of the file system.
## Modules to Import
```js
import statfs from '@ohos.statfs';
```
## Guidelines
Before using the APIs provided by this module to perform operations on a file or directory, obtain the path of the application sandbox. For details, see [getOrCreateLocalDir of the Context module](js-apis-Context.md).
Application sandbox path of a file or directory = Application directory + File name or directory name
For example, if the application directory obtained by using **getOrCreateLocalDir** is **dir** and the file name is **xxx.txt**, the application sandbox path of the file is as follows:
```js
let path = dir + "xxx.txt";
```
## statfs.getFreeBytes
getFreeBytes(path:string):Promise&lt;number&gt;
......@@ -72,8 +59,12 @@ Obtains the number of free bytes of the specified file system in asynchronous mo
- Example
```js
statfs.getFreeBytes(path, function(err, number){
console.info("getFreeBytes callback successfully:"+ number);
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getFilesDir().then(function (path) {
statfs.getFreeBytes(path, function(err, number){
console.info("getFreeBytes callback successfully:"+ number);
});
});
```
......@@ -126,7 +117,11 @@ Obtains the total number of bytes of the specified file system in asynchronous m
- Example
```js
statfs.getTotalBytes(path, function(err, number){
console.info("getTotalBytes callback successfully:"+ number);
import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext();
context.getFilesDir().then(function (path) {
statfs.getTotalBytes(path, function(err, number){
console.info("getTotalBytes callback successfully:"+ number);
});
});
```
......@@ -2,7 +2,7 @@
An entrance piece that can contain images and text. It is usually used to display receivers, for example, email recipients or message recipients.
## Child Component
## Child Components
None
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册