提交 9c9789bf 编写于 作者: 徐杰

Merge remote-tracking branch 'origin/master' into tiaodan_yafei_0613

Change-Id: I5a7e93de2ade85a290a914fb6bc85b8ce0bd0e54
......@@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path|
| -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/|
| cacheDir | <Path prefix>/<Encryption level>/base/cache/|
| filesDir | <Path prefix>/<Encryption level>/base/files/|
| preferencesDir | <Path prefix>/<Encryption level>/base/preferences/|
| tempDir | <Path prefix>/<Encryption level>/base/temp/|
| databaseDir | <Path prefix>/<Encryption level>/database/|
| distributedFilesDir | <Path prefix>/el2/distributedFiles/|
| bundleCodeDir | \<Path prefix>/el1/bundle/|
| cacheDir | \<Path prefix>/\<Encryption level>/base/cache/|
| filesDir | \<Path prefix>/\<Encryption level>/base/files/|
| preferencesDir | \<Path prefix>/\<Encryption level>/base/preferences/|
| tempDir | \<Path prefix>/\<Encryption level>/base/temp/|
| databaseDir | \<Path prefix>/\<Encryption level>/database/|
| distributedFilesDir | \<Path prefix>/el2/distributedFiles/|
The sample code is as follows:
......@@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path|
| -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/|
| cacheDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/cache/|
| filesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/files/|
| preferencesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/preferences/|
| tempDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/temp/|
| databaseDir | <Path prefix>/<Encryption level>/database/**\<module-name>**/|
| distributedFilesDir | <Path prefix>/el2/distributedFiles/**\<module-name>**/|
| bundleCodeDir | \<Path prefix>/el1/bundle/|
| cacheDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/cache/|
| filesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/files/|
| preferencesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/preferences/|
| tempDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/temp/|
| databaseDir | \<Path prefix>/\<Encryption level>/database/**\<module-name>**/|
| distributedFilesDir | \<Path prefix>/el2/distributedFiles/**\<module-name>**/|
The sample code is as follows:
......
# Setting Atomic Services to Support Sharing
By means of sharing, users can quickly access atomic services and use their features.
## How to Develop
In the sharing scenario, there are two parties involved: a target application that shares data and an application that obtains the shared data. The two can be physically the same. The target application uses the **onShare()** lifecycle callback to set the data to share. After the target application is started, you can run the **hdc shell aa dump -a** command to check the started services and processes and find its mission ID. After the current application is started, call the **abilityManager.acquireShareData()** API with the mission ID passed in to obtain the shared data.
> **NOTE**
>
> The mission ID of the target application can also be obtained by calling [missionManager.getMissionInfos()](../reference/apis/js-apis-app-ability-missionManager.md#getmissioninfos).
1. The target application calls **UIAbility.onShare()** provided by the UIAbility component to set the data to share. **ohos.extra.param.key.contentTitle** indicates the title of the content to share in the sharing box, **ohos.extra.param.key.shareAbstract** provides an abstract description of the content, and **ohos.extra.param.key.shareUrl** indicates the online address of the service. You need to set these three items as objects, with the key set to **title**, **abstract**, and **url**, respectively.
1. An application calls [UIAbility.onShare()](../reference/apis/js-apis-app-ability-uiAbility.md#onshare), a lifecycle callback provided by the UIAbility component, to set the data to share. In this lifecycle callback, **ohos.extra.param.key.contentTitle** indicates the title of the content to share in the sharing box, **ohos.extra.param.key.shareAbstract** provides an abstract description of the content, and **ohos.extra.param.key.shareUrl** indicates the online address of the service. You need to set these three items as objects, with the key set to **title**, **abstract**, and **url**, respectively.
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onShare(wantParams) {
console.log('onShare');
wantParams['ohos.extra.param.key.contentTitle'] = {title: "W3"};
wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for huawei employee"};
wantParams['ohos.extra.param.key.shareUrl'] = {url: "w3.huawei.com"};
wantParams['ohos.extra.param.key.contentTitle'] = {title: "OA"};
wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for company employee"};
wantParams['ohos.extra.param.key.shareUrl'] = {url: "oa.example.com"};
}
}
```
2. The current application calls **abilityManager.acquireShareData()** to obtain the data shared by the target application. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the **missionManager.getMissionInfos()** API after the target application is started. **wantParam** indicates the data shared by the target application through the **UIAbility.onShare()** lifecycle callback.
2. A system dialog box calls [abilityManager.acquireShareData()](../reference/apis/js-apis-app-ability-abilityManager.md#acquiresharedata) to obtain data shared through atomic service sharing. Specifically, the system finds the UIAbility based on the mission ID and calls the **OnShare()** lifecycle of the UIAbility to obtain the shared data.
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
......
......@@ -18,8 +18,85 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
| ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | stopVibration(): Promise&lt;void&gt; | Stops vibration in all modes. This API uses a promise to return the result. |
| ohos.vibrator | stopVibration(callback: AsyncCallback&lt;void&gt;): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | isSupportEffect(effectId: string): Promise&lt;boolean&gt; | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
| ohos.vibrator | isSupportEffect(effectId: string): Promise&lt;boolean&gt; | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
## Custom Vibration Format
Custom vibration enables you to design desired vibration effects by customizing a vibration configuration file and orchestrating vibration forms based on the corresponding rules.
The custom vibration configuration file is in JSON format. An example file is as follows:
```json
{
"MetaData": {
"Create": "2023-01-09",
"Description": "a haptic case",
"Version": 1.0,
"ChannelNumber": 1
},
"Channels": [
{
"Parameters": {
"Index": 1
},
"Pattern": [
{
"Event": {
"Type": "transient",
"StartTime": 0,
"Parameters": {
"Intensity": 100,
"Frequency": 31
}
}
},
{
"Event": {
"Type": "continuous",
"StartTime": 100,
"Duration": 54,
"Parameters": {
"Intensity": 38,
"Frequency": 30
}
}
}
]
}
]
}
```
This JSON file contains two attributes: **MetaData** and **Channels**.
- **MetaData** contains information about the file header. You can add the following attributes under **MetaData**:
- **Version**: version number of the file format, which is forward compatible. Currently, only version 1.0 is supported. This parameter is mandatory.
- **ChannelNumber**: number of channels for vibration. Currently, only one channel is supported, and the value is fixed at **1**. This parameter is mandatory.
- **Create**: time when the file was created. This parameter is optional.
- **Description**: additional information such as the vibration effect and creation information. This parameter is optional.
- **Channels** provides information about the vibration channel. It is a JSON array that holds information about each channel. It contains two attributes: **Parameters** and **Pattern**.
- **Parameters** provides parameters related to the channel. Under it, **Index** indicates the channel ID. The value is fixed at **1** for a single channel. This parameter is mandatory.
- **Pattern** indicates the vibration sequence. It is a JSON array. Under it, **Event** indicates a vibration event, which can be either of the following types:
- **transient**: short vibration
- **continuous**: long vibration
The table below describes the parameters under **Event**.
| Parameter| Description| Value or Value Range|
| --- | ------------------------ | ---|
| Type | Type of the vibration event. This parameter is mandatory.| **transient** or **continuous**|
| StartTime | Start time of the vibration. This parameter is mandatory.| [0, 1800 000], in ms, without overlapping|
| Duration | Duration of the vibration. This parameter is valid only when **Type** is **continuous**.| (10, 1600), in ms|
| Intensity | Intensity of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration strength.|
| Frequency | Frequency of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration frequency|
The following requirements must be met:
| Item| Description |
| -------- | ------------------------ |
| Number of vibration events| No more than 128|
| Length of the vibration configuration file| Not greater than 64 KB|
## How to Develop
......@@ -54,19 +131,19 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js
import vibrator from '@ohos.vibrator';
try {
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission.
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission.
vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
} catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
}
```
4. Stop vibration in all modes.
```js
......@@ -135,3 +212,63 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
console.error('Exception in, error:' + JSON.stringify(error));
}
```
6. Start and stop custom vibration.
```js
import vibrator from '@ohos.vibrator';
import resourceManager from '@ohos.resourceManager';
const FILE_NAME = "xxx.json";
async function openResource(fileName) {
let fileDescriptor = undefined;
let mgr = await resourceManager.getResourceManager();
await mgr.getRawFd(fileName).then(value => {
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
console.log('openResource success fileName: ' + fileName);
}).catch(error => {
console.log('openResource err: ' + error);
});
return fileDescriptor;
}
async function closeResource(fileName) {
let mgr = await resourceManager.getResourceManager();
await mgr.closeRawFd(fileName).then(()=> {
console.log('closeResource success fileName: ' + fileName);
}).catch(error => {
console.log('closeResource err: ' + error);
});
}
// Obtain the file descriptor of the vibration configuration file.
let rawFd = openResource(FILE_NAME);
// To use startVibration and stopVibration, you must configure the ohos.permission.VIBRATE permission.
try {
// Start custom vibration.
vibrator.startVibration({
type: "file",
hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length }
}, {
usage: "alarm"
}).then(() => {
console.info('startVibration success');
}, (error) => {
console.info('startVibration error');
});
// Stop vibration in all modes.
vibrator.stopVibration(function (error) {
if (error) {
console.log('error.code' + error.code + 'error.message' + error.message);
return;
}
console.log('Callback returned to indicate successful.');
})
} catch (error) {
console.info('errCode: ' + error.code + ' ,msg: ' + error.message);
}
// Close the vibration configuration file.
closeResource(FILE_NAME);
```
......@@ -38,7 +38,7 @@ Log level.
| Name | Value | Description |
| ----- | ------ | ------------------------------------------------------------ |
| DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.|
| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,<br>Log level used to record information about unexpected exceptions, such as network signal loss and login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.|
| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running as well as information about unexpected exceptions, such as network signal loss and login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.|
| WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.|
| ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.|
| FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified.
......
......@@ -47,12 +47,12 @@ The following figure shows the application file directories. The path of a file
3. Level 3 directories **el1/** and **el2/**: indicate directories for files of different encryption levels (els).
- **el1**: directory for the data that can be accessed once the device starts. This directory contains device-focused files.
- **el2**: directory for the data that can be accessed only after at lease one successful unlocking operation (by PIN, fingerprint, or facial authentication, or password-free sign-in) upon the start of the device. This directory contains user-focused files.<br>
Unless otherwise required, application data is placed in the **el2** directory for security purposes. However, the data that needs to be accessed before the screen is unlocked (such as the clock, alarm, and wallpaper data) can be placed in the **el1** directory. For details about how to switch to and modify the **el** directories, see [Obtaining and Modifying el Directories](../application-models/application-context-stage.md#obtaining-and-modifying-encryption-areas).
Unless otherwise required, application data is placed in the **el2** directory for security purposes. However, the data that needs to be accessed before the screen is unlocked (such as the clock, alarm, and wallpaper data) can be placed in the **el1** directory. For details about how to switch to and modify the **el** directories, see [Obtaining and Modifying el Directories](../application-models/application-context-stage.md#obtaining-and-modifying-encryption-levels).
4. Level 4 and level 5 directories:
The application's global data is stored in the **files**, **cache**, **preferences**, **temp**, and **distributedfiles** folders in **base**. You can use **ApplicationContext** to obtain the application file paths of these folders.
You can use **UIAbilityContext**, **AbilityStageContext**, and **ExtensionContext** to obtain application file paths related to the OpenHarmoy Ability Package (HAP). When the HAP is uninstalled, the files stored in these directories are automatically deleted, without affecting the files in app-level directories. An application in the development state contains one or more HAPs. For details, see [Application Package Structure in Stage Mode](../quick-start/application-package-structure-stage.md).
You can use **UIAbilityContext**, **AbilityStageContext**, and **ExtensionContext** to obtain application file paths related to the OpenHarmony Ability Package (HAP). When the HAP is uninstalled, the files stored in these directories are automatically deleted, without affecting the files in app-level directories. An application in the development state contains one or more HAPs. For details, see [Application Package Structure in Stage Mode](../quick-start/application-package-structure-stage.md).
For details about how to obtain the context and application file paths, see [Context (Stage Model)](../application-models/application-context-stage.md).
......
# Image Transformation (Native)
You will learn how to use native image APIs to process images, including cropping, rotating, scaling, flipping, translating, and opacity setting.
You will learn how to use native image APIs to process images.
## How to Develop
......@@ -22,9 +22,9 @@ Open the **src/main/cpp/hello.cpp** file and add the following API mappings to t
static napi_value Init(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
{ "createPixelMap", nullptr, CreatePixelMap, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "createAlphaPixelMap", nullptr, CreateAlphaPixelMap, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "transform", nullptr, Transform, nullptr, nullptr, nullptr, napi_default, nullptr }
{ "testGetImageInfo", nullptr, TestGetImageInfo, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "testAccessPixels", nullptr, TestAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "testUnAccessPixels", nullptr, TestUnAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr },
};
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
......@@ -40,159 +40,56 @@ For details about the APIs, see [Image API Reference](../reference/native-apis/i
Obtain the JS resource object from the **hello.cpp** file and convert it to a native resource object. Then you can call native APIs. The sample code is as follows:
1. Create a **PixelMap** object based on a pixel array.
```c++
// Create a PixelMap object.
napi_value CreatePixelMap(napi_env env, napi_callback_info info)
1. Obtain the **PixelMap** information and store the information to the **OhosPixelMapInfo** struct.
```c++
static napi_value TestGetImageInfo(napi_env env, napi_callback_info info)
{
napi_value udfVar = nullptr;
napi_value thisVar = nullptr;
napi_value argValue[2] = {0};
size_t argCount = 2;
napi_value result = nullptr;
napi_get_undefined(env, &result);
void* buffer = nullptr;
size_t bufferSize = 0;
struct OhosPixelMapCreateOps createOps;
napi_value pixelmap = nullptr;
napi_value thisVar = nullptr;
napi_value argValue[1] = {0};
size_t argCount = 1;
napi_get_undefined(env, &udfVar);
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
if (napi_get_arraybuffer_info(env, argValue[0], &buffer, &bufferSize) != napi_ok ||
buffer == nullptr || bufferSize == 0) {
return udfVar;
}
createOps.width = 4;
createOps.height = 6;
createOps.pixelFormat = 4;
createOps.alphaType = 0;
int32_t res = OH_PixelMap_CreatePixelMap(env, createOps, (uint8_t *)buffer, bufferSize, &pixelmap);
if (res != OHOS_IMAGE_RESULT_SUCCESS || pixelmap == nullptr) {
return udfVar;
}
return pixelmap;
OHOS::Media::OhosPixelMapInfo pixelMapInfo;
OHOS::Media::OH_GetImageInfo(env, argValue[0], &pixelMapInfo);
return result;
}
// Create a PixelMap object that contains only the alpha channel.
napi_value CreateAlphaPixelMap(napi_env env, napi_callback_info info)
```
2. Obtain the memory address of a **PixelMap** object and lock the memory.
```c++
static napi_value TestAccessPixels(napi_env env, napi_callback_info info)
{
napi_value udfVar = nullptr;
napi_value result = nullptr;
napi_get_undefined(env, &result);
napi_value thisVar = nullptr;
napi_value argValue[1] = {0};
size_t argCount = 1;
napi_value alphaPixelmap = nullptr;
napi_get_undefined(env, &udfVar);
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok ||
argCount < 1 || argValue[0] == nullptr) {
return udfVar;
}
int32_t res = OH_PixelMap_CreateAlphaPixelMap(env, argValue[0], &alphaPixelmap);
if (res != OHOS_IMAGE_RESULT_SUCCESS || alphaPixelmap == nullptr) {
return udfVar;
}
return alphaPixelmap;
void* addrPtr = nullptr;
OHOS::Media::OH_AccessPixels(env, argValue[0], &addrPtr);
return result;
}
```
2. Perform image transformation. For details about the operation, read the comments in the sample code below.
3. Unlock the memory of the **PixelMap** object.
```c++
napi_value Transform(napi_env env, napi_callback_info info)
static napi_value TestUnAccessPixels(napi_env env, napi_callback_info info)
{
napi_value thisVar = nullptr;
napi_value argValue[1] = {0};
size_t argCount = 1;
if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok ||
argCount < 1 || argValue[0] == nullptr) {
return nullptr;
}
napi_value result = nullptr;
napi_get_undefined(env, &result);
NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[0]);
if (native == nullptr) {
return result;
}
napi_value thisVar = nullptr;
napi_value argValue[1] = {0};
size_t argCount = 1;
// Obtain image information.
struct OhosPixelMapInfo pixelmapInfo;
OH_PixelMap_GetImageInfo(native, &pixelmapInfo);
// Obtain the number of bytes per row of the PixelMap object.
int32_t rowBytes;
OH_PixelMap_GetBytesNumberPerRow(native, &rowBytes);
// Check whether the PixelMap object is editable.
int32_t editable = 0;
OH_PixelMap_GetIsEditable(native, &editable);
// Check whether the PixelMap object supports alpha channels.
int32_t supportAlpha = 0;
OH_PixelMap_IsSupportAlpha(native, &supportAlpha);
// Set an alpha channel for the PixelMap object.
int32_t alphaAble = 0;
OH_PixelMap_SetAlphaAble(native, alphaAble);
// Obtain the pixel density of the PixelMap object.
int32_t densityG;
OH_PixelMap_GetDensity(native, &densityG);
// Set the pixel density for the PixelMap object.
int32_t densityS = 100;
OH_PixelMap_SetDensity(native, densityS);
// Set the opacity for the PixelMap object.
float opacity = 0.5;
OH_PixelMap_SetOpacity(native, opacity);
// Scale the image.
// scaleX: The width of the image after scaling is 0.5 of the original width.
// scaleY: The height of the image after scaling is 0.5 of the original height.
float scaleX = 0.5;
float scaleY = 0.5;
OH_PixelMap_Scale(native, scaleX, scaleY);
// Translate the image.
// translateX: Translate the image by 50 units downwards.
// translateY: Translate the image by 50 units rightwards.
float translateX = 50;
float translateY = 50;
OH_PixelMap_Translate(native, translateX, translateY);
// Rate the image clockwise by 90°.
float angle = 90;
OH_PixelMap_Rotate(native, angle);
// Flip the image.
// flipX: whether to flip the image horizontally. The value 1 means to flip the image and 0 means the opposite.
// flipY: whether to flip the image vertically. The value 1 means to flip the image and 0 means the opposite.
int32_t flipX = 0;
int32_t flipY = 1;
OH_PixelMap_Flip(native, flipX, flipY);
// Crop the image.
// cropX: x-axis coordinate of the start point for cropping (0).
// cropY: y-axis coordinate of the start point for cropping (0).
// cropH: height after cropping (10), cropping from top to bottom.
// cropW: width after cropping (10), cropping from left to right.
int32_t cropX = 1;
int32_t cropY = 1;
int32_t cropW = 10;
int32_t cropH = 10;
OH_PixelMap_Crop(native, cropX, cropY, cropW, cropH);
uint8_t* pixelAddr = nullptr;
// Obtain the memory address of the PixelMap object and lock the memory.
OH_PixelMap_AccessPixels(native, &pixelAddr);
// Unlock the memory of the PixelMap object.
OH_PixelMap_UnAccessPixels(native);
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
OHOS::Media::OH_UnAccessPixels(env, argValue[0]);
return result;
}
```
......@@ -205,37 +102,41 @@ Obtain the JS resource object from the **hello.cpp** file and convert it to a na
```js
import testNapi from 'libentry.so'
import image from '@ohos.multimedia.image'
import image from '@ohos.multimedia.image';
@Entry
@Component
struct Index {
@State _pixelMap: image.PixelMap = undefined;
build() {
Row() {
Column() {
Button("PixelMap")
.width(100)
.height(100)
.onClick(() => {
const color = new ArrayBuffer(96);
var bufferArr = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = 0x80;
}
this._pixelMap = testNapi.createPixelMap(color);
testNapi.transform(this._pixelMap);
@State message: string = 'IMAGE'
@State _PixelMap: image.PixelMap = undefined
build() {
Row() {
Column() {
Button(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(() => {
const color = new ArrayBuffer(96);
let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
this._PixelMap = pixelmap;
})
Image(this._pixelMap)
.width(500)
.height(500)
.objectFit(ImageFit.Cover)
}
.width('100%')
}
.height('100%')
testNapi.testGetImageInfo(this._PixelMap);
console.info("Test GetImageInfo success");
testNapi.testAccessPixels(this._PixelMap);
console.info("Test AccessPixels success");
testNapi.testUnAccessPixels(this._PixelMap);
console.info("Test UnAccessPixels success");
})
}
.width('100%')
}
.height('100%')
}
}
```
......@@ -5,5 +5,6 @@
- [Raw File Development](rawfile-guidelines.md)
- [Native Window Development](native-window-guidelines.md)
- [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md)
- [Using MindSpore Lite for Offline Model Conversion and Inference](mindspore-lite-offline-model-guidelines.md)
- [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md)
- [Purgeable Memory Development](purgeable-memory-guidelines.md)
# Using MindSpore Lite for Offline Model Conversion and Inference
## Basic Concepts
- MindSpore Lite: a built-in AI inference engine of OpenHarmony that provides inference deployment for deep learning models.
- Neural Network Runtime (NNRt): a bridge that connects the upper-layer AI inference framework to the bottom-layer acceleration chip to implement cross-chip inference and computing of AI models.
- Offline model: a model obtained using the offline model conversion tool of the AI hardware vendor. The hardware vendor is responsible for parsing and inference of AI models.
## When to Use
The common process for MindSpore Lite AI model deployment is as follows:
- Use the MindSpore Lite model conversion tool to convert third-party models (such as ONNX and CAFFE) to `.ms` models.
- Call APIs of the MindSpore Lite inference engine to perform model inference. By specifying NNRt as the inference device, you can then use the AI hardware in the system to accelerate inference.
When MindSpore Lite + NNRt inference is used, dynamic image composition in the initial phase will introduce a certain model loading delay.
If you want to reduce the loading delay to meet the requirements of the deployment scenario, you can use offline model-based inference as an alternative. The operation procedure is as follows:
- Use the offline model conversion tool provided by the AI hardware vendor to compile an offline model in advance.
- Use the MindSpore Lite conversion tool to encapsulate the offline model as a black box into the `.ms` model.
- Pass the `.ms` model to MindSpore Lite for inference.
During inference, MindSpore Lite directly sends the offline model to the AI hardware connected to NNRt. This way, the model can be loaded without the need for online image composition, greatly reducing the model loading delay. In addition, MindSpore Lite can provide additional hardware-specific information to assist the AI hardware in model inference.
The following sections describe the offline model inference and conversion process in detail.
## Constraints
- Offline model inference can only be implemented at the NNRt backend. The AI hardware needs to connect to NNRt and supports offline model inference.
## Offline Model Conversion
### 1. Building the MindSpore Lite Release Package
Obtain the [MindSpore Lite source code](https://gitee.com/openharmony/third_party_mindspore). The source code is managed in "compressed package + patch" mode. Run the following commands to decompress the source code package and install the patch:
```bash
cd mindspore
python3 build_helper.py --in_zip_path=./mindspore-v1.8.1.zip --patch_dir=./patches/ --out_src_path=./mindspore-src
```
If the command execution is successful, the complete MindSpore Lite source code is generated in `mindspore-src/source/`.
Run the following commands to start building:
```bash
cd mindspore-src/source/
bash build.sh -I x86_64 -j 8
```
After the building is complete, you can obtain the MindSpore Lite release package from the `output/` directory in the root directory of the source code.
### 2. Writing Extended Configuration File of the Conversion Tool
The offline model comes as a black box and cannot be parsed by the conversion tool to obtain its input and output tensor information. Therefore, you need to manually configure the tensor information in the extended configuration file of the conversion tool. Based on the extended configuration, the conversion tool can then generate the `.ms` model file for encapsulating the offline model.
An example of the extended configuration is as follows:
- `[third_party_model]` in the first line is a fixed keyword that indicates the section of offline model configuration.
- The following lines exhibit the name, data type, shape, and memory format of the input and output tensors of the model respectively. Each field occupies a line and is expressed in the key-value pair format. The sequence of fields is not limited.
- Among the fields, data type and shape are mandatory, and other parameters are optional.
- Extended parameters are also provided. They are used to encapsulate custom configuration of the offline model into an `.ms` file in the the key-value pair format. The `.ms` file is passed to the AI hardware by NNRt during inference.
```text
[third_party_model]
input_names=in_0;in_1
input_dtypes=float32;float32
input_shapes=8,256,256;8,256,256,3
input_formats=NCHW;NCHW
output_names=out_0
output_dtypes=float32
output_shapes=8,64
output_formats=NCHW
extended_parameters=key_foo:value_foo;key_bar:value_bar
```
The related fields are described as follows:
- `input_names` (optional): model input name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them.
- `input_dtypes` (mandatory): model input data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them.
- `input_shapes` (mandatory): model input shape, which is in the integer array format. If multiple input shapes are specified, use a semicolon (`;`) to separate them.
- `input_formats` (optional): model input memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`.
- `output_names` (optional): model output name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them.
- `output_dtypes` (mandatory): model output data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them.
- `output_shapes` (mandatory): model output shape, which is in the integer array format. If multiple output shapes are specified, use a semicolon (`;`) to separate them.
- `output_formats` (optional): model output memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`.
- `extended_parameters` (optional): custom configuration of the inference hardware, which is in the key-value pair format. It is passed to the AI hardware through the NNRt backend during inference.
### 3. Converting an Offline Model
Decompress the MindSpore Lite release package obtained in step 1. Go to the directory where the conversion tool is located (that is, `tools/converter/converter/`), and run the following commands:
```bash
export LD_LIBRARY_PATH=${PWD}/../lib
./converter_lite --fmk=THIRDPARTY --modelFile=/path/to/your_model --configFile=/path/to/your_config --outputFile=/path/to/output_model
```
The offline model conversion is complete.
The related parameters are described as follows:
- `--fmk`: original format of the input model. `THIRDPARTY` indicates an offline model.
- `--modelFile`: path of the input model.
- `--configFile`: path of the extended configuration file. The file is used to configure offline model information.
- `--outputFile`: path of the output model. You do not need to add the file name extension. The `.ms` suffix is generated automatically.
> **NOTE**
>
> If `fmk` is set to `THIRDPARTY`, offline model conversion is performed. In this case, only the preceding four parameters and the extended configuration file take effect.
## Offline Model Inference
Offline model inference is the same as common MindSpore Lite model inference except that only NNRt devices can be added to the inference context.
For details about the MindSpore Lite model inference process, see [Using MindSpore Lite for Model Inference](./mindspore-lite-guidelines.md).
......@@ -12,12 +12,12 @@ The following scenarios are common for native purgeable memory development:
## Available APIs
| API| Description|
| API| Description|
| -------- | -------- |
| OH_PurgeableMemory \*OH_PurgeableMemory_Create(size_t size, OH_PurgeableMemory_ModifyFunc func, void \*funcPara) | Creates a **PurgeableMemory** object. A new **PurgeableMemory** object is generated each time this API is called.|
| bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory \*purgObj) | Destroys a **PurgeableMemory** object.|
| bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory \*purgObj) | Begins a read operation on a **PurgeableMemory** object.|
| void OH_PurgeableMemory_EndRead(OH_PurgeableMemory \*purgObj) | Ends a read operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.|
| OH_PurgeableMemory \*OH_PurgeableMemory_Create(size_t size, OH_PurgeableMemory_ModifyFunc func, void \*funcPara) | Creates a **PurgeableMemory** object. A new **PurgeableMemory** object is generated each time this API is called.|
| bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory \*purgObj) | Destroys a **PurgeableMemory** object.|
| bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory \*purgObj) | Begins a read operation on a **PurgeableMemory** object.|
| void OH_PurgeableMemory_EndRead(OH_PurgeableMemory \*purgObj) | Ends a read operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.|
|bool OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory \*purgObj) | Begins a write operation on a **PurgeableMemory** object.|
|void OH_PurgeableMemory_EndWrite(OH_PurgeableMemory \*purgObj)|Ends a write operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.|
|void \*OH_PurgeableMemory_GetContent(OH_PurgeableMemory \*purgObj)|Obtains the memory data of a **PurgeableMemory** object.|
......@@ -35,34 +35,32 @@ The following steps describe how to use the native purgeable memory APIs to appl
struct ParaData{
int start;
int end;
}
};
// Declare a function for modifying the object.
bool FactorialFunc(void* data, size_t size, void* param){
bool ret = true;
int oriData = *(int*)(data);
int i = param->start;
while(i<param->end){
oriData *= i;
}
*data = oriData;
if(oriData < 0)
ret = false;
return ret;
bool ret = true;
ParaData *pdata = (ParaData*) param;
int* oriData = (int*)data;
int i = pdata->start;
while(i<pdata->end){
*oriData *= i;
}
return ret;
}
// Declare the parameters of the extended function for modifying the object.
struct AppendParaData{
int newPara;
}
};
// Declare the extended function for modifying the object.
bool AddFunc(void* data, size_t size, void* param){
bool ret = true;
int oriData = *(int*)(data);
oriData += param->newPara;
*data = oriData;
return ret;
bool ret = true;
int *oriDatap = (int*) data;
AppendParaData* apData = (AppendParaData*)param;
*oriDatap += apData->newPara;
return ret;
}
```
2. Create a **PurgeableMemory** object.
......@@ -74,11 +72,14 @@ The following steps describe how to use the native purgeable memory APIs to appl
struct ParaData pdata = {1,2};
// Create a PurgeableMemory object.
OH_PurgableMmory* pPurgmem = OH_PurgableMmory_Create(DATASIZE, FactorialFunc, &pdata);
OH_PurgeableMemory* pPurgmem = OH_PurgeableMemory_Create(DATASIZE, FactorialFunc, &pdata);
```
3. Perfrom a read operation on the **PurgeableMemory** object.
```c++
// Define an object type based on the service requirements.
class ReqObj;
// Begin a read operation on the object.
OH_PurgeableMemory_BeginRead(pPurgmem);
......@@ -94,8 +95,11 @@ The following steps describe how to use the native purgeable memory APIs to appl
4. Perform a write operation on the **PurgeableMemory** object.
```c++
// Define an object type based on the service requirements.
class ReqObj;
// Begin a write operation on the object.
OH_PurgeableMemory_BeginWrite(pPurgmem)
OH_PurgeableMemory_BeginWrite(pPurgmem);
// Obtain the object data.
ReqObj* pReqObj = (ReqObj*) OH_PurgeableMemory_GetContent(pPurgmem);
......
......@@ -86,8 +86,10 @@
- [AppStateData](js-apis-inner-application-appStateData.md)
- [BaseContext](js-apis-inner-application-baseContext.md)
- [Context](js-apis-inner-application-context.md)
- [ContinuableInfo](js-apis-inner-application-continuableInfo.md)
- [ContinueCallback](js-apis-inner-application-continueCallback.md)
- [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md)
- [ContinueMissionInfo](js-apis-inner-application-continueMissionInfo.md)
- [ErrorObserver](js-apis-inner-application-errorObserver.md)
- [ExtensionContext](js-apis-inner-application-extensionContext.md)
- [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)
......@@ -194,8 +196,7 @@
- [@ohos.router (Page Routing)](js-apis-router.md)
- [@ohos.measure (Text Measurement)](js-apis-measure.md)
- [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md)
- Graphics
- Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
- [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md)
- [@ohos.display (Display)](js-apis-display.md)
......@@ -207,7 +208,6 @@
- webgl
- [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md)
- Multimedia
- [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md)
- [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md)
......@@ -347,6 +347,7 @@
- [@ohos.brightness (Screen Brightness)](js-apis-brightness.md)
- [@ohos.charger (Charging Type)](js-apis-charger.md)
- [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md)
- [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md)
- [@ohos.deviceInfo (Device Information)](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md)
- [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md)
......@@ -356,6 +357,7 @@
- [@ohos.multimodalInput.inputEvent (Input Event)](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient (Key Event Injection)](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor (Input Monitor)](js-apis-inputmonitor.md)
- [@ohos.multimodalInput.intentionCode (Intention Code)](js-apis-intentioncode.md)
- [@ohos.multimodalInput.keyCode (Key Code)](js-apis-keycode.md)
- [@ohos.multimodalInput.keyEvent (Key Event)](js-apis-keyevent.md)
- [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md)
......@@ -364,6 +366,7 @@
- [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md)
- [@ohos.power (System Power Management)](js-apis-power.md)
- [@ohos.runningLock (Runninglock)](js-apis-runninglock.md)
- [@ohos.resourceschedule.deviceStandby (Device Standby)](js-apis-resourceschedule-deviceStandby.md)
- [@ohos.sensor (Sensor)](js-apis-sensor.md)
- [@ohos.settings (Data Item Settings)](js-apis-settings.md)
- [@ohos.stationary (Device Status Awareness Framework)](js-apis-stationary.md)
......@@ -378,7 +381,7 @@
- [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
- Customization
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
......@@ -421,7 +424,6 @@
- Test
- [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md)
- [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md)
- [@ohos.uitest (UiTest)](js-apis-uitest.md)
- APIs No Longer Maintained
......
......@@ -388,7 +388,7 @@ abilityManager.getTopAbility().then((data) => {
acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Object}>): void;
Acquires the shared data of the target application. This API uses an asynchronous callback to return the result. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the [missionManager.getMissionInfos()](js-apis-app-ability-missionManager.md#getmissioninfos) API after the target application is started. **callback** indicates the data shared by the target application through the [UIAbility.onShare()](js-apis-app-ability-uiAbility.md#onshare) lifecycle callback.
Called by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -429,10 +429,16 @@ try {
acquireShareData(missionId: number): Promise<{[key: string]: Object}>;
Acquires the shared data of the target application. This API uses a promise to return the result. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the [missionManager.getMissionInfos()](js-apis-app-ability-missionManager.md#getmissioninfos) API after the target application is started. **Promise<{[key: string]: Object}>** indicates the data shared by the target application through the [UIAbility.onShare()](js-apis-app-ability-uiAbility.md#onshare) lifecycle callback.
Called by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| missionId | number | Yes| Mission ID on the target application. The maximum value is 2<sup>31</sup>-1.|
**Return value**
| Type | Description |
......
# @ohos.application.formBindingData (formBindingData)
# @ohos.app.form.formBindingData (formBindingData)
The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information.
......@@ -12,6 +12,19 @@ The **FormBindingData** module provides APIs for widget data binding. You can us
import formBindingData from '@ohos.app.form.formBindingData';
```
## ProxyData<sup>10+</sup>
Defines the subscription information about the widget update by proxy.
**System capability**: SystemCapability.Ability.Form
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Subscriber ID of the widget update by proxy. The value is the same as that of the data publisher.|
| subscriberId | string | No| Subscription condition of the widget update by proxy. The default value is the current widget ID (specified by **formId**).|
## FormBindingData
Describes a **FormBindingData** object.
......@@ -21,7 +34,7 @@ Describes a **FormBindingData** object.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| data | Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| proxies<sup>10+</sup> | Array<[ProxyData](#proxydata)> | No| Subscription information of the widget update by proxy. The default value is an empty array.|
## createFormBindingData
......@@ -62,3 +75,14 @@ try {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
## ProxyData
Defines the widget proxy data.
**System capability**: SystemCapability.Ability.Form
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the proxy. The value depends on the data publisher.|
| subscriberId | string | No| Subscriber ID. The value depends on the data publisher. The default value is the current widget ID.|
......@@ -379,15 +379,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that invokes the **replaceAllElements** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Error codes**
......@@ -425,15 +425,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is 0.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......@@ -468,7 +468,7 @@ Sorts elements in this container.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| comparator | function | No| Callback invoked for sorting.|
| comparator | function | No| Callback invoked for sorting. The default value is the callback function for sorting elements in ascending order.|
comparator
......
......@@ -204,7 +204,7 @@ Concatenates an array of **Buffer** instances of the specified length into a new
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| list | Buffer[]&nbsp;\|&nbsp;Uint8Array[] | Yes| Array of instances to concatenate.|
| totalLength | number | No| Total length of bytes to be copied.|
| totalLength | number | No| Total length of bytes to be copied. The default value is **0**.|
**Return value**
......@@ -1915,7 +1915,7 @@ Converts the data at the specified position in this **Buffer** instance into a s
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| encoding | string | No| Encoding format of the string. The default value is **utf-8**.|
| encoding | string | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.|
| start | number | No| Offset to the start position of the data to convert. The default value is **0**.|
| end | number | No| Offset to the end position of the data to convert. The default value is the length of this **Buffer** instance.|
......
......@@ -242,15 +242,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| deque | Deque&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| deque | Deque&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -459,14 +459,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.|
| key | K | No| Key of the element that is currently traversed.|
| map | HashMap<K, V> | No| Instance that invokes the **forEach** method.|
| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | HashMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -282,14 +282,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.|
| key | T | No| Key of the element that is currently traversed (same as **value**).|
| set | HashSet&lt;T&gt; | No| Instance that invokes the **forEach** API.|
| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key | T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.|
| set | HashSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -724,14 +724,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.|
| key | K | No| Key of the element that is currently traversed.|
| map | LightWeightMap<K, V> | No| Instance that invokes the **forEach** method.|
| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | LightWeightMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -588,14 +588,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.|
| key| T | No| Key of the element that is currently traversed (same as **value**).|
| set | LightWeightSet&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key| T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.|
| set | LightWeightSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -607,15 +607,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| LinkedList | LinkedList&lt;T&gt; | No| Instance that invokes the **forEach** API.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| LinkedList | LinkedList&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -427,15 +427,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| list | List&lt;T&gt; | No| Instance that invokes the **replaceAllElements** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| list | List&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Error codes**
......@@ -473,15 +473,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| List | List&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| List | List&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -597,14 +597,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Key of the element that is currently traversed.|
| PlainArray | PlainArray&lt;T&gt;| No| Instance that invokes the **forEach** API.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| PlainArray | PlainArray&lt;T&gt;| No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -176,15 +176,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| Queue | Queue&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| Queue | Queue&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => {
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result.
......@@ -401,7 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType): Promise<void>
removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
Removes a notification slot of a specified type. This API uses a promise to return the result.
......
......@@ -611,7 +611,7 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| actionButton<sup></sup> | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.<br>- For common applications, a maximum of two buttons are supported.<br>- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.|
| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.|
| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
......
# @ohos.resourceschedule.deviceStandby(设备待机模块)
当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。通过本模块接口,可查询设备或应用是否为待机模式,以及为应用申请或取消待机资源管控。
# @ohos.resourceschedule.deviceStandby (Device Standby)
A device enters standby mode if it is unused for a long period of time or after the Power button is pressed. The standby mode prolongs the battery life without affecting the use of applications. The **deviceStandby** module provides APIs for you to check whether a device is in standby mode and request or cancel standby resource control for an application.
> **说明**:
> **NOTE**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。<br>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## 导入模块
## Modules to Import
```js
import deviceStandby from '@ohos.resourceschedule.deviceStandby';
......@@ -15,23 +15,23 @@ import deviceStandby from '@ohos.resourceschedule.deviceStandby';
isDeviceInStandby(callback: AsyncCallback&lt;boolean&gt;): void;
当前设备是否进入待机低功耗续航模式,使用Callback异步回调。
Checks whether the device is in standby mode. This API uses an asynchronous callback to return the result.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**参数**
**Parameters**
| 参数名 | 类型 | 必填 | 说明 |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the device is standby mode.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
......@@ -39,7 +39,7 @@ isDeviceInStandby(callback: AsyncCallback&lt;boolean&gt;): void;
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
try{
......@@ -59,23 +59,23 @@ console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.co
isDeviceInStandby(): Promise&lt;boolean&gt;
当前设备是否进入待机低功耗续航模式,使用Promise异步回调。
Checks whether the device is in standby mode. This API uses a promise to return the result.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**返回值**
**Return value**
| 类型 | 说明 |
| Type | Description |
| --------------------- | ---------------------------------------- |
| Promise&lt;boolean&gt; | 指定的Promise回调方法,返回是否进入待机低功耗续航模式。|
| Promise&lt;boolean&gt; | Promise used to return whether the device is in standby mode.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
......@@ -83,7 +83,7 @@ isDeviceInStandby(): Promise&lt;boolean&gt;
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
try{
......@@ -101,26 +101,26 @@ console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.co
getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array&lt;ExemptedAppInfo&gt;>): void;
获取进入待机模式的应用名单,使用Callback异步回调。
Obtains the list of applications that can still use resources of the specified types when the device is in standby mode. This API uses an asynchronous callback to return the result.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
**参数**
**Parameters**
| 参数名 | 类型 | 必填 | 说明 |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| [ResourceTypes](#resourcetype)|number | 是 | 资源类型。 |
| callback | AsyncCallback<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 是 |豁免应用信息 。|
| [ResourceTypes](#resourcetype)|number | Yes | Types of resources that can be used.|
| callback | AsyncCallback<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | Yes |Callback used to return the exempted application information.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
......@@ -128,7 +128,7 @@ getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array&lt;Exempted
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
try{
......@@ -151,31 +151,31 @@ console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code
getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>;
获取进入待机模式的应用名单,使用Promise异步回调。
Obtains the list of applications that can still use resources of the specified type when the device is in standby mode. This API uses a promise to return the result.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
**参数**
**Parameters**
| 参数名 | 类型 | 必填 | 说明 |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| [ResourceTypes](#resourcetype)|number | 是 |资源类型。|
| [ResourceTypes](#resourcetype)|number | Yes |Types of resources that can be used.|
**返回值**
**Return value**
| 类型 | 说明 |
| Type | Description |
| --------------------- | ---------------------------------------- |
| Promise<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 豁免应用信息。 |
| Promise<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | Promise used to return the exempted application information.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 201 | Permission denied. |
| 202 | Not System App. |
......@@ -186,7 +186,7 @@ getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>;
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
try{
......@@ -207,25 +207,25 @@ console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code
requestExemptionResource(request: ResourceRequest): void;
应用订阅申请豁免,使应用临时不进入待机管控。
Requests exemption, so that the application can use restricted resources when the device is in standby mode.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
**参数**
**Parameters**
| 参数名 | 类型 | 必填 | 说明 |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| request |[ResourceRequest](#resourcerequest)| 是 | 资源请求。 |
| request |[ResourceRequest](#resourcerequest)| Yes | Request body.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
......@@ -233,7 +233,7 @@ requestExemptionResource(request: ResourceRequest): void;
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
let resRequest = {
......@@ -243,7 +243,7 @@ let resRequest = {
duration:10,
reason:"apply",
};
// 异步方法promise方式
// Promise mode
try{
deviceStandby.requestExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.');
......@@ -254,7 +254,7 @@ deviceStandby.requestExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// 异步方法callback方式
// Asynchronous callback mode
try{
deviceStandby.requestExemptionResource(resRequest, (err) => {
if (err) {
......@@ -272,25 +272,25 @@ console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + e
releaseExemptionResource(request: ResourceRequest): void;
取消应用订阅申请豁免。
Cancels exemption for the application.
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
**参数**
**Parameters**
| 参数名 | 类型 | 必填 | 说明 |
| Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------ |
| request |[ResourceRequest](#resourcerequest)| 是 | 资源请求 。|
| request |[ResourceRequest](#resourcerequest)| Yes | Request body.|
**错误码**
**Error codes**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md).
| 错误码ID | 错误信息 |
| ID | Error Message |
| ---- | --------------------- |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
......@@ -298,7 +298,7 @@ releaseExemptionResource(request: ResourceRequest): void;
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed. |
**示例**
**Example**
```js
let resRequest = {
......@@ -308,7 +308,7 @@ let resRequest = {
duration:10,
reason:"unapply",
};
// 异步方法promise方式
// Promise mode
try{
deviceStandby.releaseExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.');
......@@ -319,7 +319,7 @@ deviceStandby.releaseExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// 异步方法callback方式
// Asynchronous callback mode
try{
deviceStandby.releaseExemptionResource(resRequest, (err) => {
if (err) {
......@@ -335,48 +335,48 @@ console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + e
## ResourceType
非待机应用资源枚举。
Enumerates the types of resources that can be used by exempted applications.
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
|名称 |值 |说明|
|Name |Value |Description|
| ------------ | ------------ |--------------|
|NETWORK |1 |网络访问资源|
|RUNNING_LOCK |2 |cpu-runninglock资源|
|TIMER |4 | timer任务资源|
|WORK_SCHEDULER |8 | work任务资源|
|AUTO_SYNC |16 | 自动同步的资源 |
|PUSH |32 | pushkit资源|
|FREEZE |64 | 冻结应用资源|
|NETWORK |1 |Network access resource.|
|RUNNING_LOCK |2 |CPU running lock resource.|
|TIMER |4 | Timer task resource.|
|WORK_SCHEDULER |8 | Work task resource.|
|AUTO_SYNC |16 | Automatic synchronization resource.|
|PUSH |32 | Push kit resource.|
|FREEZE |64 | Freezing application resource.|
## ExemptedAppInfo
豁免应用信息,未进入待机管控的应用信息。
Defines the information about an exempted application.
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
|名称 |类型 | 必填 |说明 |
|Name |Type | Mandatory |Description |
| ------------ | ------------ |------------ | ------------ |
|[resourceTypes](#resourcetype) | number | 是 |应用的资源类型 |
|name |string | 是 | 应用名 |
|duration | number | 是 | 豁免时长 |
|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. |
|name |string | Yes | Name of the application. |
|duration | number | Yes | Exemption duration.|
## ResourceRequest
待机资源请求体。
Defines the message used to request to be an exempted application.
**需要权限:** ohos.permission.DEVICE_STANDBY_EXEMPTION
**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION
**系统API:** 此接口为系统接口。
**System API**: This is a system API.
|名称 |类型 | 必填 |说明 |
|Name |Type | Mandatory |Description |
| ------------ | ------------ |------------| ------------ |
|[resourceTypes](#resourcetype) | number | 是 |应用的资源类型 |
|uid | number | 是 |应用uid |
|name |string | 是 | 应用名称 |
|duration | number | 是 | 豁免时长 |
|reason |string | 是 | 申请原因 |
\ No newline at end of file
|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. |
|uid | number | Yes |UID of the application. |
|name |string | Yes | Name of the application. |
|duration | number | Yes | Exemption duration.|
|reason |string | Yes | Reason for the request. |
......@@ -220,7 +220,7 @@ screenlock.lock().then((data) => {
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications.
Registers a callback for system events related to screen locking. This API can be called only by screen lock applications.
**System capability**: SystemCapability.MiscServices.ScreenLock
......@@ -264,7 +264,7 @@ try {
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void
Sends an event to the screen lock service. This API uses an asynchronous callback to return the result.
Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock
......@@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt;
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 can be called only by screen lock applications. It uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock
......
......@@ -1766,7 +1766,7 @@ promise.then(() => {
setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses an asynchronous callback to return the result.
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Communication.NetStack
......@@ -1818,7 +1818,7 @@ tls.setExtraOptions({
setExtraOptions(options: TCPExtraOptions): Promise\<void\>
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses a promise to return the result.
Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses a promise to return the result.
**System capability**: SystemCapability.Communication.NetStack
......
......@@ -214,15 +214,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| stack | Stack&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| stack | Stack&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void;
Obtains the current charging state and battery level.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
**Parameters**
......@@ -46,7 +46,7 @@ battery.getStatus({
Object that contains the API calling result.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
......@@ -58,7 +58,7 @@ Object that contains the API calling result.
Defines a response that returns the charging status and remaining power of the device.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core
**System capability**: SystemCapability.PowerManager.BatteryManager.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......
......@@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void
Obtains the current screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters**
......@@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void
Sets the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters**
......@@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void
Obtains the screen brightness adjustment mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters**
......@@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void
Sets the screen brightness adjustment mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
Sets whether to always keep the screen on. Call this API in **onShow()**.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters**
......@@ -162,7 +162,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**.
Defines the options for obtaining the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
......@@ -174,7 +174,7 @@ Defines the options for obtaining the screen brightness.
Defines the options for setting the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
......@@ -187,7 +187,7 @@ Defines the options for setting the screen brightness.
Defines a response that returns the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......@@ -197,7 +197,7 @@ Defines a response that returns the screen brightness.
Defines the options for obtaining the screen brightness mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
......@@ -209,7 +209,7 @@ Defines the options for obtaining the screen brightness mode.
Defines the options for setting the screen brightness mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
......@@ -222,7 +222,7 @@ Defines the options for setting the screen brightness mode.
Defines a response that returns the screen brightness mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......@@ -232,7 +232,7 @@ Defines a response that returns the screen brightness mode.
Defines the options for setting the screen to be steady on.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager
**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
......
......@@ -48,7 +48,7 @@ A constructor used to create a **TreeMap** instance.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| comparator | function | No| Custom comparator.|
| comparator | function | No| Custom comparator. The default value is **hole** (a blank placeholder), indicating that no comparator. is provided.|
**Error codes**
......@@ -611,14 +611,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.|
| key | K | No| Key of the element that is currently traversed.|
| map | TreeMap<K, V> | No| Instance that invokes the **forEach** method.|
| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | TreeMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -44,7 +44,7 @@ A constructor used to create a **TreeSet** instance.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| comparator | function | No| Custom comparator.|
| comparator | function | No| Custom comparator. The default value is **hole** (a blank placeholder), indicating that no comparator. is provided.|
**Error codes**
......@@ -484,14 +484,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.|
| key | T | No| Key of the element that is currently traversed.|
| set | TreeSet&lt;T&gt; | No| Instance that invokes the **forEach** method.|
| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.|
| key | T | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| set | TreeSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes**
......
......@@ -586,7 +586,7 @@ result = textEncoder.encodeInto("\uD800¥¥");
### encodeIntoUint8Array<sup>9+</sup>
encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number }
encodeIntoUint8Array(input: string, dest: Uint8Array): { read: number; written: number }
Stores the UTF-8 encoded text.
......@@ -617,7 +617,7 @@ result = that.encodeIntoUint8Array('abcd', dest)
### encodeInto<sup>(deprecated)</sup>
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number }
encodeInto(input: string, dest: Uint8Array): { read: number; written: number }
Stores the UTF-8 encoded text.
......@@ -1100,7 +1100,7 @@ A constructor used to create a **LruCache** instance. The default capacity of th
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ---------------------------- |
| capacity | number | No | Capacity of the **LruCache** to create.|
| capacity | number | No | Capacity of the **LruCache** to create. The default value is **64**.|
**Example**
......@@ -3400,7 +3400,7 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| capacity | number | No| Capacity of the **LruBuffer** to create.|
| capacity | number | No| Capacity of the **LruBuffer** to create. The default value is **64**.|
**Example**
......
......@@ -304,15 +304,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| vector | Vector&lt;T&gt; | No| Instance that invokes the **replaceAllElements** API.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| vector | Vector&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Example**
......@@ -342,15 +342,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for replacement.|
| thisArg | Object | No| Value to use when the callback is invoked.|
| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.|
callbackfn
callbackFn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.|
| vector | Vector&lt;T&gt; | No| Instance that invokes the **forEach** API.|
| index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| vector | Vector&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Example**
......@@ -378,7 +378,7 @@ Sorts elements in this container.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| comparator | function | No| Callback invoked for sorting.|
| comparator | function | No| Callback invoked for sorting. The default value is this instance.|
comparator
......
......@@ -460,8 +460,9 @@ Describes the vibration effect.
| Type | Description |
| -------------------------------- | ------------------------------ |
| [VibrateTime](#vibratetime9) | Triggers vibration with the specified duration. This API uses a promise to return the result.|
| [VibrateTime](#vibratetime9) | Vibration with the specified duration.|
| [VibratePreset](#vibratepreset9) | Vibration with a preset effect.|
| [VibrateFromFile<sup>10+</sup>](#vibratefromfile10) | Vibration according to a custom vibration configuration file.|
## VibrateTime<sup>9+</sup>
......@@ -469,10 +470,10 @@ Describes the vibration with the specified duration.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value| Description |
| -------- | ------ | ------------------------------ |
| type | "time" | Vibration with the specified duration.|
| duration | - | Vibration duration, in ms. |
| Name | Type | Mandatory| Description |
| -------- | ------ | ----- | ------------------------------ |
| type | string | Yes | The value **time** means vibration with the specified duration.|
| duration | number | Yes | Vibration duration, in ms. |
## VibratePreset<sup>9+</sup>
......@@ -480,11 +481,34 @@ Describes the vibration with a preset effect.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value | Description |
| -------- | -------- | ------------------------------ |
| type | "preset" | Vibration with the specified effect.|
| effectId | - | Preset vibration effect ID. |
| count | - | Number of vibrations to repeat. |
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- |------------------------------ |
| type | string | Yes | The value **preset** means vibration with the specified effect.|
| effectId | string | Yes | Preset vibration effect ID. |
| count | number | Yes | Number of vibrations to repeat. |
## VibrateFromFile<sup>10+</sup>
Describes the custom vibration type, which is supported only by certain devices.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------ |
| type | string | Yes | The value **file** means vibration according to a vibration configuration file.|
| hapticFd | [HapticFileDescriptor](#hapticfiledescriptor10) | Yes| File descriptor (FD) of the vibration configuration file.|
## HapticFileDescriptor<sup>10+</sup>
Describes the FD of a custom vibration configuration file. Ensure that the file is available, and the parameters in it can be obtained from the sandbox path through the [file management API](js-apis-file-fs.md#fsopen) or from the HAP resource through the [resource management API](js-apis-resource-manager.md#getrawfd9). The use case is as follows: The system triggers vibration according to the sequence set in a configuration file, based on the specified offset and length. For details about the storage format of the vibration sequence, see [Custom Vibration Format](../../device/vibrator-guidelines.md#custom-vibration-format).
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Mandatory | Description |
| -------- | -------- |--------| ------------------------------|
| fd | number | Yes | FD of the custom vibration configuration file. |
| offset | number | No | Offset from the start position of the file, in bytes. The default value is the start position of the file, and the value cannot exceed the valid range of the file.|
| length | number | No | Resource length, in bytes. The default value is the length from the offset position to the end of the file, and the value cannot exceed the valid range of the file.|
## VibrateAttribute<sup>9+</sup>
......@@ -492,10 +516,10 @@ Describes the vibration attribute.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value| Description |
| ----- | ------ | -------------- |
| id | 0 | Vibrator ID. |
| usage | - | Vibration scenario.|
| Name | Type| Mandatory| Description |
| ----- | ------ | ---- | -------------- |
| id | number | No| Vibrator ID. The default value is 0. |
| usage | [Usage](#usage9) | Yes| Vibration scenario.|
## Usage<sup>9+</sup>
......
......@@ -63,42 +63,6 @@ struct WebComponent {
Implements a **WebMessagePort** object to send and receive messages.
### close
close(): void
Closes this message port.
**System capability**: SystemCapability.Web.Webview.Core
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
msgPort: web_webview.WebMessagePort[] = null;
build() {
Column() {
Button('close')
.onClick(() => {
if (this.msgPort && this.msgPort[1]) {
this.msgPort[1].close();
} else {
console.error("msgPort is null, Please initialize first");
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### postMessageEvent
postMessageEvent(message: WebMessage): void
......@@ -364,6 +328,7 @@ struct WebComponent {
}
```
HTML file to be loaded:
```html
<!--index.html-->
<!DOCTYPE html>
......@@ -448,6 +413,56 @@ function postStringToApp() {
}
```
### close
close(): void
Closes this message port. To use this API, a message port must first be created using [createWebMessagePorts](#createwebmessageports).
**System capability**: SystemCapability.Web.Webview.Core
**Example**
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
msgPort: web_webview.WebMessagePort[] = null;
build() {
Column() {
// Use createWebMessagePorts to create a message port.
Button('createWebMessagePorts')
.onClick(() => {
try {
this.msgPort = this.controller.createWebMessagePorts();
console.log("createWebMessagePorts size:" + this.msgPort.length)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Button('close')
.onClick(() => {
try {
if (this.msgPort && this.msgPort.length == 2) {
this.msgPort[1].close();
} else {
console.error("msgPort is null, Please initialize first");
}
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## WebviewController
Implements a **WebviewController** to control the behavior of the **\<Web>** component. A **WebviewController** can control only one **\<Web>** component, and the APIs (except static APIs) in the **WebviewController** can be invoked only after it has been bound to the target **\<Web>** component.
......@@ -473,7 +488,6 @@ export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
console.log("EntryAbility onCreate")
web_webview.WebviewController.initializeWebEngine()
globalThis.abilityWant = want
console.log("EntryAbility onCreate done")
}
}
......@@ -516,30 +530,11 @@ export default class EntryAbility extends UIAbility {
}
```
### Creating an Object
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### setWebDebuggingAccess
static setWebDebuggingAccess(webDebuggingAccess: boolean): void
Sets whether to enable web debugging.
Sets whether to enable web debugging. For details, see [Debugging Frontend Pages by Using DevTools](../../web/web-debugging-with-devtools.md).
**System capability**: SystemCapability.Web.Webview.Core
......@@ -656,70 +651,73 @@ struct WebComponent {
```
There are three methods for loading local resource files:
1. Using $rawfile
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
1. Using $rawfile
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Load a local resource file through $rawfile.
this.controller.loadUrl($rawfile('index.html'));
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Load a local resource file through $rawfile.
this.controller.loadUrl($rawfile('xxx.html'));
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
2. Using the resources protocol
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Load a local resource file through the resource protocol.
this.controller.loadUrl("resource://rawfile/xxx.html");
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Load a local resource file through the resource protocol.
this.controller.loadUrl("resource://rawfile/index.html");
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
3. Using a sandbox path. For details, see the example of loading local resource files in the sandbox in [Web](../arkui-ts/ts-basic-components-web.md#web).
```html
<!-- xxx.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
### loadData
......@@ -1343,6 +1341,24 @@ struct Index {
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
Hello world!
</body>
<script type="text/javascript">
function htmlTest() {
str = objName.test("test function")
console.log('objName.test result:'+ str)
}
</script>
</html>
```
### runJavaScript
runJavaScript(script: string, callback : AsyncCallback\<string>): void
......@@ -1406,6 +1422,24 @@ struct WebComponent {
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
Hello world!
</body>
<script type="text/javascript">
function test() {
console.log('Ark WebComponent')
return "This value is from index.html"
}
</script>
</html>
```
### runJavaScript
runJavaScript(script: string): Promise\<string>
......@@ -1444,11 +1478,9 @@ import web_webview from '@ohos.web.webview'
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State webResult: string = '';
build() {
Column() {
Text(this.webResult).fontSize(20)
Web({ src: $rawfile('index.html'), controller: this.controller })
.javaScriptAccess(true)
.onPageEnd(e => {
......@@ -1470,6 +1502,23 @@ struct WebComponent {
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>
Hello world!
</body>
<script type="text/javascript">
function test() {
console.log('Ark WebComponent')
return "This value is from index.html"
}
</script>
</html>
```
### runJavaScriptExt<sup>10+</sup>
......@@ -1569,8 +1618,11 @@ struct WebComponent {
}
}
}
```
//index.html
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html lang="en-gb">
<body>
......@@ -1681,8 +1733,11 @@ struct WebComponent {
}
}
}
```
//index.html
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
<html lang="en-gb">
<body>
......@@ -2178,14 +2233,15 @@ struct WebComponent {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: $rawfile('xxx.html'), controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -2973,14 +3029,15 @@ struct WebComponent {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -3045,14 +3102,15 @@ struct WebComponent {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -3117,14 +3175,15 @@ struct WebComponent {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -3640,7 +3699,7 @@ struct WebComponent {
.onClick(() => {
try {
let state = this.controller.serializeWebState();
// Obtain the value of globalThis.cacheDir from MainAbility.ts.
// globalThis.cacheDir is obtained from EntryAbility.ts.
let path = globalThis.cacheDir;
path += '/WebState';
// Synchronously open a file.
......@@ -3657,14 +3716,14 @@ struct WebComponent {
}
```
2. Modify **MainAbility.ts**.
2. Modify the **EntryAbility.ts** file.
Obtain the path of the application cache file.
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class MainAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind cacheDir to the globalThis object to implement data synchronization between the UIAbility component and the page.
globalThis.cacheDir = this.context.cacheDir;
......@@ -3712,7 +3771,7 @@ struct WebComponent {
Button('RestoreWebState')
.onClick(() => {
try {
// Obtain the value of globalThis.cacheDir from MainAbility.ts.
// globalThis.cacheDir is obtained from EntryAbility.ts.
let path = globalThis.cacheDir;
path += '/WebState';
// Synchronously open a file.
......@@ -3739,14 +3798,14 @@ struct WebComponent {
}
```
2. Modify **MainAbility.ts**.
2. Modify the **EntryAbility.ts** file.
Obtain the path of the application cache file.
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import web_webview from '@ohos.web.webview';
export default class MainAbility extends UIAbility {
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// Bind cacheDir to the globalThis object to implement data synchronization between the UIAbility component and the page.
globalThis.cacheDir = this.context.cacheDir;
......@@ -6230,6 +6289,9 @@ Describes the mode in which the **\<Web>** component uses HTTPDNS.
| Name | Value| Description |
| ------------- | -- |----------------------------------------- |
| Off | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.|
| Auto | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.|
| SecureOnly | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.|
| Off<sup>(deprecated)</sup> | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.<br>This API is deprecated since API version 10. You are advised to use **OFF** instead.|
| Auto<sup>(deprecated)</sup> | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.<br>This API is deprecated since API version 10. You are advised to use **AUTO** instead.|
| SecureOnly<sup>(deprecated)</sup> | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.<br>This API is deprecated since API version 10. You are advised to use **SECURE_ONLY** instead.|
| OFF | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.|
| AUTO | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.|
| SECURE_ONLY | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.|
......@@ -381,6 +381,7 @@ Creates and returns an **XmlPullParser** object.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
......@@ -432,6 +433,7 @@ Parses XML information.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -499,6 +501,7 @@ Obtains the column line number, starting from 1.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -542,6 +545,7 @@ Obtains the depth of this element.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -588,6 +592,7 @@ Obtains the current line number, starting from 1.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -631,6 +636,7 @@ Obtains the name of this element.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -673,6 +679,7 @@ Obtains the namespace of this element.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -715,6 +722,7 @@ Obtains the prefix of this element.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -758,6 +766,7 @@ Obtains the text of the current event.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -800,6 +809,7 @@ Checks whether the current element is empty.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -842,6 +852,7 @@ Checks whether the current text event contains only whitespace characters.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......@@ -883,6 +894,7 @@ Obtains the number of attributes for the current start tag.
**Example**
```js
import util from '@ohos.util';
let strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' +
......
......@@ -557,3 +557,10 @@ This API is supported in ArkTS widgets.
| LIGHT | Small area (light)| Spring effect, with stiffness of 410, damping of 38, and initial velocity of 1.| 90% |
| MIDDLE | Medium area (stable)| Spring effect, with stiffness of 350, damping of 35, and initial velocity of 0.5.| 95% |
| HEAVY | Large area (heavy)| Spring effect, with stiffness of 240, damping of 28, and initial velocity of 0.| 95% |
## TextContentStyle<sup>10+</sup>
| Name | Description |
| ------- | ------------------------------------------------------------ |
| DEFAULT | Default style. The caret width is fixed at 1.5 vp, and the caret height is subject to the background height and font size of the selected text.|
| INLINE | Inline input style. The background height of the selected text is the same as the height of the text box. |
......@@ -26,7 +26,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| ----------- | ---------- | ------------------ |
| vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Default value: **'\#33182431'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.|
| strokeWidth | number \| string | Width of the divider.<br>Default value: **1px**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.|
| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.|
......
......@@ -21,7 +21,7 @@ Not supported
Image(src: PixelMap | ResourceStr | DrawableDescriptor)
Obtains an image from the specified source for subsequent rendering and display.
Obtains an image from the specified source for subsequent rendering and display. If the **\<Image>** component fails to obtain the image or the obtained image size is 0, the **\<Image>** component is automatically resized to 0 and does not follow the layout constraints of its parent component.
Since API version 9, this API is supported in ArkTS widgets.
......@@ -29,7 +29,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | ---------------------------------------- |
| src | [PixelMap](../apis/js-apis-image.md#pixelmap7) \| ResourceStr\| [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use **\$r** to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], where [base64 data] is a Base64 string.<br/>\- Strings with the **datashare://** prefix are supported, which are used to access the image path provided by a Data ability.<br/>\- Strings with the **file:///data/storage** prefix are supported, which are used to read image resources in the **files** folder in the installation directory of the current application. Ensure that the application has the read permission to the files in the specified path.<br/>\- [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) objects are supported.<br/>- For details, see [Displaying Images](../../ui/arkts-graphics-display.md).<br/>**NOTE**<br/>- ArkTS widgets support GIF animations, but the animations only play once on display.<br/>- ArkTS widgets do not support the strings with the **http://**, **datashare://**, or **file:///data/storage** prefix.<br>- ArkTS widgets do not support the [PixelMap](../apis/js-apis-image.md#pixelmap7) type.|
| src | [PixelMap](../apis/js-apis-image.md#pixelmap7) \|ResourceStr\| [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | Yes | Image source. Both local and online images are supported.<br>When using an image referenced using a relative path, for example, **Image("common/test.jpg")**, the **\<Image>** component cannot be called across bundles or modules. Therefore, you are advised to use **\$r** to reference image resources that need to be used globally.<br>- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.<br>\- Base64 strings are supported. The value format is data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data], where [base64 data] is a Base64 string.<br/>\- Strings with the **datashare://** prefix are supported, which are used to access the image path provided by a Data ability.<br/>\- Strings with the **file:///data/storage** prefix are supported, which are used to read image resources in the **files** folder in the installation directory of the current application. Ensure that the application has the read permission to the files in the specified path.<br/>\- [DrawableDescriptor](../apis/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) objects are supported.<br/>- For details, see [Displaying Images](../../ui/arkts-graphics-display.md).<br/>**NOTE**<br/>- ArkTS widgets support GIF animations, but the animations only play once on display.<br/>- ArkTS widgets do not support the strings with the **http://**, **datashare://**, or **file:///data/storage** prefix.<br>- ArkTS widgets do not support the [PixelMap](../apis/js-apis-image.md#pixelmap7) type.|
## Attributes
......@@ -50,7 +50,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| syncLoad<sup>8+</sup> | boolean | Whether to load the image synchronously. By default, the image is loaded asynchronously. During synchronous loading, the UI thread is blocked and the placeholder diagram is not displayed.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether the image can be copied. (SVG images cannot be copied.)<br>When **copyOption** is set to a value other than **CopyOptions.None**, the image can be copied in various manners, such as long pressing, right-clicking, or pressing Ctrl+C.<br>Default value: **CopyOptions.None**<br>This API is supported in ArkTS widgets.|
| colorFilter<sup>9+</sup> | [ColorFilter](ts-types.md#colorfilter9) | Color filter of the image.<br>This API is supported in ArkTS widgets. |
| draggable<sup>9+</sup> | boolean | Whether the image is draggable. This attribute cannot be used together with the [onDragStart](ts-universal-events-drag-drop.md) event.<br>Default value: **false**<br>This API is supported in ArkTS widgets.|
| draggable<sup>(deprecated)</sup> | boolean | Whether the image is draggable. This attribute cannot be used together with the [onDragStart](ts-universal-events-drag-drop.md) event.<br>Default value: **false**<br>This API is supported in ArkTS widgets.<br>**NOTE**<br>This API is supported since API version 8 and deprecated since API version 10. You are advised to use the universal attribute [draggable](ts-universal-events-drag-drop.md) instead.|
> **NOTE**
>
......
# Progress
The **\<Progress>** component is used to provide a progress indicator that displays the progress of content loading or an operation.
The **\<Progress>** component represents a progress indicator that displays the progress of content loading or an operation.
> **NOTE**
>
......@@ -22,47 +22,77 @@ Since API version 9, this API is supported in ArkTS widgets.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | Yes| Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used.<br>Since API version 9, this API is supported in ArkTS widgets.|
| total | number | No| Total progress.<br>Default value: **100**<br>Since API version 9, this API is supported in ArkTS widgets.|
| type<sup>8+</sup> | [ProgressType](#progresstype) | No| Style the progress indicator.<br>Default value: **ProgressType.Linear**<br>Since API version 9, this API is supported in ArkTS widgets.|
| style<sup>deprecated</sup> | [ProgressStyle](#progressstyle) | No| Type of the progress indicator.<br>This parameter is deprecated since API version 8. You are advised to use **type** instead.<br>Default value: **ProgressStyle.Linear**|
| Name | Type | Mandatory | Description |
| -------------------------- | ----------------------------------- | ---- | ---------------------------------------- |
| value | number | Yes | Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used.<br>Since API version 9, this API is supported in ArkTS widgets.|
| total | number | No | Total progress.<br>Default value: **100**<br>Since API version 9, this API is supported in ArkTS widgets.|
| type<sup>8+</sup> | [ProgressType](#progresstype) | No | Style of the progress indicator.<br>Default value: **ProgressType.Linear**<br>Since API version 9, this API is supported in ArkTS widgets.|
| style<sup>deprecated</sup> | [ProgressStyle](#progressstyle) | No | Style of the progress indicator.<br>This parameter is deprecated since API version 8. You are advised to use **type** instead.<br>Default value: **ProgressStyle.Linear**|
## ProgressType
Since API version 9, this API is supported in ArkTS widgets.
| Name| Description|
| -------- | -------- |
| Linear | Linear type. Since API version 9, the progress indicator adaptively switches to vertical layout if the height is greater than the width.|
| Ring<sup>8+</sup> | Indeterminate ring type. The ring fills up as the progress increases.|
| Eclipse<sup>8+</sup> | Eclipse type, which visualizes the progress in a way similar to the moon waxing from new to full.|
| ScaleRing<sup>8+</sup> | Determinate ring type, which is similar to the clock scale. Since API version 9, when the outer circles of scales overlap, the progress indicator is automatically converted to the **Ring** type.|
| Capsule<sup>8+</sup> | Capsule type. At both ends, the progress indicator works in a same manner as the eclipse type. In the middle part of the capsule, the progress indicator works in a same manner as the linear type. If the height is greater than the width, the progress indicator adaptively switches to vertical layout.|
| Name | Description |
| ---------------------- | ---------------------------------------- |
| Linear | Linear style. Since API version 9, the progress indicator adaptively switches to vertical layout if the height is greater than the width. |
| Ring<sup>8+</sup> | Indeterminate ring style. The ring fills up as the progress increases. |
| Eclipse<sup>8+</sup> | Eclipse style, which visualizes the progress in a way similar to the moon waxing from new to full. |
| ScaleRing<sup>8+</sup> | Determinate ring style, which is similar to the clock scale. Since API version 9, when the outer circles of scales overlap, the progress indicator is automatically converted to the **Ring** style.|
| Capsule<sup>8+</sup> | Capsule style. At both ends, the progress indicator works in a same manner as the eclipse style. In the middle part of the capsule, the progress indicator works in a same manner as the linear style. If the height is greater than the width, the progress indicator adaptively switches to vertical layout.|
## ProgressStyle
Since API version 9, this API is supported in ArkTS widgets.
| Name | Description |
| --------- | ------------------------------------------------------------ |
| Linear | Linear type.|
| Ring | Indeterminate ring type. The ring fills up as the progress increases.|
| Eclipse | Eclipse type, which visualizes the progress in a way similar to the moon waxing from new to full.|
| ScaleRing | Determinate ring type, which is similar to the clock scale.|
| Capsule | Capsule type. At both ends, the progress indicator works in a same manner as the eclipse type. In the middle part of the capsule, the progress indicator works in a same manner as the linear type. If the height is greater than the width, the progress indicator adaptively switches to vertical layout.|
| Name | Description |
| --------- | ---------------------------------------- |
| Linear | Linear style. |
| Ring | Indeterminate ring style. The ring fills up as the progress increases. |
| Eclipse | Eclipse style, which visualizes the progress in a way similar to the moon waxing from new to full. |
| ScaleRing | Determinate ring style, which is similar to the clock scale. |
| Capsule | Capsule style. At both ends, the progress indicator works in a same manner as the eclipse style. In the middle part of the capsule, the progress indicator works in a same manner as the linear style. If the height is greater than the width, the progress indicator adaptively switches to vertical layout.|
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name| Type| Description|
| -------- | -------- | -------- |
| value | number | Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used. Invalid values do not take effect.<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Default value: **'\#ff007dff'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Default value: **'\#19182431'**<br><br>Since API version 9, this API is supported in ArkTS widgets.|
| style<sup>8+</sup> | {<br>strokeWidth?: [Length](ts-types.md#length),<br>scaleCount?: number,<br>scaleWidth?: [Length](ts-types.md#length)<br>} | Component style.<br>- **strokeWidth**: stroke width of the progress indicator. It cannot be set in percentage. Since API version 9, if the stroke width of the ring progress bar is greater than or equal to the radius, the width is changed to half of the radius.<br>Default value: **4.0Vp**<br>- **scaleCount**: number of divisions on the determinate ring-type process indicator.<br>Default value: **120**<br>- **scaleWidth**: scale width of the ring progress bar. It cannot be set in percentage. If it is greater than the value of **strokeWidth**, the default scale width is used.<br>Default value: **2.0Vp**<br>Since API version 9, this API is supported in ArkTS widgets.|
| Name | Type | Description |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| value | number | Current progress. If the value is less than 0, the value **0** is used. If the value is greater than that of **total**, the value of **total** is used. Invalid values do not take effect.<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) \| [LinearGradient<sup>10+</sup>](ts-basic-components-datapanel.md#lineargradient10) | Background color of the progress indicator. Since API version 10, this attribute can be set to **LinearGradient** for the **Ring** style.<br>Default value (API version 9): **'\#ff007dff'**<br>Default value (API version 10):<br>- Capsule: **'\#33006cde'**<br>- Ring: starting point: **'\#ff3b61f7'**, ending point: **'\#ff6591bf'**<br>- Other styles: **'\#ff007dff'**<br>Since API version 9, this API is supported in ArkTS widgets, except that **LinearGradient** is not supported.|
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | Background color of the progress indicator.<br>Default value (API version 9): **'\#19182431'**<br>Default value (API version 10):<br>- Capsule: **'\#33ffffff'**<br>- Ring: **'\#08182431'**<br>- Other styles: **'\#19182431'**<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>The settings of the universal attribute [backgroundColor](./ts-universal-attributes-background.md) applies to the progress indicator instead of the entire **\<Progress>** component.|
| style<sup>8+</sup> | [ProgressStyleOptions](#progressstyleoptions) \| [CapsuleStyleOptions<sup>10+</sup>](#capsulestyleoptions10) \| [RingStyleOptions<sup>10+</sup>](#ringstyleoptions10) | Component style. Since API version 10, this attribute can be set to **CapsuleStyleOptions** or **RingStyleOptions**.<br>- **CapsuleStyleOptions** is available for the **Capsule** style.<br>- **RingStyleOptions** is available for the **Ring** style.<br>- **ProgressStyleOptions** is available for other styles.<br>Since API version 9, this API is supported in ArkTS widgets, except that **CapsuleStyleOptions** and **RingStyleOptions** are not supported.|
## ProgressStyleOptions
| Name | Type | Mandatory| Description |
| ------------ | ---------------------------- | ---- | ------------------------------------------------------------------------------------------ |
| strokeWidth | [Length](ts-types.md#length) | No | Stroke width of the progress indicator. It cannot be set in percentage.<br>Default value: **4.0Vp** |
| scaleCount | number | No | Number of divisions on the ring-style process indicator.<br>Default value: **120** |
| scaleWidth | [Length](ts-types.md#length) | No | Scale width of the ring-style progress bar. It cannot be set in percentage. If it is greater than the value of **strokeWidth**, the default scale width is used.<br>Default value: **2.0Vp**|
## CapsuleStyleOptions<sup>10+</sup>
| Name | Type| Mandatory| Description|
| ------------- | ------- | ---- | -------- |
| borderColor | [ResourceColor](ts-types.md#resourcecolor) | No| Border color.<br>Default value: **'\#33006cde'**|
| borderWidth | [Length](ts-types.md#length) | No| Border width. It cannot be set in percentage.<br>Default value: **1 Vp**|
| content | string | No| Text content, which can be customized .|
| font | [Font](ts-types.md#font) | No| Text style.<br>Default value:<br>- Font size (cannot be set in percentage): **12Fp**<br>- Other attributes: following the settings of the **\<Text>** component.|
| fontColor | [ResourceColor](ts-types.md#resourcecolor) | No| Font color.<br>Default value: **'\#ff182431'**|
| enableScanEffect | boolean | No| Whether to enable the scan effect.<br>Default value: **false**|
## RingStyleOptions<sup>10+</sup>
| Name | Type | Mandatory| Description |
| ------------- | ---------------------------- | ---- | ------------------------------------------------------------------------------------------ |
| strokeWidth | [Length](ts-types.md#length) | No | Stroke width of the progress indicator. It cannot be set in percentage. A value greater than or equal to the radius evaluates to half of the radius.<br>Default value: **4Vp**|
| shadow | boolean | No | Whether to enable the shadow effect.<br>Default value: **false** |
| status | [ProgressStatus<sup>10+</sup>](#progressstatus10) | No| Status of the progress indicator. When this parameter is set to **LOADING**, the **value** settings do not take effect.<br>Default value: **ProgressStatus.PROGRESSING**|
## ProgressStatus<sup>10+</sup>
| Name | Description |
| ----------------------- | ---------------- |
| LOADING<sup>10+</sup> | Loading.|
| PROGRESSING<sup>10+</sup> | The progress is being updated.|
## Events
......@@ -111,7 +141,7 @@ struct ProgressExample {
Progress({ value: 10, type: ProgressType.Ring }).width(100)
Progress({ value: 20, total: 150, type: ProgressType.Ring })
.color(Color.Grey).value(50).width(100)
.style({ strokeWidth: 20, scaleCount: 30, scaleWidth: 20 })
.style({ strokeWidth: 20 })
}
Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
......@@ -128,4 +158,4 @@ struct ProgressExample {
}
```
![progress](figures/progress.png)
![progress](figures/arkts-progress.png)
......@@ -20,29 +20,32 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex
| Name | Type | Mandatory | Description |
| ----------------------- | ---------------------------------------- | ---- | -------------- |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | No | Placeholder text displayed when there is no input. It is not displayed once there is any input. |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | No | Placeholder text displayed when no text input is set. <br>When only the **placeholder** attribute is set, the text selection handle is still available; and the caret moves back to the beginning of the placeholder text when the handle is released. |
| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.<br>If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,<br>so as to prevent display errors when the component is updated.<br>Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.|
| controller<sup>8+</sup> | [TextAreaController](#textareacontroller8) | No | Text area controller.|
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name | Type | Description |
| ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color. |
| placeholderFont | [Font](ts-types.md#font) | Placeholder text style, including the font size, font width, font family, and font style. Currently, only the default font family is supported.|
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.<br>Default value: **TextAlign.Start**|
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but the copy and cut operations are not.|
Among the [universal attributes](ts-universal-attributes-size.md) and [universal text attributes](ts-universal-attributes-text-style.md), **fontColor**, **fontSize**, **fontStyle**, **fontWeight**, and **fontFamily** are supported. In addition, the following attributes are supported.
| Name | Type | Description |
| ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color.<br>The default value follows the theme. |
| placeholderFont | [Font](ts-types.md#font) | Placeholder text style, including the font size, font width, font family, and font style. Currently, only the default font family is supported.|
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.<br>Default value: **TextAlign.Start**<br>**NOTE**<br>Available options are **TextAlign.Start**, **TextAlign.Center**, and **TextAlign.End**.<br>To set vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute. The **align** attribute alone does not control the horizontal position of the text. In other words, **Alignment.TopStart**, **Alignment.Top**, and **Alignment.TopEnd** produce the same effect, top-aligning the text; **Alignment.Start**, **Alignment.Center**, and **Alignment.End** produce the same effect, centered-aligning the text vertically; **Alignment.BottomStart**, **Alignment.Bottom**, and **Alignment.BottomEnd** produce the same effect, bottom-aligning the text.|
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box.<br>Default value: **'#007DFF'** |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) => void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>Default value: **CopyOptions.LocalDevice**<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but the copy and cut operations are not.|
| maxLength<sup>10+</sup> | number | Maximum number of characters in the text input.<br>By default, there is no maximum number of characters.|
| showCounter<sup>10+</sup> | boolean | Whether to show the number of entered characters when **maxLength** is set.<br>Default value: **false** |
| style<sup>10+</sup> | [TextContentStyle](ts-appendix-enums.md#textcontentstyle10) | Style of the component.<br>Default value: **TextContentStyle.DEFAULT** |
| enableKeyboardOnFocus<sup>10+</sup> | boolean | Whether to enable the input method when the component obtains focus.<br>Default value: **true** |
> **NOTE**
>
> The default value of the universal attribute [padding](ts-universal-attributes-size.md) is as follows: <br>{<br> top: 8 vp,<br> right: 16 vp,<br> bottom: 8 vp,<br> left: 16 vp<br> }
## Events
In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
......
......@@ -21,30 +21,35 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te
| Name | Type | Mandatory | Description |
| ----------------------- | ---------------------------------------- | ---- | --------------- |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | No | Placeholder text displayed when there is no input. |
| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.<br>If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event,<br>so as to prevent display errors when the component is updated.<br>Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables.|
| text | [ResourceStr](ts-types.md#resourcestr) | No | Current text input.<br>If the component has [stateStyles](ts-universal-attributes-polymorphic-style.md) or any other attribute that may trigger updating configured, you are advised to bind the state variable to the text in real time through the **onChange** event, so as to prevent display errors when the component is updated.<br>Since API version 10, this parameter supports [$$](../../quick-start/arkts-two-way-sync.md) for two-way binding of variables. |
| controller<sup>8+</sup> | [TextInputController](#textinputcontroller8) | No | Text input controller.|
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
Among the [universal attributes](ts-universal-attributes-size.md) and [universal text attributes](ts-universal-attributes-text-style.md), **fontColor**, **fontSize**, **fontStyle**, **fontWeight**, and **fontFamily** are supported. In addition, the following attributes are supported.
| Name | Type | Description |
| ------------------------ | ---------------------------------------- | ---------------------------------------- |
| type | [InputType](#inputtype) | Input box type.<br>Default value: **InputType.Normal** |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color.|
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | Placeholder text color.<br>The default value follows the theme. |
| placeholderFont | [Font](ts-types.md#font) | Placeholder text font.|
| enterKeyType | [EnterKeyType](#enterkeytype) | Type of the Enter key. Currently, only the default value is supported.<br>Default value: **EnterKeyType.Done**|
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box. |
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the caret in the text box.<br>Default value: **'#007DFF'** |
| maxLength | number | Maximum number of characters in the text input. |
| inputFilter<sup>8+</sup> | {<br>value: [ResourceStr](ts-types.md#resourcestr),<br>error?: (value: string) =&gt; void<br>} | Regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The regular expression can match single characters, but not strings.<br>- **value**: regular expression to set.<br>- **error**: filtered-out content to return when regular expression matching fails.|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
| showPasswordIcon<sup>9+</sup> | boolean | Whether to display the show password icon at the end of the password text box.<br>Default value: **true**|
| style<sup>9+</sup> | [TextInputStyle](#textinputstyle9) | Text input style.<br>Default value: **TextInputStyle.Default**|
| textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Alignment mode of the text in the text box.<br>Default value: **TextAlign.Start** |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Whether copy and paste is allowed.<br>Default value: **CopyOptions.LocalDevice**<br>If this attribute is set to **CopyOptions.None**, the paste operation is allowed, but not the copy or cut operation.|
| showPasswordIcon<sup>9+</sup> | boolean | Whether to display the password icon at the end of the password text box.<br>Default value: **true**|
| style<sup>9+</sup> | [TextInputStyle](#textinputstyle9) \| [TextContentStyle](ts-appendix-enums.md#textcontentstyle10) | Text input style.<br>Default value: **TextInputStyle.Default**|
| textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | Horizontal alignment of the text.<br>Default value: **TextAlign.Start**<br>**NOTE**<br>Available options are **TextAlign.Start**, **TextAlign.Center**, and **TextAlign.End**.<br>To set vertical alignment for the text, use the [align](ts-universal-attributes-location.md) attribute. The **align** attribute alone does not control the horizontal position of the text. In other words, **Alignment.TopStart**, **Alignment.Top**, and **Alignment.TopEnd** produce the same effect, top-aligning the text; **Alignment.Start**, **Alignment.Center**, and **Alignment.End** produce the same effect, centered-aligning the text vertically; **Alignment.BottomStart**, **Alignment.Bottom**, and **Alignment.BottomEnd** produce the same effect, bottom-aligning the text. |
| selectedBackgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.<br>If the opacity is not set, the color is opaque. For example, **0x80000000** indicates black with 50% opacity.|
| caretStyle<sup>10+</sup> | {<br>width: [Length](ts-types.md#length)<br>} | Caret style. |
| caretPosition<sup>10+</sup> | number | Caret position.|
| showUnit<sup>10+</sup> | [CustomBuilder](ts-types.md#CustomBuilder8) | Unit for content in the component.<br>By default, there is no unit.|
| showError<sup>10+</sup> | string \| undefined | Error text displayed when an error occurs.<br>By default, no error text is displayed.|
| showUnderline<sup>10+</sup> | boolean | Whether to show an underline.<br>Default value: **false**|
| passwordIcon<sup>10+</sup> | [PasswordIcon](#passwordicon10) | Password icon to display at the end of the password text box.<br>By default, the system-provided icon is used.|
| enableKeyboardOnFocus<sup>10+</sup> | boolean | Whether to enable the input method when the component obtains focus.<br>Default value: **true** |
> **NOTE**
>
......@@ -77,6 +82,13 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Default | Default style. The caret width is fixed at 1.5 vp, and the caret height is subject to the background height and font size of the selected text. |
| Inline | Inline input style. The background height of the selected text is the same as the height of the text box. |
## PasswordIcon<sup>10+</sup>
| Name | Type | Mandatory| Description |
| ---------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
| onIconSrc | string \|[Resource](ts-types.md#resource)| No | Icon that can be used to hide the password in password input mode.|
| offIconSrc | string \|[Resource](ts-types.md#resource)| No | Icon that can be used to show the password in password input mode.|
## Events
In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
......
......@@ -87,28 +87,28 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
Example of loading local resource files in the sandbox:
1. Use [globalthis](../../application-models/uiability-data-sync-with-ui.md#using-globalthis-between-uiability-and-page) to obtain the path of the sandbox.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
let url = 'file://' + globalThis.filesDir + '/xxx.html'
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
// Load the files in the sandbox.
Web({ src: url, controller: this.controller })
}
}
}
```
1. Use [globalthis](../../application-models/uiability-data-sync-with-ui.md#using-globalthis-between-uiability-and-ui-page) to obtain the path of the sandbox.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview'
let url = 'file://' + globalThis.filesDir + '/index.html'
2. Modify the **MainAbility.ts** file.
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining the Application Development Path](../../application-models/application-context-stage.md#obtaining-the-application-development-path).
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
// Load the files in the sandbox.
Web({ src: url, controller: this.controller })
}
}
}
```
2. Modify the **EntryAbility.ts** file.
The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths).
```ts
// xxx.ts
import UIAbility from '@ohos.app.ability.UIAbility';
......@@ -123,6 +123,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController})
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
......@@ -587,15 +588,16 @@ Sets whether to display the horizontal scrollbar, including the default system s
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
.horizontalScrollBarAccess(true)
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -640,15 +642,16 @@ Sets whether to display the vertical scrollbar, including the default system scr
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
Web({ src: $rawfile('index.html'), controller: this.controller })
.verticalScrollBarAccess(true)
}
}
}
```
HTML file to be loaded:
```html
<!--xxx.html-->
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -669,6 +672,11 @@ Sets whether to display the vertical scrollbar, including the default system scr
</html>
```
### password
password(password: boolean)
Sets whether the password should be saved. This API is a void API.
### cacheMode
......@@ -1236,6 +1244,18 @@ Sets whether to enable forcible dark mode for the web page. By default, this fea
}
```
### tableData
tableData(tableData: boolean)
Sets whether form data should be saved. This API is a void API.
### wideViewModeAccess
wideViewModeAccess(wideViewModeAccess: boolean)
Sets whether to support the viewport attribute of the HTML **\<meta>** tag. This API is a void API.
### pinchSmooth<sup>9+</sup>
pinchSmooth(isEnabled: boolean)
......@@ -1420,7 +1440,7 @@ Called when **alert()** is invoked to display an alert dialog box on the web pag
controller: web_webview.WebviewController = new web_webview.WebviewController()
build() {
Column() {
Web({ src: $rawfile("xxx.html"), controller: this.controller })
Web({ src: $rawfile("index.html"), controller: this.controller })
.onAlert((event) => {
console.log("event.url:" + event.url)
console.log("event.message:" + event.message)
......@@ -1450,8 +1470,9 @@ Called when **alert()** is invoked to display an alert dialog box on the web pag
}
```
```
<!--xxx.html-->
HTML file to be loaded:
```html
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -1502,7 +1523,7 @@ Called when this page is about to exit after the user refreshes or closes the pa
build() {
Column() {
Web({ src: $rawfile("xxx.html"), controller: this.controller })
Web({ src: $rawfile("index.html"), controller: this.controller })
.onBeforeUnload((event) => {
console.log("event.url:" + event.url)
console.log("event.message:" + event.message)
......@@ -1532,8 +1553,9 @@ Called when this page is about to exit after the user refreshes or closes the pa
}
```
```
<!--xxx.html-->
HTML file to be loaded:
```html
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -1584,7 +1606,7 @@ Called when **confirm()** is invoked by the web page.
build() {
Column() {
Web({ src: $rawfile("xxx.html"), controller: this.controller })
Web({ src: $rawfile("index.html"), controller: this.controller })
.onConfirm((event) => {
console.log("event.url:" + event.url)
console.log("event.message:" + event.message)
......@@ -1614,8 +1636,9 @@ Called when **confirm()** is invoked by the web page.
}
```
```
<!--xxx.html-->
HTML file to be loaded:
```html
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -1673,7 +1696,7 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul
build() {
Column() {
Web({ src: $rawfile("xxx.html"), controller: this.controller })
Web({ src: $rawfile("index.html"), controller: this.controller })
.onPrompt((event) => {
console.log("url:" + event.url)
console.log("message:" + event.message)
......@@ -1704,8 +1727,9 @@ onPrompt(callback: (event?: { url: string; message: string; value: string; resul
}
```
```
<!--xxx.html-->
HTML file to be loaded:
```html
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
......@@ -1776,6 +1800,8 @@ Called to notify the host application of a JavaScript console message.
onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void)
Instructs the main application to start downloading a file.
**Parameters**
| Name | Type | Description |
......@@ -2084,6 +2110,26 @@ Called when loading of the web page is complete. This API is used by an applicat
}
```
### onSslErrorReceive<sup>(deprecated)</sup>
onSslErrorReceive(callback: (event?: { handler: Function, error: object }) => void)
Called when an SSL error occurs during resource loading.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [onSslErrorEventReceive<sup>9+</sup>](#onsslerroreventreceive9) instead.
### onFileSelectorShow<sup>(deprecated)</sup>
onFileSelectorShow(callback: (event?: { callback: Function, fileSelector: object }) => void)
Called to process an HTML form whose input type is **file**, in response to the tapping of the **Select File** button.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [onShowFileSelector<sup>9+</sup>](#onshowfileselector9) instead.
### onRenderExited<sup>9+</sup>
onRenderExited(callback: (event?: { renderExitReason: RenderExitReason }) => void)
......@@ -3308,7 +3354,7 @@ Called when the **\<Web>** component is about to access a URL. This API is used
| Name | Type | Description |
| ------- | ---------------------------------------- | --------- |
| request | [Webresourcerequest](#webresourcerequest) | Information about the URL request.|
| request | [WebResourceRequest](#webresourcerequest) | Information about the URL request.|
**Return value**
......@@ -4280,6 +4326,7 @@ Enumerates the error codes returned by **onSslErrorEventReceive** API.
| Name | Description | Remarks |
| --------- | ------------- | -------------------------- |
| MidiSysex | MIDI SYSEX resource.| Currently, only permission events can be reported. MIDI devices are not yet supported.|
| VIDEO_CAPTURE<sup>10+</sup> | Video capture resource, such as a camera.| |
## WebDarkMode<sup>9+</sup>
| Name | Description |
......@@ -4933,6 +4980,7 @@ This API is deprecated since API version 9. You are advised to use [registerJava
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
......@@ -4993,7 +5041,7 @@ This API is deprecated since API version 9. You are advised to use [runJavaScrip
}
}
```
HTML file to be loaded:
```html
<!-- index.html -->
<!DOCTYPE html>
......@@ -5009,7 +5057,6 @@ This API is deprecated since API version 9. You are advised to use [runJavaScrip
}
</script>
</html>
```
### stop<sup>(deprecated)</sup>
......@@ -5075,17 +5122,12 @@ This API is deprecated since API version 9. You are advised to use [clearHistory
Manages behavior of cookies in **\<Web>** components. All **\<Web>** components in an application share a **WebCookie**. You can use the **getCookieManager** API in **controller** to obtain the **WebCookie** for subsequent cookie management.
### setCookie<sup>(deprecated)</sup>
setCookie(url: string, value: string): boolean
Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
This API is deprecated since API version 9. You are advised to use [setCookie<sup>9+</sup>](../apis/js-apis-webview.md#setcookie) instead.
setCookie(): boolean
**Parameters**
Sets the cookie. This API returns the result synchronously. Returns **true** if the operation is successful; returns **false** otherwise.
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | Yes | - | URL of the cookie to set. A complete URL is recommended.|
| value | string | Yes | - | Value of the cookie to set. |
This API is deprecated since API version 9. You are advised to use [setCookie<sup>9+</sup>](../apis/js-apis-webview.md#setcookie) instead.
**Return value**
......@@ -5093,31 +5135,12 @@ This API is deprecated since API version 9. You are advised to use [setCookie<su
| ------- | ------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('setCookie')
.onClick(() => {
let result = this.controller.getCookieManager().setCookie("https://www.example.com", "a=b")
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
### saveCookie<sup>(deprecated)</sup>
saveCookie(): boolean
Saves the cookies in the memory to the drive. This API returns the result synchronously.
This API is deprecated since API version 9. You are advised to use [saveCookieAsync<sup>9+</sup>](../apis/js-apis-webview.md#savecookieasync) instead.
**Return value**
......@@ -5125,25 +5148,3 @@ This API is deprecated since API version 9. You are advised to use [saveCookieAs
| Type | Description |
| ------- | -------------------- |
| boolean | Operation result.|
**Example**
```ts
// xxx.ets
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
Button('saveCookie')
.onClick(() => {
let result = this.controller.getCookieManager().saveCookie()
console.log("result: " + result)
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
......@@ -14,20 +14,39 @@ Since API version 9, child components are supported when **type** is set to **"c
## APIs
XComponent(value: {id: string, type: string, libraryname?: string, controller?: XComponentController})
**API 1**: XComponent(value: {id: string, type: string, libraryname?: string, controller?: XComponentController})
**Parameters**
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | ---------------------------------------- |
| id | string | Yes | Unique ID of the component. The value can contain a maximum of 128 characters. |
| type | string | Yes | Type of the component. The options are as follows:<br>- **"surface"**: The content of the component is displayed individually, without being combined with that of other components. This option is used for displaying EGL/OpenGL ES and media data.<br>- **"component"**<sup>9+</sup>: The component becomes a container where non-UI logic can be executed to dynamically load the display content.|
| libraryname | string | No | Name of the dynamic library generated after compilation at the application native layer. This parameter is valid only when the component type is **"surface"**.|
| controller | [XComponentcontroller](#xcomponentcontroller) | No | Controller bound to the component, which can be used to invoke methods of the component. This parameter is valid only when the component type is **"surface"**.|
| Name | Type | Mandatory| Description |
| ----------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| id | string | Yes | Unique ID of the component. The value can contain a maximum of 128 characters. |
| type | string | Yes | Type of the component. The options are as follows:<br>- **"surface"**: The custom content is displayed individually on the screen. This option is used for displaying EGL/OpenGL ES and media data.<br>- **"component"**<sup>9+</sup>: The component becomes a container where non-UI logic can be executed to dynamically load the display content.<br>Any other value evaluates to **"surface"**.|
| libraryname | string | No | Name of the dynamic library generated after compilation at the application native layer. This parameter is valid only when **type** is **"surface"**.|
| controller | [XComponentcontroller](#xcomponentcontroller) | No | Controller bound to the component, which can be used to invoke methods of the component. This parameter is valid only when the component type is **"surface"**.|
**API 2**: XComponent(value: {id: string, type: XComponentType, libraryname?: string, controller?: XComponentController})<sup>10+</sup>
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| id | string | Yes | Unique ID of the component. The value can contain a maximum of 128 characters. |
| type | [XComponentType](#xcomponenttype10) | Yes | Type of the component. |
| libraryname | string | No | Name of the dynamic library generated after compilation at the application native layer. This parameter is valid only when **type** is **SURFACE** or **TEXTURE**.|
| controller | [XComponentcontroller](#xcomponentcontroller) | No | Controller bound to the component, which can be used to invoke methods of the component. This parameter is valid only when **type** is **SURFACE** or **TEXTURE**.|
## XComponentType<sup>10+</sup>
| Name | Description |
| --------- | ------------------------------------------------------------ |
| SURFACE | The custom content is displayed individually on the screen. This option is used for displaying EGL/OpenGL ES and media data.|
| COMPONENT | The component becomes a container where non-UI logic can be executed to dynamically load the display content.|
| TEXTURE | The custom content of the component is grouped and displayed together with content of the component.|
> **NOTE**
>
> When **type** is set to **"component"**, the **\<XComponent>** functions as a container, where child components are laid out vertically.
> When **type** is set to **COMPONENT("component")**, the **\<XComponent>** functions as a container, where child components are laid out vertically.
>
> - Vertical alignment: [FlexAlign](ts-appendix-enums.md#flexalign).Start
> - Horizontal alignment: [FlexAlign](ts-appendix-enums.md#flexalign).Center
......@@ -39,13 +58,14 @@ XComponent(value: {id: string, type: string, libraryname?: string, controller?:
> The non-UI logic written internally needs to be encapsulated in one or more functions.
## Attributes
- You can customize the content displayed in the **\<XComponent>**. Among the universal attributes, the [background](./ts-universal-attributes-background.md), [opacity](./ts-universal-attributes-opacity.md), and [image effects](./ts-universal-attributes-image-effect.md) attributes are not supported.
- When **type** is set to **"surface"**, you are advised to use the APIs provided by the EGL/OpenGL ES to set the display content.
- When **type** is set to **"component"**, you are advised to mount child components to set the display content.
- You can customize the content displayed in the **\<XComponent>**. Depending on the **type** settings, the support for the universal attributes [background](./ts-universal-attributes-background.md), [opacity](./ts-universal-attributes-opacity.md), and [image effects](./ts-universal-attributes-image-effect.md) varies:
- When **type** is set to **SURFACE("surface")**, none of these attributes is supported. For configuration, you are advised to use the APIs provided by EGL/OpenGL ES instead.
- When **type** is set to **COMPONENT("component")**, none of these attributes is supported. For configuration, you are advised to mount child components.
- When **type** is set to **TEXTURE**, only [opacity](./ts-universal-attributes-opacity.md) and **backgroundColor** in [background](./ts-universal-attributes-background.md) are supported. For configuration of other attributes, you are advised to use the APIs provided by EGL/OpenGL ES instead.
## Events
The following events are supported only when **type** is set to **"surface"**. The [universal events](ts-universal-events-click.md) and [universal gestures](ts-gesture-settings.md) are not supported.
When **type** is set to **SURFACE("surface")** or **TEXTURE**, the following events are supported. The [universal events](ts-universal-events-click.md) and gestures (ts-gesture-settings.md) are not supported.
### onLoad
......@@ -79,7 +99,7 @@ xcomponentController: XComponentController = new XComponentController()
getXComponentSurfaceId(): string
Obtains the ID of the surface held by the **\<XComponent>**. The ID can be used for @ohos interfaces. For details, see [Camera Management](../apis/js-apis-camera.md). This API works only when **type** of the **\<XComponent>** is set to **"surface"**.
Obtains the ID of the surface held by the **\<XComponent>**, which can then be used for @ohos APIs. For details, see [Camera Management](../apis/js-apis-camera.md). This API works only when **type** of the **\<XComponent>** is set to **SURFACE("surface")** or **TEXTURE**.
**Return value**
......@@ -93,7 +113,7 @@ Obtains the ID of the surface held by the **\<XComponent>**. The ID can be used
setXComponentSurfaceSize(value: {surfaceWidth: number, surfaceHeight: number}): void
Sets the width and height of the surface held by the **\<XComponent>**. This API works only when **type** of the **\<XComponent>** is set to **"surface"**.
Sets the width and height of the surface held by the **\<XComponent>**. This API works only when **type** of the **\<XComponent>** is set to **SURFACE("surface")** or **TEXTURE**.
**Parameters**
......@@ -108,7 +128,7 @@ Sets the width and height of the surface held by the **\<XComponent>**. This API
getXComponentContext(): Object
Obtains the context of an **\<XComponent>** object. This API works only when **type** of the **\<XComponent>** is set to **"surface"**.
Obtains the context of an **\<XComponent>** object. This API works only when **type** of the **\<XComponent>** is set to **SURFACE("surface")** or **TEXTURE**.
**Return value**
......
......@@ -22,7 +22,7 @@
## Stack, Flex, and Grid
- [Stack](ts-container-stack.md)
- [Stack](ts-container-stack.md)
A container where child components are successively stacked and the latter one overwrites the previous one.
- [Flex](ts-container-flex.md)
......@@ -63,7 +63,7 @@
## Scroll and Swipe
- [Scroll](ts-container-scroll.md)
- [Scroll](ts-container-scroll.md)
A container that scrolls the content when the layout size of a component exceeds the size of its parent component.
- [Swiper](ts-container-swiper.md)
......@@ -79,9 +79,9 @@
## Navigation
- [Navigator](ts-container-navigator.md)
- [Navigator](ts-container-navigator.md)
A container that provides redirection.
A container that provides redirection.
- [Navigation](ts-basic-components-navigation.md)
A container that typically functions as the root container of a page and displays the title bar, toolbar, and navigation bar based on the attribute settings.
......@@ -293,7 +293,7 @@
A component that is used to display widgets.
- [Menu](ts-basic-components-menu.md)
A component that is used to present a vertical list of items to the user.
A component that is used to present a vertical list of items to the user.
- [MenuItem](ts-basic-components-menuitem.md)
A component that is used to represent an item in a menu.
......
......@@ -29,9 +29,9 @@ AbilityComponent(want: Want)
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](../apis/js-apis-app-ability-want.md) | Yes| Description of the default ability to load.|
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | --------------- |
| want | [Want](../apis/js-apis-app-ability-want.md) | Yes | Description of the default ability to load.|
## Events
......@@ -74,5 +74,3 @@ struct MyComponent {
}
}
```
<!--no_check-->
\ No newline at end of file
......@@ -11,13 +11,28 @@ The **\<ListItem>** component displays specific items in the list. It must be us
This component can contain a single child component.
## APIs
ListItem(value?: string)
Since API version 9, this API is supported in ArkTS widgets.
**API 1**: ListItem(value?: ListItemOptions)<sup>10+</sup>
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------- | ---- | ------------------------------------------------------------ |
| value | [ListItemOptions](#listitemoptions10) | No | Value of the list item, containing the **style** parameter of the **ListItemStyle**enum type.|
**API 2**: ListItem(value?: string)<sup>(deprecated)</sup>
This API is deprecated since API version 10. You are advised to use API 1 instead.
**Parameters**
| Name| Type | Mandatory| Description|
| ------ | ----------------------------- | ---- | -------- |
| value | string<sup>(deprecated)</sup> | No | N/A |
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
......@@ -27,7 +42,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated) | Sticky effect of the list item.<br>Default value: **Sticky.None**<br>This API is deprecated since API version 9. You are advised to use **sticky** of the [\<List>](ts-container-list.md#attributes) component.|
| editable<sup>(deprecated)</sup> | boolean \| [EditMode](#editmodedeprecated) | Whether to enter editing mode, where the list item can be deleted or moved.<br>This API is deprecated since API version 9.<br>Default value: **false**|
| selectable<sup>8+</sup> | boolean | Whether the current list item is selectable by mouse drag.<br>**NOTE**<br>This attribute takes effect only when mouse frame selection is enabled for the parent **\<List>** container.<br>Default value: **true**|
| swipeAction<sup>9+</sup> | {<br>start?: CustomBuilder,<br>end?:CustomBuilder,<br>edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),<br>} | Component displayed when the list item is swiped out from the screen edge.<br>- **start**: component on the left of the list item when the item is swiped to the right (in vertical list layout) or component above the list item when the item is swiped down (in horizontal list layout).<br>- **end**: component on the right of the list item when the item is swiped to the left (in vertical list layout) or component below the list item when the item is swiped up (in horizontal list layout).<br>- **edgeEffect**: scroll effect.<br>**NOTE**<br>The top level of the **@builder** function corresponding to **start** and **end** must be a single component and cannot be an **if/else**, **ForEach**, or **LazyForEach** statement.|
| swipeAction<sup>9+</sup> | {<br>start?: CustomBuilder \| [SwipeActionItem](#swipeactionitem10),<br>end?:CustomBuilder \| [SwipeActionItem](#swipeactionitem10),<br>edgeEffect?: [SwipeEdgeEffect](#swipeedgeeffect9),<br>} | Swipe action displayed when the list item is swiped out from the screen edge.<br>- **start**: swipe action displayed on the left of the list item when the item is swiped right (in vertical list layout) or above the list item when the item is swiped down (in horizontal list layout).<br>- **end**: swipe action displayed on the right of the list item when the item is swiped left (in vertical list layout) or below the list item when the item is swiped up (in horizontal list layout).<br>- **edgeEffect**: scroll effect.<br>**NOTE**<br>- The top level of the **@builder** function corresponding to **start** and **end** must be a single component and cannot be an **if/else**, **ForEach**, or **LazyForEach** statement.<br> - The swipe gesture works only in the list item area. If a swipe causes a child component to extend beyond the list item area, the portion outside the area does not respond to the swipe. In light of this, avoid setting **swipeAction** to a component too wide in a multi-column list. |
## Sticky<sup>(deprecated)</sup>
This API is deprecated since API version 9. You are advised to use [stickyStyle](ts-container-list.md#stickystyle9) of the **\<List>** component.
......@@ -48,8 +63,36 @@ This API is deprecated since API version 9.
## SwipeEdgeEffect<sup>9+</sup>
| Name| Description|
| -------- | -------- |
| Spring | When the list item scrolls to the edge of the list, it can continue to scroll for a distance and rebound after being released.|
| None | The list item cannot scroll beyond the edge of the list|
| Spring | When the list item scrolls to the edge of the list, it can continue to scroll for a distance. If the delete area is set, the list item can continue to scroll after the scroll distance reaches the delete threshold and, after being released, rebound following the spring curve.|
| None | The list item cannot scroll beyond the edge of the list. If the delete area is set, the list item cannot continue to scroll after the scroll distance reaches the delete threshold. If the delete callback is set, it is triggered when the delete threshold is reached and the list item is released.|
## SwipeActionItem<sup>10+</sup>
Describes the swipe action item.
For a list in vertical layout, it refers to the delete item displayed on the left (or right) of the list item when the list item is swiped right (or left).
For a list in horizontal layout, it refers to the delete item displayed below (or above) the list item when the list item is swiped up (or down).
| Name | Type | Mandatory| Description |
| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| deleteAreaDistance | [Length](ts-types.md#length) | No| Swipe distance threshold for deleting the list item.<br>Default value: **56vp**<br>**NOTE**<br>This parameter cannot be set in percentage.<br>If the value is greater than the list item width minus the width of **swipeAction**, or is less than or equal to 0, the delete area will not be set.|
| onDelete | () => void | No| Callback invoked when the list item is released while in the delete area.<br>**NOTE**<br> This callback is invoked only when the list item is released in a position that meets or goes beyond the specified swipe distance threshold (which must be valid) for deleting the list item.|
| onEntryDeleteArea | () => void | No| Callback invoked each time the list item enters the delete area.|
| onExitDeleteArea | () => void | No|Callback invoked each time the list item exits the delete area.|
| builder | CustomBuilder | No|Swipe action item displayed when the list item is swiped left or right (in vertical list layout) or up or down (in horizontal list layout).|
| useDefaultDeleteAnimation | boolean | No|Whether to use the default delete animation.<br>Default value: **true**|
## ListItemOptions<sup>10+</sup>
| Name | Type | Mandatory| Description |
| ----- | ----------------------------------------- | ---- | ------------------------------------------------------------ |
| style | [ListItemStyle](#listitemstyle10) | No | Style of the list item.<br>Default value: **ListItemStyle.NONE**<br>If this parameter is set to **ListItemStyle.NONE**, no style is applied.<br>If this parameter is set to **ListItemStyle.CARD**, the default card style is applied, but only when **ListItemGroupStyle.CARD** is set for [\<ListItemGroup>](ts-container-listitemgroup.md).<br>In the default card style, the list item has a 48 vp height and 100% width. It can be in focus, hover, press, selected, or disable style depending on the state.<br>**NOTE**<br>In the default card style, the list has its **listDirection** attribute fixed at **Axis.Vertical** and **alignListItem** attribute at **ListItemAlign.Center**. |
## ListItemStyle<sup>10+</sup>
| Name| Description |
| ---- | ------------------ |
| NONE | No style. |
| CARD | Default card style.|
## Events
......@@ -78,6 +121,7 @@ struct ListItemExample {
}
}, item => item)
}.width('90%')
.scrollBar(BarState.Off)
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
......@@ -85,45 +129,63 @@ struct ListItemExample {
![en-us_image_0000001219864159](figures/en-us_image_0000001219864159.gif)
```ts
// xxx.ets
@Entry
@Component
struct ListItemExample2 {
@State message: string = 'Hello World'
@State arr: number[] = [0, 1, 2, 3, 4]
@State enterEndDeleteAreaString: string = "not enterEndDeleteArea"
@State exitEndDeleteAreaString: string = "not exitEndDeleteArea"
@Builder itemEnd() {
Row () {
Button("Del").margin("4vp")
Row() {
Button("Delete").margin("4vp")
Button("Set").margin("4vp")
}.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
}
build() {
Column() {
List({space:10}) {
ListItem() {
Text(this.message)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.swipeAction({ end:this.itemEnd})
ListItem() {
Text(this.message)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.swipeAction({ start:this.itemEnd})
List({ space: 10 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text("item" + item)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.transition({ type: TransitionType.Delete, opacity: 0 })
.swipeAction({
end: {
builder: this.itemEnd.bind(this, item),
useDefaultDeleteAnimation: true,
onDelete: () => {
animateTo({ duration: 1000 }, () => {
let index = this.arr.indexOf(item)
this.arr.splice(index, 1)
})
},
deleteAreaDistance: 80,
onEnterDeleteArea: () => {
this.enterEndDeleteAreaString = "enterEndDeleteArea"
this.exitEndDeleteAreaString = "not exitEndDeleteArea"
},
onExitDeleteArea: () => {
this.enterEndDeleteAreaString = "not enterEndDeleteArea"
this.exitEndDeleteAreaString = "exitEndDeleteArea"
}
}
})
}, item => item)
}
Text(this.enterEndDeleteAreaString).fontSize(20)
Text(this.exitEndDeleteAreaString).fontSize(20)
}
.padding(10)
.backgroundColor(0xDCDCDC)
......@@ -132,4 +194,4 @@ struct ListItemExample2 {
}
}
```
![en-us_image_1501929990650](figures/en-us_image_1501929990650.jpg)
![deleteListItem](figures/deleteListItem.gif)
......@@ -19,15 +19,16 @@ This component supports the **[\<ListItem>](ts-container-listitem.md)** child co
## APIs
ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?: number | string})
ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?: number | string, style?: ListItemGroupStyle})
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| header | [CustomBuilder](ts-types.md#custombuilder8) | No| Header of the **\<ListItemGroup>** component.|
| footer | [CustomBuilder](ts-types.md#custombuilder8) | No| Footer of the **\<ListItemGroup>** component.|
| space | number \| string | No| Spacing between list items. This parameter is valid only between list items, but not between a header and list item or between a footer and list item.|
| Name | Type | Mandatory| Description |
| ------------------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
| header | [CustomBuilder](ts-types.md#custombuilder8) | No | Header of the list item group. |
| footer | [CustomBuilder](ts-types.md#custombuilder8) | No | Footer of the list item group. |
| space | number \| string | No | Spacing between list items. This parameter is valid only between list items, but not between a header and list item or between a footer and list item.|
| style<sup>10+</sup> | [ListItemGroupStyle](#listitemgroupstyle10) | No | Style of the list item group.<br>Default value: **ListItemGroupStyle.NONE**<br>If this parameter is set to **ListItemGroupStyle.NONE**, no style is applied.<br>If this parameter is set to **ListItemGroupStyle.CARD**, the default card style is applied, but only when **ListItemStyle.CARD** is set for [\<ListItem>](ts-container-listitem.md).<br>It can be in focus, hover, press, selected, or disable style depending on the state.<br>**NOTE**<br>In the default card style, the list has its **listDirection** attribute fixed at **Axis.Vertical** and **alignListItem** attribute at **ListItemAlign.Center**; the **header** and **footer** parameters cannot be set for the list item group. |
## Attributes
......@@ -35,6 +36,13 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?:
| -------- | -------- | -------- |
| divider | {<br>strokeWidth: [Length](ts-types.md#length),<br>color?: [ResourceColor](ts-types.md#resourcecolor),<br>startMargin?: [Length](ts-types.md#length),<br>endMargin?: [Length](ts-types.md#length)<br>} \| null | Style of the divider for the list items. By default, there is no divider.<br>- **strokeWidth**: stroke width of the divider.<br>- **color**: color of the divider.<br>- **startMargin**: distance between the divider and the start of the list.<br>- **endMargin**: distance between the divider and the end of the list.|
## ListItemGroupStyle<sup>10+</sup>
| Name| Description |
| ---- | ------------------ |
| NONE | No style. |
| CARD | Default card style.|
> **NOTE**
>
> The **\<ListItemGroup>** component does not support the universal attribute **[aspectRatio](ts-universal-attributes-layout-constraints.md)**.
......@@ -99,12 +107,12 @@ struct ListItemGroupExample {
}
}, item => item)
}
.borderRadius(20)
.divider ({ strokeWidth: 1,color:Color.Blue }) // Divider between lines
})
}
.width('90%')
.sticky(StickyStyle.Header|StickyStyle.Footer)
.scrollBar(BarState.Off)
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
......
......@@ -34,6 +34,7 @@ SideBarContainer( type?: SideBarContainerType )
| -------- | -------- |
| Embed | The sidebar is embedded in the component and displayed side by side with the content area.|
| Overlay | The sidebar is displayed overlaid on the content area.|
| AUTO | The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth**<br>and in Overlay mode otherwise.|
## Attributes
......@@ -50,6 +51,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| autoHide<sup>9+</sup> | boolean | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.<br>Default value: **true**<br>**NOTE**<br>The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.<br>Whether the sidebar should be hidden is determined when it is being dragged. When its width is less than the minimum width, the damping effect is required to trigger hiding (a distance out of range).|
| sideBarPosition<sup>9+</sup> | [SideBarPosition](#sidebarposition9) | Position of the sidebar.<br>Default value: **SideBarPosition.Start**|
| divider<sup>10+</sup> | [DividerStyle](#dividerstyle10) \| null | Divider style.<br>- **DividerStyle** (default): The divider is displayed.<br>- **null**: The divider is not displayed.|
| minContentWidth<sup>10+</sup> | Dimension | Minimum width of the content area of the sidebar container.<br>Default value: **360**<br>Unit: vp|
## ButtonStyle
......
......@@ -27,8 +27,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name| Type| Description|
| -------- | -------- | -------- |
| tabBar | string \| Resource \| {<br>icon?: string \| Resource,<br>text?: string \| Resource<br>}<br>\| [CustomBuilder](ts-types.md)<sup>8+</sup> | Content displayed on the tab bar.<br>**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).<br>**NOTE**<br>If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image.<br>If the content set exceeds the space provided by the tab bar, it will be clipped.|
| tabBar<sup>9+</sup> | [SubTabBarStyle](#subtabbarstyle) \| [BottomTabBarStyle](#bottomtabbarstyle) | Content displayed on the tab bar.<br>**SubTabBarStyle**: subtab style. It takes text as its input parameter.<br>**BottomTabBarStyle**: bottom and side tab style. It takes text and images as its input parameters.<br>**NOTE**<br>The bottom tab style does not include an underline.<br>When an icon display error occurs, a gray blank block is displayed.|
| tabBar | string \| [Resource](ts-types.md#resource) \| {<br>icon?: string \| [Resource](ts-types.md#resource),<br>text?: string \| [Resource](ts-types.md#resource)<br>}<br>\| [CustomBuilder](ts-types.md)<sup>8+</sup> | Content displayed on the tab bar.<br>**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).<br>**NOTE**<br>If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image.<br>If the content set exceeds the space provided by the tab bar, it will be clipped.|
| tabBar<sup>9+</sup> | [SubTabBarStyle](#subtabbarstyle9) \| [BottomTabBarStyle](#bottomtabbarstyle9) | Content displayed on the tab bar.<br>**SubTabBarStyle**: subtab style. It takes text as its input parameter.<br>**BottomTabBarStyle**: bottom and side tab style. It takes text and images as its input parameters.<br>**NOTE**<br>The bottom tab style does not include an underline.<br>When an icon display error occurs, a gray blank block is displayed.|
> **NOTE**
>
......@@ -81,10 +81,10 @@ The following attributes are supported.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------------------------------- |
| color | [ResourceColor](ts-types.md#resourcecolor) | No| Underline indicator color and board color.<br>Default value: **#FF007DFF**|
| height | [Length](ts-types.md#length) | No| Height of the underline indicator.<br>Default value: **2.0**<br>Unit: vp|
| width | [Length](ts-types.md#length) | No| Width of the underline indicator.<br>Default value: **0.0**<br>Unit: vp|
| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the underline indicator.<br>Default value: **0.0**<br>Unit: vp|
| marginTop | [Length](ts-types.md#length) | No| Spacing between the underline indicator and text.<br>Default value: **8.0**<br>Unit: vp|
| height | [Length](ts-types.md#length) | No| Height of the underline indicator. It cannot be set in percentage.<br>Default value: **2.0**<br>Unit: vp|
| width | [Length](ts-types.md#length) | No| Width of the underline indicator. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp|
| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the underline indicator. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp|
| marginTop | [Length](ts-types.md#length) | No| Spacing between the underline indicator and text. It cannot be set in percentage.<br>Default value: **8.0**<br>Unit: vp|
## SelectedMode<sup>10+</sup>
| Name | Description |
......@@ -96,7 +96,7 @@ The following attributes are supported.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | ------------------------------------ |
| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the underline indicator.<br>Default value: **8.0**<br>Unit: vp|
| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the board. It cannot be set in percentage.<br>Default value: **8.0**<br>Unit: vp|
## LabelStyle<sup>10+</sup>
......
......@@ -41,7 +41,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| vertical | boolean | Whether to use vertical tabs. The value **true** means to use vertical tabs, and **false** means to use horizontal tabs.<br>Default value: **false**|
| scrollable | boolean | Whether the tabs are scrollable. The value **true** means that the tabs are scrollable, and **false** means the opposite.<br>Default value: **true**|
| barMode | BarMode | Tab bar layout mode. For details, see **BarMode**.<br>Default value: **BarMode.Fixed**|
| barWidth | number \| Length<sup>8+</sup> | Width of the tab bar.<br>The default value varies.<br>If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is the width of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is the width of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is **96vp**.<br>If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is the width of the **\<Tabs>** component.<br>**NOTE**<br><br>A value less than 0 or greater than the width of the **\<Tabs>** component evaluates to the default value.|
| barWidth | number \| Length<sup>8+</sup> | Width of the tab bar.<br>The default value varies.<br>If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is the width of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is the width of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is **96vp**.<br>If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is the width of the **\<Tabs>** component.<br>**NOTE**<br>A value less than 0 or greater than the width of the **\<Tabs>** component evaluates to the default value.|
| barHeight | number \| Length<sup>8+</sup> | Height of the tab bar.<br>The default value varies.<br>If the tab bar has the **vertical** attribute set to **false** and does not have a style specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **true** and does not have a style specified, the default value is the height of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **false** and **SubTabbarStyle** specified, the default value is **56vp**.<br>If the tab bar has the **vertical** attribute set to **true** and **SubTabbarStyle** specified, the default value is the height of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **true** and **BottomTabbarStyle** specified, the default value is the height of the **\<Tabs>** component.<br>If the tab bar has the **vertical** attribute set to **false** and **BottomTabbarStyle** specified, the default value is **56vp**.<br>**NOTE**<br>A value less than 0 or greater than the height of the **\<Tabs>** component evaluates to the default value. |
| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.<br>Default value: **300**<br>**NOTE**<br>A value less than 0 or in percentage evaluates to the default value. |
| divider<sup>10+</sup> | [DividerStyle](#dividerstyle10) \| null | Whether the divider is displayed for the **\<TabBar>** and **\<TabContent>** components and the divider style. By default, the divider is not displayed.<br> **DividerStyle**: divider style.<br> **null**: The divider is not displayed.|
......@@ -53,10 +53,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | ----------------------------------- |
| strokeWidth | [Length](ts-types.md#length) | Yes | Width of the divider. |
| strokeWidth | [Length](ts-types.md#length) | Yes | Width of the divider. It cannot be set in percentage. |
| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the divider.<br>Default value: **#33182431** |
| startMargin | [Length](ts-types.md#length) | No | Distance between the divider and the top of the sidebar.<br>Default value: **0.0**<br>Unit: vp|
| endMargin | [Length](ts-types.md#length) | No | Distance between the divider and the bottom of the sidebar.<br>Default value: **0.0**<br>Unit: vp|
| startMargin | [Length](ts-types.md#length) | No | Distance between the divider and the top of the sidebar. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp|
| endMargin | [Length](ts-types.md#length) | No | Distance between the divider and the bottom of the sidebar. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp|
## BarMode
......
# Custom Component Lifecycle
The lifecycle callbacks of a custom component are used to notify users of the lifecycle of the component. These callbacks are private and are invoked by the development framework at a specified time at runtime. They cannot be manually invoked from applications.
>**NOTE**
>
>Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters.
>- 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.
>- Promise and asynchronous callback functions can be used in lifecycle functions, for example, network resource getters and timer setters.
## aboutToAppear
......@@ -123,8 +122,8 @@ Since API version 10, this API is supported in ArkTS widgets.
**Parameters**
| Name| Type | Description |
| ------ | -------------------------- | -------------------- |
| Name | Type | Description |
| ------ | -------------------------- | ---------- |
| params | { [key: string]: unknown } | Parameters used for constructing the custom component.|
......
# Pixel Units
The framework provides four pixel units, with vp as the reference data unit.
ArkUI provides four pixel units, with vp as the reference data unit.
>**Notes:**
>
>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.
| Name| Description |
| ---- | ------------------------------------------------------------ |
| px | Physical pixel unit of the screen. |
| Name | Description |
| ---- | ---------------------------------------- |
| px | Physical pixel unit of the screen. |
| vp | Pixel unit specific to the screen density. Pixels in this unit are converted into physical pixels of the screen based on the screen pixel density. This unit is used for values whose unit is not specified. On a screen with an actual width of 1440 physical pixels, 1 vp is approximately equal to 3 px.|
| fp | Font pixel, which is similar to vp and varies according to the system font size.|
| fp | Font pixel, which is similar to vp and varies according to the system font size. |
| lpx | Logical pixel unit of the window. It is the ratio of the actual screen width to the logical width (configured by **designWidth**). For example, if **designWidth** is set to **720** (default value), then 1 lpx is equal to 2 px for a screen with an actual width of 1440 physical pixels.|
......@@ -15,12 +19,12 @@ The framework provides four pixel units, with vp as the reference data unit.
Conversion between px and other pixel units is supported.
| API | Description |
| --------------------------------------------------- | ------------------------------------------------------------ |
| vp2px(value : number) : number | Converts a value in units of vp to a value in units of px.<br>Since API version 9, this API is supported in ArkTS widgets.|
| px2vp(value : number) : number | Converts a value in units of px to a value in units of vp.<br>Since API version 9, this API is supported in ArkTS widgets.|
| fp2px(value : number) : number | Converts a value in units of fp to a value in units of px.<br>Since API version 9, this API is supported in ArkTS widgets.|
| px2fp(value : number) : number | Converts a value in units of px to a value in units of fp.<br>Since API version 9, this API is supported in ArkTS widgets.|
| API | Description |
| ---------------------------------------- | ---------------------------------------- |
| vp2px(value : number) : number | Converts a value in units of vp to a value in units of px.<br>Since API version 9, this API is supported in ArkTS widgets.|
| px2vp(value : number) : number | Converts a value in units of px to a value in units of vp.<br>Since API version 9, this API is supported in ArkTS widgets.|
| fp2px(value : number) : number | Converts a value in units of fp to a value in units of px.<br>Since API version 9, this API is supported in ArkTS widgets.|
| px2fp(value : number) : number | Converts a value in units of px to a value in units of fp.<br>Since API version 9, this API is supported in ArkTS widgets.|
| lpx2px(value : number) : number | Converts a value in units of lpx to a value in units of px.<br>Since API version 9, this API is supported in ArkTS widgets.|
| px2lpx(value : number) : number | Converts a value in units of px to a value in units of lpx.<br>Since API version 9, this API is supported in ArkTS widgets.|
......
......@@ -23,7 +23,7 @@ CSS files can be imported using the **\@import** statement. This facilitates mod
The **.css** file with the same name as the **.hml** file in each page directory describes the styles of components on the HML page, determining how the components will be displayed.
1. Internal style: The **style** and **class** attributes can be used to specify the component style. Example:
```html
<!-- index.hml -->
<div class="container">
......@@ -31,7 +31,7 @@ The **.css** file with the same name as the **.hml** file in each page directory
</div>
```
```css
/* index.css */
.container {
......@@ -40,7 +40,7 @@ The **.css** file with the same name as the **.hml** file in each page directory
```
2. External style files: You need to import the files. For example, create a **style.css** file in the **common** directory and import the file at the beginning of **index.css**.
```css
/* style.css */
.title {
......@@ -48,7 +48,7 @@ The **.css** file with the same name as the **.hml** file in each page directory
}
```
```css
/* index.css */
@import '../../common/style.css';
......@@ -62,10 +62,10 @@ The **.css** file with the same name as the **.hml** file in each page directory
A CSS selector is used to select elements for which styles need to be added to. The following table lists the supported selectors.
| Selector| Example| Description|
| -------- | -------- | -------- |
| Selector | Example | Description |
| ------ | ---------- | ------------------------- |
| .class | .container | Selects all components whose **class** is **container**.|
| \#id | \#titleId | Selects all components whose **id** is **titleId**.|
| \#id | \#titleId | Selects all components whose **id** is **titleId**. |
Example:
......
......@@ -7,6 +7,7 @@
- [Drawing](_drawing.md)
- [Image](image.md)
- [Rawfile](rawfile.md)
- [RDB](_r_d_b.md)
- [MindSpore](_mind_spore.md)
- [NeuralNeworkRuntime](_neural_nework_runtime.md)
- [AudioDecoder](_audio_decoder.md)
......@@ -58,6 +59,12 @@
- [native_huks_api.h](native__huks__api_8h.md)
- [native_huks_param.h](native__huks__param_8h.md)
- [native_huks_type.h](native__huks__type_8h.md)
- [oh_cursor.h](oh__cursor_8h.md)
- [oh_predicates.h](oh__predicates_8h.md)
- [oh_value_object.h](oh__value__object_8h.md)
- [oh_values_bucket.h](oh__values__bucket_8h.md)
- [relational_store_error_code.h](relational__store__error__code_8h.md)
- [relational_store.h](relational__store_8h.md)
- [syscap_ndk.h](syscap__ndk_8h.md)
- [purgeable_memory.h](purgeable__memory_8h.md)
- Structs
......@@ -95,3 +102,9 @@
- [OH_Huks_ParamSet](_o_h___huks___param_set.md)
- [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md)
- [OH_Huks_Result](_o_h___huks___result.md)
- [OH_Cursor](_o_h___cursor.md)
- [OH_Predicates](_o_h___predicates.md)
- [OH_Rdb_Config](_o_h___rdb___config.md)
- [OH_Rdb_Store](_o_h___rdb___store.md)
- [OH_VBucket](_o_h___v_bucket.md)
- [OH_VObject](_o_h___v_object.md)
# OH_Cursor
## Overview
Defines a result set.
It provides APIs to access the result set obtained by querying the RDB store.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [id](_r_d_b.md) | Unique identifier of the **OH_Cursor** struct.|
| [getColumnCount](_r_d_b.md#getcolumncount) | Pointer to the function used to obtain the number of columns in the result set.|
| [getColumnType](_r_d_b.md#getcolumntype) | Pointer to the function used to obtain the column type based on the specified column index.|
| [getColumnIndex](_r_d_b.md#getcolumnindex) | Pointer to the function used to obtain the column index based on the specified column name.|
| [getColumnName](_r_d_b.md#getcolumnname) | Pointer to the function used to obtain the column name based on the specified column index.|
| [getRowCount](_r_d_b.md#getrowcount) | Pointer to the function used to obtain the number of rows in the result set.|
| [goToNextRow](_r_d_b.md#gotonextrow) | Pointer to the function used to go to the next row of the result set.|
| [getSize](_r_d_b.md#getsize) | Pointer to the function used to obtain information about the memory required when the column data type in the result set is **BLOB** or **TEXT**.|
| [getText](_r_d_b.md#gettext) | Pointer to the function used to obtain the value in the form of a string based on the specified column and the current row.|
| [getInt64](_r_d_b.md#getint64) | Pointer to the function used to obtain the value of the int64_t type based on the specified column and the current row.|
| [getReal](_r_d_b.md#getreal) | Pointer to the function used to obtain the value of the double type based on the specified column and the current row.|
| [getBlob](_r_d_b.md#getblob) | Pointer to the function used to obtain the value in the form of a byte array based on the specified column and the current row.|
| [isNull](_r_d_b.md#isnull-12) | Pointer to the function used to check whether the value in the specified column is null.|
| [close](_r_d_b.md#close) | Pointer to the function used to close a result set.|
# OH_Predicates
## Overview
Defines the predicates.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [id](_r_d_b.md#id-14) | Unique identifier of the **OH_Predicates** struct.|
| [equalTo](_r_d_b.md#equalto) | Pointer to the function used to set a predicates object to match the field whose value is equal to the specified value.|
| [notEqualTo](_r_d_b.md#notequalto) | Pointer to the function used to set a predicates object to match the field whose value is not equal to the specified value.|
| [beginWrap](_r_d_b.md#beginwrap) | Pointer to the function used to add a left parenthesis to the predicates.|
| [endWrap](_r_d_b.md#endwrap) | Pointer to the function used to add a right parenthesis to the predicates.|
| [orOperate](_r_d_b.md#oroperate) | Pointer to the function used to add the OR operator to the predicates.|
| [andOperate](_r_d_b.md#andoperate) | Pointer to the function used to add the AND operator to the predicates.|
| [isNull](_r_d_b.md#isnull-22) | Pointer to the function used to set a predicates object to match the field whose value is null.|
| [isNotNull](_r_d_b.md#isnotnull) | Pointer to the function used to set a predicates object to match the field whose value is not null.|
| [like](_r_d_b.md#like) | Pointer to the function used to set a predicates object to match a string that is similar to the specified value.|
| [between](_r_d_b.md#between) | Pointer to the function used to set a predicates object to match the field whose value is within the specified range.|
| [notBetween](_r_d_b.md#notbetween) | Pointer to the function used to set a predicates object to match the field whose value is out of the specified range.|
| [greaterThan](_r_d_b.md#greaterthan) | Pointer to the function used to set a predicates object to match the field with value greater than the specified value.|
| [lessThan](_r_d_b.md#lessthan) | Pointer to the function used to set a predicates object to match the field with value less than the specified value.|
| [greaterThanOrEqualTo](_r_d_b.md#greaterthanorequalto) | Pointer to the function used to set a predicates object to match the field with value greater than or equal to the specified value.|
| [lessThanOrEqualTo](_r_d_b.md#lessthanorequalto) | Pointer to the function used to set a predicates object to match the field with value less than or equal to the specified value.|
| [orderBy](_r_d_b.md#orderby) | Pointer to the function used to set a predicates object to sort the values in a column in ascending or descending order.|
| [distinct](_r_d_b.md#distinct) | Pointer to the function used to set a predicates object to filter out duplicate records.|
| [limit](_r_d_b.md#limit) | Pointer to the function used to set a predicates object to specify the maximum number of records.|
| [offset](_r_d_b.md#offset) | Pointer to the function used to set a predicates object to specify the start position of the returned result.|
| [groupBy](_r_d_b.md#groupby) | Pointer to the function used to set a predicates object to group rows that have the same value into summary rows.|
| [in](_r_d_b.md#in) | Pointer to the function used to set a predicates object to match the field with the value within the specified range.|
| [notIn](_r_d_b.md#notin) | Pointer to the function used to set a predicates object to match the field with the value out of the specified range.|
| [clear](_r_d_b.md#clear-12) | Pointer to the function used to clear a predicates instance.|
| [destroyPredicates](_r_d_b.md#destroypredicates) | Destroys an **OH_Predicates** object and reclaims the memory occupied.|
# OH_Rdb_Config
## Overview
Defines the RDB store configuration.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [path](_r_d_b.md#path) | Path of the database file.|
| [isEncrypt](_r_d_b.md#isencrypt) | Whether to encrypt the RDB store.|
| [securityLevel](_r_d_b.md#securitylevel) | RDB store security level [OH_Rdb_SecurityLevel](_r_d_b.md#oh_rdb_securitylevel).|
# OH_Rdb_Store
## Overview
Defines the RDB store type.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [id](_r_d_b.md#id-44) | Unique identifier of the **OH_Rdb_Store** struct.|
# OH_VBucket
## Overview
Defines the types of the key and value in a KV pair.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [id](_r_d_b.md#id-34) | Unique identifier of the **OH_VBucket** struct.|
| [capability](_r_d_b.md#capability) | Number of the KV pairs in the struct.|
| [putText](_r_d_b.md#puttext-12) | Puts a char value into the **OH_VBucket** object in the given column.|
| [putInt64](_r_d_b.md#putint64-12) | Puts an int64_t value into the **OH_VBucket** object in the given column.|
| [putReal](_r_d_b.md#putreal) | Puts a double value into the **OH_VBucket** object in the given column.|
| [putBlob](_r_d_b.md#putblob) | Puts a const uint8_t value into the **OH_VBucket** object in the given column.|
| [putNull](_r_d_b.md#putnull) | Puts a null value into the **OH_VBucket** object in the given column.|
| [clear](_r_d_b.md#clear-22) | Clears an **OH_VBucket** object.|
| [destroyValuesBucket](_r_d_b.md#destroyvaluesbucket) | Destroys an **OH_VBucket** object and reclaims the memory occupied.|
# OH_VObject
## Overview
Defines the allowed data field types.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Member Variables
| Name| Description|
| -------- | -------- |
| [id](_r_d_b.md#id-24) | Unique identifier of the **OH_VObject** struct.|
| [putInt64](_r_d_b.md#putint64-22) | Converts a single parameter or an array of the int64 type into a value of the OH_VObject type.|
| [putDouble](_r_d_b.md#putdouble) | Converts a single parameter or an array of the int64 type into a value of the OH_VObject type.|
| [putText](_r_d_b.md#puttext-22) | Converts a character array of the char type to a value of the OH_VObject type.|
| [putTexts](_r_d_b.md#puttexts) | Converts a string array of the char type to a value of the OH_VObject type.|
| [destroyValueObject](_r_d_b.md#destroyvalueobject) | Destroys an OH_VObject object and reclaims the memory occupied.|
此差异已折叠。
......@@ -5,10 +5,11 @@
Provides **Context** APIs for configuring runtime information.
**Since:**
**Since**
9
**Related Modules:**
**Related Modules**
[MindSpore](_mind_spore.md)
......@@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information.
### Types
| Name | Description |
| Name| Description|
| -------- | -------- |
| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. |
| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. |
| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information.|
### Functions
| Name | Description |
| Name| Description|
| -------- | -------- |
| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object. |
| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object. |
| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. |
| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads. |
| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. |
| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. |
| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. |
| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. |
| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. |
| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. |
| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. |
| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object. |
| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. |
| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. |
| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. |
| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. |
| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. |
| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. |
| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. |
| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. |
| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object.|
| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object.|
| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads.|
| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads.|
| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.|
| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores.|
| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread.|
| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores.|
| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available.|
| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported.|
| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context.|
| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object.|
| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually.|
| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name.|
| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name.|
| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device.|
| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device.|
| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the device type.|
| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.|
| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.|
| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices.|
| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices.|
| [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system.|
| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).|
| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.|
| [OH_AI_GetNameFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description.|
| [OH_AI_GetTypeFromNNRTDeviceDesc](_mind_spore.md#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description.|
| [OH_AI_CreateNNRTDeviceInfoByName](_mind_spore.md#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.|
| [OH_AI_CreateNNRTDeviceInfoByType](_mind_spore.md#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](_mind_spore.md#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.|
| [OH_AI_DeviceInfoSetDeviceId](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices.|
| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices.|
# oh_cursor.h
## Overview
Provides APIs to access the result set obtained by querying the RDB store.
A result set is a set of results returned by **query()**.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [OH_Cursor](_o_h___cursor.md) | Defines a result set.|
### Types
| Name| Description|
| -------- | -------- |
| [OH_Cursor](_r_d_b.md#oh_cursor) | Indicates a result set.|
### Enums
| Name| Description|
| -------- | -------- |
| [OH_ColumnType](_r_d_b.md#oh_columntype)&nbsp;{<br>TYPE_NULL&nbsp;=&nbsp;0,&nbsp;TYPE_INT64,&nbsp;TYPE_REAL,&nbsp;TYPE_TEXT,<br>TYPE_BLOB<br>} | Enumerates the field types in an RDB store.|
# oh_predicates.h
## Overview
Defines the predicates for RDB stores.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [OH_Predicates](_o_h___predicates.md) | Defines a **predicates** object. |
### Types
| Name| Description|
| -------- | -------- |
| [OH_Predicates](_r_d_b.md#oh_predicates) | Indicates a **predicates** object. |
### Enums
| Name| Description|
| -------- | -------- |
| [OH_OrderType](_r_d_b.md#oh_ordertype)&nbsp;{&nbsp;ASC&nbsp;=&nbsp;0,&nbsp;DESC&nbsp;=&nbsp;1&nbsp;} | Enumerates the sorting types.|
# oh_value_object.h
## Overview
Provides type conversion methods.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [OH_VObject](_o_h___v_object.md) | Defines the allowed data field types.|
### Types
| Name| Description|
| -------- | -------- |
| [OH_VObject](_r_d_b.md#oh_vobject) | Indicates the allowed data field types. |
# oh_values_bucket.h
## Overview
Defines the types of the key and value in a key-value (KV) pair.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [OH_VBucket](_o_h___v_bucket.md) | Defines the types of the key and value in a KV pair.|
### Types
| Name| Description|
| -------- | -------- |
| [OH_VBucket](_r_d_b.md#oh_vbucket) | Indicates the types of the key and value in a KV pair. |
# relation_store.h
## Overview
Provides APIs to manage a relational database (RDB) store.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Structs
| Name| Description|
| -------- | -------- |
| [OH_Rdb_Config](_o_h___rdb___config.md) | Defines the RDB store configuration.|
| [OH_Rdb_Store](_o_h___rdb___store.md) | Defines the RDB store type.|
### Enums
| Name| Description|
| -------- | -------- |
| [OH_Rdb_SecurityLevel](_r_d_b.md#oh_rdb_securitylevel) { S1 = 1, S2, S3, S4 } | Enumerates the RDB store security levels.|
### Functions
| Name| Description|
| -------- | -------- |
| [OH_Rdb_CreateValueObject](_r_d_b.md#oh_rdb_createvalueobject) (void) | Creates an [OH_VObject](_o_h___v_object.md) instance.|
| [OH_Rdb_CreateValuesBucket](_r_d_b.md#oh_rdb_createvaluesbucket) (void) | Creates an [OH_VBucket](_o_h___v_bucket.md) instance.|
| [OH_Rdb_CreatePredicates](_r_d_b.md#oh_rdb_createpredicates) (const char \*table) | Creates an [OH_Predicates](_o_h___predicates.md) instance.|
| [OH_Rdb_GetOrOpen](_r_d_b.md#oh_rdb_getoropen) (const [OH_Rdb_Config](_o_h___rdb___config.md) \*config, int \*errCode) | Obtains an [OH_Rdb_Store](_o_h___rdb___store.md) instance for RDB store operations.|
| [OH_Rdb_CloseStore](_r_d_b.md#oh_rdb_closestore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Destroys an [OH_Rdb_Store](_o_h___rdb___store.md) object and reclaims the memory occupied by the object.|
| [OH_Rdb_DeleteStore](_r_d_b.md#oh_rdb_deletestore) (const char \*path) | Deletes an RDB store with the specified database file configuration.|
| [OH_Rdb_Insert](_r_d_b.md#oh_rdb_insert) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*table, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket) | Inserts a row of data into a table.|
| [OH_Rdb_Update](_r_d_b.md#oh_rdb_update) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket, [OH_Predicates](_o_h___predicates.md) \*predicates) | Updates data in an RDB store based on specified conditions.|
| [OH_Rdb_Delete](_r_d_b.md#oh_rdb_delete) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates) | Deletes data from an RDB store based on specified conditions.|
| [OH_Rdb_Query](_r_d_b.md#oh_rdb_query) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates, const char \*const \*columnNames, int length) | Queries data in an RDB store based on specified conditions.|
| [OH_Rdb_Execute](_r_d_b.md#oh_rdb_execute) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Executes the SQL statement that returns no value.|
| [OH_Rdb_ExecuteQuery](_r_d_b.md#oh_rdb_executequery) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Queries data in an RDB store based on the SQL statements executed.|
| [OH_Rdb_BeginTransaction](_r_d_b.md#oh_rdb_begintransaction) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Starts the transaction before executing the SQL statements.|
| [OH_Rdb_RollBack](_r_d_b.md#oh_rdb_rollback) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Rolls back the SQL statements executed. |
| [OH_Rdb_Commit](_r_d_b.md#oh_rdb_commit) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Commits the executed SQL statements.|
| [OH_Rdb_Backup](_r_d_b.md#oh_rdb_backup) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Backs up the RDB store in the specified path.|
| [OH_Rdb_Restore](_r_d_b.md#oh_rdb_restore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Restores an RDB store from the specified database backup file.|
| [OH_Rdb_GetVersion](_r_d_b.md#oh_rdb_getversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int \*version) | Obtains the RDB store version.|
| [OH_Rdb_SetVersion](_r_d_b.md#oh_rdb_setversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int version) | Sets the RDB store version.|
# relation_error_code.h
## Overview
Declares the error codes used for relational database (RDB) stores.
**Since**
10
**Related Modules**
[RDB](_r_d_b.md)
## Summary
### Enums
| Name| Description|
| -------- | -------- |
| [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode)&nbsp;{&nbsp;RDB_ERR_INVALID_ARGS&nbsp;=&nbsp;-2,&nbsp;RDB_ERR&nbsp;=&nbsp;-1,&nbsp;RDB_ERR_OK&nbsp;=&nbsp;0&nbsp;} | Enumerates the RDB store error codes. |
......@@ -359,6 +359,14 @@ Power management display
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No |
## SystemCapability.PowerManager.DisplayPowerManager.Lite
Lite device capabilities of the system power management display
| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | Yes | Yes | Yes | No | Yes | No | No |
## SystemCapability.PowerManager.ThermalManager
Temperature control
......
......@@ -46,9 +46,11 @@ Adhere to the following constraints and rules when using transient tasks:
- **Quota mechanism**: To prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). The default quota for a single day is 10 minutes, and the maximum quota for each request is 3 minutes. After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.)
## Continuous Tasks
Continuous tasks provide background running lifecycle support for services that can be directly perceived by users and need to run in the background. For example, if a service needs to play audio or continue with navigation and positioning in the background, which can be perceived by users, it can execute a continuous task in the respective background mode.
### Background Mode Classification
OpenHarmony provides 9 background modes for services that require continuous task execution.
**Table 1** Background modes for continuous tasks
......@@ -66,6 +68,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas
| taskKeeping | Computing task | A computing task is running | Effective only for specific devices |
### Restrictions on Using Continuous Tasks
- If a user triggers a perceivable task, such as broadcasting and navigation, the corresponding background mode is triggered. When the task is started, the system forcibly displays a notification to the user.
- If the task is complete, the application should exit the background mode. If the system detects that an application is not using the resources in the corresponding background mode when the application is running in the background, the application is suspended.
- Ensure that the requested continuous task background mode matches the application type. If the background mode does not match the application type, the system will suspend the task once it detects the issue.
......@@ -73,6 +76,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas
- An ability can request only one continuous task at a time. If an application has multiple abilities, you can request a continuous task for each ability.
## Work Scheduler Tasks
The Work Scheduler provides a mechanism for an application to execute a non-real-time task, for example, data learning, when the system is idle. The system places the Work Scheduler tasks requested by applications in a queue and determines the optimal scheduling time of each task based on the storage space, power consumption, temperature, and more. Persistence is supported. This means that a requested Work Scheduler task can be triggered when the application exits or the device restarts.
### Restrictions on Using Work Scheduler Tasks
......@@ -103,6 +107,7 @@ The use of the Work Scheduler must comply with the following restrictions and ru
- The carried parameters can be of the number, string, or boolean type.
## Efficiency Resources
Efficiency resources are classified into software (WORK_SCHEDULER, COMMON_EVENT, and TIMER) and hardware resources (CPU, GPS, BLUETOOTH, and AUDIO).
An application can perform different operations based on the requested efficiency resources.
......@@ -126,6 +131,7 @@ An application can perform different operations based on the requested efficienc
| AUDIO | 64 | AUDIO resources, which prevent audio resources from being proxied when the application is suspended. |
### Restrictions on Using Efficiency Resources
- Applications or processes are responsible for requesting and releasing efficiency resources. A process can release the resources requested by itself, whereas an application can release the resources requested by both itself and its processes. For example, an application requests CPU resources, and its process requests CPU and WORK_SCHEDULER resources. If the application initiates CPU resource release, the CPU resources requested by the process are also released. However, the WORK_SCHEDULER resources are not released. If the process initiates CPU resource release, the CPU resources requested by the application are retained until being released by the application.
- If persistent resources and non-persistent resources of the same type are requested, the persistent resources overwrite the non-persistent resources and they will not be released upon a timeout. For example, if an application first requests 10-second CPU resources and then requests persistent CPU resources at the 5th second, the CPU resources become persistent and will not be released at the tenth second. If the application releases the CPU resources at the 8th second, both types of CPU resources are released.
- The WORK_SCHEDULER resources can be requested and released by applications, but not by processes.
......
......@@ -54,33 +54,36 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
- Capsule button (default type)
Buttons of this type have rounded corners whose radius is automatically set to half of the button height. The rounded corners cannot be reset through the **borderRadius** attribute.
```ts
Button('Disable', { type: ButtonType.Capsule, stateEffect: false })
.backgroundColor(0x317aff)
.width(90)
.height(40)
```
![en-us_image_0000001511421208](figures/en-us_image_0000001511421208.png)
- Circle button
Buttons of this type are round. The rounded corners cannot be reset through the **borderRadius** attribute.
```ts
Button('Circle', { type: ButtonType.Circle, stateEffect: false })
.backgroundColor(0x317aff)
.width(90)
.height(90)
```
![en-us_image_0000001511740428](figures/en-us_image_0000001511740428.png)
- Normal button
Buttons of this type have rounded corners set to 0. The rounded corners can be reset through the **borderRadius** attribute.
```ts
Button('Ok', { type: ButtonType.Normal, stateEffect: true })
.borderRadius(8)
......@@ -88,56 +91,60 @@ Use the **type** parameter to set the button type to **Capsule**, **Circle**, or
.width(90)
.height(40)
```
![en-us_image_0000001563060641](figures/en-us_image_0000001563060641.png)
## Setting Styles
- Set the border radius:
- Set the border radius.
In general cases, you can use universal attributes to define the button styles. For example, you can use the **borderRadius** attribute to set the border radius.
```ts
Button('circle border', { type: ButtonType.Normal })
.borderRadius(20)
.height(40)
```
![en-us_image_0000001511900392](figures/en-us_image_0000001511900392.png)
- The **Font** type is used to set the text style.
Add a font style for text displayed on the button.
- Set the text style.
Add text style attributes for the button.
```ts
Button('font style', { type: ButtonType.Normal })
.fontSize(20)
.fontColor(Color.Pink)
.fontWeight(800)
```
![en-us_image_0000001511580828](figures/en-us_image_0000001511580828.png)
- Set the background color:
You can do so by adding the **backgroundColor** attribute.
- Set the background color.
Add the **backgroundColor** attribute for the button.
```ts
Button('background color').backgroundColor(0xF55A42)
```
![en-us_image_0000001562940477](figures/en-us_image_0000001562940477.png)
- Assign a function to the button:
- Assign a function to the button.
In this example, the delete function is assigned to the button.
```ts
Button({ type: ButtonType.Circle, stateEffect: true }) {
Image($r('app.media.ic_public_delete_filled')).width(30).height(30)
}.width(55).height(55).margin({ left: 20 }).backgroundColor(0xF55A42)
```
![en-us_image_0000001511740436](figures/en-us_image_0000001511740436.png)
......@@ -153,9 +160,10 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
```
## Example Scenario
## Example
- Using the button for startup
- Using the Button for Startup
You can use the button for any UI element that involves the startup operation. The button triggers the predefined event based on the user's operation. For example, you can use a button in the **\<List>** container to redirect the user to another page.
```ts
......@@ -194,7 +202,8 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
![en-us_image_0000001562700393](figures/en-us_image_0000001562700393.png)
- Use the button for submitting forms:
- Using the button for submitting forms
On the user login/registration page, you can use a button to submit a login or registration request.
```ts
......@@ -217,7 +226,8 @@ Button('Ok', { type: ButtonType.Normal, stateEffect: true })
![en-us_image_0000001562940473](figures/en-us_image_0000001562940473.png)
- Configure the button to float:
- Configuring the button to float
The button can remain floating when the user swipes on the screen.
```ts
......
......@@ -28,8 +28,17 @@ To use DevTools for frontend page debugging, perform the following steps:
}
}
```
2. Declare the required permission in the **module.json5** file of the application project in DevEco Studio.
2. Connect your device to a PC, and configure port mapping on the PC as follows:
```
"requestPermissions":[
{
"name" : "ohos.permission.INTERNET"
}
]
```
3. Connect your device to a PC, and configure port mapping on the PC as follows:
```
// Configure port mapping.
......@@ -38,7 +47,7 @@ To use DevTools for frontend page debugging, perform the following steps:
hdc fport ls
```
3. Enter **chrome://inspect/\#devices** in the address box of the Chrome browser on the PC. Once the device is identified, you can get started with page debugging. The debugging effect is as follows:
4. Enter **chrome://inspect/\#devices** in the address box of the Chrome browser on the PC. Once the device is identified, you can get started with page debugging. The debugging effect is as follows:
**Figure 1** Page debugging effect
......
# ArkUI Subsystem Changelog
## cl.arkui.1 Change in the \<Button> Component Hover Effect
The hover effect of the **\<Button>** component is changed from scale-up by 100% to 105% to overlay of 0% to 5% opacity. The pressed effect of the component is changed to overlay of 5% to 10% opacity.
**Change Impact**
The visual effect of the **\<Button>** is affected.
## cl.arkui.2 Change in the Multi-line Text Alignment Mode of Toasts
Changed the alignment mode of multi-line text in toasts from center-aligned to left-aligned.
**Change Impact**
The visual effect of toasts is affected.
......@@ -8,5 +8,10 @@
| Multi-language runtime subsystem| Verification enhanced | [New alarms are added and existing alarms are enhanced along with the upgrade from LLVM 12 to LLVM 15](changelogs-arkcompiler.md)|
| Multi-language runtime subsystem| Verification enhanced | [LLVM emu-tls is changed. If you use both LLVM 12 and LLVM 15, the emu-tls symbol cannot be found in libc++.so.](changelogs-arkcompiler.md)|
| Multi-language runtime subsystem| Verification enhanced | [New features and internal interface changes in the official release of LLVM 15 are inherited.](changelogs-arkcompiler.md)|
| ArkUI | Behavior changed | [The stack layout issue is fixed.](changelogs-arkui.md) |
| ArkUI | Default value changed | [The default state of the scrollbar in the \<List> and \<Gird> components is changed.](changelogs-arkui.md) |
| ArkUI | UX changed | [The hover effect of the \<Button> component is changed from scale-up by 100% to 105% to overlay of 0% to 5% opacity.](changelogs-arkui.md)|
| ArkUI | UX changed | [The alignment mode of multi-line text in toasts is changed from center-aligned to left-aligned.](changelogs-arkui.md)|
| Bundle management subsystem | Mechanism changed | [The HAP is no longer decompressed during HAP installation.](changelogs-bundlemanager.md)|
| Web | Input parameter added | [The input parameter type Resource is added for the setResponseData API.](changelogs-web.md) |
| Resource scheduler subsystem | Behavior changed | [The reminder agent allows you to customize buttons for system applications. Clicking a custom button will redirect you to the specified application page.](changelogs-resourceschedule.md)|
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册