diff --git a/en/application-dev/application-models/application-context-stage.md b/en/application-dev/application-models/application-context-stage.md index 8c26d7fbb70a19db0ab07ada99f4df8cc0b290df..17fe99577ab5cd782bcd4154274555bb8064da24 100644 --- a/en/application-dev/application-models/application-context-stage.md +++ b/en/application-dev/application-models/application-context-stage.md @@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different. | Name| Path| | -------- | -------- | - | bundleCodeDir | /el1/bundle/| - | cacheDir | //base/cache/| - | filesDir | //base/files/| - | preferencesDir | //base/preferences/| - | tempDir | //base/temp/| - | databaseDir | //database/| - | distributedFilesDir | /el2/distributedFiles/| + | bundleCodeDir | \/el1/bundle/| + | cacheDir | \/\/base/cache/| + | filesDir | \/\/base/files/| + | preferencesDir | \/\/base/preferences/| + | tempDir | \/\/base/temp/| + | databaseDir | \/\/database/| + | distributedFilesDir | \/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 | /el1/bundle/| - | cacheDir | //base/**haps/\**/cache/| - | filesDir | //base/**haps/\**/files/| - | preferencesDir | //base/**haps/\**/preferences/| - | tempDir | //base/**haps/\**/temp/| - | databaseDir | //database/**\**/| - | distributedFilesDir | /el2/distributedFiles/**\**/| + | bundleCodeDir | \/el1/bundle/| + | cacheDir | \/\/base/**haps/\**/cache/| + | filesDir | \/\/base/**haps/\**/files/| + | preferencesDir | \/\/base/**haps/\**/preferences/| + | tempDir | \/\/base/**haps/\**/temp/| + | databaseDir | \/\/database/**\**/| + | distributedFilesDir | \/el2/distributedFiles/**\**/| The sample code is as follows: diff --git a/en/application-dev/application-models/atomic-services-support-sharing.md b/en/application-dev/application-models/atomic-services-support-sharing.md index 99feea4719836f576762c3a43b0323c6bf2388cc..ba99573b28c4e25ef5ed2c8ca472e559a00f4713 100644 --- a/en/application-dev/application-models/atomic-services-support-sharing.md +++ b/en/application-dev/application-models/atomic-services-support-sharing.md @@ -1,27 +1,21 @@ # 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'; diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md index c028f5be4890c476bab762cfc8b0f0d12d9fdda8..cfa6e7cd1d26d5781a850384aa4be148ebb247e2 100644 --- a/en/application-dev/device/vibrator-guidelines.md +++ b/en/application-dev/device/vibrator-guidelines.md @@ -18,8 +18,85 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md | ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. | | ohos.vibrator | stopVibration(): Promise<void> | Stops vibration in all modes. This API uses a promise to return the result. | | ohos.vibrator | stopVibration(callback: AsyncCallback<void>): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. | -| ohos.vibrator | isSupportEffect(effectId: string): Promise<boolean> | 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<boolean>): 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<boolean> | 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<boolean>): 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); + ``` + diff --git a/en/application-dev/media/image-transformation-native.md b/en/application-dev/media/image-transformation-native.md index 06d342d8092744d7c565d02d0e62c13b71cc12d2..fbe7bed8cac71bdae20b90f9781a5329da3d0dcf 100644 --- a/en/application-dev/media/image-transformation-native.md +++ b/en/application-dev/media/image-transformation-native.md @@ -1,6 +1,6 @@ # 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%') + } } ``` diff --git a/en/application-dev/napi/purgeable-memory-guidelines.md b/en/application-dev/napi/purgeable-memory-guidelines.md index ffc2ff72ddd045d61da55c41f07434a8d4e31c28..706786d429b492f79f86c4c108cf8e3e63940def 100644 --- a/en/application-dev/napi/purgeable-memory-guidelines.md +++ b/en/application-dev/napi/purgeable-memory-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(iend){ - 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(iend){ + *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); diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 37bf36f22b5089789f6315e37a18947918501ff4..95713286ff3115e23e4733f63e84d77d3fecdc94 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -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 diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md index ed56fca0dd96bdd53e0bc66548c72c028a0ddf4f..a19759144290c86e6af1f6812569683e39d74bae 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md @@ -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 231-1.| + **Return value** | Type | Description | diff --git a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md index dbef711c25369d3eac61ca1b6516a7c43d8ecbc2..1f8af971be9c75fc3781d7a66422c38466f29aa4 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md @@ -1,4 +1,4 @@ -# @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'; ``` + +## ProxyData10+ + +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.| - +| proxies10+ | 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.| diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index 0cd79c938c8bb74f7fb919c7e6dc2e1afaa97cd8..f9012db2add74f9810baa032b103a4eff48dbd04 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -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<T> | 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<T> | 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<T> | 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<T> | 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 diff --git a/en/application-dev/reference/apis/js-apis-buffer.md b/en/application-dev/reference/apis/js-apis-buffer.md index 737c9f1dbf05e30e2f84e185b89e804642b0c39f..f50bdfe83cca98808fbb79237bd21194ec30b7a4 100644 --- a/en/application-dev/reference/apis/js-apis-buffer.md +++ b/en/application-dev/reference/apis/js-apis-buffer.md @@ -204,7 +204,7 @@ Concatenates an array of **Buffer** instances of the specified length into a new | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | list | Buffer[] \| 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.| diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md index 7242e7dabbf12e7e44a98fa23bc44b9ead440a1e..24a211683113a62ae975f77ea86d5139c4aeffc8 100644 --- a/en/application-dev/reference/apis/js-apis-deque.md +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-hashmap.md b/en/application-dev/reference/apis/js-apis-hashmap.md index c880644673fd9a8cd9d15ac05ec01afc9785bf3e..fc0a1e56470f7fb3a66a5feb1ad168b2c0fcea4a 100644 --- a/en/application-dev/reference/apis/js-apis-hashmap.md +++ b/en/application-dev/reference/apis/js-apis-hashmap.md @@ -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 | 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 | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md index df65bfcb4a3167ed9c9f2292065554a505e9f4e1..e396f5e4e5256a946c508b549cb183e35b439715 100644 --- a/en/application-dev/reference/apis/js-apis-hashset.md +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-lightweightmap.md b/en/application-dev/reference/apis/js-apis-lightweightmap.md index ed1848ad8df12b8a5526699908347ade635a9041..af435ce52e23abbca6d5f3777f2dadc82c4701d4 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/en/application-dev/reference/apis/js-apis-lightweightmap.md @@ -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 | 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 | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md index 05eba80d96783d32a427f1181bdc5b71bdab596b..7446c334dfa3022b943d1155e9bdab10e8e1e0a9 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightset.md +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-linkedlist.md b/en/application-dev/reference/apis/js-apis-linkedlist.md index 14382577e7b3fb1881e74527b8ec31ab87a89169..fa13281b52c968658e016fd7ee82be77e570fd60 100644 --- a/en/application-dev/reference/apis/js-apis-linkedlist.md +++ b/en/application-dev/reference/apis/js-apis-linkedlist.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index b7618d64c1d61a52324ada111347f666e7095c73..a9dd535c30efa333db867f444e28502f65ab8537 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -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<T> | 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<T> | 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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-plainarray.md b/en/application-dev/reference/apis/js-apis-plainarray.md index 14f73f6d4b11059551b376f7fcb9e56ee4e1ab84..5ce7718cc4bcb677a35f83079d9392d2b9d0ba0c 100644 --- a/en/application-dev/reference/apis/js-apis-plainarray.md +++ b/en/application-dev/reference/apis/js-apis-plainarray.md @@ -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<T>| 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<T>| No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md index c926b741543cd384f6c4b7649c2e8f1881883a55..ff4639e830aee3ba615858a38e3b8a84b12575a5 100644 --- a/en/application-dev/reference/apis/js-apis-queue.md +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 0c7fa19432c45e801f82b2892d47fa9ed384ea4e..a817d3bc82a541c9937c05aec30b2ecd0bb830ff 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ## reminderAgent.removeNotificationSlot(deprecated) -removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void +removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\): 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(deprecated) -removeNotificationSlot(slotType: notification.SlotType): Promise +removeNotificationSlot(slotType: notification.SlotType): Promise\ Removes a notification slot of a specified type. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md index 87a8ea3167b1cc125eb8e2bf5e30b4cfe54cc5a3..644759435975c722de9fd274b704ecd01804d2fd 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -611,7 +611,7 @@ Defines the reminder to publish. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| -| actionButton10+ | [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 | [ActionButton](#actionbutton) | No| Buttons 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.| | 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**.| diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md new file mode 100644 index 0000000000000000000000000000000000000000..116d4af987fb061f516d6ec37053794737f65c84 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md @@ -0,0 +1,382 @@ +# @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** +> +> 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'; +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(callback: AsyncCallback<boolean>): void; + +Checks whether the device is in standby mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the device is standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby((err, res) => { + if (err) { + console.log('DEVICE_STANDBY isDeviceInStandby callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY isDeviceInStandby callback succeeded, result: ' + JSON.stringify(res)); + } + }); +} catch(error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(): Promise<boolean> + +Checks whether the device is in standby mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<boolean> | Promise used to return whether the device is in standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby().then( res => { + console.log('DEVICE_STANDBY isDeviceInStandby promise succeeded, result: ' + JSON.stringify(res)); +}).catch( err => { + console.log('DEVICE_STANDBY isDeviceInStandby promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); +} catch (error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number, callback: AsyncCallback): void; + +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. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes | Types of resources that can be used.| +| callback | AsyncCallback | Yes |Callback used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes, (err, res) => { + if (err) { + console.log('DEVICE_STANDBY getExemptedApps callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY getExemptedApps callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps callback result ' + JSON.stringify(res[i])); + } + } +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number): 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. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes |Types of resources that can be used.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise | Promise used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 201 | Permission denied. | +| 202 | Not System App. | +| 401 | Parameter error. | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes).then( res => { + console.log('DEVICE_STANDBY getExemptedApps promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps promise result ' + JSON.stringify(res[i])); + } +}).catch( err => { + console.log('DEVICE_STANDBY getExemptedApps promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.requestExemptionResource + +requestExemptionResource(request: ResourceRequest): void; + +Requests exemption, so that the application can use restricted resources when the device is in standby mode. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.example.app", + duration:10, + reason:"apply", +}; +// Promise mode +try{ +deviceStandby.requestExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY requestExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.requestExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY requestExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY requestExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.releaseExemptionResource + +releaseExemptionResource(request: ResourceRequest): void; + +Cancels exemption for the application. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.demo.app", + duration:10, + reason:"unapply", +}; +// Promise mode +try{ +deviceStandby.releaseExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY releaseExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.releaseExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY releaseExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY releaseExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## ResourceType + +Enumerates the types of resources that can be used by exempted applications. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Value |Description| +| ------------ | ------------ |--------------| +|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. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------ | ------------ | +|[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. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------| ------------ | +|[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. | diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index e633bf43d4a8879701dd4d3f63f66f51a0f20425..c1136e75989e9dd2cfe00de84a9dee9c23bfb3cd 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -220,7 +220,7 @@ screenlock.lock().then((data) => { onSystemEvent(callback: Callback<SystemEvent>): 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<boolean>): 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<boolean> -Sends an event to the screen lock service. This API uses a promise to return the result. +Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md index 9ecf69bced25271e1c68299bb78e2a19bbaab756..998d202a759c605a87b43997132a023a68188373 100644 --- a/en/application-dev/reference/apis/js-apis-stack.md +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index 8eef0562cdedb91214d4eb9e688445eb6d8ff9b8..ec63058c998fcbaeb278a7a7c3ef7fcbc4620f2d 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -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| | -------- | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 01a1defec2d87411735e0ffcf30b08beb93faccf..55b0bdee44b6f421863162c3d078bd092fcfb95a 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -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 | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md index f05edc6533e92d21c49cf1dd2c91b7e9aa12ff0a..38f3d0525c9d7a35b33a808e0ae8fd38ea58bf4d 100644 --- a/en/application-dev/reference/apis/js-apis-treemap.md +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -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 | 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 | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md index b3259d3ccbf19fab20c027accad98c6519bf7f52..fafe6553d2469bd19badd9ec5ce0814b12b02299 100644 --- a/en/application-dev/reference/apis/js-apis-treeset.md +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -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<T> | 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<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 6600939a007d9ac3abd1ad964f3270445cec3a7e..c049c8f2a2a4a3cc3a37bc47c5672da9cb4bb3fe 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -586,7 +586,7 @@ result = textEncoder.encodeInto("\uD800¥¥"); ### encodeIntoUint8Array9+ -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(deprecated) -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** diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 7e59a7685b38a014a76065ee04255b106c9d8133..137cf7bfffa33bc4035ec80d10c7e09075b00ae1 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -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<T> | 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<T> | 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<T> | 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<T> | 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 diff --git a/en/application-dev/reference/apis/js-apis-vibrator.md b/en/application-dev/reference/apis/js-apis-vibrator.md index 46e6f69db5327502add3c26ba6fd6b897868fc0c..c0e2de3e09ae03dfb4a5e76c0e727e37856e807c 100644 --- a/en/application-dev/reference/apis/js-apis-vibrator.md +++ b/en/application-dev/reference/apis/js-apis-vibrator.md @@ -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.| +| [VibrateFromFile10+](#vibratefromfile10) | Vibration according to a custom vibration configuration file.| ## VibrateTime9+ @@ -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. | ## VibratePreset9+ @@ -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. | + +## VibrateFromFile10+ + +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.| + +## HapticFileDescriptor10+ + +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.| ## VibrateAttribute9+ @@ -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.| ## Usage9+ diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index f8e8f0fff5917b56be67e1f3ab0b21ac949e7ee3..9554f5b07dd9f131c81c7ef8e30df9813cc303e9 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -381,6 +381,7 @@ Creates and returns an **XmlPullParser** object. **Example** ```js +import util from '@ohos.util'; let strXml = '' + ']>' + @@ -432,6 +433,7 @@ Parses XML information. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -499,6 +501,7 @@ Obtains the column line number, starting from 1. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -542,6 +545,7 @@ Obtains the depth of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -588,6 +592,7 @@ Obtains the current line number, starting from 1. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -631,6 +636,7 @@ Obtains the name of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -673,6 +679,7 @@ Obtains the namespace of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -715,6 +722,7 @@ Obtains the prefix of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -758,6 +766,7 @@ Obtains the text of the current event. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -800,6 +809,7 @@ Checks whether the current element is empty. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -842,6 +852,7 @@ Checks whether the current text event contains only whitespace characters. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -883,6 +894,7 @@ Obtains the number of attributes for the current start tag. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md index f2c85939598b88cf371efdb21c6f7389992e7ee5..7428f4d9be2f17a6c591527137341fcbb46be3aa 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -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.
**true**: A vertical divider is used.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.
Default value: **'\#33182431'**
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | number \| string | Width of the divider.
Default value: **1**
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
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.
Default value: **1px**
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
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.
Default value: **LineCapStyle.Butt**
Since API version 9, this API is supported in ArkTS widgets.| diff --git a/en/application-dev/reference/arkui-ts/ts-components-summary.md b/en/application-dev/reference/arkui-ts/ts-components-summary.md index 19bc1f97eec987ec2e7b97f4507b3e8fc107f29d..d6195e588c8874f362faf3c1c88d4943bced4ad4 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/en/application-dev/reference/arkui-ts/ts-components-summary.md @@ -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. diff --git a/en/application-dev/reference/syscap-list.md b/en/application-dev/reference/syscap-list.md index f550259f41ac46bd6841083f87c412ba4e6c9a0f..bf294b95d9b536f5a71c41618896c26b893ab2fe 100644 --- a/en/application-dev/reference/syscap-list.md +++ b/en/application-dev/reference/syscap-list.md @@ -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 diff --git a/en/application-dev/task-management/background-task-overview.md b/en/application-dev/task-management/background-task-overview.md index c17f1b3827430f5b0aa2408fb4289276c63942a9..3132796740f148f69af750ff7982af4b9fe54133 100644 --- a/en/application-dev/task-management/background-task-overview.md +++ b/en/application-dev/task-management/background-task-overview.md @@ -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. diff --git a/en/application-dev/tools/packing-tool.md b/en/application-dev/tools/packing-tool.md index db0f232d6c53cdb7bf47c540010c2aea3f83d06c..dd219250333636f96f715530b3ef8c86f0810223 100644 --- a/en/application-dev/tools/packing-tool.md +++ b/en/application-dev/tools/packing-tool.md @@ -1,7 +1,7 @@ -# Packing and Unpacking Tools +# Packing Tool ## Overview -The packing tool packs compiled files for installation and release. The packing tool supports the generation of application packages (HAP), application sets (APP) to launch to the application market, quick fix packages (HQF), quick fix packages (APPQF) to launch to the application market, static shared libraries (HAR), and dynamic shared libraries (HSP). The unpacking tool is used to unpack the HAP, APP, HQF, APPQF, HAR, and HSP files and parse the HAP, HSP, APP, and APPQF files. Generally, the packing process is automatically carried out in DevEco Studio. However, you can also use the JAR package of the packing tool to pack files. The JAR package is stored in the **toolchains** directory in the SDK path. +The packing tool packs compiled files for installation and release. The packing tool supports the generation of HAP (an application package), APP (application set to launch to the application market), HQF (quick fix package), APPQF (quick fix package to launch to the application market ), HAR (static shared library), and HSP (dynamic shared library) files. The unpacking tool is used to unpack the HAP, APP, HQF, APPQF, HAR, and HSP files and parse the HAP, HSP, APP, and APPQF files. Generally, the packing process is automatically carried out in DevEco Studio. However, you can also use the JAR package of the packing tool to pack files. The JAR package is stored in the **toolchains** directory in the SDK path. ## Packing Commands @@ -15,7 +15,7 @@ You can use the JAR package of the packing tool to generate an HAP file by impor ``` - java -jar app_packing_tool.jar --mode hap --json-path