提交 54a46f05 编写于 作者: W wusongqing 提交者: Gitee

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

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
...@@ -85,14 +85,19 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin ...@@ -85,14 +85,19 @@ zh-cn/device-dev/subsystems/subsys-security-sigverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-rightmanagement.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-communicationverify.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-security-devicesecuritylevel.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-appspawn.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-appspawn-standard.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-bootstrap.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-syspara.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-faqs.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-cfg.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-jobs.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-plugin.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-sandbox.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-service.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init-sysparam.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-init.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-overview.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23 zh-cn/device-dev/subsystems/subsys-boot-ref.md @Austin23
zh-cn/device-dev/subsystems/subsys-boot.md @Austin23
zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23 zh-cn/device-dev/subsystems/subsys-testguide-test.md @Austin23
zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-dfx-overview.md @duangavin123_admin
zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin zh-cn/device-dev/subsystems/subsys-dfx-hilog-rich.md @duangavin123_admin
......
此差异已折叠。
...@@ -6,7 +6,7 @@ HiTraceMeter provides APIs for system performance tracing. You can call the APIs ...@@ -6,7 +6,7 @@ HiTraceMeter provides APIs for system performance tracing. You can call the APIs
## Available APIs ## Available APIs
The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference]( ../reference/apis/js-apis-hitracemeter.md). The performance tracing APIs are provided by the **hiTraceMeter** module. For details, see [API Reference](../reference/apis/js-apis-hitracemeter.md).
**APIs for performance tracing** **APIs for performance tracing**
......
# Guide to Switching to Full SDK
Both the public SDK and full SDK are toolkits for application development.
The public SDK is intended for application developers and provided as standard in DevEco Studio. It does not contain system APIs – APIs required by system applications.
The full SDK is intended for original equipment manufacturers (OEMs) and provided separately. It contains system APIs.
The SDK of API version 8 provided in DevEco Studio is a public SDK. If your project depends on any system API, such as the **animator** component, **xcomponent** component, or APIs in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, or **@ohos.bluetooth.d.ts**, switch to the full SDK by performing the following steps.
## Downloading the Full SDK (of 3.1.1 Release in this example)
Manually download the full SDK. For details, see the source code acquisition section in [OpenHarmony 3.1.1 Release](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-v3.1.1-release.md).
![image-20220613161049897](figures/en-us_image_0000001655128646.png)
## Checking the Local SDK Location<br>In this example, an eTS project is used. For a JS project, replace **ets** with **js**.
In DevEco Studio, choose **Tools** > **OpenHarmony SDK Manager** to check the location of the local SDK.
![](figures/en-us_image_0000001655128939.png)
![image-20220613160524053](figures/en-us_image_0000001655128998.png)
## Replacing the SDK
1. Make sure the downloaded SDK is a full SDK.
a. Verify that the name of the downloaded file contains **sdk-full**.
![image-20220613220702504](figures/en-us_image_0000001655129232.png)
b. Verify that the SDK contains system APIs (such as APIs defined in **@ohos.application.abilityManager.d.ts**, **@ohos.application.formInfo.d.ts**, and **@ohos.bluetooth.d.ts**).
Note: The criteria for identifying system APIs are subject to the released API documentation.
2. Replace the SDK. The following uses full SDK 3.1.6.6 for Windows as an example.
a. Decompress the downloaded full SDK file: `ets-windows-3.1.6.5-Release.zip`
![image-20220613165018184](figures/en-us_image_0000001655129264.png)
b. Replace the SDK files.
Back up the local SDK files. (Copy and rename the version number directory in the **ets** directory, or copy the entire **ets** directory to another local path.)
Go to the obtained location of the local installed SDK and back up the files therein.
![image-20220613161352157](figures/en-us_image_0000001655129041.png)
Note: The name of the backup version number directory must be different from the value of **version** field in the **oh-uni-package.json** file. In the example below, the name of the backup version number directory is **3.1.6.6_backup**.
![image-20220613165018184](figures/en-us_image_0000001655129398.png)
The configuration in the **oh-uni-package.json** file is as follows:
```
{
"apiVersion": "8",
"displayName": "Ets",
"meta": {
"metaVersion": "3.0.0"
},
"path": "ets",
"releaseType": "Release",
"version": "3.1.6.6"
}
```
**Delete all files in the original SDK (3.1.6.6) directory.** Failure to do so may result in some files being unable to be overwritten.
Copy the full SDK to the location of the local SDK.
Copy all files in the **ets** directory in the full SDK to the **ets\3.1.6.6** directory in the location of the local SDK.
Change the value of **version** in the **oh-uni-package.json** file to the current SDK version number.
In the **3.1.6.6\build-tools\ets-loader** directory, open the **cmd/powerShell** window and run the **npm install** command to download the **node_modules** dependency package.
![image-20220613171111405](figures/en-us_image_0000001655129333.png)
c. Check for system APIs.
![image-20220613213038104](figures/en-us_image_0000001655129372.png)
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
- [@ohos.ability.errorCode](js-apis-ability-errorCode.md) - [@ohos.ability.errorCode](js-apis-ability-errorCode.md)
- [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md) - [@ohos.ability.wantConstant](js-apis-ability-wantConstant.md)
- [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md) - [@ohos.application.abilityDelegatorRegistry](js-apis-abilityDelegatorRegistry.md)
- [@ohos.application.abilityManager](js-apis-application-abilityManager.md)
- [@ohos.application.appManager](js-apis-appmanager.md) - [@ohos.application.appManager](js-apis-appmanager.md)
- [@ohos.application.Configuration](js-apis-configuration.md) - [@ohos.application.Configuration](js-apis-configuration.md)
- [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md) - [@ohos.application.ConfigurationConstant](js-apis-configurationconstant.md)
...@@ -43,6 +44,8 @@ ...@@ -43,6 +44,8 @@
- [@ohos.application.formProvider](js-apis-formprovider.md) - [@ohos.application.formProvider](js-apis-formprovider.md)
- [@ohos.application.missionManager](js-apis-missionManager.md) - [@ohos.application.missionManager](js-apis-missionManager.md)
- [@ohos.application.Want](js-apis-application-Want.md) - [@ohos.application.Want](js-apis-application-Want.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationExtraParams.md)
- [@ohos.continuation.continuationManager](js-apis-continuation-continuationManager.md)
- [@ohos.wantAgent](js-apis-wantAgent.md) - [@ohos.wantAgent](js-apis-wantAgent.md)
- application/[abilityDelegator](js-apis-application-abilityDelegator.md) - application/[abilityDelegator](js-apis-application-abilityDelegator.md)
- application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md) - application/[abilityDelegatorArgs](js-apis-application-abilityDelegatorArgs.md)
...@@ -52,7 +55,7 @@ ...@@ -52,7 +55,7 @@
- application/[MissionSnapshot](js-apis-application-MissionSnapshot.md) - application/[MissionSnapshot](js-apis-application-MissionSnapshot.md)
- application/[ProcessRunningInfo](js-apis-processrunninginfo.md) - application/[ProcessRunningInfo](js-apis-processrunninginfo.md)
- application/[shellCmdResult](js-apis-application-shellCmdResult.md) - application/[shellCmdResult](js-apis-application-shellCmdResult.md)
- continuation/[ContinuationResult](js-apis-continuation-continuationResult.md)
- Common Event and Notification - Common Event and Notification
- [@ohos.commonEvent](js-apis-commonEvent.md) - [@ohos.commonEvent](js-apis-commonEvent.md)
......
...@@ -25,9 +25,9 @@ abilitymanager.getAbilityRunningInfos((err,data) => { ...@@ -25,9 +25,9 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. | | ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.| | pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. | | uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. | | processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. | | startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](js-apis-abilityManager.md#abilityState) | Yes| No| Ability state. | | abilityState | [abilityManager.AbilityState](js-apis-application-abilityManager.md#abilitystate) | Yes| No| Ability state. |
...@@ -7,7 +7,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying ...@@ -7,7 +7,7 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications. > The APIs of this module are system APIs and cannot be called by third-party applications.
# Modules to Import ## Modules to Import
```js ```js
import AbilityManager from '@ohos.application.abilityManager' import AbilityManager from '@ohos.application.abilityManager'
...@@ -19,6 +19,8 @@ Enumerates the ability states. ...@@ -19,6 +19,8 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.| | INITIAL | 0 | The ability is in the initial state.|
......
# ContinuationExtraParams
The **ContinuationExtraParams** module provides the extra parameters required by the device manager in the continuation management entry.
> **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.
## ContinuationExtraParams
Describes the extra parameters required by the device selection module in the continuation management entry.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| deviceType | Array\<string> | Yes| Yes| Device type.|
| targetBundle | string | Yes| Yes| Target bundle name.|
| description | string | Yes| Yes| Device filtering description.|
| filter | any | Yes| Yes| Device filtering parameter.|
| continuationMode | [ContinuationMode](js-apis-continuation-continuationManager.md#continuationmode) | Yes| Yes| Continuation mode.|
| authInfo | { [key: string]: any } | Yes| Yes| Authentication information.|
# continuationManager
The **continuationManager** module provides the continuation management entry. You can use the APIs of this module to connect to and cancel the continuation management service, subscribe to and unsubscribe from device connection events, start the device selection module, and update the device connection state.
Currently, this module provides incomplete functions, and its APIs are mainly used to start the device selection module. **The continuation capability is not available for application development.**
> **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
```js
import continuationManager from '@ohos.continuation.continuationManager'
```
## continuationManager.register
register(callback: AsyncCallback\<number>): void;
Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
continuationManager.register((err, data) => {
if (err.code != 0) {
console.error('register failed, cause: ' + JSON.stringify(err));
return;
}
console.info('register finished, ' + JSON.stringify(data));
token = data;
});
```
## continuationManager.register
register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void;
Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.register(continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('register failed, cause: ' + JSON.stringify(err));
return;
}
console.info('register finished, ' + JSON.stringify(data));
token = data;
});
```
## continuationManager.register
register(options?: ContinuationExtraParams): Promise\<number>;
Registers the continuation management service and obtains a token. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<number> | Promise used to return the token generated after the continuation management service is connected.|
**Example**
```js
let token = -1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.register(continuationExtraParams)
.then((data) => {
console.info('register finished, ' + JSON.stringify(data));
token = data;
})
.catch((err) => {
console.error('register failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.on("deviceConnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect) instead.
on(type: "deviceConnect", callback: Callback\<ContinuationResult>): void;
Subscribes to device connection events. This API uses an asynchronous callback to return the result.
## continuationManager.on("deviceDisconnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect) instead.
on(type: "deviceDisconnect", callback: Callback\<string>): void;
Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
## continuationManager.off("deviceConnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect) instead.
off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void;
Unsubscribes from device connection events. This API uses an asynchronous callback to return the result.
## continuationManager.off("deviceDisconnect")<sup>(deprecated)</sup>
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect) instead.
off(type: "deviceDisconnect", callback?: Callback\<string>): void;
Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result.
## continuationManager.on("deviceConnect")<sup>9+</sup>
on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void;
Subscribes to device connection events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
**Example**
```js
let token = 1;
continuationManager.on("deviceConnect", token, (data) => {
console.info('onDeviceConnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data[i].id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data[i].type));
console.info('onDeviceConnect deviceName: ' + JSON.stringify(data[i].name));
}
});
```
## continuationManager.on("deviceDisconnect")<sup>9+</sup>
on(type: "deviceDisconnect", token: number, callback: Callback\<Array\<string>>): void;
Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | Callback\<Array\<string>> | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.|
**Example**
```js
let token = 1;
continuationManager.on("deviceDisconnect", token, (data) => {
console.info('onDeviceDisconnect len: ' + data.length);
for (let i = 0; i < data.length; i++) {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data[i]));
}
console.info('onDeviceDisconnect finished.');
});
```
## continuationManager.off("deviceConnect")<sup>9+</sup>
off(type: "deviceConnect", token: number): void;
Unsubscribes from device connection events.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Example**
```js
let token = 1;
continuationManager.off("deviceConnect", token);
```
## continuationManager.off("deviceDisconnect")<sup>9+</sup>
off(type: "deviceDisconnect", token: number): void;
Unsubscribes from device disconnection events.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Example**
```js
let token = 1;
continuationManager.off("deviceDisconnect", token);
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, callback: AsyncCallback\<void>): void;
Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
continuationManager.startDeviceManager(token, (err, data) => {
if (err.code != 0) {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startDeviceManager finished, ' + JSON.stringify(data));
});
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void;
Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.startDeviceManager(token, continuationExtraParams, (err, data) => {
if (err.code != 0) {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
return;
}
console.info('startDeviceManager finished, ' + JSON.stringify(data));
});
```
## continuationManager.startDeviceManager
startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>;
Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
let continuationExtraParams = {
deviceType: ["00E"]
};
continuationManager.startDeviceManager(token, continuationExtraParams)
.then((data) => {
console.info('startDeviceManager finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.updateConnectStatus
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void;
Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| deviceId | string | Yes| Device ID.|
| status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err, data) => {
if (err.code != 0) {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
return;
}
console.info('updateConnectStatus finished, ' + JSON.stringify(data));
});
```
## continuationManager.updateConnectStatus
updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>;
Instructs the device selection module to update the device connection state. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| deviceId | string | Yes| Device ID.|
| status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
.then((data) => {
console.info('updateConnectStatus finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
});
```
## continuationManager.unregister
unregister(token: number, callback: AsyncCallback\<void>): void;
Deregisters the continuation management service. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
```js
let token = 1;
continuationManager.unregister(token, (err, data) => {
if (err.code != 0) {
console.error('unregister failed, cause: ' + JSON.stringify(err));
return;
}
console.info('unregister finished, ' + JSON.stringify(data));
});
```
## continuationManager.unregister
unregister(token: number): Promise\<void>;
Deregisters the continuation management service. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| token | number | Yes| Token obtained after the registration of the continuation management service.|
**Return value**
| Type | Description |
| ------------------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
let token = 1;
continuationManager.unregister(token)
.then((data) => {
console.info('unregister finished, ' + JSON.stringify(data));
})
.catch((err) => {
console.error('unregister failed, cause: ' + JSON.stringify(err));
});
```
## DeviceConnectState
Enumerates the device connection states.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Value| Description|
| -------- | -------- | -------- | -------- |
| IDLE | number | 0 | The device is in the initial state.|
| CONNECTING | number | 1 | The device is being connected.|
| CONNECTED | number | 2 | The device is connected.|
| DISCONNECTING | number | 3 | The device is being disconnected.|
## ContinuationMode
Enumerates the continuation modes provided by the device selection module.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Value| Description|
| -------- | -------- | -------- | -------- |
| COLLABORATION_SINGLE | number | 0 | Single-choice mode.|
| COLLABORATION_MULTIPLE | number | 1 | Multi-choice mode.|
# ContinuationResult
> **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.
## ContinuationResult
Describes the device information returned by the continuation management entry.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | string | Yes| Yes| Device ID.|
| type | string | Yes| Yes| Device type.|
| name | string | Yes| Yes| Device name.|
# XML-to-JavaScript Conversion # XML-to-JavaScript Conversion
> **NOTE**<br/> The **convertxml** module provides APIs for converting XML text into JavaScript objects.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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.
...@@ -47,10 +50,10 @@ let xml = ...@@ -47,10 +50,10 @@ let xml =
'</note>'; '</note>';
let conv = new convertxml.ConvertXML(); let conv = new convertxml.ConvertXML();
let options = {trim : false, declarationKey:"_declaration", let options = {trim : false, declarationKey:"_declaration",
instructionKey : "_instruction", attributesKey : "_attributes", instructionKey : "_instruction", attributesKey : "_attributes",
textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype", textKey : "_text", cdataKey:"_cdata", doctypeKey : "_doctype",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type", commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"} nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options)); let result = JSON.stringify(conv.convert(xml, options));
console.log(result) console.log(result)
``` ```
......
# Value Bucket # Value Bucket
The **ValueBucket** holds data in key-value (KV) pairs. You can use it to insert data into a database. The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
>**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. >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.
...@@ -20,7 +20,7 @@ Enumerates the value types allowed by the database. ...@@ -20,7 +20,7 @@ Enumerates the value types allowed by the database.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string.| | string | The value is a string.|
...@@ -28,10 +28,10 @@ Enumerates the value types allowed by the database. ...@@ -28,10 +28,10 @@ Enumerates the value types allowed by the database.
## ValuesBucket ## ValuesBucket
Holds a set of KV pairs. Defines the types of the key and value in a KV pair.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Type | Mandatory| Description | | Key Type | Value Type |
| ------------- | --------------------------------------------- | ---- | ------------------------------------------------------------ | | ------------- | --------------------------------------------- |
| [key: string] | [ValueType](#valuetype)\| Uint8Array \| null | Yes | KV pairs in a **ValuesBucket**. The key is of the string type. The value can be a number, string, Boolean value, Unit8Array, or **null**.| | string | [ValueType](#valuetype)\| Uint8Array \| null |
...@@ -789,7 +789,7 @@ Enumerates the value types. ...@@ -789,7 +789,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core **System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
...@@ -681,7 +681,7 @@ Enumerates the value types. ...@@ -681,7 +681,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Description | | Type | Description |
| -------------- | ------------------------------ | | -------------- | ------------------------------ |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
...@@ -781,13 +781,6 @@ Sets the **RdbPredicates** to filter out duplicate records. ...@@ -781,13 +781,6 @@ Sets the **RdbPredicates** to filter out duplicate records.
```js ```js
let predicates = new data_rdb.RdbPredicates("EMPLOYEE") let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME") predicates.equalTo("NAME", "Rose").distinct("NAME")
let promise = rdbStore.query(predicates, ["NAME"])
promise.then((resultSet) => {
console.log("ResultSet column names: " + resultSet.columnNames)
console.log("ResultSet column count: " + resultSet.columnCount)
}).catch((err) => {
console.log("Query err.")
})
``` ```
...@@ -1133,7 +1126,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) { ...@@ -1133,7 +1126,7 @@ rdbStore.update("EMPLOYEE", valueBucket, predicates, function (err, ret) {
``` ```
### update<sup>9+</sup> ### update<sup>9+</sup>
update(table: string, values: ValuesBucket, predicates: DataSharePredicates):Promise&lt;number&gt; update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result. Updates data in the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
...@@ -1215,7 +1208,7 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object. ...@@ -1215,7 +1208,7 @@ Deletes data from the RDB store based on the specified **RdbPredicates** object.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the number of rows updated.| | Promise&lt;number&gt; | Promise used to return the number of rows updated.|
**Example** **Example**
```js ```js
...@@ -1231,7 +1224,7 @@ promise.then((rows) => { ...@@ -1231,7 +1224,7 @@ promise.then((rows) => {
### delete<sup>9+</sup> ### delete<sup>9+</sup>
delete(table: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
...@@ -1275,7 +1268,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o ...@@ -1275,7 +1268,7 @@ Deletes data from the RDB store based on the specified **DataSharePredicates** o
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the number of rows updated.| | Promise&lt;number&gt; | Promise used to return the number of rows updated.|
**Example** **Example**
```js ```js
...@@ -1354,7 +1347,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro ...@@ -1354,7 +1347,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro
### query<sup>9+</sup> ### query<sup>9+</sup>
query(predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
Queries data in the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Queries data in the RDB store based on specified conditions. This API uses an asynchronous callback to return the result.
...@@ -1363,6 +1356,7 @@ Queries data in the RDB store based on specified conditions. This API uses an as ...@@ -1363,6 +1356,7 @@ Queries data in the RDB store based on specified conditions. This API uses an as
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
| columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | Yes| Columns to query. If this parameter is not specified, the query applies to all columns.|
| callback | AsyncCallback&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.| | callback | AsyncCallback&lt;[ResultSet](js-apis-data-resultset.md)&gt; | Yes| Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
...@@ -1384,7 +1378,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], ...@@ -1384,7 +1378,7 @@ rdbStore.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"],
### query<sup>9+</sup> ### query<sup>9+</sup>
query(predicates: DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt; query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
Queries data in the RDB store based on specified conditions. This API uses a promise to return the result. Queries data in the RDB store based on specified conditions. This API uses a promise to return the result.
...@@ -1393,6 +1387,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro ...@@ -1393,6 +1387,7 @@ Queries data in the RDB store based on specified conditions. This API uses a pro
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| table | string | Yes| Name of the target table.|
| predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.| | predicates | [DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes| Query conditions specified by the **DataSharePredicates** object.|
| columns | Array&lt;string&gt; | No| Columns to query. If this parameter is not specified, the query applies to all columns.| | columns | Array&lt;string&gt; | No| Columns to query. If this parameter is not specified, the query applies to all columns.|
...@@ -1591,7 +1586,7 @@ rdbStore.commit() ...@@ -1591,7 +1586,7 @@ rdbStore.commit()
### rollBack<sup>8+</sup> ### rollBack<sup>8+</sup>
rollBack():void; rollBack():void
Rolls back the SQL statements that have been executed. Rolls back the SQL statements that have been executed.
...@@ -1997,7 +1992,7 @@ Defines the data types allowed. ...@@ -1997,7 +1992,7 @@ Defines the data types allowed.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Number.| | number | Number.|
| string | String.| | string | String.|
...@@ -2006,14 +2001,13 @@ Defines the data types allowed. ...@@ -2006,14 +2001,13 @@ Defines the data types allowed.
## ValuesBucket ## ValuesBucket
Defines a bucket to store key-value pairs. Defines the types of the key and value in a KV pair.
**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core **System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
| Name| Type| Mandatory| Description| | Key Type| Value Type|
| -------- | -------- | -------- | -------- | | -------- | -------- |
| [key:&nbsp;string] | [ValueType](#valuetype)\|&nbsp;Uint8Array&nbsp;\|&nbsp;null | Yes| Defines a bucket to store key-value pairs.| | string | [ValueType](#valuetype)\|&nbsp;Uint8Array&nbsp;\|&nbsp;null |
## SyncMode<sup>8+</sup> ## SyncMode<sup>8+</sup>
......
...@@ -793,7 +793,7 @@ Enumerates the value types. ...@@ -793,7 +793,7 @@ Enumerates the value types.
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core **System capability**: SystemCapability.DistributedDataManager.Preferences.Core
| Name | Description | | Type | Description |
| ------- | -------------------- | | ------- | -------------------- |
| number | The value is a number. | | number | The value is a number. |
| string | The value is a string. | | string | The value is a string. |
......
# Environment # Environment
This module provides JS APIs for obtaining the root directories of the storage and public files.
> **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. > - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module are system APIs and cannot be called by third-party applications. > - The APIs of this module are system APIs and cannot be called by third-party applications.
This module provides JS APIs for obtaining the root directories of the storage and public files.
## Modules to Import ## Modules to Import
```js ```js
......
# Screen Lock Management # Screen Lock Management
The **screenlock** module is a system module in OpenHarmony. It provides APIs for screen lock applications to subscribe to screen lock status changes as well as callbacks for them to receive the results. It also provides APIs for third-party applications to unlock the screen, obtain the screen locked status, and check whether a lock screen password has been set.
> **NOTE** > **NOTE**
> >
> The initial APIs of this module are supported since API version Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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 ## Modules to Import
...@@ -73,6 +75,7 @@ Checks whether a device is in secure mode. This API uses an asynchronous callbac ...@@ -73,6 +75,7 @@ Checks whether a device is in secure mode. This API uses an asynchronous callbac
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -125,6 +128,7 @@ Unlocks the screen. This API uses an asynchronous callback to return the result. ...@@ -125,6 +128,7 @@ Unlocks the screen. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -174,10 +178,12 @@ Subscribes to screen lock status changes. ...@@ -174,10 +178,12 @@ Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit. | | type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.|
| callback | Callback\<void\> | Yes| Callback used to return the result.| | callback | Callback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -196,10 +202,12 @@ Subscribes to screen lock status changes. ...@@ -196,10 +202,12 @@ Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.| | type | string | Yes| Event type.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
| callback | Callback\<number\> | Yes| Callback used to return the result. | | callback | Callback\<number\> | Yes| Callback used to return the result. |
**Example** **Example**
...@@ -217,11 +225,13 @@ Subscribes to screen lock status changes. ...@@ -217,11 +225,13 @@ Subscribes to screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'screenlockEnabled'**: Screen lock is enabled.| | type | string | Yes| Event type.<br>- **"screenlockEnabled"**: Screen lock is enabled.|
| callback | Callback\<boolean\> | Yes| Callback used to return the result. | | callback | Callback\<boolean\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -240,10 +250,12 @@ Unsubscribes from screen lock status changes. ...@@ -240,10 +250,12 @@ Unsubscribes from screen lock status changes.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **'beginWakeUp'**: Wakeup starts.<br>- **'endWakeUp'**: Wakeup ends.<br>- **'beginScreenOn'**: Screen turn-on starts.<br>- **'endScreenOn'**: Screen turn-on ends.<br>- **'beginScreenOff'**: Screen turn-off starts.<br>- **'endScreenOff'**: Screen turn-off ends.<br>- **'unlockScreen'**: The screen is unlocked.<br>- **'beginExitAnimation'**: Animation starts to exit.<br>- **'screenlockEnabled'**: Screen lock is enabled.<br>- **'beginSleep'**: The screen enters sleep mode.<br>- **'endSleep'**: The screen exits sleep mode.<br>- **'changeUser'**: The user is switched.| | type | string | Yes| Event type.<br>- **"beginWakeUp"**: Wakeup starts.<br>- **"endWakeUp"**: Wakeup ends.<br>- **"beginScreenOn"**: Screen turn-on starts.<br>- **"endScreenOn"**: Screen turn-on ends.<br>- **"beginScreenOff"**: Screen turn-off starts.<br>- **"endScreenOff"**: Screen turn-off ends.<br>- **"unlockScreen"**: The screen is unlocked.<br>- **"beginExitAnimation"**: Animation starts to exit.<br>- **"screenlockEnabled"**: Screen lock is enabled.<br>- **"beginSleep"**: The screen enters sleep mode.<br>- **"endSleep"**: The screen exits sleep mode.<br>- **"changeUser"**: The user is switched.|
| callback | Callback\<void\> | Yes| Callback used to return the result.| | callback | Callback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -262,11 +274,13 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac ...@@ -262,11 +274,13 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | String | Yes| Event type.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.| | event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.| | parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.|
| callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result.| | callback | AsyncCallback\<boolean\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -279,18 +293,19 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac ...@@ -279,18 +293,19 @@ Sends an event to the screen lock service. This API uses an asynchronous callbac
## screenlock.sendScreenLockEvent<sup>9+</sup> ## screenlock.sendScreenLockEvent<sup>9+</sup>
sendScreenLockEvent(event: String, parameter: number): Promise<boolean> sendScreenLockEvent(event: String, parameter: number): Promise\<boolean\>
Sends an event to the screen lock service. This API uses a promise to return the result. Sends an event to the screen lock service. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
**Parameters** **System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| event | String | Yes| Event type.<br>- **'unlockScreenResult'**: Screen unlock result.<br>- **'screenDrawDone'**: Screen drawing is complete.| | event | String | Yes| Event type.<br>- **"unlockScreenResult"**: Screen unlock result.<br>- **"screenDrawDone"**: Screen drawing is complete.|
| parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **0**: The unlock failed.<br>- **2**: The unlock was canceled.| | parameter | number | Yes| Screen unlock status.<br>- **0**: The unlock is successful.<br>- **1**: The unlock failed.<br>- **2**: The unlock was canceled.|
**Return value** **Return value**
| Type| Description| | Type| Description|
...@@ -300,7 +315,7 @@ Sends an event to the screen lock service. This API uses a promise to return the ...@@ -300,7 +315,7 @@ Sends an event to the screen lock service. This API uses a promise to return the
**Example** **Example**
```js ```js
screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((err, result) => { screenlock.sendScreenLockEvent('unlockScreenResult', 0).then((result) => {
console.log('sending result:' + result); console.log('sending result:' + result);
}); });
``` ```
...@@ -5,6 +5,7 @@ The **uiAppearance** module provides basic capabilities for managing the system ...@@ -5,6 +5,7 @@ The **uiAppearance** module provides basic capabilities for managing the system
> **NOTE** > **NOTE**
> >
> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. > The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
>
> The APIs provided by this module are system APIs. > The APIs provided by this module are system APIs.
...@@ -20,6 +21,8 @@ import uiAppearance from '@ohos.uiAppearance' ...@@ -20,6 +21,8 @@ import uiAppearance from '@ohos.uiAppearance'
Enumerates the color modes. Enumerates the color modes.
**System capability**: SystemCapability.ArkUI.UiAppearance
| Name| Value| Description| | Name| Value| Description|
| -- | -- | -- | | -- | -- | -- |
| ALWAYS_DARK | 0 | The system is always in dark mode. | | ALWAYS_DARK | 0 | The system is always in dark mode. |
...@@ -32,12 +35,11 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void ...@@ -32,12 +35,11 @@ setDarkMode(mode: DarkMode, callback: AsyncCallback\<void>): void
Sets the system color mode. This API uses an asynchronous callback to return the result. Sets the system color mode. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.UiAppearance
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -- | -- | -- | -- | | -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| | mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
...@@ -57,15 +59,21 @@ setDarkMode(mode: DarkMode): Promise\<void>; ...@@ -57,15 +59,21 @@ setDarkMode(mode: DarkMode): Promise\<void>;
Sets the system color mode. This API uses a promise to return the result. Sets the system color mode. This API uses a promise to return the result.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.UiAppearance
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -- | -- | -- | -- | | -- | -- | -- | -- |
| mode | [DarkMode](#darkmode) | Yes| Color mode to set.| | mode | [DarkMode](#darkmode) | Yes| Color mode to set.|
**Return value**
| Type | Description |
| ------ | ------------------------------ |
| Promise\<void> | Promise that returns no value.|
**Example** **Example**
```ts ```ts
uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => { uiAppearance.setDarkMode(uiAppearance.DarkMode.ALWAYS_DARK).then(() => {
...@@ -82,12 +90,11 @@ getDarkMode(): DarkMode; ...@@ -82,12 +90,11 @@ getDarkMode(): DarkMode;
Obtains the system color mode. Obtains the system color mode.
**Required permissions**: ohos.permission.UPDATE_CONFIGRATION **Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.UiAppearance
**Return value** **Return value**
| Type| Description| | Type| Description|
| -- | -- | | -- | -- |
|[DarkMode](#darkmode) | Color mode obtained.| |[DarkMode](#darkmode) | Color mode obtained.|
......
# Wallpaper # Wallpaper
> **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. > **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 ## Modules to Import
...@@ -465,7 +467,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses an a ...@@ -465,7 +467,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses an a
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.setWallpaper ## wallpaper.setWallpaper
...@@ -520,7 +522,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses a pr ...@@ -520,7 +522,7 @@ Sets a specified source as the wallpaper of a specified type. This API uses a pr
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getFile<sup>8+</sup> ## wallpaper.getFile<sup>8+</sup>
...@@ -528,7 +530,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo ...@@ -528,7 +530,7 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo
Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result. Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE **Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -557,7 +559,7 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt; ...@@ -557,7 +559,7 @@ getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
Obtains the wallpaper of the specified type. This API uses a promise to return the result. Obtains the wallpaper of the specified type. This API uses a promise to return the result.
**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE **Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -636,7 +638,7 @@ Obtains the pixel image for the wallpaper of the specified type. This API uses a ...@@ -636,7 +638,7 @@ Obtains the pixel image for the wallpaper of the specified type. This API uses a
**Example** **Example**
```js ```js
wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data); console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data)); console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
...@@ -695,9 +697,9 @@ Unsubscribes from the wallpaper color change event. ...@@ -695,9 +697,9 @@ Unsubscribes from the wallpaper color change event.
wallpaper.on('colorChange', listener); wallpaper.on('colorChange', listener);
// Unsubscribe from the listener. // Unsubscribe from the listener.
wallpaper.off('colorChange', listener); wallpaper.off('colorChange', listener);
//Unsubscribe from all subscriptions of the colorChange type. // Unsubscribe from all subscriptions of the colorChange type.
wallpaper.off('colorChange'); wallpaper.off('colorChange');
``` ```
## RgbaColor ## RgbaColor
......
# ImageAnimator ImageAnimator
The **\<ImageAnimator>** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured. The **\<ImageAnimator>** component enables images to be played frame by frame. The list of images to be played can be configured, and the duration of each image can be configured.
...@@ -23,47 +23,47 @@ ImageAnimator() ...@@ -23,47 +23,47 @@ ImageAnimator()
## Attributes ## Attributes
| Name | Type | Default Value | Mandatory | Description | | Name | Type | Default Value | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- | | ---------- | ---------------------------------------- | ----------------------- | --------- | ---------------------------------------- |
| images | Array&lt;{<br>src:string,<br>width?:Length,<br>height?:Length,<br>top?:Length,<br>left?:Length,<br>duration?:number<br>}&gt; | [] | Yes | Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:<br>**src**: image path. The image format can be SVG, PNG, or JPG.<br>**width**: image width.<br>**height**: image height.<br>**top**: vertical coordinate of the image relative to the upper left corner of the component.<br>**left**: horizontal coordinate of the image relative to the upper left corner of the component.<br>**duration**: playback duration of the image, in ms. | | images | Array&lt;{<br>src:string,<br>width?:Length,<br>height?:Length,<br>top?:Length,<br>left?:Length,<br>duration?:number<br>}&gt; | [] | Yes | Image frame information. The information of each frame includes the image path, image size, image position, and image playback duration. The detailed description is as follows:<br>**src**: image path. The image format can be SVG, PNG, or JPG.<br>**width**: image width.<br>**height**: image height.<br>**top**: vertical coordinate of the image relative to the upper left corner of the component.<br>**left**: horizontal coordinate of the image relative to the upper left corner of the component.<br>**duration**: playback duration of the image, in ms. |
| state | AnimationStatus | AnimationStatus.Initial | No | Playback status of the animation. The default status is **Initial**. | | state | AnimationStatus | AnimationStatus.Initial | No | Playback status of the animation. The default status is **Initial**. |
| duration | number | 1000 | No | Playback duration, in ms. The default duration is 1000 ms. When the duration is **0**, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid. | | duration | number | 1000 | No | Playback duration, in ms. The default duration is 1000 ms. When the duration is **0**, no image is played. The value change takes effect only at the beginning of the next cycle. When a separate duration is set in images, the setting of this attribute is invalid. |
| reverse | boolean | false | No | Playback sequence. The value **false** indicates that images are played from the first one to the last one, and **true** indicates that images are played from the last one to the first one. | | reverse | boolean | false | No | Playback sequence. The value **false** indicates that images are played from the first one to the last one, and **true** indicates that images are played from the last one to the first one. |
| fixedSize | boolean | true | No | Whether the image size is the same as the component size. **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. **false**: The width, height, top, and left attributes of each image must be set separately. | | fixedSize | boolean | true | No | Whether the image size is the same as the component size. **true**: The image size is the same as the component size. In this case, the width, height, top, and left attributes of the image are invalid. **false**: The width, height, top, and left attributes of each image must be set separately. |
| preDecode | number | 0 | No | Whether to enable pre-decoding. The default value **0** indicates that pre-decoding is disabled. If this attribute is set to **2**, two images following the currently playing frame will be cached in advance to improve performance. | | preDecode | number | 0 | No | Whether to enable pre-decoding. The default value **0** indicates that pre-decoding is disabled. If this attribute is set to **2**, two images following the currently playing frame will be cached in advance to improve performance. |
| fillMode | FillMode | FillMode.Forwards | No | Status before and after the animation starts. For details about the options, see **FillMode**. | | fillMode | FillMode | FillMode.Forwards | No | Status before and after the animation starts. For details about the options, see **FillMode**. |
| iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. | | iterations | number | 1 | No | By default, the animation is played once. The value **-1** indicates that the animation is played for an unlimited number of times. |
- ImageFrameInfo - ImageFrameInfo
| Name| Type| Default Value| Mandatory| Description| | Name | Type | Default Value | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ------------- | --------- | ---------------------------------------- |
| src | string \| [Resource](.../ui/ts-types.md#resource-type)<sup>9+</sup>| "" | Yes| Image path. The image format can be .svg, .png, or .jpg.| | src | string \| [Resource](../../ui/ts-types.md)<sup>9+</sup> | "" | Yes | Image path. The image format can be .svg, .png, or .jpg. |
| width | [Length](.../ui/ts-types.md#length-type)| 0 | No| Image width.| | width | [Length](../../ui/ts-types.md) | 0 | No | Image width. |
| height | [Length](.../ui/ts-types.md#length-type)| 0 | No| Image height.| | height | [Length](../../ui/ts-types.md) | 0 | No | Image height. |
| top | [Length](.../ui/ts-types.md#length-type)| 0 | No| Vertical coordinate of the image relative to the upper left corner of the component.| | top | [Length](../../ui/ts-types.md) | 0 | No | Vertical coordinate of the image relative to the upper left corner of the component. |
| left | [Length](.../ui/ts-types.md#length-type)| 0 | No| Horizontal coordinate of the image relative to the upper left corner of the component.| | left | [Length](../../ui/ts-types.md) | 0 | No | Horizontal coordinate of the image relative to the upper left corner of the component. |
| duration | number | 0 | No| Playback duration of each image frame, in milliseconds.| | duration | number | 0 | No | Playback duration of each image frame, in milliseconds. |
- AnimationStatus enums - AnimationStatus enums
| Name | Description | | Name | Description |
| -------- | -------- | | ------- | -------------------------------------- |
| Initial | The animation is in the initial state. | | Initial | The animation is in the initial state. |
| Running | The animation is being played. | | Running | The animation is being played. |
| Paused | The animation is paused. | | Paused | The animation is paused. |
| Stopped | The animation is stopped. | | Stopped | The animation is stopped. |
- FillMode enums - FillMode enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | ---------------------------------------- |
| None | After the playback is complete, the animation restores to the initial state. | | None | After the playback is complete, the animation restores to the initial state. |
| Forwards | After the playback is complete, the animation remains in the end state. | | Forwards | After the playback is complete, the animation remains in the end state. |
## Events ## Events
| Name | Description | | Name | Description |
| -------- | -------- | | --------------------- | ---------------------------------------- |
| onStart() =&gt; void | Triggered when the animation starts to play. | | onStart() =&gt; void | Triggered when the animation starts to play. |
| onPause() =&gt; void | Triggered when the animation playback is paused. | | onPause() =&gt; void | Triggered when the animation playback is paused. |
| onRepeat() =&gt; void | Triggered when the animation playback is repeated. | | onRepeat() =&gt; void | Triggered when the animation playback is repeated. |
| onCancel() =&gt; void | Triggered when the animation playback is canceled. | | onCancel() =&gt; void | Triggered when the animation playback is canceled. |
| onFinish() =&gt; void | Triggered when the animation playback is complete. | | onFinish() =&gt; void | Triggered when the animation playback is complete. |
......
# Text # Text
> **NOTE**<br/>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **\<Text>** component is used to display a piece of textual information. The **\<Text>** component is used to display a piece of textual information.
> **NOTE**
>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
N/A None
## Child Components ## Child Components
...@@ -32,8 +32,8 @@ Text(content?: string) ...@@ -32,8 +32,8 @@ Text(content?: string)
| Name| Type| Default Value| Description| | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text.| | textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text.|
| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters. | | textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br/><br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters.<br>This attribute must be used with `maxLines` to take effect.|
| maxLines | number | Infinity | Maximum number of lines in the text.| | maxLines | number | Infinity | Maximum number of lines in the text.<br>**NOTE**<br/><br>By default, text is automatically folded. If this parameter is specified, the text does not exceed the specified number of lines. If there is extra text, you can use `textOverflow` to specify the truncation mode.|
| lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.| | lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.|
| decoration | {<br>type: TextDecorationType,<br>color?: Color<br>} | {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.| | decoration | {<br>type: TextDecorationType,<br>color?: Color<br>} | {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.|
| baselineOffset | Length | - | Offset of the text baseline.| | baselineOffset | Length | - | Offset of the text baseline.|
...@@ -78,7 +78,7 @@ Text(content?: string) ...@@ -78,7 +78,7 @@ Text(content?: string)
| LocalDevice | Intra-device copy and paste is allowed.| | LocalDevice | Intra-device copy and paste is allowed.|
| CrossDevice | Cross-device copy and paste is allowed.| | CrossDevice | Cross-device copy and paste is allowed.|
> **NOTE**<br/> > **NOTE**<br/>
> If the **\<Text>** component contains both the text and the **\<Span>** child component, only the content in **\<Span>** is displayed. > If the **\<Text>** component contains both the text and the **\<Span>** child component, only the content in **\<Span>** is displayed.
......
...@@ -20,14 +20,14 @@ CanvasRenderingContext2D(setting: RenderingContextSetting) ...@@ -20,14 +20,14 @@ CanvasRenderingContext2D(setting: RenderingContextSetting)
### RenderingContextSettings ### RenderingContextSettings
RenderingContextSettings(antialias?: bool) RenderingContextSettings(antialias?: boolean)
Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing. Configures the settings of a **CanvasRenderingContext2D** object, including whether to enable antialiasing.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| --------- | ---- | --------- | ------------- | -------------------------------- | | --------- | ---- | --------- | ------------- | -------------------------------- |
| antialias | bool | No | false | Whether antialiasing is enabled. | | antialias | boolean | No | false | Whether antialiasing is enabled. |
## Attributes ## Attributes
......
# ImageBitmap # ImageBitmap
> **NOTE**<br> > **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
**CanvasImageData** stores pixel data rendered on a canvas. An **ImageBitmap** object stores pixel data rendered on a canvas.
## Attributes ## Attributes
| Name | Type | Description | | Name | Type | Description |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| width | number | Actual width of the rectangle on the canvas, in pixels. | | width | number | Actual width of the rectangle on the canvas, in pixels. |
| height | number | Actual height of the rectangle on the canvas, in pixels. | | height | number | Actual height of the rectangle on the canvas, in pixels. |
| data | &lt;Uint8ClampedArray&gt; | A one-dimensional array of color values. The values range from 0 to 255. |
# Refresh # Refresh
> **NOTE**<br/> The **\<Refresh>** component is a container that provides the pull-to-refresh feature.
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The **<Refresh\>** component is used to refresh a page through a pull-down gesture. > **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -19,11 +20,11 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri ...@@ -19,11 +20,11 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri
- Parameters - Parameters
| Name | Value Type | Mandatory | Default Value | Description | | Name| Value Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| refreshing | boolean | Yes| - | Whether the current component is being refreshed. | | refreshing | boolean | Yes| - | Whether the current component is being refreshed.|
| offset | Length | No| 16 | Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture. | | offset | Length | No| 16 | Distance to the top of the parent component from the **<Refresh\>** component that comes to rest after a successful pull-down gesture.|
| friction | number | No| 62 | Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100. <br/>- **0**: The **<Refresh\>** component is not sensitive to the pull-down gesture. <br/>- **100**: The **<Refresh\>** component is highly sensitive to the pull-down gesture. <br/>- Value greater than **100**: The **<Refresh\>** component is much more sensitive to the pull-down gesture. | | friction | number&nbsp;\|&nbsp;string | No| 62 | Coefficient of friction, which indicates the **<Refresh\>** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.<br>- **0** indicates that the **\<Refresh>** component is not sensitive to the pull-down gesture.<br>- **100** indicates that the **\<Refresh>** component is highly sensitive to the pull-down gesture.<br>- A larger value indicates a more sensitive response of the **\<Refresh>** component to the pull-down gesture.|
...@@ -32,23 +33,24 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri ...@@ -32,23 +33,24 @@ Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number | stri
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes. <br/>**state** indicates the refresh status. | | onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes.<br>**state**: refresh status.|
| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state. | | onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.|
- RefreshStatus enums - RefreshStatus enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Inactive | The component is not pulled down. This is the default value. | | Inactive | The component is not pulled down. This is the default value.|
| Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh. | | Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh.|
| OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh. | | OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh.|
| Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state. | | Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state.|
| Done | The refresh is complete, and the component returns to the initial state (top). | | Done | The refresh is complete, and the component returns to the initial state (top).|
## Example ## Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct RefreshExample { struct RefreshExample {
......
# Motion Path Animation # Motion Path Animation
You can apply a motion path animation to a component, by setting the motion path of the component in a translation animation.
> **NOTE** > **NOTE**
> >
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The attributes below can be used to set the motion path of the component in a translation animation.
## Attributes ## Attributes
...@@ -19,7 +19,8 @@ The attributes below can be used to set the motion path of the component in a tr ...@@ -19,7 +19,8 @@ The attributes below can be used to set the motion path of the component in a tr
## Example ## Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct MotionPathExample { struct MotionPathExample {
......
# Component ID # Component ID
**id** identifies a component uniquely within an application. This module provides APIs for obtaining the attributes of or sending events to the component with the specified ID.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. >
> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -12,93 +14,250 @@ None ...@@ -12,93 +14,250 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | string | '' | Unique ID of the component. The uniqueness is ensured by the user. | | id | string | '' | Unique ID you assigned to the component.|
## APIs ## APIs
### getInspectorByKey ### getInspectorByKey<sup>9+</sup>
getInspectorByKey(id: string): string getInspectorByKey(id: string): string
Obtains all attributes of the component with the specified ID, excluding the information about child components. Obtains all attributes of the component with the specified ID, excluding the information about child components.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| id | string | Yes | - | ID of the component whose attributes are to be obtained. | | id | string | Yes| - | ID of the component whose attributes are to be obtained.|
- Return value - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | JSON string of the component attribute list. | | string | JSON string of the component attribute list.|
### getInspectorTree<sup>9+</sup>
### sendEventByKey getInspectorTree(): string
Obtains the component tree and component attributes.
- Return value
| Type | Description |
| ------ | ---------------------------------- |
| string | JSON string of the component tree and component attribute list.|
### sendEventByKey<sup>9+</sup>
sendEventByKey(id: string, action: number, params: string): boolean sendEventByKey(id: string, action: number, params: string): boolean
Sends an event to the component with the specified ID. Sends an event to the component with the specified ID.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| id | string | Yes | - | ID of the component for which the event is to be sent. | | id | string | Yes| - | ID of the component to which the event is to be sent.|
| action | number | Yes | - | Type of the event to be sent. The options are as follows:<br/>- Click event: 10.<br/>- LongClick: 11. | | action | number | Yes| - | Type of the event to be sent. The options are as follows:<br>- **10**: click event.<br>- **11**: long-click event.|
| params | string | Yes | - | Event parameters. If there is no parameter, pass an empty string **""**. | | params | string | Yes| - | Event parameters. If there is no parameter, pass an empty string **""**.|
- Return value - Return value
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **false** if the component with the specified ID cannot be found; returns **true** otherwise. | | boolean | Returns **true** if the component with the specified ID is found; returns **false** otherwise.|
### sendTouchEvent<sup>9+</sup>
sendTouchEvent(event: TouchObject): boolean
Sends a touch event.
- Parameters
| Name | Type | Mandatory| Default Value| Description |
| ----- | ----------- | ---- | ------ | ------------------------------------------------------------ |
| event | TouchObject | Yes | - | Location where a touch event is triggered. For details, see [TouchEvent](ts-universal-events-touch.md#touchevent).|
- Return value
| Type | Description |
| ------- | ------------------------------------------- |
| boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
### sendKeyEvent<sup>9+</sup>
sendKeyEvent(event: KeyEvent): boolean
Sends a key event.
- Parameters
| Name | Type | Mandatory| Default Value| Description |
| ----- | -------- | ---- | ------ | ------------------------------------------------------------ |
| event | KeyEvent | Yes | - | Key event. For details, see [KeyEvent](ts-universal-events-key.md#keyevent).|
- Return value
| Type | Description |
| ------- | --------------------------------------------- |
| boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
### sendMouseEvent<sup>9+</sup>
sendMouseEvent(event: MouseEvent): boolean
Sends a mouse event.
- Parameters
| Name | Type | Mandatory| Default Value| Description |
| ----- | ---------- | ---- | ------ | ------------------------------------------------------------ |
| event | MouseEvent | Yes | - | Mouse event. For details, see [MouseEvent](ts-universal-mouse-key.md#mouseevent).|
- Return value
| Type | Description |
| ------- | --------------------------------------------- |
| boolean | Returns **true** if the event is sent successfully; returns **false** otherwise.|
## Example ## Example
```ts
``` // xxx.ets
class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
}
@Entry @Entry
@Component @Component
struct IdExample { struct IdExample {
@State text: string = ''
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button() { Button() {
Text('click') Text('onKeyTab').fontSize(25).fontWeight(FontWeight.Bold)
.fontSize(25) }.margin({ top: 20 }).backgroundColor('#0D9FFB')
.fontWeight(FontWeight.Bold) .onKeyEvent(() => {
} this.text = "onKeyTab"
.type(ButtonType.Capsule) })
.margin({
top: 20 Button() {
}).onClick(() => { Text('click to start').fontSize(25).fontWeight(FontWeight.Bold)
}.margin({ top: 20 })
.onClick(() => {
console.info(getInspectorByKey("click")) console.info(getInspectorByKey("click"))
console.info(getInspectorTree()) console.info(getInspectorTree())
this.text = "Button 'click to start' is clicked"
setTimeout(() => { setTimeout(() => {
sendEventByKey("longclick", 11, "") sendEventByKey("longClick", 11, "")
}, 2000) }, 2000)
}).id('click') }).id('click')
Button() { Button() {
Text('longclick') Text('longClick').fontSize(25).fontWeight(FontWeight.Bold)
.fontSize(25) }.margin({ top: 20 }).backgroundColor('#0D9FFB')
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.gesture( .gesture(
LongPressGesture().onActionEnd(() => { LongPressGesture().onActionEnd(() => {
console.info('long clicked') console.info('long clicked')
})) this.text = "Button 'longClick' is longclicked"
.id('longclick') setTimeout(() => {
let rect = Utils.getComponentRect('onTouch')
let touchPoint: TouchObject = {
id: 1,
x: rect.left + (rect.right - rect.left) / 2,
y: rect.top + (rect.bottom - rect.top) / 2,
type: TouchType.Down,
screenX: rect.left + (rect.right - rect.left) / 2,
screenY: rect.left + (rect.right - rect.left) / 2,
}
sendTouchEvent(touchPoint)
touchPoint.type = TouchType.Up
sendTouchEvent(touchPoint)
}, 2000)
})).id('longClick')
Button() {
Text('onTouch').fontSize(25).fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule).margin({ top: 20 })
.onClick(() => {
console.info('onTouch is clicked')
this.text = "Button 'onTouch' is clicked"
setTimeout(() => {
let rect = Utils.getComponentRect('onMouse')
let mouseEvent: MouseEvent = {
button: MouseButton.Left,
action: MouseAction.Press,
x: rect.left + (rect.right - rect.left) / 2,
y: rect.top + (rect.bottom - rect.top) / 2,
screenX: rect.left + (rect.right - rect.left) / 2,
screenY: rect.top + (rect.bottom - rect.top) / 2,
timestamp: 1,
target: {
area: {
width: 1,
height: 1,
position: {
x: 1,
y: 1
},
globalPosition: {
x: 1,
y: 1
}
}
},
source: SourceType.Mouse
}
sendMouseEvent(mouseEvent)
}, 2000)
}).id('onTouch')
Button() {
Text('onMouse').fontSize(25).fontWeight(FontWeight.Bold)
}.margin({ top: 20 }).backgroundColor('#0D9FFB')
.onMouse(() => {
console.info('onMouse')
this.text = "Button 'onMouse' in onMouse"
setTimeout(() => {
let keyEvent: KeyEvent = {
type: KeyType.Down,
keyCode: 2049,
keyText: 'tab',
keySource: 4,
deviceId: 0,
metaKey: 0,
timestamp: 0
}
sendKeyEvent(keyEvent)
}, 2000)
}).id('onMouse')
Text(this.text).fontSize(25).padding(15)
} }
.width('100%') .width('100%').height('100%')
.height('100%')
} }
} }
``` ```
# Popup Control # Popup Control
The popup attribute defines the popup displayed when a component is clicked.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. >
> This attribute is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Required Permissions ## Required Permissions
...@@ -13,48 +15,52 @@ None ...@@ -13,48 +15,52 @@ None
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bindPopup | show: boolean,<br/>popup: PopupOptions \| CustomPopupOptions | - | Settings of the popup bound to a component.<br/>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br/>**popup**: parameters of the current popup. | | bindPopup | show: boolean,<br>popup: PopupOptions \| CustomPopupOptions | - | Settings of the popup bound to a component.<br>**show**: whether to display the popup on the creation page by default. The default value is **false**.<br>**popup**: parameters of the popup.|
- PopupOptions attributes - PopupOptions
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| message | string | Yes | - | Content of the popup message. | | message | string | Yes| - | Content of the popup message.|
| placementOnTop | boolean | No | false | Whether to display the popup above the component. The default value is **false**. | | placementOnTop | boolean | No| false | Whether to display the popup above the component. The default value is **false**.|
| primaryButton | {<br/>value: string,<br/>action: () =&gt; void<br/>} | No | - | First button.<br/>**value**: text of the primary button in the popup.<br/>**action**: callback function for clicking the primary button. | | primaryButton | {<br>value: string,<br>action: () =&gt; void<br>} | No| - | Primary button.<br>**value**: text of the primary button in the popup.<br>**action**: callback for clicking the primary button.|
| secondaryButton | {<br/>value: string,<br/>action: () =&gt; void<br/>} | No | - | Second button.<br/>**value**: text of the secondary button in the popup.<br/>**action**: callback function for clicking the secondary button. | | secondaryButton | {<br>value: string,<br>action: () =&gt; void<br>} | No| - | Secondary button.<br>**value**: text of the secondary button in the popup.<br>**action**: callback for clicking the secondary button.|
| onStateChange | (isVisible: boolean) =&gt; void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | | onStateChange | (isVisible: boolean) =&gt; void | No| - | Callback for the popup status change event. The parameter **isVisible** indicates whether the popup is visible.|
- CustomPopupOptions<sup>8+</sup> - CustomPopupOptions<sup>8+</sup>
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| builder | () =&gt; any | Yes | - | Builder of the tooltip content. | | builder | () =&gt; any | Yes| - | Builder of the popup content.|
| placement | Placement | No | Placement.Bottom | Preferred position of the tooltip component. If the set position is insufficient for holding the component, it will be automatically adjusted. | | placement | Placement | No| Placement.Bottom | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.|
| maskColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip mask. | | maskColor | [ResourceColor](../../ui/ts-types.md) | No| - | Color of the popup mask.|
| popupColor | [Color](../../ui/ts-types.md) | No | - | Color of the tooltip. | | popupColor | [ResourceColor](../../ui/ts-types.md) | No| - | Color of the popup.|
| enableArrow | boolean | No | true | Whether to display arrows. Arrows are displayed only for tooltips in the up and down directions. | | enableArrow | boolean | No| true | Whether to display an arrow.<br>Since API version 9, if the location set for the arrow is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left** and the popup height is less than the arrow width (32 vp), the arrow will not be displayed.|
| autoCancel | boolean | No | true | Whether to automatically close the tooltip when an operation is performed on the page. | | autoCancel | boolean | No| true | Whether to automatically close the popup when an operation is performed on the page.|
| onStateChange | (isVisible: boolean) =&gt; void | No | - | Callback for the popup status change event. The parameter **isVisible** indicates the visibility of the popup. | | onStateChange | (isVisible: boolean) =&gt; void | No| - | Callback for the popup status change event. The parameter **isVisible** indicates whether the popup is visible.|
- Placement<sup>8+</sup> enums - Placement<sup>8+</sup> enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Left | The tooltip is on the left of the component. | | Left | The popup is on the left of the component, vertically aligned with the component on the left.|
| Right | The tooltip is on the right of the component. | | Right | The popup is on the right of the component, vertically aligned with the component on the right.|
| Top | The tooltip is on the top of the component. | | Top | The popup is at the top of the component, horizontally aligned with the component at the top.|
| Bottom | The tooltip is at the bottom of the component. | | Bottom | The popup is at the bottom of the component, horizontally aligned with the component at the bottom.|
| TopLeft | The tooltip is in the upper left corner of the component. | | TopLeft | The popup is at the top of the component and, since API version 9, aligned with the left of the component.|
| TopRight | The tooltip is in the upper right corner of the component. | | TopRight | The popup is at the top of the component and, since API version 9, aligned with the right of the component.|
| BottomLeft | The tooltip is in the lower left corner of the component. | | BottomLeft | The popup is at the bottom of the component and, since API version 9, aligned with the left of the component.|
| BottomRight | The tooltip is in the lower right corner of the component. | | BottomRight | The popup is at the bottom of the component and, since API version 9, aligned with the right of the component.|
| LeftTop<sup>9+</sup> | The popup is on the left of the component and aligned with the top of the component.|
| LeftBottom<sup>9+</sup> | The popup is on the left of the component and aligned with the bottom of the component.|
| RightTop<sup>9+</sup> | The popup is on the right of the component and aligned with the top of the component.|
| RightBottom<sup>9+</sup> | The popup is on the right of the component and aligned with the bottom of the component.|
## Example ## Example
```ts
``` // xxx.ets
@Entry @Entry
@Component @Component
struct PopupExample { struct PopupExample {
...@@ -65,7 +71,7 @@ struct PopupExample { ...@@ -65,7 +71,7 @@ struct PopupExample {
@Builder popupBuilder() { @Builder popupBuilder() {
Row({ space: 2 }) { Row({ space: 2 }) {
Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 }) Image('/resource/ic_public_thumbsup.svg').width(24).height(24).margin({ left: -5 })
Text('Custom Popup').fontSize(12) Text('Custom Popup').fontSize(10)
}.width(100).height(50).backgroundColor(Color.White) }.width(100).height(50).backgroundColor(Color.White)
} }
......
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md). The **@Builder** decorated method is used to define the declarative UI description of a component and quickly generate multiple layouts in a custom component. The functionality and syntax of the **@Builder** decorator are the same as those of the [build Function](ts-function-build.md).
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct CompA { struct CompA {
size : number = 100; size1 : number = 100;
@Builder SquareText(label: string) { @Builder SquareText(label: string) {
Text(label) Text(label)
.width(1 * this.size) .width(1 * this.size1)
.height(1 * this.size) .height(1 * this.size1)
} }
@Builder RowOfSquareTexts(label1: string, label2: string) { @Builder RowOfSquareTexts(label1: string, label2: string) {
...@@ -21,8 +22,8 @@ struct CompA { ...@@ -21,8 +22,8 @@ struct CompA {
this.SquareText(label1) this.SquareText(label1)
this.SquareText(label2) this.SquareText(label2)
} }
.width(2 * this.size) .width(2 * this.size1)
.height(1 * this.size) .height(1 * this.size1)
} }
build() { build() {
...@@ -32,12 +33,12 @@ struct CompA { ...@@ -32,12 +33,12 @@ struct CompA {
this.SquareText("B") this.SquareText("B")
// or as long as tsc is used // or as long as tsc is used
} }
.width(2 * this.size) .width(2 * this.size1)
.height(1 * this.size) .height(1 * this.size1)
this.RowOfSquareTexts("C", "D") this.RowOfSquareTexts("C", "D")
} }
.width(2 * this.size) .width(2 * this.size1)
.height(2 * this.size) .height(2 * this.size1)
} }
} }
``` ```
...@@ -51,7 +52,8 @@ In certain circumstances, you may need to add a specific function, such as a cli ...@@ -51,7 +52,8 @@ In certain circumstances, you may need to add a specific function, such as a cli
### Component Initialization Through Parameters ### Component Initialization Through Parameters
When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`). When initializing a custom component through parameters, assign a **@Builder** decorated method to the **@BuilderParam** decorated attribute — **content**, and call the value of **content** in the custom component. If no parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `content: this.specificParam`), define the type of the attribute as a function without a return value (for example, `@BuilderParam content: () => void`). If any parameter is passed when assigning a value to the **@BuilderParam** decorated attribute (for example, `callContent: this.specificParam1("111")`), define the type of the attribute as `any` (for example,`@BuilderParam callContent: any;`).
``` ```ts
// xxx.ets
@Component @Component
struct CustomContainer { struct CustomContainer {
header: string = ""; header: string = "";
...@@ -100,7 +102,8 @@ struct CustomContainerUser { ...@@ -100,7 +102,8 @@ struct CustomContainerUser {
In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute. In a custom component, use the **@BuilderParam** decorated attribute to receive a trailing closure. When the custom component is initialized, the component name is followed by a pair of braces ({}) to form a trailing closure (`CustomComponent(){}`). You can consider a trailing closure as a container and add content to it. For example, you can add a component (`{Column(){Text("content")}`) to a trailing closure. The syntax of the closure is the same as that of [build](../ui/ts-function-build.md). In this scenario, the custom component has one and only one **@BuilderParam** decorated attribute.
Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**. Example: Add a **\<Column>** component and a click event to the closure, and call the **specificParam** method decorated by **@Builder** in the new **\<Column>** component. After the **\<Column>** component is clicked, the value of the component's `header` attribute will change to `changeHeader`. In addition, when the component is initialized, the content of the trailing closure will be assigned to the `closer` attribute decorated by **@BuilderParam**.
``` ```ts
// xxx.ets
@Component @Component
struct CustomContainer { struct CustomContainer {
header: string = ""; header: string = "";
......
...@@ -6,14 +6,14 @@ The member variables of a component can be initialized in either of the followin ...@@ -6,14 +6,14 @@ The member variables of a component can be initialized in either of the followin
- Local initialization. For example: - Local initialization. For example:
``` ```ts
@State counter: Counter = new Counter() @State counter: Counter = new Counter()
``` ```
- Initialization using constructor parameters. For example: - Initialization using constructor parameters. For example:
``` ```ts
MyComponent(counter: $myCounter) MyComponent({counter: $myCounter})
``` ```
...@@ -73,43 +73,57 @@ As indicated by the preceding table: ...@@ -73,43 +73,57 @@ As indicated by the preceding table:
## Example ## Example
``` ```ts
// xxx.ets
class ClassA {
public a:number
constructor(a: number) {
this.a = a
}
}
@Entry @Entry
@Component @Component
struct Parent { struct Parent {
@State parentState: ClassA = new ClassA() @State parentState: ClassA = new ClassA(1)
build() {
Row() { build() {
CompA({aState: new ClassA, aLink: $parentState}) // valid Column() {
CompA({aLink: $parentState}) // valid Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA() // invalid, @Link aLink remains uninitialized CompA({ aState: new ClassA(2), aLink: $parentState })
CompA({aLink: new ClassA}) // invalid, @Link aLink must be a reference ($) to either @State or @Link variable }
} Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA({ aLink: $parentState })
}
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
CompA({ aState: new ClassA(3), aLink: $parentState })
}
} }
}
} }
@Component @Component
struct CompA { struct CompA {
@State aState: boolean = false // must initialize locally @State aState: any = false
@Link aLink: ClassA // must not initialize locally @Link aLink: ClassA
build() { build() {
Row() { Column() {
CompB({bLink: $aLink, // valid init a @Link with reference of another @Link, CompB({ bLink: $aLink, bProp: this.aState })
bProp: this.aState}) // valid init a @Prop with value of a @State CompB({ bLink: $aState, bProp: false })
CompB({aLink: $aState, // invalid: type mismatch expected ref to ClassA, provided reference to boolean
bProp: false}) // valid init a @Prop by constants value
}
} }
}
} }
@Component @Component
struct CompB { struct CompB {
@Link bLink: ClassA = new ClassA() // invalid, must not initialize locally @Link bLink: ClassA
@Prop bProp: boolean = false // invalid must not initialize locally @Prop bProp: boolean
build() { build() {
... Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
} Text(JSON.stringify(this.bLink.a)).fontSize(30)
Text(JSON.stringify(this.bProp)).fontSize(30).fontColor(Color.Red)
}.margin(10)
}
} }
``` ```
...@@ -7,7 +7,8 @@ In this section, we will develop an infographic food details page, by building c ...@@ -7,7 +7,8 @@ In this section, we will develop an infographic food details page, by building c
## Building the Stack Layout ## Building the Stack Layout
1. Create a food name. 1. Create a food name.
Delete the code of the build method in the project template, create a &lt;Stack&gt; component, and place the **\<Text>** component in the braces of the **\<Stack>** component so that the &lt;Text&gt; component becomes a child component of the &lt;Stack&gt; component. A **\<Stack>** component consists of one or more child components. The latter child component overwrites the former one.
Delete the code of the **build** method in the project template, create a **\<Stack>** component, and place the **\<Text>** component in the braces of the **\<Stack>** component. When the **\<Stack>** component contains multiple child components, the latter child component overwrites the former one.
``` ```
@Entry @Entry
...@@ -23,10 +24,11 @@ In this section, we will develop an infographic food details page, by building c ...@@ -23,10 +24,11 @@ In this section, we will develop an infographic food details page, by building c
} }
``` ```
![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png) ![en-us_image_0000001222967780](figures/en-us_image_0000001222967780.png)
2. Display food pictures. 2. Display food pictures.
Create an **\<Image>** component and specify a URL for it. The **\<Image>** and **\<Text>** components are mandatory. To display the **\<Text>** component above the **\<Image>** component, you need to declare the **\<Image>** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where filename indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\<Image>** component to reference image resources.
Create an **\<Image>** component and specify a URL for it. The **\<Image>** and **\<Text>** components are mandatory. To display the **\<Text>** component above the **\<Image>** component, you need to declare the **\<Image>** component first. Image resources are stored in the **rawfile** folder in **resources**. When referencing the resources in the **rawfile** folder, use the `"$rawfile('filename')"` format, where **filename** indicates the relative path of the file in the **rawfile** folder. Currently, `$rawfile` only allows the **\<Image>** component to reference image resources.
``` ```
@Entry @Entry
...@@ -46,9 +48,10 @@ In this section, we will develop an infographic food details page, by building c ...@@ -46,9 +48,10 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001267887861](figures/en-us_image_0000001267887861.png) ![en-us_image_0000001267887861](figures/en-us_image_0000001267887861.png)
3. Access images through resources. 3. Access images through resources.
In addition to specifying the image path, you can also use the media resource symbol $r to reference resources based on the resource qualifier rules in the resources folder. Right-click the resources folder, choose **New** &gt; **Resource Directory**, and set **Resource Type** to **Media (image resource)**. Place Tomato.png in the media folder.
You can then can reference the application resource in the ` "$r('app.type.name')"` format, that is, `$r('app.media.Tomato')`. In addition to specifying the image path, you can also use the media resource symbol `$r` to reference resources in the **resources** folder based on the resource qualifier rules. Right-click the **resources** folder, choose **New** &gt; **Resource Directory**, and set **Resource Type** to **Media (image resource)**.
Place **Tomato.png** in the **media** folder. You can then can reference the application resource in the `$r('app.type.name')` format, that is, `$r('app.media.Tomato')`.
``` ```
...@@ -68,30 +71,31 @@ In this section, we will develop an infographic food details page, by building c ...@@ -68,30 +71,31 @@ In this section, we will develop an infographic food details page, by building c
} }
``` ```
4. Set the width and height of the image, and set the objectFit attribute of the image to ImageFit.Contain, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary.If the image fills the entire screen, the possible causes are as follows: 4. Set the width and height of the image, and set the **objectFit** attribute of the image to **ImageFit.Contain**, which means to keep the aspect ratio of the image to ensure that the image is completely displayed within the boundary. If the image fills the entire screen, the possible causes are as follows:
1. The width and height of the image are not set. 1. The width and height of the image are not set.
2. The default attribute of **objectFit** of the image is **ImageFit.Cover**, that is, the image is zoomed in or zoomed out to fill the entire display boundary with the aspect ratio locked. 2. The default attribute of **objectFit** of the image is **ImageFit.Cover**, that is, the image is zoomed in or zoomed out to fill the entire display boundary with the aspect ratio locked.
``` ```
@Entry @Entry
@Component @Component
struct MyComponent { struct MyComponent {
build() { build() {
Stack() { Stack() {
Image($r('app.media.Tomato')) Image($r('app.media.Tomato'))
.objectFit(ImageFit.Contain) .objectFit(ImageFit.Contain)
.height(357) .height(357)
Text('Tomato') Text('Tomato')
.fontSize(26) .fontSize(26)
.fontWeight(500) .fontWeight(500)
}
} }
} }
} ```
```
![en-us_image_0000001223127732](figures/en-us_image_0000001223127732.png) ![en-us_image_0000001223127732](figures/en-us_image_0000001223127732.png)
5. Set the food image and name layout. Set the alignment mode of the stack to bottom alignment. By default, the stack is center aligned. Set **alignContent** to **Alignment.BottomStart**. Similar to **FontWeight**, **Alignment** is a built-in enumeration type provided by the framework. 5. Set the food image and name layout. Set **alignContent** to **Alignment.BottomStart**. Similar to **FontWeight**, **Alignment** is a built-in enumeration type provided by the framework.
``` ```
@Entry @Entry
...@@ -112,9 +116,9 @@ In this section, we will develop an infographic food details page, by building c ...@@ -112,9 +116,9 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001267647873](figures/en-us_image_0000001267647873.png) ![en-us_image_0000001267647873](figures/en-us_image_0000001267647873.png)
6. You can change the background color of the food image by setting the background color of the stack. You can set the background color in either of the following ways: 6. You can change the background color of the food image by setting the background color of the **\<Stack>** component in either of the following ways:
1. By using the built-in enumeration value of Color provided by the framework. For example, **backgroundColor(Color.Red)** indicates that the background color is set to red. 1. Using the built-in **Color** enums provided by the framework. For example, **backgroundColor(Color.Red)** indicates that the background color is set to red.
2. By using the parameter of the string type. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting **backgroundColor(??\#0000FF??)** and set the background color to white by setting **backgroundColor(??rgb(255, 255, 255)??)**. 2. Using the string-type parameter. The supported color formats are rgb, rgba, and HEX. For example, you can set the background color to blue by setting **backgroundColor(??\#0000FF??)** and set the background color to white by setting **backgroundColor(??rgb(255, 255, 255)??)**.
``` ```
...@@ -163,7 +167,7 @@ In this section, we will develop an infographic food details page, by building c ...@@ -163,7 +167,7 @@ In this section, we will develop an infographic food details page, by building c
![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png) ![en-us_image_0000001222967776](figures/en-us_image_0000001222967776.png)
8. Adjust the structure between components and semanticize component names. Create the FoodDetail page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component. 8. Adjust the structure between components and semanticize component names. Create the **FoodDetail** page entry component, create a column in **FoodDetail**, and set the alignment to **alignItems(HorizontalAlign.Center)**. Change the name of the **MyComponent** component to **FoodImageDisplay**, which is a child component of the **FoodDetail** component.
A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set. A column is a container component whose child components are vertically arranged. It is a linear layout in essence. Therefore, only the alignment in the cross axis direction can be set.
...@@ -202,7 +206,7 @@ In this section, we will develop an infographic food details page, by building c ...@@ -202,7 +206,7 @@ In this section, we will develop an infographic food details page, by building c
You can use the Flex layout to build a food composition table. In this way you do not need to worry about the width and height calculation. The size of different cells can be flexibly set based on the proportion. You can use the Flex layout to build a food composition table. In this way you do not need to worry about the width and height calculation. The size of different cells can be flexibly set based on the proportion.
1. Create a **ContentTable** component as a child component of the FoodDetail component. 1. Create a **ContentTable** component as a child component of the **FoodDetail** component.
``` ```
@Component @Component
...@@ -239,13 +243,13 @@ You can use the Flex layout to build a food composition table. In this way you d ...@@ -239,13 +243,13 @@ You can use the Flex layout to build a food composition table. In this way you d
} }
``` ```
2. Create a Flex component to display two food composition categories in the tomato: Calories and Nutrition. 2. Create a Flex component to display two food composition categories in the tomato: **Calories** and **Nutrition**.
Calories contains information about calories. Nutrition contains information about protein, fat, carbohydrates, and vitamin C. **Calories** contains information about calories. **Nutrition** contains information about protein, fat, carbohydrates, and vitamin C.
Create the Calories class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three Text child components, which represent the category name (Calories), content name (Calories), and contain value (17 kcal), respectively. By default, child components in the Flex component are arranged horizontally. Create the **Calories** class. Create a Flex component and set its height to 280, and the top, right, and left margins to 30. The Flex component contains three **\<Text>** child components, which represent the category name (**Calories**), content name (**Calories**), and contain value (**17 kcal**), respectively. By default, child components in the Flex component are arranged horizontally.
In the following example, code of FoodImageDisplay is omitted, and only code of ContentTable is provided. In the following example, code of **FoodImageDisplay** is omitted, and only code of **ContentTable** is provided.
``` ```
...@@ -281,14 +285,14 @@ Create the Calories class. Create a Flex component and set its height to 280, an ...@@ -281,14 +285,14 @@ Create the Calories class. Create a Flex component and set its height to 280, an
![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png) ![en-us_image_0000001267767869](figures/en-us_image_0000001267767869.png)
3. Adjust the layout and set the proportion (layoutWeight) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space flexGrow(1). 3. Adjust the layout and set the proportion (**layoutWeight**) of each part. Set the proportion of the category name to **1**, and the total proportion of content name and content value to **2**. The content name and content value are in a same Flex, and the content name occupies all remaining space **flexGrow(1)**.
``` ```
@Component @Component
struct FoodImageDisplay { struct FoodImageDisplay {
build() { build() {
Stack({ alignContent: Alignment.BottomStart }) { Stack({ alignContent: Alignment.BottomStart }) {
Image($m('Tomato.png')) Image($r('app.media.Tomato'))
.objectFit(ImageFit.Contain) .objectFit(ImageFit.Contain)
.height(357) .height(357)
Text('Tomato') Text('Tomato')
...@@ -337,7 +341,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an ...@@ -337,7 +341,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an
![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png) ![en-us_image_0000001267607901](figures/en-us_image_0000001267607901.png)
4. Create the **Nutrient** class in a similar process. Nutrition consists of four parts: Protein, Fat, Carbohydrates, and VitaminC. The names of the last three parts are omitted in the table and represented by spaces. 4. Create the **Nutrient** class in a similar process. **Nutrition** consists of four parts: **Protein**, **Fat**, **Carbohydrates**, and **VitaminC**. The names of the last three parts are omitted in the table and represented by spaces.
Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**. Set **FlexDirection.Column**, **FlexAlign.SpaceBetween**, and **ItemAlign.Start**.
...@@ -442,7 +446,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an ...@@ -442,7 +446,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an
Currently, all food groups are declared, resulting in code duplication and redundancy. You can use @Builder to build a custom method and abstract the same UI structure declaration. The @Builder decorated method and the build method for the @Component decorated component are used to declare some UI rendering structures and comply with the same eTS syntax. You can define one or more methods decorated by @Builder, but a component decorated by @Component can have only one build method. Currently, all food groups are declared, resulting in code duplication and redundancy. You can use @Builder to build a custom method and abstract the same UI structure declaration. The @Builder decorated method and the build method for the @Component decorated component are used to declare some UI rendering structures and comply with the same eTS syntax. You can define one or more methods decorated by @Builder, but a component decorated by @Component can have only one build method.
Declare the IngredientItem method decorated by @Builder in ContentTable to declare the UI descriptions for the category name, content name, and content value. Declare the **IngredientItem** method decorated by @Builder in **ContentTable** to declare the UI descriptions for the category name, content name, and content value.
``` ```
...@@ -455,9 +459,6 @@ Create the Calories class. Create a Flex component and set its height to 280, an ...@@ -455,9 +459,6 @@ Create the Calories class. Create a Flex component and set its height to 280, an
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
.layoutWeight(1) .layoutWeight(1)
Flex({ alignItems: ItemAlign.Center }) { Flex({ alignItems: ItemAlign.Center }) {
Circle({width: 6, height: 6})
.margin({right: 12})
.fill(colorValue)
Text(name) Text(name)
.fontSize(17.4) .fontSize(17.4)
.flexGrow(1) .flexGrow(1)
...@@ -470,7 +471,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an ...@@ -470,7 +471,7 @@ Create the Calories class. Create a Flex component and set its height to 280, an
} }
``` ```
When the ` IngredientItem` API is called in the build method of ContentTable, ` this ` needs to be used to invoke the method in the scope of the component to distinguish the global method call. When the `IngredientItem` API is called in the **build** method of **ContentTable**, `this` needs to be used to invoke the method in the scope of the component to distinguish the global method call.
``` ```
...@@ -491,7 +492,7 @@ When the ` IngredientItem` API is called in the build method of ContentTable, ...@@ -491,7 +492,7 @@ When the ` IngredientItem` API is called in the build method of ContentTable,
} }
``` ```
The overall code of the ContentTable component is as follows: The overall code of the **ContentTable** component is as follows:
``` ```
......
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
- [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md) - [Layout Constraints](reference/arkui-ts/ts-universal-attributes-layout-constraints.md)
- [Flex Layout](reference/arkui-ts/ts-universal-attributes-flex-layout.md) - [Flex Layout](reference/arkui-ts/ts-universal-attributes-flex-layout.md)
- [Border](reference/arkui-ts/ts-universal-attributes-border.md) - [Border](reference/arkui-ts/ts-universal-attributes-border.md)
- [ͼƬ߿](reference/arkui-ts/ts-universal-attributes-border-image.md) - [Border Image](reference/arkui-ts/ts-universal-attributes-border-image.md)
- [Background](reference/arkui-ts/ts-universal-attributes-background.md) - [Background](reference/arkui-ts/ts-universal-attributes-background.md)
- [Opacity](reference/arkui-ts/ts-universal-attributes-opacity.md) - [Opacity](reference/arkui-ts/ts-universal-attributes-opacity.md)
- [Visibility](reference/arkui-ts/ts-universal-attributes-visibility.md) - [Visibility](reference/arkui-ts/ts-universal-attributes-visibility.md)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## Overview ## Overview
In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the independent service mode for API adaptation. In this mode, each device independently publishes a service to process external access requests. When receiving an access request, the HDF DeviceManager extracts parameters from the request to call the internal APIs of the target device. In the independent service mode, the HDF DeviceManager provides service management capabilities. However, you need to configure a node for each device, which increases memory usage. In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the independent service mode for API adaptation. In this mode, each device independently publishes a service to process external access requests. When receiving an access request, the HDF DeviceManager extracts parameters from the request to call the internal APIs of the target device. In the independent service mode, the HDF DeviceManager provides service management capabilities. However, you need to configure a node for each device, which increases memory usage.
**Figure 1** Independent service mode **Figure 1** Independent service mode
...@@ -14,7 +14,7 @@ In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the inde ...@@ -14,7 +14,7 @@ In the Hardware Driver Foundation (HDF), the MultiMedia Card (MMC) uses the inde
**MmcCntlrOps**: **MmcCntlrOps**:
``` ```
struct MmcCntlrOps { struct MmcCntlrOps {
int32_t (*request)(struct MmcCntlr *cntlr, struct MmcCmd *cmd); int32_t (*request)(struct MmcCntlr *cntlr, struct MmcCmd *cmd);
...@@ -37,23 +37,23 @@ struct MmcCntlrOps { ...@@ -37,23 +37,23 @@ struct MmcCntlrOps {
**Table 1** Description of callback functions in MmcCntlrOps **Table 1** Description of callback functions in MmcCntlrOps
| Function| Input Parameter| Return Value| Description| | Function| Input Parameter| Return Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| doRequest | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmd**: structure pointer to the command to execute.| HDF_STATUS| Processes the request.| | doRequest | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmd**: structure pointer to the command to execute.| HDF_STATUS| Processes the request.|
| setClock | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**clock**: clock frequency to set.| HDF_STATUS| Sets the clock frequency.| | setClock | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**clock**: clock frequency to set.| HDF_STATUS| Sets the clock frequency.|
| setPowerMode | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**mode**: power consumption mode, which is an enumerated value.| HDF_STATUS| Sets the power consumption mode.| | setPowerMode | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**mode**: power consumption mode, which is an enumerated value.| HDF_STATUS| Sets the power consumption mode.|
| setBusWidth | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**width**: bus width, which is an enumerated value.| HDF_STATUS| Sets the bus width.| | setBusWidth | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**width**: bus width, which is an enumerated value.| HDF_STATUS| Sets the bus width.|
| setBusTiming | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**timing**: bus timing, which is an enumerated value.| HDF_STATUS| Sets the bus timing.| | setBusTiming | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**timing**: bus timing, which is an enumerated value.| HDF_STATUS| Sets the bus timing.|
| setSdioIrq | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable Secure Digital Input Output (SDIO) interrupts.| HDF_STATUS| Enables or disables SDIO interrupts.| | setSdioIrq | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable Secure Digital Input Output (SDIO) interrupts.| HDF_STATUS| Enables or disables SDIO interrupts.|
| hardwareReset | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Resets hardware.| | hardwareReset | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Resets hardware.|
| systemInit | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Performs system initialization.| | systemInit | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Performs system initialization.|
| setEnhanceSrobe | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable the enhanced strobe feature.| HDF_STATUS| Sets the enhanced strobe feature.| | setEnhanceSrobe | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**enable**: whether to enable the enhanced strobe feature.| HDF_STATUS| Sets the enhanced strobe feature.|
| switchVoltage | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**volt**: voltage to set, which can be 3.3 V, 1.8 V, or 1.2 V.| HDF_STATUS| Sets the voltage.| | switchVoltage | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**volt**: voltage to set, which can be 3.3 V, 1.8 V, or 1.2 V.| HDF_STATUS| Sets the voltage.|
| devReadOnly | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is read-only.| | devReadOnly | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is read-only.|
| cardPluged | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is removed.| | cardPluged | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is removed.|
| devBusy | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is being used.| | devBusy | **cntlr**: structure pointer to the MMC controller at the core layer.| Boolean value| Checks whether the device is being used.|
| tune | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmdCode**: command code of the uint32_t type.| HDF_STATUS| Tunes the oscillator circuit frequency. | | tune | **cntlr**: structure pointer to the MMC controller at the core layer.<br>**cmdCode**: command code of the uint32_t type.| HDF_STATUS| Tunes the oscillator circuit frequency.|
| rescanSdioDev | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Scans and adds an SDIO device.| | rescanSdioDev | **cntlr**: structure pointer to the MMC controller at the core layer.| HDF_STATUS| Scans and adds an SDIO device.|
## How to Develop ## How to Develop
...@@ -75,7 +75,6 @@ The MMC module adaptation involves the following steps: ...@@ -75,7 +75,6 @@ The MMC module adaptation involves the following steps:
> For details about the functions in **MmcCntlrOps**, see [Available APIs](#available-apis). > For details about the functions in **MmcCntlrOps**, see [Available APIs](#available-apis).
4. Debug the driver. 4. Debug the driver.
(Optional) For new drivers, verify the basic functions, for example, check the information returned after the **MmcCntlrOps** instance is attached and whether the device starts successfully. (Optional) For new drivers, verify the basic functions, for example, check the information returned after the **MmcCntlrOps** instance is attached and whether the device starts successfully.
...@@ -88,7 +87,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -88,7 +87,7 @@ The following uses **himci.c** as an example to present the information required
Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit. Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit.
MMC driver entry example: MMC driver entry example:
``` ```
struct HdfDriverEntry g_mmcDriverEntry = { struct HdfDriverEntry g_mmcDriverEntry = {
.moduleVersion = 1, .moduleVersion = 1,
...@@ -106,7 +105,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -106,7 +105,7 @@ The following uses **himci.c** as an example to present the information required
- **device_info.hcs** configuration example - **device_info.hcs** configuration example
``` ```
root { root {
device_info { device_info {
...@@ -147,7 +146,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -147,7 +146,7 @@ The following uses **himci.c** as an example to present the information required
- **mmc_config.hcs** configuration example - **mmc_config.hcs** configuration example
``` ```
root { root {
platform { platform {
...@@ -196,15 +195,15 @@ The following uses **himci.c** as an example to present the information required ...@@ -196,15 +195,15 @@ The following uses **himci.c** as an example to present the information required
} }
} }
} }
} }
``` ```
3. Initialize the **MmcCntlr** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) to instantiate **MmcCntlrOps** in **MmcCntlr** (so that the underlying driver functions can be called). 3. Initialize the **MmcCntlr** object at the core layer, including defining a custom structure (to pass parameters and data) and implementing the **HdfDriverEntry** member functions (**Bind**, **Init**, and **Release**) to instantiate **MmcCntlrOps** in **MmcCntlr** (so that the underlying driver functions can be called).
- Defining a custom structure - Defining a custom structure
To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **mmc_config.hcs** file to initialize the members in the custom structure and passes important parameters to the **MmcCntlr** object at the core layer. To the driver, the custom structure holds parameters and data. The **DeviceResourceIface** method provided by the HDF reads the values in the **mmc_config.hcs** file to initialize the members in the custom structure and passes important parameters to the **MmcCntlr** object at the core layer.
``` ```
struct HimciHost { struct HimciHost {
struct MmcCntlr *mmc;// (Mandatory) Core layer structure struct MmcCntlr *mmc;// (Mandatory) Core layer structure
...@@ -257,7 +256,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -257,7 +256,7 @@ The following uses **himci.c** as an example to present the information required
- Instantiating **MmcCntlrOps** in **MmcCntlr** (other members are initialized by **Bind**) - Instantiating **MmcCntlrOps** in **MmcCntlr** (other members are initialized by **Bind**)
``` ```
static struct MmcCntlrOps g_himciHostOps = { static struct MmcCntlrOps g_himciHostOps = {
.request = HimciDoRequest, .request = HimciDoRequest,
...@@ -300,7 +299,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -300,7 +299,7 @@ The following uses **himci.c** as an example to present the information required
Initializes the custom structure **HimciHost** object and **MmcCntlr**, and calls the **MmcCntlrAdd** function at the core layer. **MmcCntlr**, **HimciHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully. Initializes the custom structure **HimciHost** object and **MmcCntlr**, and calls the **MmcCntlrAdd** function at the core layer. **MmcCntlr**, **HimciHost**, and **HdfDeviceObject** assign values with each other so that other functions can be converted successfully.
``` ```
static int32_t HimciMmcBind(struct HdfDeviceObject *obj) static int32_t HimciMmcBind(struct HdfDeviceObject *obj)
{ {
...@@ -347,7 +346,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -347,7 +346,7 @@ The following uses **himci.c** as an example to present the information required
Implements **ProcMciInit**. Implements **ProcMciInit**.
``` ```
static int32_t HimciMmcInit(struct HdfDeviceObject *obj) static int32_t HimciMmcInit(struct HdfDeviceObject *obj)
{ {
...@@ -377,7 +376,7 @@ The following uses **himci.c** as an example to present the information required ...@@ -377,7 +376,7 @@ The following uses **himci.c** as an example to present the information required
Releases the memory and deletes the controller. This function assigns values to the **Release** function in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the value assignment operations. Releases the memory and deletes the controller. This function assigns values to the **Release** function in the driver entry structure. If the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the value assignment operations.
``` ```
static void HimciMmcRelease(struct HdfDeviceObject *obj) static void HimciMmcRelease(struct HdfDeviceObject *obj)
{ {
......
...@@ -18,7 +18,7 @@ The implementation of the OpenHarmony project directories and functions relies o ...@@ -18,7 +18,7 @@ The implementation of the OpenHarmony project directories and functions relies o
| /build/lite | OpenHarmony basic compilation and building framework.| | /build/lite | OpenHarmony basic compilation and building framework.|
| /kernel/liteos_m | Basic kernel. The implementation related to the chip architecture is in the **arch** directory.| | /kernel/liteos_m | Basic kernel. The implementation related to the chip architecture is in the **arch** directory.|
| /device | Board-level implementation, which complies with the OpenHarmony specifications. For details about the directory structure and porting process, see [Overview](../porting/porting-chip-board-overview.md).| | /device | Board-level implementation, which complies with the OpenHarmony specifications. For details about the directory structure and porting process, see [Overview](../porting/porting-chip-board-overview.md).|
| /vendor | Product-level implementation, which is contributed by Huawei or product vendors.| | /vendor | Product-level implementation, which is contributed by product vendors. |
The **device** directory is in the internal structure of **device/{Chip solution vendor}/{Development board}**. The following uses HiSilicon **hispark_taurus** as an example: The **device** directory is in the internal structure of **device/{Chip solution vendor}/{Development board}**. The following uses HiSilicon **hispark_taurus** as an example:
...@@ -37,7 +37,7 @@ device ...@@ -37,7 +37,7 @@ device
``` ```
The **vendor** directory is in the internal structure of **vendor/{Product solution vendor}/{Product name}**. The following uses the Huawei Wi-Fi IoT product as an example: The **vendor** directory is in the internal structure of **vendor/{Product solution vendor}/{Product name}**. The following uses the Wi-Fi IoT product as an example:
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册