提交 7aee500f 编写于 作者: X xinking129

Merge remote-tracking branch 'upstream/master'

...@@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different. ...@@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path| | Name| Path|
| -------- | -------- | | -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/| | bundleCodeDir | \<Path prefix>/el1/bundle/|
| cacheDir | <Path prefix>/<Encryption level>/base/cache/| | cacheDir | \<Path prefix>/\<Encryption level>/base/cache/|
| filesDir | <Path prefix>/<Encryption level>/base/files/| | filesDir | \<Path prefix>/\<Encryption level>/base/files/|
| preferencesDir | <Path prefix>/<Encryption level>/base/preferences/| | preferencesDir | \<Path prefix>/\<Encryption level>/base/preferences/|
| tempDir | <Path prefix>/<Encryption level>/base/temp/| | tempDir | \<Path prefix>/\<Encryption level>/base/temp/|
| databaseDir | <Path prefix>/<Encryption level>/database/| | databaseDir | \<Path prefix>/\<Encryption level>/database/|
| distributedFilesDir | <Path prefix>/el2/distributedFiles/| | distributedFilesDir | \<Path prefix>/el2/distributedFiles/|
The sample code is as follows: The sample code is as follows:
...@@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different. ...@@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path| | Name| Path|
| -------- | -------- | | -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/| | bundleCodeDir | \<Path prefix>/el1/bundle/|
| cacheDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/cache/| | cacheDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/cache/|
| filesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/files/| | filesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/files/|
| preferencesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/preferences/| | preferencesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/preferences/|
| tempDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/temp/| | tempDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/temp/|
| databaseDir | <Path prefix>/<Encryption level>/database/**\<module-name>**/| | databaseDir | \<Path prefix>/\<Encryption level>/database/**\<module-name>**/|
| distributedFilesDir | <Path prefix>/el2/distributedFiles/**\<module-name>**/| | distributedFilesDir | \<Path prefix>/el2/distributedFiles/**\<module-name>**/|
The sample code is as follows: The sample code is as follows:
......
# Setting Atomic Services to Support Sharing # Setting Atomic Services to Support Sharing
By means of sharing, users can quickly access atomic services and use their features.
## How to Develop ## 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 ```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility { class MyUIAbility extends UIAbility {
onShare(wantParams) { onShare(wantParams) {
console.log('onShare'); console.log('onShare');
wantParams['ohos.extra.param.key.contentTitle'] = {title: "W3"}; wantParams['ohos.extra.param.key.contentTitle'] = {title: "OA"};
wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for huawei employee"}; wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for company employee"};
wantParams['ohos.extra.param.key.shareUrl'] = {url: "w3.huawei.com"}; 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 ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
......
...@@ -18,8 +18,85 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.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&lt;void&gt;): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. | | ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback&lt;void&gt;): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | stopVibration(): Promise&lt;void&gt; | Stops vibration in all modes. This API uses a promise to return the result. | | ohos.vibrator | stopVibration(): Promise&lt;void&gt; | Stops vibration in all modes. This API uses a promise to return the result. |
| ohos.vibrator | stopVibration(callback: AsyncCallback&lt;void&gt;): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. | | ohos.vibrator | stopVibration(callback: AsyncCallback&lt;void&gt;): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | isSupportEffect(effectId: string): Promise&lt;boolean&gt; | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | | ohos.vibrator | isSupportEffect(effectId: string): Promise&lt;boolean&gt; | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | | ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.|
## Custom Vibration Format
Custom vibration enables you to design desired vibration effects by customizing a vibration configuration file and orchestrating vibration forms based on the corresponding rules.
The custom vibration configuration file is in JSON format. An example file is as follows:
```json
{
"MetaData": {
"Create": "2023-01-09",
"Description": "a haptic case",
"Version": 1.0,
"ChannelNumber": 1
},
"Channels": [
{
"Parameters": {
"Index": 1
},
"Pattern": [
{
"Event": {
"Type": "transient",
"StartTime": 0,
"Parameters": {
"Intensity": 100,
"Frequency": 31
}
}
},
{
"Event": {
"Type": "continuous",
"StartTime": 100,
"Duration": 54,
"Parameters": {
"Intensity": 38,
"Frequency": 30
}
}
}
]
}
]
}
```
This JSON file contains two attributes: **MetaData** and **Channels**.
- **MetaData** contains information about the file header. You can add the following attributes under **MetaData**:
- **Version**: version number of the file format, which is forward compatible. Currently, only version 1.0 is supported. This parameter is mandatory.
- **ChannelNumber**: number of channels for vibration. Currently, only one channel is supported, and the value is fixed at **1**. This parameter is mandatory.
- **Create**: time when the file was created. This parameter is optional.
- **Description**: additional information such as the vibration effect and creation information. This parameter is optional.
- **Channels** provides information about the vibration channel. It is a JSON array that holds information about each channel. It contains two attributes: **Parameters** and **Pattern**.
- **Parameters** provides parameters related to the channel. Under it, **Index** indicates the channel ID. The value is fixed at **1** for a single channel. This parameter is mandatory.
- **Pattern** indicates the vibration sequence. It is a JSON array. Under it, **Event** indicates a vibration event, which can be either of the following types:
- **transient**: short vibration
- **continuous**: long vibration
The table below describes the parameters under **Event**.
| Parameter| Description| Value or Value Range|
| --- | ------------------------ | ---|
| Type | Type of the vibration event. This parameter is mandatory.| **transient** or **continuous**|
| StartTime | Start time of the vibration. This parameter is mandatory.| [0, 1800 000], in ms, without overlapping|
| Duration | Duration of the vibration. This parameter is valid only when **Type** is **continuous**.| (10, 1600), in ms|
| Intensity | Intensity of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration strength.|
| Frequency | Frequency of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration frequency|
The following requirements must be met:
| Item| Description |
| -------- | ------------------------ |
| Number of vibration events| No more than 128|
| Length of the vibration configuration file| Not greater than 64 KB|
## How to Develop ## How to Develop
...@@ -54,19 +131,19 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ...@@ -54,19 +131,19 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js ```js
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
try { try {
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission. // 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) { vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) {
if (error) { if (error) {
console.log('error.code' + error.code + 'error.message' + error.message); console.log('error.code' + error.code + 'error.message' + error.message);
return; return;
} }
console.log('Callback returned to indicate successful.'); console.log('Callback returned to indicate successful.');
}) })
} catch (err) { } catch (err) {
console.info('errCode: ' + err.code + ' ,msg: ' + err.message); console.info('errCode: ' + err.code + ' ,msg: ' + err.message);
} }
``` ```
4. Stop vibration in all modes. 4. Stop vibration in all modes.
```js ```js
...@@ -135,3 +212,63 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ...@@ -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)); 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);
```
# Image Transformation (Native) # 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 ## How to Develop
...@@ -22,9 +22,9 @@ Open the **src/main/cpp/hello.cpp** file and add the following API mappings to t ...@@ -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) static napi_value Init(napi_env env, napi_value exports)
{ {
napi_property_descriptor desc[] = { napi_property_descriptor desc[] = {
{ "createPixelMap", nullptr, CreatePixelMap, nullptr, nullptr, nullptr, napi_default, nullptr }, { "testGetImageInfo", nullptr, TestGetImageInfo, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "createAlphaPixelMap", nullptr, CreateAlphaPixelMap, nullptr, nullptr, nullptr, napi_default, nullptr }, { "testAccessPixels", nullptr, TestAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr },
{ "transform", nullptr, Transform, 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); 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 ...@@ -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: 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. 1. Obtain the **PixelMap** information and store the information to the **OhosPixelMapInfo** struct.
```c++
```c++ static napi_value TestGetImageInfo(napi_env env, napi_callback_info info)
// Create a PixelMap object.
napi_value CreatePixelMap(napi_env env, napi_callback_info info)
{ {
napi_value udfVar = nullptr; napi_value result = nullptr;
napi_value thisVar = nullptr; napi_get_undefined(env, &result);
napi_value argValue[2] = {0};
size_t argCount = 2;
void* buffer = nullptr; napi_value thisVar = nullptr;
size_t bufferSize = 0; napi_value argValue[1] = {0};
struct OhosPixelMapCreateOps createOps; size_t argCount = 1;
napi_value pixelmap = nullptr;
napi_get_undefined(env, &udfVar);
napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); 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) { OHOS::Media::OhosPixelMapInfo pixelMapInfo;
return udfVar; OHOS::Media::OH_GetImageInfo(env, argValue[0], &pixelMapInfo);
} return result;
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;
} }
```
// Create a PixelMap object that contains only the alpha channel. 2. Obtain the memory address of a **PixelMap** object and lock the memory.
napi_value CreateAlphaPixelMap(napi_env env, napi_callback_info info) ```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 thisVar = nullptr;
napi_value argValue[1] = {0}; napi_value argValue[1] = {0};
size_t argCount = 1; size_t argCount = 1;
napi_value alphaPixelmap = nullptr; napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
napi_get_undefined(env, &udfVar);
if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || void* addrPtr = nullptr;
argCount < 1 || argValue[0] == nullptr) { OHOS::Media::OH_AccessPixels(env, argValue[0], &addrPtr);
return udfVar; return result;
}
int32_t res = OH_PixelMap_CreateAlphaPixelMap(env, argValue[0], &alphaPixelmap);
if (res != OHOS_IMAGE_RESULT_SUCCESS || alphaPixelmap == nullptr) {
return udfVar;
}
return alphaPixelmap;
} }
``` ```
3. Unlock the memory of the **PixelMap** object.
2. Perform image transformation. For details about the operation, read the comments in the sample code below.
```c++ ```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_value result = nullptr;
napi_get_undefined(env, &result); napi_get_undefined(env, &result);
NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[0]); napi_value thisVar = nullptr;
if (native == nullptr) { napi_value argValue[1] = {0};
return result; size_t argCount = 1;
}
// Obtain image information. napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr);
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);
OHOS::Media::OH_UnAccessPixels(env, argValue[0]);
return result; return result;
} }
``` ```
...@@ -205,37 +102,41 @@ Obtain the JS resource object from the **hello.cpp** file and convert it to a na ...@@ -205,37 +102,41 @@ Obtain the JS resource object from the **hello.cpp** file and convert it to a na
```js ```js
import testNapi from 'libentry.so' import testNapi from 'libentry.so'
import image from '@ohos.multimedia.image' import image from '@ohos.multimedia.image';
@Entry @Entry
@Component @Component
struct Index { struct Index {
@State _pixelMap: image.PixelMap = undefined; @State message: string = 'IMAGE'
build() { @State _PixelMap: image.PixelMap = undefined
Row() {
Column() { build() {
Button("PixelMap") Row() {
.width(100) Column() {
.height(100) Button(this.message)
.onClick(() => { .fontSize(50)
const color = new ArrayBuffer(96); .fontWeight(FontWeight.Bold)
var bufferArr = new Uint8Array(color); .onClick(() => {
for (var i = 0; i < bufferArr.length; i++) { const color = new ArrayBuffer(96);
bufferArr[i] = 0x80; let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } }
} image.createPixelMap(color, opts)
.then( pixelmap => {
this._pixelMap = testNapi.createPixelMap(color); this._PixelMap = pixelmap;
testNapi.transform(this._pixelMap);
}) })
Image(this._pixelMap) testNapi.testGetImageInfo(this._PixelMap);
.width(500) console.info("Test GetImageInfo success");
.height(500)
.objectFit(ImageFit.Cover) testNapi.testAccessPixels(this._PixelMap);
} console.info("Test AccessPixels success");
.width('100%')
} testNapi.testUnAccessPixels(this._PixelMap);
.height('100%') console.info("Test UnAccessPixels success");
})
} }
.width('100%')
}
.height('100%')
}
} }
``` ```
...@@ -12,12 +12,12 @@ The following scenarios are common for native purgeable memory development: ...@@ -12,12 +12,12 @@ The following scenarios are common for native purgeable memory development:
## Available APIs ## 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.| | 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_Destroy(OH_PurgeableMemory \*purgObj) | Destroys a **PurgeableMemory** object.|
| bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory \*purgObj) | Begins a read operation on 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.| | 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.| |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_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.| |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 ...@@ -35,34 +35,32 @@ The following steps describe how to use the native purgeable memory APIs to appl
struct ParaData{ struct ParaData{
int start; int start;
int end; int end;
} };
// Declare a function for modifying the object. // Declare a function for modifying the object.
bool FactorialFunc(void* data, size_t size, void* param){ bool FactorialFunc(void* data, size_t size, void* param){
bool ret = true; bool ret = true;
int oriData = *(int*)(data); ParaData *pdata = (ParaData*) param;
int i = param->start; int* oriData = (int*)data;
while(i<param->end){ int i = pdata->start;
oriData *= i; while(i<pdata->end){
} *oriData *= i;
*data = oriData; }
if(oriData < 0) return ret;
ret = false;
return ret;
} }
// Declare the parameters of the extended function for modifying the object. // Declare the parameters of the extended function for modifying the object.
struct AppendParaData{ struct AppendParaData{
int newPara; int newPara;
} };
// Declare the extended function for modifying the object. // Declare the extended function for modifying the object.
bool AddFunc(void* data, size_t size, void* param){ bool AddFunc(void* data, size_t size, void* param){
bool ret = true; bool ret = true;
int oriData = *(int*)(data); int *oriDatap = (int*) data;
oriData += param->newPara; AppendParaData* apData = (AppendParaData*)param;
*data = oriData; *oriDatap += apData->newPara;
return ret; return ret;
} }
``` ```
2. Create a **PurgeableMemory** object. 2. Create a **PurgeableMemory** object.
...@@ -74,11 +72,14 @@ The following steps describe how to use the native purgeable memory APIs to appl ...@@ -74,11 +72,14 @@ The following steps describe how to use the native purgeable memory APIs to appl
struct ParaData pdata = {1,2}; struct ParaData pdata = {1,2};
// Create a PurgeableMemory object. // 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. 3. Perfrom a read operation on the **PurgeableMemory** object.
```c++ ```c++
// Define an object type based on the service requirements.
class ReqObj;
// Begin a read operation on the object. // Begin a read operation on the object.
OH_PurgeableMemory_BeginRead(pPurgmem); OH_PurgeableMemory_BeginRead(pPurgmem);
...@@ -94,8 +95,11 @@ The following steps describe how to use the native purgeable memory APIs to appl ...@@ -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. 4. Perform a write operation on the **PurgeableMemory** object.
```c++ ```c++
// Define an object type based on the service requirements.
class ReqObj;
// Begin a write operation on the object. // Begin a write operation on the object.
OH_PurgeableMemory_BeginWrite(pPurgmem) OH_PurgeableMemory_BeginWrite(pPurgmem);
// Obtain the object data. // Obtain the object data.
ReqObj* pReqObj = (ReqObj*) OH_PurgeableMemory_GetContent(pPurgmem); ReqObj* pReqObj = (ReqObj*) OH_PurgeableMemory_GetContent(pPurgmem);
......
...@@ -86,8 +86,10 @@ ...@@ -86,8 +86,10 @@
- [AppStateData](js-apis-inner-application-appStateData.md) - [AppStateData](js-apis-inner-application-appStateData.md)
- [BaseContext](js-apis-inner-application-baseContext.md) - [BaseContext](js-apis-inner-application-baseContext.md)
- [Context](js-apis-inner-application-context.md) - [Context](js-apis-inner-application-context.md)
- [ContinuableInfo](js-apis-inner-application-continuableInfo.md)
- [ContinueCallback](js-apis-inner-application-continueCallback.md) - [ContinueCallback](js-apis-inner-application-continueCallback.md)
- [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md) - [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md)
- [ContinueMissionInfo](js-apis-inner-application-continueMissionInfo.md)
- [ErrorObserver](js-apis-inner-application-errorObserver.md) - [ErrorObserver](js-apis-inner-application-errorObserver.md)
- [ExtensionContext](js-apis-inner-application-extensionContext.md) - [ExtensionContext](js-apis-inner-application-extensionContext.md)
- [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md) - [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md)
...@@ -194,8 +196,7 @@ ...@@ -194,8 +196,7 @@
- [@ohos.router (Page Routing)](js-apis-router.md) - [@ohos.router (Page Routing)](js-apis-router.md)
- [@ohos.measure (Text Measurement)](js-apis-measure.md) - [@ohos.measure (Text Measurement)](js-apis-measure.md)
- [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md) - [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md)
- Graphics
- Graphics
- [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md) - [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md)
- [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md) - [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md)
- [@ohos.display (Display)](js-apis-display.md) - [@ohos.display (Display)](js-apis-display.md)
...@@ -207,7 +208,6 @@ ...@@ -207,7 +208,6 @@
- webgl - webgl
- [WebGL](js-apis-webgl.md) - [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md) - [WebGL2](js-apis-webgl2.md)
- Multimedia - Multimedia
- [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md)
- [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md)
...@@ -347,6 +347,7 @@ ...@@ -347,6 +347,7 @@
- [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md)
- [@ohos.charger (Charging Type)](js-apis-charger.md) - [@ohos.charger (Charging Type)](js-apis-charger.md)
- [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.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.deviceInfo (Device Information)](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md)
- [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md)
...@@ -356,6 +357,7 @@ ...@@ -356,6 +357,7 @@
- [@ohos.multimodalInput.inputEvent (Input Event)](js-apis-inputevent.md) - [@ohos.multimodalInput.inputEvent (Input Event)](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient (Key Event Injection)](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputEventClient (Key Event Injection)](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor (Input Monitor)](js-apis-inputmonitor.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.keyCode (Key Code)](js-apis-keycode.md)
- [@ohos.multimodalInput.keyEvent (Key Event)](js-apis-keyevent.md) - [@ohos.multimodalInput.keyEvent (Key Event)](js-apis-keyevent.md)
- [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md)
...@@ -364,6 +366,7 @@ ...@@ -364,6 +366,7 @@
- [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md) - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md)
- [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.power (System Power Management)](js-apis-power.md)
- [@ohos.runningLock (Runninglock)](js-apis-runninglock.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.sensor (Sensor)](js-apis-sensor.md)
- [@ohos.settings (Data Item Settings)](js-apis-settings.md) - [@ohos.settings (Data Item Settings)](js-apis-settings.md)
- [@ohos.stationary (Device Status Awareness Framework)](js-apis-stationary.md) - [@ohos.stationary (Device Status Awareness Framework)](js-apis-stationary.md)
...@@ -378,7 +381,7 @@ ...@@ -378,7 +381,7 @@
- [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md)
- [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md)
- [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md)
- Customization - Customization
- [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md)
...@@ -421,7 +424,6 @@ ...@@ -421,7 +424,6 @@
- Test - Test
- [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md) - [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md)
- [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md)
- [@ohos.uitest (UiTest)](js-apis-uitest.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md)
- APIs No Longer Maintained - APIs No Longer Maintained
......
...@@ -388,7 +388,7 @@ abilityManager.getTopAbility().then((data) => { ...@@ -388,7 +388,7 @@ abilityManager.getTopAbility().then((data) => {
acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Object}>): void; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -429,10 +429,16 @@ try { ...@@ -429,10 +429,16 @@ try {
acquireShareData(missionId: number): Promise<{[key: string]: Object}>; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| missionId | number | Yes| Mission ID on the target application. The maximum value is 2<sup>31</sup>-1.|
**Return value** **Return value**
| Type | Description | | Type | Description |
......
# @ohos.application.formBindingData (formBindingData) # @ohos.app.form.formBindingData (formBindingData)
The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information. 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 ...@@ -12,6 +12,19 @@ The **FormBindingData** module provides APIs for widget data binding. You can us
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
``` ```
## ProxyData<sup>10+</sup>
Defines the subscription information about the widget update by proxy.
**System capability**: SystemCapability.Ability.Form
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Subscriber ID of the widget update by proxy. The value is the same as that of the data publisher.|
| subscriberId | string | No| Subscription condition of the widget update by proxy. The default value is the current widget ID (specified by **formId**).|
## FormBindingData ## FormBindingData
Describes a **FormBindingData** object. Describes a **FormBindingData** object.
...@@ -21,7 +34,7 @@ Describes a **FormBindingData** object. ...@@ -21,7 +34,7 @@ Describes a **FormBindingData** object.
| Name| Type| Mandatory| Description| | 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.| | data | Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| proxies<sup>10+</sup> | Array<[ProxyData](#proxydata)> | No| Subscription information of the widget update by proxy. The default value is an empty array.|
## createFormBindingData ## createFormBindingData
...@@ -62,3 +75,14 @@ try { ...@@ -62,3 +75,14 @@ try {
console.error(`catch error, code: ${error.code}, message: ${error.message}`); console.error(`catch error, code: ${error.code}, message: ${error.message}`);
} }
``` ```
## ProxyData
Defines the widget proxy data.
**System capability**: SystemCapability.Ability.Form
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the proxy. The value depends on the data publisher.|
| subscriberId | string | No| Subscriber ID. The value depends on the data publisher. The default value is the current widget ID.|
...@@ -379,15 +379,15 @@ Replaces all elements in this container with new elements, and returns the new o ...@@ -379,15 +379,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that invokes the **replaceAllElements** method.| | arrlist | ArrayList&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Error codes** **Error codes**
...@@ -425,15 +425,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -425,15 +425,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is 0.|
| arrlist | ArrayList&lt;T&gt; | No| Instance that invokes the **forEach** method.| | arrlist | ArrayList&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
...@@ -468,7 +468,7 @@ Sorts elements in this container. ...@@ -468,7 +468,7 @@ Sorts elements in this container.
| Name| Type| Mandatory| Description| | 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 comparator
......
...@@ -204,7 +204,7 @@ Concatenates an array of **Buffer** instances of the specified length into a new ...@@ -204,7 +204,7 @@ Concatenates an array of **Buffer** instances of the specified length into a new
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| list | Buffer[]&nbsp;\|&nbsp;Uint8Array[] | Yes| Array of instances to concatenate.| | list | Buffer[]&nbsp;\|&nbsp;Uint8Array[] | Yes| Array of instances to concatenate.|
| totalLength | number | No| Total length of bytes to be copied.| | totalLength | number | No| Total length of bytes to be copied. The default value is **0**.|
**Return value** **Return value**
...@@ -1915,7 +1915,7 @@ Converts the data at the specified position in this **Buffer** instance into a s ...@@ -1915,7 +1915,7 @@ Converts the data at the specified position in this **Buffer** instance into a s
| Name| Type| Mandatory| Description| | 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**.| | 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.| | end | number | No| Offset to the end position of the data to convert. The default value is the length of this **Buffer** instance.|
......
...@@ -242,15 +242,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -242,15 +242,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| deque | Deque&lt;T&gt; | No| Instance that invokes the **forEach** method.| | deque | Deque&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -459,14 +459,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -459,14 +459,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.| | 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.| | key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | HashMap<K, V> | No| Instance that invokes the **forEach** method.| | map | HashMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -282,14 +282,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -282,14 +282,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.| | 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**).| | key | T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.|
| set | HashSet&lt;T&gt; | No| Instance that invokes the **forEach** API.| | set | HashSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -724,14 +724,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -724,14 +724,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.| | 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.| | key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | LightWeightMap<K, V> | No| Instance that invokes the **forEach** method.| | map | LightWeightMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -588,14 +588,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -588,14 +588,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.| | 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**).| | key| T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.|
| set | LightWeightSet&lt;T&gt; | No| Instance that invokes the **forEach** method.| | set | LightWeightSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -607,15 +607,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -607,15 +607,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| LinkedList | LinkedList&lt;T&gt; | No| Instance that invokes the **forEach** API.| | LinkedList | LinkedList&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -427,15 +427,15 @@ Replaces all elements in this container with new elements, and returns the new o ...@@ -427,15 +427,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Value Type | Mandatory| Description| | Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.| | 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| | Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| list | List&lt;T&gt; | No| Instance that invokes the **replaceAllElements** method.| | list | List&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Error codes** **Error codes**
...@@ -473,15 +473,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -473,15 +473,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Value Type | Mandatory| Description| | Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for the replacement.| | 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| | Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| List | List&lt;T&gt; | No| Instance that invokes the **forEach** method.| | List | List&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -597,14 +597,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -597,14 +597,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type | Mandatory| Description| | Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type | Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Key of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| PlainArray | PlainArray&lt;T&gt;| No| Instance that invokes the **forEach** API.| | PlainArray | PlainArray&lt;T&gt;| No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -176,15 +176,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -176,15 +176,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| Queue | Queue&lt;T&gt; | No| Instance that invokes the **forEach** method.| | Queue | Queue&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ...@@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => {
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void
Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. 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, ...@@ -401,7 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup> ## reminderAgent.removeNotificationSlot<sup>(deprecated)</sup>
removeNotificationSlot(slotType: notification.SlotType): Promise<void> removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
Removes a notification slot of a specified type. This API uses a promise to return the result. Removes a notification slot of a specified type. This API uses a promise to return the result.
......
...@@ -611,7 +611,7 @@ Defines the reminder to publish. ...@@ -611,7 +611,7 @@ Defines the reminder to publish.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.|
| actionButton<sup>10+</sup> | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| | actionButton<sup></sup> | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.<br>- For common applications, a maximum of two buttons are supported.<br>- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.|
| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| | 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.| | 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**.| | ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.|
......
# @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&lt;boolean&gt;): 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&lt;boolean&gt; | 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&lt;boolean&gt;
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&lt;boolean&gt; | 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<Array&lt;ExemptedAppInfo&gt;>): 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<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 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<Array&lt;ExemptedAppInfo&gt;>;
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<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 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. |
...@@ -220,7 +220,7 @@ screenlock.lock().then((data) => { ...@@ -220,7 +220,7 @@ screenlock.lock().then((data) => {
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications. Registers a callback for system events related to screen locking. This API can be called only by screen lock applications.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
...@@ -264,7 +264,7 @@ try { ...@@ -264,7 +264,7 @@ try {
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void
Sends an event to the screen lock service. This API uses an asynchronous callback to return the result. Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
...@@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { ...@@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt; sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt;
Sends an event to the screen lock service. This API uses a promise to return the result. Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
......
...@@ -214,15 +214,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -214,15 +214,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| stack | Stack&lt;T&gt; | No| Instance that invokes the **forEach** method.| | stack | Stack&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void; ...@@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void;
Obtains the current charging state and battery level. Obtains the current charging state and battery level.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core **System capability**: SystemCapability.PowerManager.BatteryManager.Lite
**Parameters** **Parameters**
...@@ -46,7 +46,7 @@ battery.getStatus({ ...@@ -46,7 +46,7 @@ battery.getStatus({
Object that contains the API calling result. Object that contains the API calling result.
**System capability**: SystemCapability.PowerManager.BatteryManager.Core **System capability**: SystemCapability.PowerManager.BatteryManager.Lite
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -58,7 +58,7 @@ Object that contains the API calling result. ...@@ -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. 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| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
......
...@@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void ...@@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void
Obtains the current screen brightness. Obtains the current screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters** **Parameters**
...@@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void ...@@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void
Sets the screen brightness. Sets the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters** **Parameters**
...@@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void ...@@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void
Obtains the screen brightness adjustment mode. Obtains the screen brightness adjustment mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters** **Parameters**
...@@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void ...@@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void
Sets the screen brightness adjustment mode. Sets the screen brightness adjustment mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
Sets whether to always keep the screen on. Call this API in **onShow()**. 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** **Parameters**
...@@ -162,7 +162,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. ...@@ -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. Defines the options for obtaining the screen brightness.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -174,7 +174,7 @@ Defines the options for obtaining the screen brightness. ...@@ -174,7 +174,7 @@ Defines the options for obtaining the screen brightness.
Defines the options for setting 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 | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
...@@ -187,7 +187,7 @@ Defines the options for setting the screen brightness. ...@@ -187,7 +187,7 @@ Defines the options for setting the screen brightness.
Defines a response that returns 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| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -197,7 +197,7 @@ Defines a response that returns the screen brightness. ...@@ -197,7 +197,7 @@ Defines a response that returns the screen brightness.
Defines the options for obtaining the screen brightness mode. Defines the options for obtaining the screen brightness mode.
**System capability**: SystemCapability.PowerManager.DisplayPowerManager **System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
...@@ -209,7 +209,7 @@ Defines the options for obtaining the screen brightness mode. ...@@ -209,7 +209,7 @@ Defines the options for obtaining the screen brightness mode.
Defines the options for setting 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 | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
...@@ -222,7 +222,7 @@ Defines the options for setting the screen brightness mode. ...@@ -222,7 +222,7 @@ Defines the options for setting the screen brightness mode.
Defines a response that returns 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| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -232,7 +232,7 @@ Defines a response that returns the screen brightness mode. ...@@ -232,7 +232,7 @@ Defines a response that returns the screen brightness mode.
Defines the options for setting the screen to be steady on. 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 | | Name | Type | Mandatory| Description |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
......
...@@ -48,7 +48,7 @@ A constructor used to create a **TreeMap** instance. ...@@ -48,7 +48,7 @@ A constructor used to create a **TreeMap** instance.
| Name| Type| Mandatory| Description| | 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** **Error codes**
...@@ -611,14 +611,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -611,14 +611,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | V | No| Value of the element that is currently traversed.| | 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.| | key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| map | TreeMap<K, V> | No| Instance that invokes the **forEach** method.| | map | TreeMap<K, V> | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -44,7 +44,7 @@ A constructor used to create a **TreeSet** instance. ...@@ -44,7 +44,7 @@ A constructor used to create a **TreeSet** instance.
| Name| Type| Mandatory| Description| | 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** **Error codes**
...@@ -484,14 +484,14 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -484,14 +484,14 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | No| Value of the element that is currently traversed.| | 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.| | key | T | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.|
| set | TreeSet&lt;T&gt; | No| Instance that invokes the **forEach** method.| | set | TreeSet&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Error codes** **Error codes**
......
...@@ -586,7 +586,7 @@ result = textEncoder.encodeInto("\uD800¥¥"); ...@@ -586,7 +586,7 @@ result = textEncoder.encodeInto("\uD800¥¥");
### encodeIntoUint8Array<sup>9+</sup> ### encodeIntoUint8Array<sup>9+</sup>
encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number } encodeIntoUint8Array(input: string, dest: Uint8Array): { read: number; written: number }
Stores the UTF-8 encoded text. Stores the UTF-8 encoded text.
...@@ -617,7 +617,7 @@ result = that.encodeIntoUint8Array('abcd', dest) ...@@ -617,7 +617,7 @@ result = that.encodeIntoUint8Array('abcd', dest)
### encodeInto<sup>(deprecated)</sup> ### encodeInto<sup>(deprecated)</sup>
encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } encodeInto(input: string, dest: Uint8Array): { read: number; written: number }
Stores the UTF-8 encoded text. Stores the UTF-8 encoded text.
...@@ -1100,7 +1100,7 @@ A constructor used to create a **LruCache** instance. The default capacity of th ...@@ -1100,7 +1100,7 @@ A constructor used to create a **LruCache** instance. The default capacity of th
| Name | Type | Mandatory| Description | | 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** **Example**
...@@ -3400,7 +3400,7 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t ...@@ -3400,7 +3400,7 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t
| Name| Type| Mandatory| Description| | 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** **Example**
......
...@@ -304,15 +304,15 @@ Replaces all elements in this container with new elements, and returns the new o ...@@ -304,15 +304,15 @@ Replaces all elements in this container with new elements, and returns the new o
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for replacement.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| vector | Vector&lt;T&gt; | No| Instance that invokes the **replaceAllElements** API.| | vector | Vector&lt;T&gt; | No| Instance that calls the **replaceAllElements** API. The default value is this instance.|
**Example** **Example**
...@@ -342,15 +342,15 @@ Uses a callback to traverse the elements in this container and obtain their posi ...@@ -342,15 +342,15 @@ Uses a callback to traverse the elements in this container and obtain their posi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callbackFn | function | Yes| Callback invoked for replacement.| | 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| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | T | Yes| Value of the element that is currently traversed.| | value | T | Yes| Value of the element that is currently traversed.|
| index | number | No| Position index of the element that is currently traversed.| | index | number | No| Position index of the element that is currently traversed. The default value is **0**.|
| vector | Vector&lt;T&gt; | No| Instance that invokes the **forEach** API.| | vector | Vector&lt;T&gt; | No| Instance that calls the **forEach** API. The default value is this instance.|
**Example** **Example**
...@@ -378,7 +378,7 @@ Sorts elements in this container. ...@@ -378,7 +378,7 @@ Sorts elements in this container.
| Name| Type| Mandatory| Description| | 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 comparator
......
...@@ -460,8 +460,9 @@ Describes the vibration effect. ...@@ -460,8 +460,9 @@ Describes the vibration effect.
| Type | Description | | 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.| | [VibratePreset](#vibratepreset9) | Vibration with a preset effect.|
| [VibrateFromFile<sup>10+</sup>](#vibratefromfile10) | Vibration according to a custom vibration configuration file.|
## VibrateTime<sup>9+</sup> ## VibrateTime<sup>9+</sup>
...@@ -469,10 +470,10 @@ Describes the vibration with the specified duration. ...@@ -469,10 +470,10 @@ Describes the vibration with the specified duration.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ------------------------------ | | -------- | ------ | ----- | ------------------------------ |
| type | "time" | Vibration with the specified duration.| | type | string | Yes | The value **time** means vibration with the specified duration.|
| duration | - | Vibration duration, in ms. | | duration | number | Yes | Vibration duration, in ms. |
## VibratePreset<sup>9+</sup> ## VibratePreset<sup>9+</sup>
...@@ -480,11 +481,34 @@ Describes the vibration with a preset effect. ...@@ -480,11 +481,34 @@ Describes the vibration with a preset effect.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value | Description | | Name | Type | Mandatory| Description |
| -------- | -------- | ------------------------------ | | -------- | -------- | ---- |------------------------------ |
| type | "preset" | Vibration with the specified effect.| | type | string | Yes | The value **preset** means vibration with the specified effect.|
| effectId | - | Preset vibration effect ID. | | effectId | string | Yes | Preset vibration effect ID. |
| count | - | Number of vibrations to repeat. | | count | number | Yes | Number of vibrations to repeat. |
## VibrateFromFile<sup>10+</sup>
Describes the custom vibration type, which is supported only by certain devices.
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Mandatory| Description |
| -------- | -------- | ---- | ------------------------------ |
| type | string | Yes | The value **file** means vibration according to a vibration configuration file.|
| hapticFd | [HapticFileDescriptor](#hapticfiledescriptor10) | Yes| File descriptor (FD) of the vibration configuration file.|
## HapticFileDescriptor<sup>10+</sup>
Describes the FD of a custom vibration configuration file. Ensure that the file is available, and the parameters in it can be obtained from the sandbox path through the [file management API](js-apis-file-fs.md#fsopen) or from the HAP resource through the [resource management API](js-apis-resource-manager.md#getrawfd9). The use case is as follows: The system triggers vibration according to the sequence set in a configuration file, based on the specified offset and length. For details about the storage format of the vibration sequence, see [Custom Vibration Format](../../device/vibrator-guidelines.md#custom-vibration-format).
**System capability**: SystemCapability.Sensors.MiscDevice
| Name | Type | Mandatory | Description |
| -------- | -------- |--------| ------------------------------|
| fd | number | Yes | FD of the custom vibration configuration file. |
| offset | number | No | Offset from the start position of the file, in bytes. The default value is the start position of the file, and the value cannot exceed the valid range of the file.|
| length | number | No | Resource length, in bytes. The default value is the length from the offset position to the end of the file, and the value cannot exceed the valid range of the file.|
## VibrateAttribute<sup>9+</sup> ## VibrateAttribute<sup>9+</sup>
...@@ -492,10 +516,10 @@ Describes the vibration attribute. ...@@ -492,10 +516,10 @@ Describes the vibration attribute.
**System capability**: SystemCapability.Sensors.MiscDevice **System capability**: SystemCapability.Sensors.MiscDevice
| Name | Value| Description | | Name | Type| Mandatory| Description |
| ----- | ------ | -------------- | | ----- | ------ | ---- | -------------- |
| id | 0 | Vibrator ID. | | id | number | No| Vibrator ID. The default value is 0. |
| usage | - | Vibration scenario.| | usage | [Usage](#usage9) | Yes| Vibration scenario.|
## Usage<sup>9+</sup> ## Usage<sup>9+</sup>
......
...@@ -381,6 +381,7 @@ Creates and returns an **XmlPullParser** object. ...@@ -381,6 +381,7 @@ Creates and returns an **XmlPullParser** object.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' + '<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
...@@ -432,6 +433,7 @@ Parses XML information. ...@@ -432,6 +433,7 @@ Parses XML information.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -499,6 +501,7 @@ Obtains the column line number, starting from 1. ...@@ -499,6 +501,7 @@ Obtains the column line number, starting from 1.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -542,6 +545,7 @@ Obtains the depth of this element. ...@@ -542,6 +545,7 @@ Obtains the depth of this element.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -588,6 +592,7 @@ Obtains the current line number, starting from 1. ...@@ -588,6 +592,7 @@ Obtains the current line number, starting from 1.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -631,6 +636,7 @@ Obtains the name of this element. ...@@ -631,6 +636,7 @@ Obtains the name of this element.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -673,6 +679,7 @@ Obtains the namespace of this element. ...@@ -673,6 +679,7 @@ Obtains the namespace of this element.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -715,6 +722,7 @@ Obtains the prefix of this element. ...@@ -715,6 +722,7 @@ Obtains the prefix of this element.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -758,6 +766,7 @@ Obtains the text of the current event. ...@@ -758,6 +766,7 @@ Obtains the text of the current event.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -800,6 +809,7 @@ Checks whether the current element is empty. ...@@ -800,6 +809,7 @@ Checks whether the current element is empty.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -842,6 +852,7 @@ Checks whether the current text event contains only whitespace characters. ...@@ -842,6 +852,7 @@ Checks whether the current text event contains only whitespace characters.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
...@@ -883,6 +894,7 @@ Obtains the number of attributes for the current start tag. ...@@ -883,6 +894,7 @@ Obtains the number of attributes for the current start tag.
**Example** **Example**
```js ```js
import util from '@ohos.util';
let strXml = let strXml =
'<?xml version="1.0" encoding="utf-8"?>' + '<?xml version="1.0" encoding="utf-8"?>' +
'<note importance="high" logged="true">' + '<note importance="high" logged="true">' +
......
...@@ -26,7 +26,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the ...@@ -26,7 +26,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the
| ----------- | ---------- | ------------------ | | ----------- | ---------- | ------------------ |
| vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.| | vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.<br>**true**: A vertical divider is used.<br>Default value: **false**<br>Since API version 9, this API is supported in ArkTS widgets.|
| color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Default value: **'\#33182431'**<br>Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.<br>Default value: **'\#33182431'**<br>Since API version 9, this API is supported in ArkTS widgets.|
| strokeWidth | number \| string | Width of the divider.<br>Default value: **1**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.| | strokeWidth | number \| string | Width of the divider.<br>Default value: **1px**<br>Unit: vp<br>Since API version 9, this API is supported in ArkTS widgets.<br>**NOTE**<br>This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.|
| lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.| | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.<br>Default value: **LineCapStyle.Butt**<br>Since API version 9, this API is supported in ArkTS widgets.|
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
## Stack, Flex, and Grid ## 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. A container where child components are successively stacked and the latter one overwrites the previous one.
- [Flex](ts-container-flex.md) - [Flex](ts-container-flex.md)
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
## Scroll and Swipe ## 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. 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) - [Swiper](ts-container-swiper.md)
...@@ -79,9 +79,9 @@ ...@@ -79,9 +79,9 @@
## Navigation ## 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) - [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. 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 @@ ...@@ -293,7 +293,7 @@
A component that is used to display widgets. A component that is used to display widgets.
- [Menu](ts-basic-components-menu.md) - [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) - [MenuItem](ts-basic-components-menuitem.md)
A component that is used to represent an item in a menu. A component that is used to represent an item in a menu.
......
...@@ -359,6 +359,14 @@ Power management display ...@@ -359,6 +359,14 @@ Power management display
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| Yes | No | Yes | Yes | No | Yes | No | No | | 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 ## SystemCapability.PowerManager.ThermalManager
Temperature control Temperature control
......
...@@ -46,9 +46,11 @@ Adhere to the following constraints and rules when using transient tasks: ...@@ -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.) - **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
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. 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 ### Background Mode Classification
OpenHarmony provides 9 background modes for services that require continuous task execution. OpenHarmony provides 9 background modes for services that require continuous task execution.
**Table 1** Background modes for continuous tasks **Table 1** Background modes for continuous tasks
...@@ -66,6 +68,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas ...@@ -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 | | taskKeeping | Computing task | A computing task is running | Effective only for specific devices |
### Restrictions on Using Continuous Tasks ### 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 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. - 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. - 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 ...@@ -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. - 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 ## 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. 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 ### Restrictions on Using Work Scheduler Tasks
...@@ -103,6 +107,7 @@ The use of the Work Scheduler must comply with the following restrictions and ru ...@@ -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. - The carried parameters can be of the number, string, or boolean type.
## Efficiency Resources ## Efficiency Resources
Efficiency resources are classified into software (WORK_SCHEDULER, COMMON_EVENT, and TIMER) and hardware resources (CPU, GPS, BLUETOOTH, and AUDIO). 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. 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 ...@@ -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. | | AUDIO | 64 | AUDIO resources, which prevent audio resources from being proxied when the application is suspended. |
### Restrictions on Using Efficiency Resources ### 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. - 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. - 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. - The WORK_SCHEDULER resources can be requested and released by applications, but not by processes.
......
# Packing and Unpacking Tools # Packing Tool
## Overview ## 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 ## Packing Commands
...@@ -15,7 +15,7 @@ You can use the JAR package of the packing tool to generate an HAP file by impor ...@@ -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 <option> --resources-path <option> --ets-path <option> --index-path <option> --pack-info-path <option> --out-path path\out\srcEntrance.hap --force true java -jar app_packing_tool.jar --mode hap --json-path <option> --resources-path <option> --ets-path <option> --index-path <option> --pack-info-path <option> --out-path <option> --force true
``` ```
- A packing command example in the FA model: - A packing command example in the FA model:
...@@ -72,13 +72,13 @@ java -jar app_packing_tool.jar --mode har --json-path [option] --jar-path [optio ...@@ -72,13 +72,13 @@ java -jar app_packing_tool.jar --mode har --json-path [option] --jar-path [optio
### Packing Commands for APP Files ### Packing Commands for APP Files
You can use the JAR package of the packing tool to generate an APP file by importing packing options and file paths. The APP file is used to release the application to the application market. You can use the JAR package of the packing tool to generate an APP file by importing packing options and file paths. The APP file is used to release the application to the application market.
#### Example #### Example
``` ```
java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option> --out-path [option] --signature-path [option] --certificate-path [option] --pack-info [option]--force [option] java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option> --out-path <option> --signature-path [option] --certificate-path [option] --pack-info [option]--force [option]
``` ```
#### Parameters #### Parameters
...@@ -89,14 +89,14 @@ java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option ...@@ -89,14 +89,14 @@ java -jar app_packing_tool.jar --mode app --hap-path <option> --hsp-path <option
| --hap-path | Yes | NA | Path of the HAP file. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HAP file is stored.| | --hap-path | Yes | NA | Path of the HAP file. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HAP file is stored.|
| --hsp-path | No | NA | Path of the HSP file. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HSP file is stored.| | --hsp-path | No | NA | Path of the HSP file. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HSP file is stored.|
| --pack-info-path | Yes | NA | Path of the **pack.info** file. The file name must be **pack.info**. | | --pack-info-path | Yes | NA | Path of the **pack.info** file. The file name must be **pack.info**. |
| --out-path | No | NA | Path of the target file. The file name extension must be .app. | | --out-path | Yes | NA | Path of the target file. The file name extension must be .app. |
| --signature-path | No | NA | Path of the signature file. | | --signature-path | No | NA | Path of the signature file. |
| --certificate-path | No | NA | Path of the certificate file. | | --certificate-path | No | NA | Path of the certificate file. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. |
#### HAP Validity Check During APP Packing #### HAP Validity Check During APP Packing
When packing the HAP files in a project to generate an APP file, ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **minAPIVersion**, **targetAPIVersion**, and **apiReleaseType** configured in each JSON file of the HAP are the same, and the value of **moduleName** is unique in all the JSON files. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files. When packing the HAP files in a project to generate an APP file, ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, **targetAPIVersion**, and **apiReleaseType** configured in each JSON file of the HAP are the same, and the value of **moduleName** is unique in all the JSON files. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files.
### Multi-project Packing ### Multi-project Packing
...@@ -105,7 +105,7 @@ If multiple teams develop the same application but it is inconvenient to share c ...@@ -105,7 +105,7 @@ If multiple teams develop the same application but it is inconvenient to share c
#### Example #### Example
``` ```
java -jar app_packing_tool.jar --mode multiApp --hap-list 1.hap,2.hap --app-list 1.app,2.app --out-path final.app java -jar app_packing_tool.jar --mode multiApp --hap-list [option] --hsp-list [option] --app-list [option] --out-path <option>
``` ```
#### Parameters #### Parameters
...@@ -116,11 +116,12 @@ java -jar app_packing_tool.jar --mode multiApp --hap-list 1.hap,2.hap --app-list ...@@ -116,11 +116,12 @@ java -jar app_packing_tool.jar --mode multiApp --hap-list 1.hap,2.hap --app-list
| --hap-list | No | Path of the HAP files | Path of the HAP files. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HAP file is stored. | | --hap-list | No | Path of the HAP files | Path of the HAP files. The file name extension must be .hap. If there are multiple HAP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HAP file is stored. |
| --hsp-list | No | Path of the HSP files | Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HSP file is stored. | | --hsp-list | No | Path of the HSP files | Path of the HSP files. The file name extension must be .hsp. If there are multiple HSP files, separate them with commas (,).<br>The value can also be the directory (folder) where the HSP file is stored. |
| --app-list | No | Path of the APP files | Path of the APP files. The file name extension must be .app. If there are multiple APP files, separate them with commas (,).<br>The value can also be the directory (folder) where the APP file is stored.<br>You must specify **--hap-list**, **--hsp-list**, or **--app-list**, or any of their combinations.| | --app-list | No | Path of the APP files | Path of the APP files. The file name extension must be .app. If there are multiple APP files, separate them with commas (,).<br>The value can also be the directory (folder) where the APP file is stored.<br>You must specify **--hap-list**, **--hsp-list**, or **--app-list**, or any of their combinations.|
| --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf.|
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. |
#### HAP Validity Check During Multi-project Packing #### HAP Validity Check During Multi-project Packing
Ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **minAPIVersion**, **targetAPIVersion**, and **apiReleaseType** configured in each JSON file of the HAP are the same, the value of **moduleName** is unique in all the JSON files, and the value of **entry** is unique for the same device. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files. Ensure that the values of **bundleName**, **versionCode**, **versionName**, **minCompatibleVersionCode**, **debug**, **minAPIVersion**, **targetAPIVersion**, **apiReleaseType**, **compileSdkVersion**, and **compileSdkType** configured in each JSON file of the HAP are the same, the value of **moduleName** is unique in all the JSON files, and the value of **entry** is unique for the same device. For the FA model, you must also ensure that the value of **package** is unique in all the JSON files.
### Packing Commands for HQF Files ### Packing Commands for HQF Files
...@@ -129,7 +130,7 @@ If you find detects in the application and want to rectify the defects quickly, ...@@ -129,7 +130,7 @@ If you find detects in the application and want to rectify the defects quickly,
#### Example #### Example
``` ```
java -jar app_packing_tool.jar --mode hqf --json-path <option> ---lib-path <option> --ets-path <option> --out-path <option> java -jar app_packing_tool.jar --mode hqf --json-path <option> --lib-path <option> --ets-path <option> --out-path <option>
``` ```
#### Parameters #### Parameters
...@@ -139,7 +140,7 @@ java -jar app_packing_tool.jar --mode hqf --json-path <option> ---lib-path <opti ...@@ -139,7 +140,7 @@ java -jar app_packing_tool.jar --mode hqf --json-path <option> ---lib-path <opti
| --mode | Yes | hqf | Packing mode. | | --mode | Yes | hqf | Packing mode. |
| --json-path | Yes | NA | Path of the JSON file. The file name must be **patch.json**. | | --json-path | Yes | NA | Path of the JSON file. The file name must be **patch.json**. |
| --lib-path | No | NA | Path of the library file. | | --lib-path | No | NA | Path of the library file. |
| --ets-path | No | NA | Path of the ETS file. | | --ets-path | Yes | NA | Path of the ETS file. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf. | | --out-path | Yes | NA | Path of the target file. The file name extension must be .hqf. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing.| | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing.|
...@@ -188,430 +189,3 @@ java -jar path\app_packing_tool.jar --mode hsp --json-path <option> --resources- ...@@ -188,430 +189,3 @@ java -jar path\app_packing_tool.jar --mode hsp --json-path <option> --resources-
| --ets-path | No | NA | Path of the ETS file. | | --ets-path | No | NA | Path of the ETS file. |
| --out-path | Yes | NA | Path of the target file. The file name extension must be .hsp. | | --out-path | Yes | NA | Path of the target file. The file name extension must be .hsp. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. | | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during packing. |
## Unpacking Commands
### Unpacking Commands for HAP Files
You can use the JAR package of the unpacking tool to unpack an HAP file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <option> --hap-path <options> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- | ------------- | ------------------------------------------------------------ |
| --mode | Yes | hap | Unpacking mode. |
| --hap-path | Yes | NA | Path of the HAP file. |
| --rpcid | No | true or false| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.|
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking. |
### Unpacking Commands for HAR Files
You can use the JAR package of the unpacking tool to unpack an HAR file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <options> --har-path <option> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- |-------------| ----------------------------------------------------------- |
| --mode | Yes | har | Unpacking mode. |
| --har-path | Yes | NA | Path of the HAR file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
### Unpacking Commands for APP Files
You can use the JAR package of the unpacking tool to unpack an APP file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <options> --app-path <option> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- |-------------| ----------------------------------------------------------- |
| --mode | Yes | app | Unpacking mode. |
| --app-path | Yes | NA | Path of the APP file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
### Obtaining the rpcid File from the HAP File
You can use the JAR package of the unpacking tool to unpack an HAP file to obtain the rpcid file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode hap --rpcid true --hap-path <option> --out-path <option> --force true
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- | ------------- | ------------------------------------------------------------ |
| --mode | Yes | hap | Unpacking mode. |
| --rpcid | No | true or false| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.|
| --hap-path | Yes | NA | Path of the HAP file. |
| --out-path | Yes | NA | Path of the target rpcid file. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking. |
### Unpacking Commands for HSP Files
You can use the JAR package of the unpacking tool to unpack an HSP file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <option> --hsp-path <options> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
|------------| ---------- | ------------- |------------------------------------|
| --mode | Yes | hsp | Unpacking mode. |
| --hsp-path | Yes | NA | Path of the HSP file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
### Unpacking Commands for APPQF Files
You can use the JAR package of the unpacking tool to unpack an APPQF file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <option> --appqf-path <options> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
|--------------| ---------- |-------------|------------------------------------|
| --mode | Yes | appqf | Unpacking mode. |
| --appqf-path | Yes | NA | Path of the APPQF file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
## Package Parsing APIs
The package parsing APIs are used to parse an HAP file and obtain information such as the configuration file.
### Available APIs
| Class | Prototype | Type | Description |
| ------------------ | ------------------------------------------------------------ | -------- |-------------------------------------------------------------------|
| UncompressEntrance | UncomperssResult parseApp(String appPath,String parseMode,String deviceType,String hapName) | Java| Function: Parses **pack.info** in the APP file.<br>Input parameters: **appPath**, which specifies the path of the APP file.<br>Return value: **UncomperssResult**.|
| UncompressEntrance | UncomperssResult parseApp(InputStream input,String parseMode,String deviceType,String hapName,String outPath) | Java| Function: Parses **pack.info** in the APP file.<br>Input parameters: **input**, which specifies the stream of the APP file.<br>Return value: **UncomperssResult**.|
| UncompressEntrance | UncomperssResult parseHap(String hapPath) | Java| Function: Parses the JSON file in the APP file.<br>Input parameters: **hapPath**, which specifies the path of the HAP file.<br>Return value: **UncomperssResult**. |
| UncompressEntrance | UncomperssResult parseHap(InputStream input) | Java| Function: Parses the JSON file in the APP file.<br>Input parameters: **input**, which specifies the stream of the HAP file.<br>Return value: **UncomperssResult**. |
## Fields of the Unpacking Tool
### UncomperssResult (Bundle Information) Struct
| Field | Type | Description | Remarks|
| ------------ | ------------------ |----------------------------------------| ---- |
| result | boolean | Whether the parsing is successful. | NA |
| message | String | Failure cause returned if the parsing fails. | NA |
| packInfos | List\<PackInfo> | Information about **packages** in the **pack.info** file of the bundle. | NA |
| profileInfos | List\<profileInfo> | Configuration information of the application. | NA |
| icon | String | Path of the icon of the entry component. If there is no entry component, the icon path of the first component is returned.| NA |
| label | String | Label of the entry component. If there is no entry component, the label of the first component is returned.| NA |
### PackInfo Struct
| Field | Type | Description | Remarks|
| ------------------- | ------------- | --------------------------------------- | ---- |
| name | String | Bundle name. | NA |
| moduleName | String | HAP (module) name. | NA |
| moduleType | String | Module type. | NA |
| deviceType | List\<String> | Device type supported by the current HAP. | NA |
| deliveryWithInstall | boolean | Whether the HAP is installed when the user installs the application.| NA |
### ProfileInfo Struct
| Field | Type | Description | Remarks |
| ------------ | ------------------------------ | ------------------------------------------ | ------------------------------------------------------------ |
| hapName | String | Name of the HAP file that is being parsed. | NA |
| appInfo | AppInfo struct (see **AppInfo Struct** below)| Struct of the application information. For details, see **AppInfo Struct** below. | NA |
| deviceConfig | Map\<String,DeviceConfig> | Device information. | The storage type is Map\<String,String>, which indicates the device type name and device type value, respectively. In the stage model, this field is stored in the **app** struct.|
| hapInfo | HapInfo struct (see **HapInfo Struct** below)| Module information in the HAP file. For details, see **HapInfo Struct** below.| NA |
### AppInfo Struct
| Field | Type | Description | Remarks |
|--------------------------------|---------|-----------------------------------------------------------------------------|-----------|
| bundleName | String | Bundle name of the application. | NA |
| bundleType | String | Bundle type.<br>- **app**: The bundle is used for a common application.<br>- **atomicService**: The bundle is used for an atomic service.<br>- **shared**: The bundle is used for a shared library.| NA |
| vendor | String | Vendor of the application. | NA |
| releatedBundleName | String | Related bundle name of the application. | NA |
| versionName | String | Version name of the application. | NA |
| versionCode | String | Version code of the application. | NA |
| targetApiVersion | int | Target API version required for running the application. | NA |
| compatibleApiVersion | int | API version compatible with the application. | NA |
| appName | String | Label of the ability displayed on the home screen. | NA |
| releaseType | String | Release type of the target API version required for running the application. | NA |
| shellVersionCode | String | API version in HarmonyOS. | NA |
| shellVersionName | String | API version name in HarmonyOS. | NA |
| multiFrameworkBundle | String | Bundle name of the application in the dual-framework scenario. | NA |
| debug | boolean | Whether the application can be debugged. | NA |
| icon | String | Path of the application icon. | NA |
| label | String | Label of the application. | NA |
| description | String | Description of the application. | This field is newly added to the stage model.|
| minCompatibleVersionCode | int | Earliest compatible version of the application. | NA |
| distributedNotificationEnabled | boolean | Whether the distributed notification feature is enabled for the application. | This field is newly added to the stage model.|
| jointUserid | String | Shared user ID. | This field is unique to the FA model. |
| process | String | Process name of the application. | This field is unique to the FA model. |
| directLaunch | String | Whether the application can be started when the screen is locked. | NA |
| distributedNotificationEnabled | boolean | Whether the distributed notification feature is enabled for the application. | This field is unique to the stage model.|
### HapInfo Struct
| Field | Type | Description | Remarks |
| ------------------ |------------------------------------------------|--------------------------------| ------------------------------------------------------- |
| packageStr | String | Package information about the application. | This field is unique to the FA model. |
| name | String | Name of the module. | NA |
| description | String | Description of the HAP file. | This field is unique to the FA model. |
| supporteModes | List\<String> | Mode supported by the HAP file. | NA |
| abilities | Array of AbilityInfo | Ability information of the HAP file. | NA |
| distro | Distro Struct | Distro description of the HAP file. | NA |
| deviceType | List\<String> | Type of devices on which the HAP can run. | This field corresponds to **deviceTypes** in the stage model. |
| metadata | metaData struct (see **metaData Struct** below) | Custom metadata of the HAP. | NA |
| isJs | boolean | Whether the application is a JS application. | This field is unique to the FA model. |
| reqPermissions | ReqPermission struct array (see **ReqPermission** below) | Permissions requested by the application. | This field corresponds to **requestPermissions** in the stage model. |
| commonEvents | CommonEvent struct (see **CommonEvent Struct** below) | Static event. | NA |
| shortcuts | Shortcut struct array (see **Shortcut** below) | Shortcuts information of the application. | NA |
| distrofilter | DistroFilter struct | Information distributed by the application market by device form. | NA |
| srcEntrance | String | Entry code path of the application. | This field is newly added to the stage model. |
| process | String | Process name of the HAP. | This field is newly added to the stage model. |
| mainElement | String | Entry ability name or ExtensionAbility name of the HAP file.| This field is newly added to the stage model. In the FA model , the value of **mainAbility** is automatically assigned to **mainElement**.|
| unSyntax | String | Syntax type of a JS component. | This field is newly added to the stage model. |
| pages | List\<String> | Information about each page in a JS component. | This field is newly added to the stage model. |
| extensionAbilities | List\<ExtensionAbilityInfo> | ExtensionAbility information. | This field is newly added to the stage model. |
| abilityFormInfos | List\<AbilityFormInfo> | Widget information. | NA |
| moduleAtomicService| ModuleAtomicService struct (see **ModuleAtomicService Struct** below)| Atomic service information of the HAP. | NA |
### AbilityInfo Struct
| Field | Type | Description | Remarks |
|-------------------|--------------------------| ------------------------------------------------- | ------------------------------- |
| name | String | Logical name of the ability. | NA |
| description | String | Description of the ability. | NA |
| icon | String | Icon of the ability. | NA |
| label | String | Ability name visible to users. | NA |
| type | String | Ability type. | In the stage model, the value is directly assigned to the **page** field.|
| uri | String | URI of the ability. | This field is supported only in the FA model. |
| launchType | String | Launcher type of the ability. | NA |
### Distro Struct
| Field | Type | Description | Remarks |
| ------------------- |---------| ------------------------------------------------------------ | ------------------------------------------------------------ |
| moduleName | String | Name of the module. | This field corresponds to the **moduleName** field under the **module** struct in the stage model. |
| moduleType | String | Type of the module. | This field corresponds to the **moduleType** field under the **module** struct in the stage model. |
| deliveryWithInstall | boolean | Whether the HAP is installed when the user installs the application. | This field corresponds to the **deliveryWithInstall** field under the **module** struct in the stage model. |
| installationFree | int | Whether the HAP supports the installation-free feature. | This parameter corresponds to the **installationFree** field under the **module** struct in the stage model. In the JSON file, if this parameter is set to **true**, **1** is returned; if this parameter is set to **false**, **0** is returned; if this parameter is not set, **2** is returned.|
| virtualMachine | String | Type of the target virtual machine (VM) where the HAP is running. It is used for cloud distribution, such as the application market and distribution center.| This field corresponds to the **virtualMachine** field under the **module** struct in the stage model. |
### Metadata Struct
| Field | Type | Description | Remarks |
| -------------- |---------------------| -------------------------------- | ------------------------- |
| parameters | List\<MetadataInfo> | Metadata information. | This field is unique to the FA model. It is deprecated in the stage model.|
| results | List\<MetadataInfo> | Result information of the metadata. | This field is unique to the FA model. It is deprecated in the stage model.|
| customizeDatas | List\<CustomizeData> | Custom data of the metadata.| NA |
### MetadataInfo Struct
| Field | Type | Description | Remarks |
| ----------- | ------ | --------------------------------- | ------------------------- |
| name | String | Name of the **MetadataInfo** struct. | This field is unique to the FA model. It is deprecated in the stage model.|
| description | String | Description of the **MetadataInfo** struct.| This field is unique to the FA model. It is deprecated in the stage model.|
| type | String | Type of the **MetadataInfo** struct. | This field is unique to the FA model. It is deprecated in the stage model.|
### CustomizeData Struct
| Field | Type | Description | Remarks |
| ----- | ------ | ---------------------------- | ----------------------- |
| name | String | Name of the **CustomizeData** struct. | This field corresponds to **metadata** in the stage model.|
| value | String | Value of the **CustomizeData** struct.| This field corresponds to **metadata** in the stage model.|
| extra | String | Extra information of the **CustomizeData** struct.| This field corresponds to **metadata** in the stage model.|
### ReqPermission Struct
| Field | Type | Description | Remarks|
| --------- | ---------------------------------- |----------------------------------------------------| ---- |
| name | String | Name of the **ReqPermission** struct. | NA |
| reason | String | Reason for requesting the permission. This field is mandatory for a user_grant permission. | NA |
| usedScene | UsedScene struct (see **UsedScene Struct** below)| Application scenario of the permission. The value can be **ability** or **when**. Multiple abilities can be configured.| NA |
### UsedScene Struct
| Field | Type | Description | Remarks|
| ------- | ------------- | ------------------------------------------------------------ | ---- |
| ability | List\<String> | Abilities that use the permission. The value is an array. | NA |
| when | String | Time when the permission is used. The value can be **inuse** (the permission can be used only in the foreground) or **always** (the permission can be used in foreground and background).| NA |
### ShortCut Struct
| Field | Type | Description | Remarks|
| ---------- | ---------------------- | :----------------------------------------------------------- | ---- |
| shortcutId | String | ID of the **ShortCut** struct. | NA |
| label | String | Label of the **ShortCut** struct. | NA |
| icon | String | Icon of the **ShortCut** struct. | NA |
| intents | List of IntentInfo structs| Intents to which the shortcut points. The attribute consists of the **targetClass** and **targetBundle** sub-attributes.| NA |
### IntentInfo Struct
| Field | Type | Description | Remarks|
| ------------ | ------ | ---------------- | ---- |
| targetClass | String | Class name for the target ability of the shortcut.| NA |
| targetBundle | String | Target bundle name of the shortcut.| NA |
### DistroFilter Struct
| Field | Type | Description | Remarks|
| ------------- | ------------------- | ------------------------------------- | ---- |
| apiVersion | ApiVersion struct | API version of the **DistroFilter** struct. | NA |
| screenShape | ScreenShape struct | Screen shape of the **DistroFilter** struct. | NA |
| screenDensity | ScreenDensity struct| Screen density of the **DistroFilter** struct.| NA |
| screenWindow | ScreenWindow struct | Screen window of the **DistroFilter** struct. | NA |
| countryCode | CountryCode struct | Country code of the **DistroFilter** struct. | NA |
### ApiVersion Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenShape Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenDensity Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenWindow Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### CountryCode Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ExtensionAbilityInfo Struct
| Field | Type | Description | Remarks |
| --------------- | ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| name | String | Logical name of the ExtensionAbility. | This field is supported only in the stage model. |
| srcEntrance | String | JS code path of the ExtensionAbility. | This field is supported only in the stage model. |
| icon | String | Icon ID of the ExtensionAbility. | This field is supported only in the stage model. |
| label | String | ExtensionAbility name visible to users. | This field is supported only in the stage model. |
| description | String | Description of the ExtensionAbility. | This field is supported only in the stage model. |
| type | String | Type of the ExtensionAbility, which can be **form**, **workScheduler**, **inputMethod**, **service**, **accessibility**, **dataShare**, **fileShare**, **wallpaper**, or **backup**.| This field is supported only in the stage model. Currently, only **form** and **staticSubscriber** information is parsed. The information of other types is not parsed.|
| permissions | List\<String> | Permissions required when the ExtensionAbility is called by the ability of another application. | This field is supported only in the stage model. |
| readPermission | String | Permission required for reading data in the ExtensionAbility. | This field is supported only in the stage model. |
| writePermission | String | Permission required for writing data to the ExtensionAbility. | This field is supported only in the stage model. |
| visible | boolean | Whether the ExtensionAbility can be called by other applications. | This field is supported only in the stage model. |
| skills | SkillInfo array | Skills of the Want that the extensionAbility can receive. | This field is supported only in the stage model. |
| metadata | CustomizeData information| Metadata of the ExtensionAbility. | The information in **metadata** is assigned to **CustomizeData**. |
| uri | String | URI of the data provided by the ExtensionAbility. | This field is supported only in the stage model. |
### SkillInfo Struct
| Field | Type | Description | Remarks|
| -------- | ------------------- |----------------------| ---- |
| actions | List\<String> | Actions of the Want that the ExtensionAbility can receive.| NA |
| entities | List\<String> | Entities of the Want that the ExtensionAbility can receive. | NA |
| uriInfos | List\<String> | URIs of the Want. | NA |
### UriInfo Struct
| Field | Type | Description | Remarks|
| ------------- | ------ |------------------------| ---- |
| schema | String | Schema information of the **ModuleUriInfo** struct. | NA |
| host | String | Host of the **ModuleUriInfo** struct. | NA |
| port | String | Port of the **ModuleUriInfo** struct. | NA |
| pathStartWith | String | Path prefix of the **ModuleUriInfo** struct. | NA |
| pathRegex | String | Path regular expression of the **ModuleUriInfo** struct.| NA |
| path | String | Path information of the **ModuleUriInfo** struct. | NA |
| type | String | Type of the **ModuleUriInfo** struct. | NA |
### AbilityFormInfo Struct
| Field | Type | Description | Remarks |
| ------------------- | ------------- | ------------------------------------------------------------ |-----------|
| name | String | Name of the widget. | NA |
| description | String | Description of the widget. | This field is newly added to the stage model.|
| type | String | Type of the widget. | NA |
| src | String | JS code of the widget. | NA |
| isDefault | boolean | Whether the widget is a default one. Each HAP has only one default widget. | NA |
| colorMode | String | Color mode of the widget, which can be **auto**, **dark**, or **light**. | NA |
| updateEnabled | boolean | Whether the widget supports scheduled refresh. | NA |
| scheduledUpdateTime | String | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. | NA |
| updateDuration | int | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. | NA |
| supportDimensions | List\<String> | Dimensions supported by the widget, which can be **1 * 2**, **2 * 2**, **2 * 4**, or **4 * 4**. | NA |
| defaultDimension | String | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.| NA |
| formConfigAbility | String | Ability name for widget adjustment. | NA |
| formVisibleNotify | String | Whether the widget is allowed to use the visibility notification. | NA |
| MetaData | MetaData | Custom data of the widget. | NA |
| providerAbility | String | Ability or ExtensionAbility name of the widget.<br>1. FA model: If the widget is configured in an ability of the Service type, set **providerAbility** to **mainAbility**.<br>2. FA model: If the widget is configured in an ability of the Page type, set **providerAbility** to the current ability.<br>3. FA model: If **mainAbility** is not configured, set **providerAbility** to the ability that preferentially uses **system.home** in the current HAP. Otherwise, set **providerAbility** to the ability of the first page.<br>4. Stage model: Set **providerAbility** to **mainElement**.| NA |
### CommonEvent Struct
| Field | Type | Description | Remarks |
| ---------- | ------------- | -------------------------------------- | ------------------------------------------------ |
| name | String | Name of the class corresponding to the current static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| permission | String | Permissions required to implement the static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| data | List\<String> | Additional data array to be carried in the static common event.| In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| type | List\<String> | Type array for configuring the static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| events | List\<String> | Events of the Want that the ExtensionAbility can receive. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
### DependencyItem Struct
| Field | Type | Description | Remarks|
|--------------| ------ |--------------| ---- |
| bundleName | String | Bundle name of the shared package.| NA |
| moduleName | String | Module name of the shared package.| NA |
| versionCode | String | Version number of the shared bundle. | NA |
### ModuleAtomicService Struct
| Field | Type | Description | Remarks|
|--------------|----------------------------------------|----------------| ---- |
| preloadItems | PreloadItem object array| Preloaded objects. | NA |
### PreloadItem Struct
| Field | Type | Description | Remarks|
|--------------|-----|---------| ---- |
| moduleName | String| Name of the preloaded module.| NA |
# Unpacking Tool # Unpacking Tool
The unpacking tool is a commissioning tool provided by OpenHarmony. It can split a HAP file into folders or split an App Pack into HAP files in command line mode. The unpacking tool is a commissioning tool used to unpack HAP (an application package), HAR (static shared library), HSP (dynamic shared library), and APP (application set to launch to the application market) files. It also provides Java APIs to parse the HAP, APP, and HSP files.
The **app_unpacking_tool.jar** package can be found in the OpenHarmony SDK downloaded locally. The **app_unpacking_tool.jar** package can be found in the OpenHarmony SDK downloaded locally.
- Unpacking a HAP File ## Unpacking Commands
```bash ### Unpacking Commands for HAP Files
java -jar app_unpacking_tool.jar --mode <option> --hap-path <option> --out-path <option> --force <option>
``` You can use the JAR package of the unpacking tool to unpack an HAP file by importing unpacking options and file paths.
The table below describes the command parameters. #### Example
| Name| Mandatory| Description| ```
| -------- | -------- | -------- | java -jar app_unpacking_tool.jar --mode <option> --hap-path <options> --out-path [option] --force [option]
| --mode | Yes| Unpacking mode. In this scenario, set this parameter to **hap**.| ```
| --hap-path | Yes| Path of the HAP file.|
| --rpcid | No| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.| #### Parameters
| --out-path | Yes| Path of the target file.|
| --force | No| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.| | Name | Mandatory| Option | Description |
| ---------- | ---------- | ------------- | ------------------------------------------------------------ |
- Unpacking an App Pack | --mode | Yes | hap | Unpacking mode. |
| --hap-path | Yes | NA | Path of the HAP file. |
```bash | --rpcid | No | true or false| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.|
java -jar app_unpacking_tool.jar --mode <option> --app-path <option> --out-path <option> --force <option> | --out-path | Yes | NA | Path of the target files. |
``` | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking. |
The table below describes the command parameters. ### Unpacking Commands for HAR Files
| Name| Mandatory| Description| You can use the JAR package of the unpacking tool to unpack an HAR file by importing unpacking options and file paths.
| -------- | -------- | -------- |
| --mode | Yes| Unpacking mode. In this scenario, set this parameter to **hap**.| #### Example
| --app-path | Yes| Path of the App Pack.|
| --out-path | Yes| Path of the target file.| ```
| --force | No| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.| java -jar app_unpacking_tool.jar --mode <options> --har-path <option> --out-path [option] --force [option]
```
- Extracting the rpcid File from a HAP file
#### Parameters
```bash
java -jar app_unpacking_tool.jar --mode <option> --rpcid <option> --hap-path <option> --out-path <option> --force <option> | Name | Mandatory| Option | Description |
``` | ---------- | ---------- |-------------| ----------------------------------------------------------- |
| --mode | Yes | har | Unpacking mode. |
The table below describes the command parameters. | --har-path | Yes | NA | Path of the HAR file. |
| --out-path | Yes | NA | Path of the target files. |
| Name| Mandatory| Description| | --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
| -------- | -------- | -------- |
| --mode | Yes| Unpacking mode. In this scenario, set this parameter to **hap**.| ### Unpacking Commands for APP Files
| --rpcid | No| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.|
| --out-path | Yes| Path of the target file.| You can use the JAR package of the unpacking tool to unpack an APP file by importing unpacking options and file paths.
| --hap-path | Yes| Path of the HAP file.|
#### Example
```
java -jar app_unpacking_tool.jar --mode <options> --app-path <option> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- |-------------| ----------------------------------------------------------- |
| --mode | Yes | app | Unpacking mode. |
| --app-path | Yes | NA | Path of the APP file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
### Obtaining the rpcid File from the HAP File
You can use the JAR package of the unpacking tool to unpack an HAP file to obtain the rpcid file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode hap --rpcid true --hap-path <option> --out-path <option> --force true
```
#### Parameters
| Name | Mandatory| Option | Description |
| ---------- | ---------- | ------------- | ------------------------------------------------------------ |
| --mode | Yes | hap | Unpacking mode. |
| --rpcid | No | true or false| Whether to extract the rpcid file from the HAP file to a specified directory. If the value is **true**, only the rpcid file is extracted and the HAP file is not unpacked.|
| --hap-path | Yes | NA | Path of the HAP file. |
| --out-path | Yes | NA | Path of the target rpcid file. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking. |
### Unpacking Commands for HSP Files
You can use the JAR package of the unpacking tool to unpack an HSP file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <option> --hsp-path <options> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
|------------| ---------- | ------------- |------------------------------------|
| --mode | Yes | hsp | Unpacking mode. |
| --hsp-path | Yes | NA | Path of the HSP file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
### Unpacking Commands for APPQF Files
You can use the JAR package of the unpacking tool to unpack an APPQF file by importing unpacking options and file paths.
#### Example
```
java -jar app_unpacking_tool.jar --mode <option> --appqf-path <options> --out-path [option] --force [option]
```
#### Parameters
| Name | Mandatory| Option | Description |
|--------------| ---------- |-------------|------------------------------------|
| --mode | Yes | appqf | Unpacking mode. |
| --appqf-path | Yes | NA | Path of the APPQF file. |
| --out-path | Yes | NA | Path of the target files. |
| --force | No | true or false| The default value is **false**. If the value is **true**, an existing target file will be forcibly deleted during unpacking.|
## Package Parsing APIs
The package parsing APIs are used to parse an HAP, APP, or HSP file and obtain information such as the configuration file.
### Available APIs
| Class | Prototype | Type | Description |
| ------------------ | ------------------------------------------------------------ | -------- |-------------------------------------------------------------------|
| UncompressEntrance | UncomperssResult parseApp(String appPath,String parseMode,String deviceType,String hapName) | Java| Function: Parses **pack.info** in the APP file.<br>Input parameters: **appPath**, which specifies the path of the APP file.<br>Return value: **UncomperssResult**.|
| UncompressEntrance | UncomperssResult parseApp(InputStream input,String parseMode,String deviceType,String hapName,String outPath) | Java| Function: Parses **pack.info** in the APP file.<br>Input parameters: **input**, which specifies the stream of the APP file.<br>Return value: **UncomperssResult**.|
| UncompressEntrance | UncomperssResult parseHap(String hapPath) | Java| Function: Parses the JSON file in the APP file.<br>Input parameters: **hapPath**, which specifies the path of the HAP file.<br>Return value: **UncomperssResult**. |
| UncompressEntrance | UncomperssResult parseHap(InputStream input) | Java| Function: Parses the JSON file in the APP file.<br>Input parameters: **input**, which specifies the stream of the HAP file.<br>Return value: **UncomperssResult**. |
## Fields of the Unpacking Tool
### UncomperssResult (Bundle Information) Struct
| Field | Type | Description | Remarks|
| ----------------| ------------------ |----------------------------------------| ---- |
| result | boolean | Whether the parsing is successful. | NA |
| message | String | Failure cause returned if the parsing fails. | NA |
| packInfos | List\<PackInfo> | Information about **packages** in the **pack.info** file of the bundle. | NA |
| profileInfos | List\<profileInfo> | Configuration information of the application. | NA |
| profileInfosStr | List\<String> | Configuration information of the application.| NA |
| icon | String | Path of the icon of the entry component. If there is no entry component, the icon path of the first component is returned.| NA |
| label | String | Label of the entry component. If there is no entry component, the label of the first component is returned.| NA |
### PackInfo Struct
| Field | Type | Description | Remarks|
| ------------------- | ------------- | --------------------------------------- | ---- |
| name | String | Bundle name. | NA |
| moduleName | String | HAP (module) name. | NA |
| moduleType | String | Module type. | NA |
| deviceType | List\<String> | Device type supported by the current HAP. | NA |
| deliveryWithInstall | boolean | Whether the HAP is installed when the user installs the application.| NA |
### ProfileInfo Struct
| Field | Type | Description | Remarks |
| ------------ | ------------------------------ | ------------------------------------------ | ------------------------------------------------------------ |
| hapName | String | Name of the HAP file that is being parsed. | NA |
| appInfo | AppInfo struct (see **AppInfo Struct** below)| Struct of the application information. For details, see **AppInfo Struct** below. | NA |
| deviceConfig | Map\<String,DeviceConfig> | Device information. | The storage type is Map\<String,String>, which indicates the device type name and device type value, respectively. In the stage model, this field is stored in the **app** struct.|
| hapInfo | HapInfo struct (see **HapInfo Struct** below)| Module information in the HAP file. For details, see **HapInfo Struct** below.| NA |
### AppInfo Struct
| Field | Type | Description | Remarks |
|--------------------------------|---------|-------------------------------------------------------------------------------|-------------|
| bundleName | String | Bundle name of the application. | NA |
| vendor | String | Vendor of the application. | NA |
| relatedBundleName | String | Related bundle name of the application. | NA |
| versionName | String | Version name of the application. | NA |
| versionCode | String | Version code of the application. | NA |
| targetApiVersion | int | Target API version required for running the application. | NA |
| compatibleApiVersion | int | API version compatible with the application. | NA |
| appName | String | Label of the ability displayed on the home screen. | NA |
| appNameEN | String | Label of the ability displayed on the home screen. | NA |
| releaseType | String | Release type of the target API version required for running the application. | NA |
| shellVersionCode | String | API version in HarmonyOS. | NA |
| shellVersionName | String | API version name in HarmonyOS. | NA |
| multiFrameworkBundle | String | Bundle name of the application in the dual-framework scenario. | NA |
| debug | boolean | Whether the application can be debugged. | NA |
| icon | String | Path of the application icon. | NA |
| label | String | Label of the application. | NA |
| description | String | Description of the application. | This field is newly added to the stage model. |
| minCompatibleVersionCode | int | Earliest compatible version of the application. | NA |
| distributedNotificationEnabled | boolean | Whether the distributed notification feature is enabled for the application. | This field is newly added to the stage model. |
| bundleType | String | Bundle type.<br>- **app**: The bundle is used for a common application.<br>- **atomicService**: The bundle is used for an atomic service.<br>- **shared**: The bundle is used for a shared library.| NA |
| compileSdkVersion | String | SDK version used for compiling the application. | This field is valid only for API version 10 and later. |
| compileSdkType | String | SDK type used for compiling the application. | This field is valid only for API version 10 and later. |
| labels | HashMap\<String, String> | Labels of the application in multiple languages.| NA |
| descriptions | HashMap\<String, String> | Descriptions of the application in multiple languages.| NA |
### HapInfo Struct
| Field | Type | Description | Remarks |
| ---------------------|-----------------------------------------------|------------------------------------| ---------------------------------------|
| appModel | AppModel enumerated value | Application framework model.<br>- FA: FA model<br>- STAGE: stage model| NA |
| packageStr | String | Package information about the application. | This field is unique to the FA model. |
| name | String | Name of the module. | NA |
| description | String | Description of the HAP. | This field is unique to the FA model. |
| supportedModes | List\<String> | Modes supported by the HAP. | NA |
| abilities | List\<AbilityInfo> | Ability information of the HAP file. | NA |
| defPermissions | List\<DefPermission> | Default permissions of the HAP. | NA |
| definePermissions | List\<DefinePermission> | Defined permissions of the HAP. | NA |
| defPermissionsGroups | List\<DefPermissionsGroups> | Default permission groups of the HAP. | NA |
| distro | Distro struct | Distro description of the HAP file. | NA |
| reqCapabilities | List\<String> | Required capabilities of the HAP. | NA |
| deviceType | List\<String> | Type of devices on which the HAP can run. | This field corresponds to **deviceTypes** in the stage model. |
| metaData | metaData struct (see **metaData Struct** below) | Custom metadata of the HAP. | NA |
| dependencies | List\<DependencyItem> | Dependencies of the HAP. | NA |
| isJs | boolean | Whether the application is a JS application. | This field is unique to the FA model. |
| reqPermissions | list\<ReqPermission> | Permissions requested by the application. | This field corresponds to **requestPermissions** in the stage model.|
| commonEvents | CommonEvent struct (see **CommonEvent Struct** below) | Static event. | NA |
| shortcuts | list\<Shortcut> | Shortcuts used by the application. | NA |
| distroFilter | DistroFilter struct | Information distributed by the application market by device form. | NA |
| srcEntrance | String | Entry code path of the application. | This field is newly added to the stage model. |
| process | String | Process name of the HAP. | This field is newly added to the stage model. |
| mainElement | String | Entry ability name or ExtensionAbility name of the HAP file.| This field is newly added to the stage model. In the FA model , the value of **mainAbility** is automatically assigned to **mainElement**.|
| uiSyntax | String | Syntax type of a JS component. | This field is newly added to the stage model. |
| pages | List\<String> | Information about each page in a JS component. | This field is newly added to the stage model. |
| extensionAbilityInfos| List\<ExtensionAbilityInfo> | Information about the ExtensionAbility. | This field is newly added to the stage model. |
| moduleAtomicService | ModuleAtomicService struct (see **ModuleAtomicService Struct** below)| Atomic service information of the HAP. | NA |
| formInfos | List\<AbilityFormInfo> | Widget information. | NA |
| descriptions | HashMap\<String, String> | Description of the HAP. | NA |
### AbilityInfo Struct
| Field | Type | Description | Remarks |
|-------------------|--------------------------| ------------------------------------------------- | ------------------------------- |
| name | String | Logical name of the ability. | NA |
| description | String | Description of the ability. | NA |
| descriptionRes | String | Description of the ability. | NA |
| icon | String | Icon of the ability. | NA |
| iconPath | String | Path of the ability icon. | NA |
| label | String | Ability name visible to users. | NA |
| labelRes | String | Ability name visible to users. | NA |
| type | String | Ability type. | In the stage model, the value is directly assigned to the **page** field.|
| formsEnabled | boolean | Whether the widget is enabled for the ability. | NA |
| formInfo | FormInfo structure | Widget information. | NA |
| uri | String | URI of the ability. | This field is supported only in the FA model. |
| launchType | String | Launcher type of the ability. | NA |
| orientation | String | Orientation of the ability. | NA |
| visible | boolean | Whether the ability is visible. | NA |
| grantPermission | boolean | Granted permissions of the ability. | NA |
| readPermission | String | Read permissions of the ability. | NA |
| writePermission | String | Write permissions of the ability. | NA |
| uriPermissionMode | String | URI permission mode of the ability. | NA |
| uriPermissionPath | String | URI permission path of the ability. | NA |
| directLaunch | boolean | Whether the ability can be directly launched. | NA |
| mission | String | Mission of the ability. | NA |
| targetAbility | String | Target ability of the ability. | NA |
| multiUserShared | boolean | Whether the ability can be shared by multiple users. | NA |
| supportPipMode | boolean | Whether the ability supports the PIP mode. | NA |
| srcLanguage | String | Source language of the ability. | NA |
| srcPath | String | Source path of the ability. | NA |
| srcEntrance | String | Source entrance of the ability. | NA |
| continuable | boolean | Whether the ability can be continued on another device. | NA |
| metaData | MetaData struct (see **MetaData Struct** below)| Custom metadata of the ability. | NA |
| configChanges | List\<String> | Configuration changes of the ability. | NA |
| formInfos | List\<AbilityFormInfo> | Widgets of the ability. | NA |
| permissions | List\<String> | Permissions of the ability. | NA |
| skills | List\<SkillInfo> | Skills of the ability. | NA |
| backgroundModes | List\<String> | Background modes of the ability. | NA |
| labels | HashMap\<String, String> | Names of the ability displayed to users in multiple languages. | NA |
| descriptions | HashMap\<String, String> | Descriptions of the ability in multiple languages. | NA |
### Distro Struct
| Field | Type | Description | Remarks |
| ------------------- |---------| --------------------------------------- | ------------------------------------------------------------ |
| moduleName | String | Name of the module. | This field corresponds to the **moduleName** field under the **module** struct in the stage model. |
| moduleType | String | Type of the HAP. | This field corresponds to the **moduleType** field under the **module** struct in the stage model. |
| deliveryWithInstall | boolean | Whether the HAP is installed when the user installs the application.| This field corresponds to the **deliveryWithInstall** field under the **module** struct in the stage model. |
| installationFree | int | Whether the HAP supports the installation-free feature. | This parameter corresponds to the **installationFree** field under the **module** struct in the stage model. In the JSON file, if this parameter is set to **true**, **1** is returned; if this parameter is set to **false**, **0** is returned; if this parameter is not set, **2** is returned.|
| virtualMachine | String | Type of the target virtual machine (VM) where the HAP is running. It is used for cloud distribution, such as the application market and distribution center.| This field corresponds to the **virtualMachine** field under the **module** struct in the stage model.|
### MetaData Struct
| Field | Type | Description | Remarks |
| -------------- |----------------------| -------------------------------- | ------------------------- |
| parameters | List\<MetaDataInfo> | Metadata information. | This field is unique to the FA model. It is deprecated in the stage model. |
| results | List\<MetaDataInfo> | Result information of the metadata. | This field is unique to the FA model. It is deprecated in the stage model. |
| customizeDatas | List\<CustomizeData> | Custom data of the metadata.| NA |
### MetaDataInfo Struct
| Field | Type | Description | Remarks |
| ----------- | ------ | --------------------------------- | ------------------------- |
| name | String | Name of the **MetaDataInfo** struct. | This field is unique to the FA model. It is deprecated in the stage model. |
| description | String | Description of the **MetaDataInfo** struct.| This field is unique to the FA model. It is deprecated in the stage model. |
| type | String | Type of the **MetaDataInfo** struct. | This field is unique to the FA model. It is deprecated in the stage model. |
### CustomizeData Struct
| Field | Type | Description | Remarks |
| ----- | ------ | ---------------------------- | ----------------------- |
| name | String | Name of the **CustomizeData** struct. | This field corresponds to **metadata** in the stage model.|
| value | String | Value of the **CustomizeData** struct.| This field corresponds to **metadata** in the stage model.|
| extra | String | Extra information of the **CustomizeData** struct.| This field corresponds to **metadata** in the stage model.|
### ReqPermission Struct
| Field | Type | Description | Remarks|
| --------- | ---------------------------------- |------------------------------------------------------------| ---- |
| name | String | Name of the requested permission. | NA |
| reason | String | Reason for requesting the permission. This field is mandatory for a user_grant permission.| NA |
| usedScene | UsedScene struct (see **UsedScene Struct** below)| Application scenario of the permission. The value can be **ability** or **when**. Multiple abilities can be configured.| NA |
| reasons | HashMap\<String, String> | Reason for requesting the permission. This field is mandatory for a user_grant permission.| NA |
### UsedScene Struct
| Field | Type | Description | Remarks|
| ------- | ------------- | ------------------------------------------------------------ | ---- |
| ability | List\<String> | Abilities that use the permission. The value is an array. | NA |
| when | String | Time when the permission is used. The value can be **inuse** (the permission can be used only in the foreground) or **always** (the permission can be used in foreground and background).| NA |
### Shortcut Struct
| Field | Type | Description | Remarks|
| ---------- | ---------------------- | :----------------------------------------------------------- | ---- |
| shortcutId | String | ID of the **ShortCut** struct. | NA |
| label | String | Label of the **ShortCut** struct. | NA |
| icon | String | Icon of the **ShortCut** struct. | NA |
| intents | List\<IntentInfo> | Intents to which the shortcut points. The attribute consists of the **targetClass** and **targetBundle** sub-attributes.| NA |
| labels | HashMap\<String, String> | Shortcut names displayed to users in multiple languages. | NA |
### IntentInfo Struct
| Field | Type | Description | Remarks|
| ------------ | ------ | ---------------- | ---- |
| targetClass | String | Class name for the target ability of the shortcut.| NA |
| targetBundle | String | Target bundle name of the shortcut.| NA |
### DistroFilter Struct
| Field | Type | Description | Remarks|
| ------------- | ------------------- | ------------------------------------- | ---- |
| apiVersion | ApiVersion struct | API version of the **DistroFilter** struct. | NA |
| screenShape | ScreenShape struct | Screen shape of the **DistroFilter** struct. | NA |
| screenDensity | ScreenDensity struct| Screen density of the **DistroFilter** struct.| NA |
| screenWindow | ScreenWindow struct | Screen window of the **DistroFilter** struct. | NA |
| countryCode | CountryCode struct | Country code of the **DistroFilter** struct. | NA |
### ApiVersion Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenShape Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenDensity Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ScreenWindow Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### CountryCode Struct
| Field | Type | Description | Remarks|
| ------ | ------------- | ------------------------ | ---- |
| policy | String | Policy information in the struct.| NA |
| value | List\<String> | Value information in the struct. | NA |
### ExtensionAbilityInfo Struct
| Field | Type | Description | Remarks |
| --------------- | ------------------------ | ----------------------------------------------------- | ----------------------------------- |
| name | String | Logical name of the ExtensionAbility. | This field is supported only in the stage model. |
| srcEntrance | String | JS code path of the ExtensionAbility. | This field is supported only in the stage model. |
| icon | String | Icon ID of the ExtensionAbility. | This field is supported only in the stage model. |
| label | String | ExtensionAbility name visible to users. | This field is supported only in the stage model. |
| description | String | Description of the ExtensionAbility. | This field is supported only in the stage model. |
| type | String | Type of the ExtensionAbility, which can be **form**, **workScheduler**, **inputMethod**, **service**, **accessibility**, **dataShare**, **fileShare**, **wallpaper**, or **backup**.| This field is supported only in the stage model. Currently, only **form** and **staticSubscriber** information is parsed. The information of other types is not parsed. |
| permissions | List\<String> | Permissions required when the ExtensionAbility is called by the ability of another application. | This field is supported only in the stage model. |
| readPermission | String | Permission required for reading data in the ExtensionAbility. | This field is supported only in the stage model. |
| writePermission | String | Permission required for writing data to the ExtensionAbility. | This field is supported only in the stage model. |
| visible | boolean | Whether the ExtensionAbility can be called by other applications. | This field is supported only in the stage model. |
| skills | List\<SkillInfo> | Skills of the Want that the extensionAbility can receive. | This field is supported only in the stage model. |
| metadataInfos | List\<ModuleMetadataInfo>| Metadata that the ExtensionAbility can receive. | This field is supported only in the stage model. |
| metadata | MetaData Struct | Metadata of the ExtensionAbility. | The information in **metadata** is assigned to **CustomizeData**.|
| uri | String | URI of the data provided by the ExtensionAbility. | This field is supported only in the stage model. |
| descriptions | HashMap\<String, String> | Descriptions of the ExtensionAbility in multiple languages. | NA |
| labels | HashMap\<String, String> | Names of the ExtensionAbility displayed to users in multiple languages. | NA |
### SkillInfo Struct
| Field | Type | Description | Remarks|
| -------- | ------------------- |----------------------| ---- |
| actions | List\<String> | Actions of the Want that the ExtensionAbility can receive.| NA |
| entities | List\<String> | Entities of the Want that the ExtensionAbility can receive. | NA |
### UriInfo Struct
| Field | Type | Description | Remarks|
| ------------- | ------ |------------------------| ---- |
| schema | String | Schema information of the **ModuleUriInfo** struct. | NA |
| host | String | Host of the **ModuleUriInfo** struct. | NA |
| port | String | Port of the **ModuleUriInfo** struct. | NA |
| pathStartWith | String | Path prefix of the **ModuleUriInfo** struct. | NA |
| pathRegex | String | Path regular expression of the **ModuleUriInfo** struct.| NA |
| path | String | Path information of the **ModuleUriInfo** struct. | NA |
| type | String | Type of the **ModuleUriInfo** struct. | NA |
### AbilityFormInfo Struct
| Field | Type | Description | Remarks |
| ------------------- | -------------------------| ------------------------------------------------------------ |-----------|
| name | String | Name of the widget. | NA |
| type | String | Type of the widget. | NA |
| updateEnabled | boolean | Whether the widget supports scheduled refresh. | NA |
| scheduledUpdateTime | String | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. | NA |
| updateDuration | int | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. | NA |
| supportDimensions | List\<String> | Dimensions supported by the widget, which can be **1 * 2**, **2 * 2**, **2 * 4**, or **4 * 4**. | NA |
| defaultDimension | String | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.| NA |
| MetaData | MetaData | Custom data of the widget. | NA |
| description | String | Description of the widget. | This field is newly added to the stage model.|
| src | String | JS code of the widget. | NA |
| windowInfo | ModuleWindowInfo struct | Window information of the ability. | NA |
| isDefault | boolean | Whether the widget is a default one. Each HAP has only one default widget. | NA |
| colorMode | String | Color mode of the widget, which can be **auto**, **dark**, or **light**. | NA |
| formConfigAbility | String | Ability name for widget adjustment. | NA |
| formVisibleNotify | String | Whether the widget is allowed to use the visibility notification. | NA |
| providerAbility | String | Ability or ExtensionAbility name of the widget provider.<br>- FA model: If the widget is configured in an ability of the Service type, set **providerAbility** to **mainAbility**.<br/>- FA model: If the widget is configured in an ability of the Page type, set **providerAbility** to the current ability.<br/>- FA model: If **mainAbility** is not configured, set **providerAbility** to the ability that preferentially uses **system.home** in the current HAP. Otherwise, set **providerAbility** to the ability of the first page.<br/>- Stage model: Set **providerAbility** to **mainElement**. | NA |
| descriptions | HashMap\<String, String> | Descriptions of the ability in multiple languages. | NA |
### CommonEvent Struct
| Field | Type | Description | Remarks |
| ---------- | ------------- | -------------------------------------- | ------------------------------------------------ |
| name | String | Name of the class corresponding to the current static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| permission | String | Permissions required to implement the static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| data | List\<String> | Additional data array to be carried in the static common event.| In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| type | List\<String> | Type array for configuring the static common event. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
| events | List\<String> | Events of the Want that the ExtensionAbility can receive. | In the stage model, the value is obtained from the StaticSubscriberExtensionAbility.|
### DependencyItem Struct
| Field | Type | Description | Remarks|
|--------------| ------ |--------------| ---- |
| bundleName | String | Bundle name of the shared package.| NA |
| moduleName | String | Module name of the shared package.| NA |
| versionCode | String | Version number of the shared bundle. | NA |
### ModuleAtomicService Struct
| Field | Type | Description | Remarks|
|--------------|------------------------|----------------| ---- |
| preloadItems | list\<PreloadItem> | Preloaded objects. | NA |
### PreloadItem Struct
| Field | Type | Description | Remarks|
|--------------|--------|----------------| ---- |
| moduleName | String | Name of the preloaded module.| NA |
### DeviceConfig Struct
| Field | Type | Description | Remarks|
|--------------------------------|-------- |------------------------------------------| ---- |
| targetReqSdk | String | Target SDK version requested. | NA |
| compatibleReqSdk | String | Compatible SDK version requested. | NA |
| jointUserid | String | Joint user ID. | NA |
| process | String | Process. | NA |
| arkFlag | String | ArkCompiler flag. | NA |
| targetArkVersion | String | Target ArkCompiler version.| NA |
| compatibleArkVersion | String | Compatible ArkCompiler version. | NA |
| directLaunch | boolean | Whether direct launch is supported. | NA |
| distributedNotificationEnabled | boolean | Whether distributed notification is enabled.| NA |
### DefPermission Struct
| Field | Type | Description | Remarks|
|----------------|--------------------------|-------------------------------------------| ---- |
| name | String | Name of the default permission. | NA |
| grantMode | String | Grant mode of the default permission. | NA |
| group | String | Group of the default permission. | NA |
| label | String | Label of the default permission. | NA |
| description | String | Description of the default permission. | NA |
| availableScope | List\<String> | Available scope of the default permission. | NA |
| labels | HashMap\<String, String> | Labels of the default permission in multiple languages. | NA |
| descriptions | HashMap\<String, String> | Descriptions of the default permission in multiple languages. | NA |
### DefinePermission Struct
| Field | Type | Description | Remarks|
|------------------------|--------------------------|----------------------------------------------------| ---- |
| name | String | Name of the defined permission. | NA |
| grantMode | String | Grant mode of the defined permission. | NA |
| availableLevel | String | Group of the defined permission. | NA |
| provisionEnable | boolean | Whether the defined permission is enabled. | NA |
| distributedSceneEnable | boolean | Whether the distributed scene is enabled for the defined permission.| NA |
| label | String | Label of the defined permission. | NA |
| description | String | Description of the defined permission. | NA |
| descriptions | HashMap\<String, String> | Descriptions of the defined permission in multiple languages. | NA |
| labels | HashMap\<String, String> | Labels of the defined permission in multiple languages. | NA |
### DefPermissionsGroups Struct
| Field | Type | Description | Remarks|
|-------------|---------|------------------------------| ---- |
| name | String | Name of the default permission group.| NA |
| order | String | Sequence of the default permission group. | NA |
| icon | String | Icon of the default permission group.| NA |
| label | String | Label of the default permission group.| NA |
| description | String | Description of the default permission group.| NA |
| request | boolean | Request for the default permission group.| NA |
### FormInfo Struct
| Field | Type | Description | Remarks|
|---------------|---------------|--------------------------| ---- |
| formEntity | List\<String> | Widget entity.| NA |
| minHeight | String | Minimum height of the widget. | NA |
| defaultHeight | String | Default height of the widget. | NA |
| minWidth | String | Minimum width of the widget | NA |
| defaultWidth | String | Default width of the widget. | NA |
### ModuleMetadataInfo Struct
| Field | Type | Description | Remarks|
|----------|---------|------------------------------| ---- |
| name | String | Name of the ModuleMetadataInfo.| NA |
| value | String | Value of the ModuleMetadataInfo. | NA |
| resource | String | Resource of the ModuleMetadataInfo.| NA |
### ModuleWindowInfo Struct
| Field | Type | Description | Remarks|
|-----------------|---------|-------------------------------------| ---- |
| designWidth | int | Designed width of the used scene of the module. | NA |
| autoDesignWidth | boolean | Automatically designed width of the used scene of the module.| NA |
...@@ -3,95 +3,96 @@ ...@@ -3,95 +3,96 @@
> **NOTE** > **NOTE**
> >
> *1. This template provides the recommended development guide document framework and writing instructions for typical knowledge points. In your writing, complete the development task scenario analysis and development guide outline design based on the specific **solution/feature/function/module**, and then write the content based on this template.* > _1. This template provides the recommended development guide document framework and writing instructions for typical knowledge points. In your writing, complete the development task scenario analysis and development guide outline design based on the specific **solution/feature/function/module**, and then write the content based on this template._
> >
> *2. Do not add any content between level-1 title (marked with #) and level-2 title (marked with ##).* > _2. Do not add any content between level-1 title (marked with #) and level-2 title (marked with ##)._
> >
> *3. Delete all the writing instructions in italics from your formal documents.* > _3. Delete all the writing instructions in italics from your formal documents._
## *Example* Overview **_[General Instructions for Writing the Development Guide]_**
_**1. Target audience**: internal and external developers (including product managers). Guidelines for UX designers are usually carried by UX design specifications and are not covered in the development guide. If UX design specifications need to be mentioned in the development guide, use hyperlinks._
*Mandatory. Based on the scenario division of the solution/feature/function/module, you need to provide either "Example Overview" or "Example Task Scenario Overview", or both of them.* _**2. Content positioning**: Introduce what the solution/feature/function/module is, why it is required, and how to design, develop, and release related applications/devices. The development guide aims to help developers learn necessary knowledge and achieve specified task objectives in actual development activities._
*1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it.* _**3. User-oriented**: Always provide developer-concerned, perceptible, and useful content from the perspective of developers._
*2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it.* _**4. Task-oriented**: Focus on actual tasks of developers, and provide complete, correct guidance that is easy to follow._
***[General Instructions for Writing the Development Guide]*** _**5. Reference purposes**: This template only provides the basic document framework. You can adjust the content based on the actual requirements._
***1. Target audience**: internal and external developers (including product managers). Guidelines for UX designers are usually carried by UX design specifications and are not covered in the development guide. If UX design specifications need to be mentioned in the development guide, use hyperlinks.*
***2. Content positioning**: Introduce what the solution/feature/function/module is, why it is required, and how to design, develop, and release related applications/devices. The development guide aims to help developers learn necessary knowledge and achieve specified task objectives in actual development activities.* ## *Example* Overview
***3. User-oriented****: Always provide developer-concerned, perceptible, and useful content from the perspective of developers.* _Mandatory. Based on the scenario division of the solution/feature/function/module, you need to provide either "Example Overview" or "Example Task Scenario Overview", or both of them._
***4. Task-oriented****: Focus on actual tasks of developers, and provide complete, correct guidance that is easy to follow.* _1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it._
*5. This template only provides the basic document framework. You can adjust the content based on the actual requirements.* _2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it._
### Introduction ### Introduction
*Mandatory.* _Mandatory._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*What is the solution/feature/function/module (definition)? What problems can it solve or what benefits can it bring (purpose/customer benefits - why)? * _What is the solution/feature/function/module (definition)? What problems can it solve or what benefits can it bring (purpose/customer benefits - why)?_
***[Key Writing Points]*** _**[Key Writing Points]**_
- *Provide easy-to-understand and scenario-specific descriptions. Refer to the SCQA method below to introduce the scenarios and characteristics of the solution/feature/function/module.* - _Provide easy-to-understand and scenario-specific descriptions. Refer to the SCQA method below to introduce the scenarios and characteristics of the solution/feature/function/module._
- *S: situation. Introduce a familiar scenario.* - _S: situation. Introduce a familiar scenario._
- *C: complication. Describe the conflict between the situation and requirement.* - _C: complication. Describe the conflict between the situation and requirement._
- *Q: question. Ask a question. What can I do in such a case?* - _Q: question. Ask a question. What can I do in such a case?_
- *A: answer. Describe the solution.* - _A: answer. Describe the solution.
- *Visualize abstract concepts. You can provide content from the perspective of consumers for better understanding, for example, scenario effect in UX.* - _Visualize abstract concepts. You can provide content from the perspective of consumers for better understanding, for example, scenario effect in UX._
***[Writing Requirements]*** _**[Writing Requirements]**_
- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* - _Provide clear content. Avoid vague, obscure, and ambiguous expressions._
- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* - _Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary._
- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* - _Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document._
### Basic Concepts ### Basic Concepts
*Optional. Describe the basic concepts that are common to all task scenarios.* _Optional. Describe the basic concepts that are common to all task scenarios._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*What are the unique concepts that I need to know when using the solution/feature/function/module?* _What are the unique concepts that I need to know when using the solution/feature/function/module?_
***[Key Writing Points]*** _**[Key Writing Points]**_
- *Provide only the concepts that are mandatory in development tasks.* - _Provide only the concepts that are mandatory in development tasks._
- *Describe here concepts used in multiple chapters such as the operation mechanism, restrictions, and development process. If a concept is used only in a chapter, describe the concept in that chapter only.* - _Describe here concepts used in multiple chapters such as the operation mechanism, restrictions, and development process. If a concept is used only in a chapter, describe the concept in that chapter only._
- *Do not describe common concepts in the industry. Use common terms in the industry instead of jargon.* - _Do not describe common concepts in the industry. Use common terms in the industry instead of jargon._
- *If there are logical relationships between concepts, you are advised to use figures to describe the relationships.* - _If there are logical relationships between concepts, you are advised to use figures to describe the relationships._
***[Writing Requirements]*** _**[Writing Requirements]**_
- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* - _Provide clear content. Avoid vague, obscure, and ambiguous expressions._
- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* - _Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary._
- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* - _Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document._
***[Example]*** ***[Example]***
Before developing relational databases, you must understand the following basic concepts: Before developing relational databases, you must understand the following basic concepts:
- **RDB** - **RDB**
A type of database based on the relational model of data. The RDB stores data in rows and columns. An RDB is also called RDB store. A type of database based on the relational model of data. The RDB stores data in rows and columns. An RDB is also called RDB store.
- **Predicate** - **Predicate**
Property or feature of a data entity, or the relationship between data entities. It is mainly used to define operation conditions. Property or feature of a data entity, or the relationship between data entities. It is mainly used to define operation conditions.
...@@ -103,29 +104,29 @@ A type of database based on the relational model of data. The RDB stores data in ...@@ -103,29 +104,29 @@ A type of database based on the relational model of data. The RDB stores data in
### Working Principles ### Working Principles
*Optional. Describe the working principles that are common to all task scenarios.* _Optional. Describe the working principles that are common to all task scenarios._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*How does the solution/feature/function/module work? What are the API calling and triggering time of key steps? I want to understand its principles for better use and debugging.* _How does the solution/feature/function/module work? What are the API calling and triggering time of key steps? I want to understand its principles for better use and debugging._
***[Key Writing Points]*** _**[Key Writing Points]**_
- *If the principle is simple and can be understood from the content under "Basic Concepts", do not provide this section.* - _If the principle is simple and can be understood from the content under "Basic Concepts", do not provide this section._
- *Describe only the mechanisms and principles that are visible in the development tasks (use or access). Do not provide internal implementation that is invisible to developers.* - _Describe only the mechanisms and principles that are visible in the development tasks (use or access). Do not provide internal implementation that is invisible to developers._
- *If necessary, use sequence diagrams and flowcharts. Ensure that the text description matches the figure description.* - _If necessary, use sequence diagrams and flowcharts. Ensure that the text description matches the figure description._
- *Be careful not to disclose internal information.* - _Be careful not to disclose internal information._
***[Writing Requirements]*** _**[Writing Requirements]**_
- *Provide clear content. Avoid vague, obscure, and ambiguous expressions.* - _Provide clear content. Avoid vague, obscure, and ambiguous expressions._
- *Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary.* - _Use only necessary terms, acronyms, abbreviations, and proper nouns, and provide explanations or links to the glossary._
- *Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document.* - _Use consistent terms, acronyms, abbreviations, and proper nouns throughout the document._
***[Example]*** ***[Example]***
...@@ -138,23 +139,23 @@ The distributed data objects are encapsulated into JS objects in distributed in- ...@@ -138,23 +139,23 @@ The distributed data objects are encapsulated into JS objects in distributed in-
### Constraints ### Constraints
*Optional. Describe constraints that are common to all task scenarios.* _Optional. Describe constraints that are common to all task scenarios._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*What are the constraints for using the solution/feature/function/module? How well is the solution/feature/function/module implemented? Can it meet my requirements?* _What are the constraints for using the solution/feature/function/module? How well is the solution/feature/function/module implemented? Can it meet my requirements?_
***[Key Writing Points]*** _**[Key Writing Points]**_
- *Describe perceptible constraints that affect development activities, including but not limited to the following:* - _Describe perceptible constraints that affect development activities, including but not limited to the following:_
- ***Function constraints*** - _Function constraints_
- *Application scope of the solution/feature/function/module (Specify scenarios that are not supported.)* - _Application scope of the solution/feature/function/module (Specify scenarios that are not supported.)_
- *Specification constraints* - _Specification constraints_
- ***Operation constraints*** - _**Operation constraints**_
- *Operations on known issues* - _Operations on known issues_
- *Potentially risky operations (such as performance deterioration)* - _Potentially risky operations (such as performance deterioration)_
- *Describe operations that are prone to errors in the procedure, but not in this section.* - _Describe operations that are prone to errors in the procedure, but not in this section._
***[Example]*** ***[Example]***
...@@ -167,45 +168,45 @@ The distributed data objects are encapsulated into JS objects in distributed in- ...@@ -167,45 +168,45 @@ The distributed data objects are encapsulated into JS objects in distributed in-
### Samples ### Samples
*Optional. Provide samples that are common to all task scenarios.* _Optional. Provide samples that are common to all task scenarios._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*What sample code, codelabs, and demo projects are available?* _What sample code, codelabs, and demo projects are available?_
***[Key Writing Points]*** _**[Key Writing Points]**_
*Provide links (generally Gitee links) to the released sample code, codelabs, and demo projects. Do not include project packages into the document as an attachment.* _Provide links (generally Gitee links) to the released sample code, codelabs, and demo projects. Do not include project packages into the document as an attachment._
***[Example]*** ***[Example]***
The following sample is provided to help you better understand how to develop abilities: The following sample is provided to help you better understand how to develop abilities:
- [Intra- and Inter-page Navigation](https://gitee.com/openharmony/codelabs/tree/master/Ability/StageAbility) - [Intra-UIAbility and Inter-UIAbility Page Redirection (ArkTS)](https://gitee.com/openharmony/codelabs/tree/master/Ability/StageAbility)
## Setting Up the Environment ## Setting Up the Environment
*Optional.* _Optional._
*Based on the analysis and breakdown of a specific task scenario, you can place the environment setup content under "Prerequisites" or "Preparations" and close to the "How to Develop" of the specific scenario.* _Based on the analysis and breakdown of a specific task scenario, you can place the environment setup content under "Prerequisites" or "Preparations" and close to the "How to Develop" of the specific scenario._
*Specify how to prepare the development environment, including software and hardware configuration requirements, tool requirements, and device requirements.* _Specify how to prepare the development environment, including software and hardware configuration requirements, tool requirements, and device requirements._
*Delete this section if no special requirements are involved.* _Delete this section if no special requirements are involved._
### Environment Requirements ### Environment Requirements
***[Writing Requirements]*** _**[Writing Requirements]**_
*Describe the software and hardware configurations required by the development environment so that developers can prepare the environment in advance. You can use subtitles if there is a large amount of content.* _Describe the software and hardware configurations required by the development environment so that developers can prepare the environment in advance. You can use subtitles if there is a large amount of content._
***[Example]*** ***[Example]***
The following table describes the environment configuration requirements specific to the Hi3861 development board. The following table describes the environment configuration requirements specific to the Hi3861 development board.
**Table 1** Hi3861 development environment-specific requirements **Table 1** Hi3861 development environment-specific requirements
| Platform Type| Development Tool| Function| How to Obtain| | Platform Type| Development Tool| Function| How to Obtain|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
...@@ -215,9 +216,9 @@ The following table describes the environment configuration requirements specifi ...@@ -215,9 +216,9 @@ The following table describes the environment configuration requirements specifi
### Setting Up the Environment ### Setting Up the Environment
***[Writing Requirements]*** _**[Writing Requirements]**_
*Describe the procedure for setting up the development environment. If there is a large amount of content, use subtitles, for example, "Setting Up the Basic Build Environment" and "Setting Up the Compilation Tool Environment".* _Describe the procedure for setting up the development environment. If there is a large amount of content, use subtitles, for example, "Setting Up the Basic Build Environment" and "Setting Up the Compilation Tool Environment"._
***[Example]*** ***[Example]***
...@@ -238,53 +239,53 @@ The following table describes the environment configuration requirements specifi ...@@ -238,53 +239,53 @@ The following table describes the environment configuration requirements specifi
### Verifying the Environment ### Verifying the Environment
***[Writing Requirements]*** _**[Writing Requirements]**_
*Optional. Provide the criteria for checking whether the environment is set up successfully. You can also provide the criteria along with the environment setup procedure, as provided in the preceding example.* _Optional. Provide the criteria for checking whether the environment is set up successfully. You can also provide the criteria along with the environment setup procedure, as provided in the preceding example._
## *Example Task Scenario* Development (Use a specific scenario name. If there is only one scenario, use the solution/feature/function/module name.) ## *Example Task Scenario* Development (Use a specific scenario name. If there is only one scenario, use the solution/feature/function/module name.)
*Mandatory.* _Mandatory._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*How do I use or access the solution/feature/function/module?* _How do I use or access the solution/feature/function/module?_
***[Key Writing Points]*** _**[Key Writing Points]**_
*Provide scenarios that are close to actual development scenarios.* _Provide scenarios that are close to actual development scenarios._
- *Task scenarios are what developers need to use to achieve development objectives.* - _Task scenarios are what developers need to use to achieve development objectives._
- *There can be one or more task scenarios. You can use multiple "Development Guidelines" sections. Follow the hierarchical logic when writing the guidelines, that is, a task scenario -> a subtask scenario -> task logic ("Development Process") -> operation procedure ("How to Develop").* - _There can be one or more task scenarios. You can use multiple "Development Guidelines" sections. Follow the hierarchical logic when writing the guidelines, that is, a task scenario -> a subtask scenario -> task logic ("Development Process") -> operation procedure ("How to Develop")._
### *Example Task Scenario* Overview ### *Example Task Scenario* Overview
*Based on the scenario division of the solution/feature/function/module, you can provide either "Example Task Scenario Overview" or "Example Overview", or both of them.* _Based on the scenario division of the solution/feature/function/module, you can provide either "Example Task Scenario Overview" or "Example Overview", or both of them._
*1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it.* _1. "Example Overview" provides an overview that is common to all task scenarios of this solution/feature/function/module and that developers need to understand. If there is nothing in common, delete it._
*2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it.* _2. "Example Task Scenario Overview" describes the contents directly related to a task scenario. The knowledge points and key writing points are the same as those in "Example Overview". In this section, you need to introduce this specific task scenario and describe basic concepts, working principles, constraints, and samples that are directly related to the task scenario. If there is no specific task scenario, delete it._
### Development Process ### Development Process
***[Key Writing Points]*** _**[Key Writing Points]**_
- *Optional. If there are many development steps (five or more core operations) or complex logical relationships between steps, provide the development process so that developers can have a panoramic view of the operations to be performed.* - _Optional. If there are many development steps (five or more core operations) or complex logical relationships between steps, provide the development process so that developers can have a panoramic view of the operations to be performed._
- *Provide flowcharts and tables if necessary.* - _Provide flowcharts and tables if necessary._
### Available APIs ### Available APIs
***[Writing Requirements]*** _**[Writing Requirements]**_
- *Optional. Describe the key APIs in the development steps and provide the API introduction, so that developers can have a general understanding of development.* - _Optional. Describe the key APIs in the development steps and provide the API introduction, so that developers can have a general understanding of development._
- *If there are more than 10 APIs, provide the main APIs only.* - _If there are more than 10 APIs, provide the main APIs only._
- *Ensure that the APIs and their functions of the corresponding version are supported when the document is released.* - _Ensure that the APIs and their functions of the corresponding version are supported when the document is released._
***[Example]*** ***[Example]***
...@@ -300,19 +301,19 @@ Certain APIs can be called only by system applications that have been granted th ...@@ -300,19 +301,19 @@ Certain APIs can be called only by system applications that have been granted th
### How to Develop ### How to Develop
***[Writing Requirements]*** _**[Writing Requirements]**_
*Mandatory.* _Mandatory._
- *Completeness and Correctness* - _Completeness and Correctness_
- *Describe the complete development process (for example, steps related to the code, resources, third-party libraries, and application configuration files in the HAP) so that developers can correctly complete the development. Do not omit key configuration operations.* - _Describe the complete development process (for example, steps related to the code, resources, third-party libraries, and application configuration files in the HAP) so that developers can correctly complete the development. Do not omit key configuration operations._
- *Ensure that the code snippet provided in the document can be built with the context in DevEco Studio.* - _Ensure that the code snippet provided in the document can be built with the context in DevEco Studio._
- *Ensure that the complete sample code provided in the document can be run in DevEco Studio, and the execution result is the same as that described in the document.* - _Ensure that the complete sample code provided in the document can be run in DevEco Studio, and the execution result is the same as that described in the document._
- *Clarity* - _Clarity_
- *Provide a clear execution owner (who), operation purpose (why), operation content (what/how), and scenario (when/where) for each step. Use imperative sentence to describe steps.* - _Provide a clear execution owner (who), operation purpose (why), operation content (what/how), and scenario (when/where) for each step. Use imperative sentence to describe steps._
- *Clearly provide the APIs (if involved) in steps, as well as their usage description and sample code.* - _Clearly provide the APIs (if involved) in steps, as well as their usage description and sample code._
- *Provide development suggestions or precautions for key steps and sample code (comments for sample code).* - _Provide development suggestions or precautions for key steps and sample code (comments for sample code)._
*Think about what questions may be raised when developers are performing the operations.* *These problems are obstacles to developers.* *Provide support information in the document to help them handle these obstacles.* *Examples of support information:* *Think about what questions may be raised when developers are performing the operations.* *These problems are obstacles to developers.* *Provide support information in the document to help them handle these obstacles.* *Examples of support information:*
- *Branch selection principle. Provide principles or suggestions for selecting branches and parameters.* - *Branch selection principle. Provide principles or suggestions for selecting branches and parameters.*
...@@ -322,9 +323,9 @@ Certain APIs can be called only by system applications that have been granted th ...@@ -322,9 +323,9 @@ Certain APIs can be called only by system applications that have been granted th
- *Error prevention/correction information. Provide guidance for preventing, locating, or rectifying typical problems that may occur in the development process.* *This type of information can be provided in "How to Develop" or "FAQs", depending on the content amount.* - *Error prevention/correction information. Provide guidance for preventing, locating, or rectifying typical problems that may occur in the development process.* *This type of information can be provided in "How to Develop" or "FAQs", depending on the content amount.*
- *Standardization* - _Standardization_
- *Provide both logically and syntactically correct sample code and write it in a standard manner. Anonymize sensitive information, such as mobile numbers, ID cards, and account names, for example, 186\*\*\*\*\*\*\*\*. Use private IP addresses or a corresponding format, for example, xx.xx.xx.xx and www.example.com, rather than real IP addresses and domain names.* - _Provide both logically and syntactically correct sample code and write it in a standard manner. Anonymize sensitive information, such as mobile numbers, ID cards, and account names, for example, 186\*\*\*\*\*\*\*\*. Use private IP addresses or a corresponding format, for example, xx.xx.xx.xx and www.example.com, rather than real IP addresses and domain names._
- *Provide code that complies with the code indentation requirements. Do not use the **Tab** key to indent code. Instead, use four spaces, to avoid incorrect display.* - _Provide code that complies with the code indentation requirements. Do not use the Tab key to indent code. Instead, use four spaces, to avoid incorrect display._
**[Example (Excerpt)]** **[Example (Excerpt)]**
...@@ -360,28 +361,28 @@ Certain APIs can be called only by system applications that have been granted th ...@@ -360,28 +361,28 @@ Certain APIs can be called only by system applications that have been granted th
### Verification ### Verification
***[Writing Requirements]*** _**[Writing Requirements]**_
- *Optional. After the development is complete, provide a guide to check whether the operation is successful if there is an independent commissioning and verification operation. The operation procedure is the same as that described in "How to Develop."* - _Optional. After the development is complete, provide a guide to check whether the operation is successful if there is an independent commissioning and verification operation. The operation procedure is the same as that described in "How to Develop."_
- *Provide only the final service commissioning. You are advised to verify the operation result of each subtask after the development is complete.* - _Provide only the final service commissioning. You are advised to verify the operation result of each subtask after the development is complete._
## FAQs ## FAQs
*Optional.* _Optional._
***[Developers' Concerns]*** _**[Developers' Concerns]**_
*What are the typical problems that may occur in the development process of the solution/feature/function/module? How do I locate and solve these problems?* _What are the typical problems that may occur in the development process of the solution/feature/function/module? How do I locate and solve these problems?_
***[Key Writing Points]*** _**[Key Writing Points]**_
*Describe the problems that may occur during the development and the solutions to them.* _Describe the problems that may occur during the development and the solutions to them._
- *Delete this section if there are no common problems.* - _Delete this section if there are no common problems._
- *It is recommended that common problems in each task scenario be described in a separate chapter. Common problems related to a single task scenario be described in the corresponding chapter.* - _It is recommended that common problems in each task scenario be described in a separate chapter. Common problems related to a single task scenario be described in the corresponding chapter._
......
# Pan-sensor Subsystem Changelog
## cl.vibrator.1 Added Attributes Related to Custom Vibration
The attributes **VibrateFromFile** (custom vibration effect) and **HapticFileDescriptor** (file descriptor of the custom vibration configuration file) are added. The vibration effect supported by **startVibration** is extended from **VibrateEffect = VibrateTime | VibratePreset** to **VibrateEffect = VibrateTime | VibratePreset | VibrateFromFile**.
**Change Impact**
When developing applications based on OpenHarmony4.0.8.2 and later SDK versions, you can use the **VibrateFromFile** attribute to enable devices that support custom vibration to trigger vibration according to the vibration sequence configured in the custom vibration configuration file.
**Key API/Component Changes**
Added the **VibrateFromFile** and **HapticFileDescriptor** attributes to **@ohos.vibrator.d.ts**.
| Module| Class| Method/Attribute/Enum/Constant| Change Type|
| -- | -- | -- | -- |
| @ohos.vibrator.d.ts | vibrator | HapticFileDescriptor | Added|
| @ohos.vibrator.d.ts | vibrator | VibrateFromFile | Added|
**Adaptation Guide**
Obtain the resources in the vibration configuration file through the resource management API, and start or stop custom vibration as required.
```ts
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);
```
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
} }
``` ```
2. 系统弹框调用[abilityManager.acquireShareData()](../reference/apis/js-apis-app-ability-abilityManager.md#acquiresharedata)接口发起原子化服务共享,根据missionId找到对应的UIAbiltiy,调用其OnShare生命周期,收到共享数据。 2. 系统弹框调用[abilityManager.acquireShareData()](../reference/apis/js-apis-app-ability-abilityManager.md#acquiresharedata)接口发起原子化服务共享,根据missionId找到对应的UIAbility,调用其OnShare生命周期,收到共享数据。
```ts ```ts
import abilityManager from '@ohos.app.ability.abilityManager'; import abilityManager from '@ohos.app.ability.abilityManager';
......
...@@ -198,6 +198,7 @@ ...@@ -198,6 +198,7 @@
- [@ohos.animator (动画)](js-apis-animator.md) - [@ohos.animator (动画)](js-apis-animator.md)
- [@ohos.arkui.componentSnapshot (组件截图)](js-apis-arkui-componentSnapshot.md) - [@ohos.arkui.componentSnapshot (组件截图)](js-apis-arkui-componentSnapshot.md)
- [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md) - [@ohos.arkui.drawableDescriptor (DrawableDescriptor)](js-apis-arkui-drawableDescriptor.md)
- [@ohos.arkui.inspector(布局回调)](js-apis-arkui-inspector.md)
- [@ohos.arkui.UIContext (UIContext)](js-apis-arkui-UIContext.md) - [@ohos.arkui.UIContext (UIContext)](js-apis-arkui-UIContext.md)
- [@ohos.curves (插值计算)](js-apis-curve.md) - [@ohos.curves (插值计算)](js-apis-curve.md)
- [@ohos.font (注册自定义字体)](js-apis-font.md) - [@ohos.font (注册自定义字体)](js-apis-font.md)
...@@ -507,4 +508,4 @@ ...@@ -507,4 +508,4 @@
- [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md) - [remoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)
- [shortcutInfo](js-apis-bundle-ShortcutInfo.md) - [shortcutInfo](js-apis-bundle-ShortcutInfo.md)
- data/rdb - data/rdb
- [resultSet (结果集)](js-apis-data-resultset.md) - [resultSet (结果集)](js-apis-data-resultset.md)
\ No newline at end of file
...@@ -15,7 +15,7 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -15,7 +15,7 @@ import abilityManager from '@ohos.app.ability.abilityManager';
## AbilityState ## AbilityState
Ability的状态,该类型为枚举,可配合[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)返回Abiltiy的状态。 Ability的状态,该类型为枚举,可配合[AbilityRunningInfo](js-apis-inner-application-abilityRunningInfo.md)返回Ability的状态。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core **系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
......
# @ohos.arkui.inspector (布局回调)
提供注册组件布局和绘制完成回调通知的能力。
> **说明:**
>
> 从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 导入模块
```js
import inspector from '@ohos.arkui.inspector'
```
## inspector.createComponentObserver
createComponentObserver(id: string): ComponentObserver
绑定指定组件,返回对应的监听句柄。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------- |
| id | string | 是 | 指定组件id。 |
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------------------------------ |
|[ComponentObserver](#componentobserver)| 组件回调事件监听句柄,用于注册和取消注册监听回调。 |
**示例:**
```js
let listener = inspector.createComponentObserver('1000'); //监听id为1000的组件回调事件
```
## ComponentObserver
组件布局绘制完成回调的句柄,包含了申请句柄时的首次查询结果。
### on
on(type: 'layout', callback: () => void): void
通过句柄向对应的查询条件注册回调,当组件布局或者绘制完成时会触发该回调。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | -------------------------------------------------------------------------------------- |
| type | string | 是 | 必须填写字符串'layout'或'draw'。<br>layout: 组件布局完成。<br>draw: 组件绘制完成。 |
| callback | void | 是 | 监听layout或draw的回调。|
### off
off(type: 'layout', callback: () => void): void
通过句柄向对应的查询条件取消注册回调,当组件布局或者绘制完成时不在触发指定的回调。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | -------------------------------------------------------------------------------------- |
| type | string | 是 | 必须填写字符串'layout'或‘draw’。<br>layout: 组件布局完成。<br>draw: 组件绘制完成。 |
| callback | void | 否 | 需要取消注册的回调,如果参数缺省则取消注册该句柄下所有的回调。 |
**示例:**
```js
import inspector from '@ohos.arkui.inspector';
@Entry
@Component
struct ImageExample {
build() {
Column() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign. Start }) {
Row({ space: 5 }) {
Image($r('app.media.app_icon'))
.width(110)
.height(110)
.border({ width: 1 })
.key('1000')
}
}
}
}.height(320).width(360).padding({ right: 10, top: 10 })
}
listener = inspector.createComponentObserver('1000')
aboutToAppear() {
let FuncLayout = this.onLayoutComplete.bind(this) // bind current js instance
let FuncDraw = this.onDrawComplete.bind(this) // bind current js instance
this.listener.on('layout', FuncLayout)
this.listener.on('draw', FuncDraw)
}
onLayoutComplete() {
// do something here
}
onDrawComplete() {
// do something here
}
}
```
\ No newline at end of file
...@@ -3213,3 +3213,94 @@ try { ...@@ -3213,3 +3213,94 @@ try {
hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message); hilog.error(0x0000, 'testTag', 'getAppProvisionInfo failed. Cause: %{public}s', err.message);
} }
``` ```
### bundleManager.getSpecifiedDistributionType<sup>10+</sup>
getSpecifiedDistributionType(bundleName: string): string;
以同步的方法查询指定bundleName的分发类型,该返回值是在调用install接口时传入的[InstallParam](./js-apis-installer.md#installparam)中的specifiedDistributionType字段。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 指定的bundleName。 |
**返回值:**
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| string | 返回指定bundleName的分发类型。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found. |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager';
let bundleName = "com.example.myapplication";
try {
let type = bundleManager.getSpecifiedDistributionType(bundleName);
console.info('getSpecifiedDistributionType successfully, type:' + type);
} catch (error) {
console.error('getSpecifiedDistributionType failed. Cause: ' + error.message);
}
```
### bundleManager.getAdditionalInfo<sup>10+</sup>
getAdditionalInfo(bundleName: string): string;
以同步接口查询指定bundleName的额外信息。该返回值是在调用install接口时传入的[InstallParam](./js-apis-installer.md#installparam)中的additionalInfo字段。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 指定的bundleName。 |
**返回值:**
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| string | 返回指定bundleName的额外信息。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found. |
**示例:**
```ts
import bundleManager from '@ohos.bundle.bundleManager';
let bundleName = "com.example.myapplication";
try {
let info = bundleManager.getAdditionalInfo(bundleName);
console.info('getAdditionalInfo successfully, additionInfo:' + info);
} catch (error) {
console.error('getAdditionalInfo failed. Cause: ' + error.message);
}
```
\ No newline at end of file
...@@ -16,7 +16,6 @@ import installer from '@ohos.bundle.installer'; ...@@ -16,7 +16,6 @@ import installer from '@ohos.bundle.installer';
| 权限 | 权限等级 | 描述 | | 权限 | 权限等级 | 描述 |
| ------------------------------ | ----------- | ---------------- | | ------------------------------ | ----------- | ---------------- |
| ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用。 | | ohos.permission.INSTALL_BUNDLE | system_core | 可安装、卸载应用。 |
| ohos.permission.GET_BUNDLE_INFO_PRIVILEGED | system_basic | 可查询所有应用信息。 |
权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明) 权限等级参考[权限等级说明](../../security/accesstoken-overview.md#权限等级说明)
...@@ -766,97 +765,6 @@ try { ...@@ -766,97 +765,6 @@ try {
} }
``` ```
## BundleInstaller.getSpecifiedDistributionType<sup>10+</sup>
getSpecifiedDistributionType(bundleName: string): string;
以同步的方法查询指定bundleName的分发类型,该返回值是在调用install接口时传入的InstallParam中的specifiedDistributionType字段。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 指定的bundleName。 |
**返回值:**
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| string | 返回指定bundleName的分发类型。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found. |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let bundleName = "com.example.myapplication";
try {
let type = installer.getSpecifiedDistributionType(bundleName);
console.info('getSpecifiedDistributionType successfully, type:' + type);
} catch (error) {
console.error('getSpecifiedDistributionType failed. Cause: ' + error.message);
}
```
## BundleInstaller.getAdditionalInfo<sup>10+</sup>
getAdditionalInfo(bundleName: string): string;
以同步接口查询指定bundleName的额外信息。该返回值是在调用install接口时传入的InstallParam中的additionalInfo字段。
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| bundleName | string | 是 | 指定的bundleName。 |
**返回值:**
| 类型 | 说明 |
| ------------- | -------------------------------------- |
| string | 返回指定bundleName的额外信息。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.bundle错误码](../errorcodes/errorcode-bundle.md)
| 错误码ID | 错误信息 |
| -------- | ------------------------------------------------------------ |
| 17700001 | The specified bundleName is not found. |
**示例:**
```ts
import installer from '@ohos.bundle.installer';
let bundleName = "com.example.myapplication";
try {
let info = installer.getAdditionalInfo(bundleName);
console.info('getAdditionalInfo successfully, additionInfo:' + info);
} catch (error) {
console.error('getAdditionalInfo failed. Cause: ' + error.message);
}
```
## HashParam ## HashParam
应用程序安装卸载哈希参数信息。 应用程序安装卸载哈希参数信息。
......
...@@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void; ...@@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void;
获取设备当前的充电状态及剩余电量。 获取设备当前的充电状态及剩余电量。
**系统能力:** SystemCapability.PowerManager.BatteryManager.Core **系统能力:** SystemCapability.PowerManager.BatteryManager.Lite
**参数:** **参数:**
...@@ -46,7 +46,7 @@ battery.getStatus({ ...@@ -46,7 +46,7 @@ battery.getStatus({
包含接口调用结果的对象。 包含接口调用结果的对象。
**系统能力:** SystemCapability.PowerManager.BatteryManager.Core **系统能力:** SystemCapability.PowerManager.BatteryManager.Lite
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -58,7 +58,7 @@ battery.getStatus({ ...@@ -58,7 +58,7 @@ battery.getStatus({
包含充电状态及剩余电量的对象。 包含充电状态及剩余电量的对象。
**系统能力:** SystemCapability.PowerManager.BatteryManager.Core **系统能力:** SystemCapability.PowerManager.BatteryManager.Lite
| 参数名 | 类型 | 可读 | 可写 | 说明 | | 参数名 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
......
...@@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void ...@@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void
获得设备当前的屏幕亮度值。 获得设备当前的屏幕亮度值。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
**参数:** **参数:**
...@@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void ...@@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void
设置设备当前的屏幕亮度值。 设置设备当前的屏幕亮度值。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
**参数:** **参数:**
...@@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void ...@@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void
获得当前屏幕亮度模式。 获得当前屏幕亮度模式。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
**参数:** **参数:**
...@@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void ...@@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void
设置设备当前的屏幕亮度模式。 设置设备当前的屏幕亮度模式。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
设置屏幕是否保持常亮状态,开启常亮模式推荐在onShow()阶段调用。 设置屏幕是否保持常亮状态,开启常亮模式推荐在onShow()阶段调用。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
**参数:** **参数:**
...@@ -162,7 +162,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -162,7 +162,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
获取屏幕亮度的参数对象。 获取屏幕亮度的参数对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
...@@ -174,7 +174,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -174,7 +174,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
设置屏幕亮度的参数对象。 设置屏幕亮度的参数对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
...@@ -187,7 +187,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -187,7 +187,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
包含屏幕亮度的对象。 包含屏幕亮度的对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -197,7 +197,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -197,7 +197,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
获取屏幕亮度模式的参数对象。 获取屏幕亮度模式的参数对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
...@@ -209,7 +209,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -209,7 +209,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
设置屏幕亮度模式的参数对象。 设置屏幕亮度模式的参数对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ------------------------------------------------------ | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ |
...@@ -222,7 +222,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -222,7 +222,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
包含屏幕亮度模式的对象。 包含屏幕亮度模式的对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
...@@ -232,7 +232,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void ...@@ -232,7 +232,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void
设置屏幕常亮的参数对象。 设置屏幕常亮的参数对象。
**系统能力:** SystemCapability.PowerManager.DisplayPowerManager **系统能力:** SystemCapability.PowerManager.DisplayPowerManager.Lite
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ |
......
...@@ -26,8 +26,8 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut ...@@ -26,8 +26,8 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| customStyle | boolean | 否 | 弹窗容器样式是否自定义。<br>默认值:false,弹窗容器的宽度根据栅格系统自适应,不跟随子节点;高度自适应子节点,最大为窗口高度的90%;圆角为24vp。 | | customStyle | boolean | 否 | 弹窗容器样式是否自定义。<br>默认值:false,弹窗容器的宽度根据栅格系统自适应,不跟随子节点;高度自适应子节点,最大为窗口高度的90%;圆角为24vp。 |
| gridCount<sup>8+</sup> | number | 否 | 弹窗宽度占[栅格宽度](../../ui/arkts-layout-development-grid-layout.md)的个数。<br>默认为按照窗口大小自适应,异常值按默认值处理,最大栅格数为系统最大栅格数。 | | gridCount<sup>8+</sup> | number | 否 | 弹窗宽度占[栅格宽度](../../ui/arkts-layout-development-grid-layout.md)的个数。<br>默认为按照窗口大小自适应,异常值按默认值处理,最大栅格数为系统最大栅格数。 |
| maskColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 否 | 自定义蒙层颜色。<br>默认值: 0x33000000 | | maskColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 否 | 自定义蒙层颜色。<br>默认值: 0x33000000 |
| openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗弹出的动画效果相关参数。<br>注意:当iterations为奇数,playMode设置为Reverse,动画结束时,弹窗不显示。 | | openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗弹出的动画效果相关参数。<br>**说明**<br>iterations默认值为1,默认播放一次,设置为其他数值时按默认值处理。<br>playMode控制动画播放模式,默认值为PlayMode.Normal,设置为其他数值时按照默认值处理。 |
| closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗关闭的动画效果相关参数。 | | closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗关闭的动画效果相关参数。<br>**说明**<br>iterations默认值为1,默认播放一次,设置为其他数值时按默认值处理。<br>playMode控制动画播放模式,默认值为PlayMode.Normal,设置为其他数值时按照默认值处理。 |
| showInSubWindow<sup>10+</sup> | boolean | 否 | 是否在子窗口显示弹窗。<br>默认值:false,在子窗口不显示弹窗。<br>**说明**:showInSubWindow为true的弹窗无法触发显示另一个showInSubWindow为true的弹窗。 | | showInSubWindow<sup>10+</sup> | boolean | 否 | 是否在子窗口显示弹窗。<br>默认值:false,在子窗口不显示弹窗。<br>**说明**:showInSubWindow为true的弹窗无法触发显示另一个showInSubWindow为true的弹窗。 |
## CustomDialogController ## CustomDialogController
......
# NativeVsync # NativeVsync
## 概述
提供NativeVsync功能。 提供NativeVsync功能。
\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
@syscap SystemCapability.Graphic.Graphic2D.NativeVsync **起始版本:**
9
**起始版本:**
## 汇总
8
### 文件
## 汇总 | 名称 | 描述 |
| -------- | -------- |
| [native_vsync.h](native__vsync_8h.md) | 定义获取和使用NativeVsync的相关函数<br/>引用文件:&lt;native_vsync/native_vsync.h&gt; |
### 文件 ### 类型定义
| 文件名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [native_vsync.h](native__vsync_8h.md) | 定义获取和使用NativeVsync的相关函数<br>引用文件:<native_vsync/native_vsync.h> | | [OH_NativeVSync](#oh_nativevsync) | 提供OH_NativeVSync结构体声明 |
| (\*[OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback)) (long long timestamp, void \*data) | VSync回调函数类型 |
### 函数 ### 函数
| 函数名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeVSync_Create](#oh_nativevsync_create) (const char \*name, unsigned int length) | 创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例 | | [OH_NativeVSync_Create](#oh_nativevsync_create) (const char \*name, unsigned int length) | 创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例 |
| [OH_NativeVSync_Destroy](#oh_nativevsync_destroy) (OH_NativeVSync \*nativeVsync) | 销毁OH_NativeVSync实例 | | [OH_NativeVSync_Destroy](#oh_nativevsync_destroy) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync) | 销毁OH_NativeVSync实例 |
| [OH_NativeVSync_RequestFrame](#oh_nativevsync_requestframe) (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | 请求下一次vsync信号,当信号到来时,调用回调函数callback | | [OH_NativeVSync_RequestFrame](#oh_nativevsync_requestframe) ([OH_NativeVSync](#oh_nativevsync) \*nativeVsync, [OH_NativeVSync_FrameCallback](#oh_nativevsync_framecallback) callback, void \*data) | 请求下一次vsync信号,当信号到来时,调用回调函数callback |
## 类型定义说明
### OH_NativeVSync
```
typedef struct OH_NativeVSync OH_NativeVSync
```
**描述:**
提供OH_NativeVSync结构体声明
## 详细描述 ### OH_NativeVSync_FrameCallback
```
typedef void(* OH_NativeVSync_FrameCallback) (long long timestamp, void *data)
```
**描述:**
VSync回调函数类型
\@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
**参数:**
| 名称 | 描述 |
| -------- | -------- |
| timestamp | VSync时间戳 |
| data | 用户自定义数据 |
## 函数说明 ## 函数说明
...@@ -45,27 +85,23 @@ ...@@ -45,27 +85,23 @@
OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length ) OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length )
``` ```
**描述** **描述:**
创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例 创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例
@syscap SystemCapability.Graphic.Graphic2D.NativeVsync \@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| name | 参数表示一个vsync连接的名字 | | name | 表示一个名字,与创建的OH_NativeVSync实例关联 |
| length | 参数是name的长度 | | length | name的长度 |
**返回** **返回:**
返回一个指向OH_NativeVSync实例的指针 返回一个指向OH_NativeVSync实例的指针
**起始版本:**
8
### OH_NativeVSync_Destroy() ### OH_NativeVSync_Destroy()
...@@ -74,21 +110,17 @@ OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length ) ...@@ -74,21 +110,17 @@ OH_NativeVSync* OH_NativeVSync_Create (const char * name, unsigned int length )
void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync) void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync)
``` ```
**描述** **描述:**
销毁OH_NativeVSync实例 销毁OH_NativeVSync实例
@syscap SystemCapability.Graphic.Graphic2D.NativeVsync \@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| nativeVsync | 参数是一个指向OH_NativeVSync实例的指针 | | nativeVsync | 一个指向OH_NativeVSync实例的指针 |
**起始版本:**
8
### OH_NativeVSync_RequestFrame() ### OH_NativeVSync_RequestFrame()
...@@ -98,24 +130,20 @@ void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync) ...@@ -98,24 +130,20 @@ void OH_NativeVSync_Destroy (OH_NativeVSync * nativeVsync)
int OH_NativeVSync_RequestFrame (OH_NativeVSync * nativeVsync, OH_NativeVSync_FrameCallback callback, void * data ) int OH_NativeVSync_RequestFrame (OH_NativeVSync * nativeVsync, OH_NativeVSync_FrameCallback callback, void * data )
``` ```
**描述** **描述:**
请求下一次vsync信号,当信号到来时,调用回调函数callback 请求下一次vsync信号,当信号到来时,调用回调函数callback
@syscap SystemCapability.Graphic.Graphic2D.NativeVsync \@syscap SystemCapability.Graphic.Graphic2D.NativeVsync
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| nativeVsync | 参数是一个指向OH_NativeVSync实例的指针 | | nativeVsync | 一个指向OH_NativeVSync实例的指针 |
| callback | 参数是一个OH_NativeVSync_FrameCallback类型的函数指针,当下一次vsync信号到来时会被调用 | | callback | 一个OH_NativeVSync_FrameCallback类型的函数指针,当下一次vsync信号到来时会被调用 |
| data | 参数是一个指向用户自定义数据结构的指针,类型是void\* | | data | 一个指向用户自定义数据结构的指针,类型是void\* |
**返回:**
返回一个由GSError定义的int32_t类型的错误码
**起始版本:** **返回:**
8 返回值为0表示执行成功
# NativeWindow # NativeWindow
提供NativeWindow功能,主要用来和egl对接。 ## 概述
提供NativeWindow功能,作为数据生产者,可用来和egl对接
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**起始版本:**
**起始版本:**
8 8
...@@ -18,61 +17,97 @@ ...@@ -18,61 +17,97 @@
### 文件 ### 文件
| 文件名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [external_window.h](external__window_8h.md) | 定义获取和使用NativeWindow的相关函数<br>引用文件:<native_window/external_window.h> | | [external_window.h](external__window_8h.md) | 定义获取和使用NativeWindow的相关函数<br/>引用文件:&lt;native_window/external_window.h&gt; |
### 结构体 ### 结构体
| 结构体名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [Region](_region.md) | 表示本地窗口NativeWindow需要更新内容的矩形区域(脏区) | | [Region](_region.md) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区) |
| [OHHDRMetaData<sup>(deprecated)](_o_h_h_d_r_meta_data.md) | HDR元数据结构体定义,从API9开始废弃,预计API14删除 | | [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | HDR元数据结构体定义 |
| [OHExtDataHandle<sup>(deprecated)](_o_h_ext_data_handle.md) | 扩展数据句柄结构体定义,从API9开始废弃,预计API14删除 | | [OHExtDataHandle](_o_h_ext_data_handle.md) | 扩展数据句柄结构体定义 |
### 类型定义 ### 类型定义
| 类型定义名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| OHNativeWindow | 提供对NativeWindow的访问功能 | | [OHNativeWindow](#ohnativewindow) | 提供对OHNativeWindow的访问功能 |
| OHNativeWindowBuffer | 提供对NativeWindow的访问功能 | | [OHNativeWindowBuffer](#ohnativewindowbuffer) | 提供对OHNativeWindowBuffer的访问功能 |
| Region | 表示本地窗口NativeWindow需要更新内容的矩形区域(脏区) | | [Region](#region) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区) |
### 枚举 ### 枚举
| 枚举名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [NativeWindowOperation](#nativewindowoperation) { SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT, GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE, SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT, SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM, SET_UI_TIMESTAMP } | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码 | | [NativeWindowOperation](#nativewindowoperation) {<br/>SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT,<br/>GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE,<br/>SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT,<br/>SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM,<br/>SET_UI_TIMESTAMP<br/>} | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码 |
| [OHScalingMode<sup>(deprecated)](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | 缩放模式 Scaling Mode,从API9开始废弃,预计API14删除 | | [OHScalingMode](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | 缩放模式 Scaling Mode |
| [OHHDRMetadataKey<sup>(deprecated)](#ohhdrmetadatakey) { OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3, OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7, OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字,从API9开始废弃,预计API14删除 | | [OHHDRMetadataKey](#ohhdrmetadatakey) {<br/>OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3,<br/>OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7,<br/>OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,<br/>OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13<br/>} | 枚举HDR元数据关键字 |
### 函数 ### 函数
| 函数名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | 创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例 | | [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | 创建OHNativeWindow实例,每次调用都会产生一个新的OHNativeWindow实例 |
| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | 将NativeWindow对象的引用计数减1,当引用计数为0的时候,该NativeWindow对象会被析构掉 | | [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | 将OHNativeWindow对象的引用计数减1,当引用计数为0的时候,该OHNativeWindow对象会被析构掉 |
| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例 | | [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例 |
| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | 将NativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该NativeWindowBuffer对象会被析构掉 | | [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | 将OHNativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该OHNativeWindowBuffer对象会被析构掉 |
| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | 通过NativeWindow对象申请一块NativeWindowBuffer,用以内容生产 | | [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | 通过OHNativeWindow对象申请一块OHNativeWindowBuffer,用以内容生产 |
| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | 通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中,用以内容消费 | | [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, Region region) | 通过OHNativeWindow将生产好内容的OHNativeWindowBuffer放回到Buffer队列中,用以内容消费 |
| [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | 通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中,供下次再申请 | | [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | 通过OHNativeWindow将之前申请出来的OHNativeWindowBuffer返还到Buffer队列中,供下次再申请 |
| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | 设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等 | | [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | 设置/获取OHNativeWindow的属性,包括设置/获取宽高、内容格式等 |
| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | 通过NativeWindowBuffer获取该buffer的BufferHandle指针 | | [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | 通过OHNativeWindowBuffer获取该buffer的BufferHandle指针 |
| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数 | | [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数 |
| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉 | | [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉 |
| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId | | [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId |
| [OH_NativeWindow_NativeWindowSetScalingMode<sup>(deprecated)](#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | 设置NativeWindow的ScalingMode,从API9开始废弃,预计API14删除 | | [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, OHScalingMode scalingMode) | 设置OHNativeWindow的ScalingMode |
| [OH_NativeWindow_NativeWindowSetMetaData<sup>(deprecated)](#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | 设置NativeWindow的元数据,从API9开始废弃,预计API14删除 | | [OH_NativeWindow_NativeWindowSetMetaData](#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const OHHDRMetaData \*metaData) | 设置OHNativeWindow的元数据 |
| [OH_NativeWindow_NativeWindowSetMetaDataSet<sup>(deprecated)](#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | 设置NativeWindow的元数据集,从API9开始废弃,预计API14删除 | | [OH_NativeWindow_NativeWindowSetMetaDataSet](#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | 设置OHNativeWindow的元数据集。 |
| [OH_NativeWindow_NativeWindowSetTunnelHandle<sup>(deprecated)](#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | 设置NativeWindow的TunnelHandle,从API9开始废弃,预计API14删除 | | [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const OHExtDataHandle \*handle) | 设置OHNativeWindow的TunnelHandle。 |
## 详细描述 ## 类型定义说明
### OHNativeWindow
```
typedef struct NativeWindow OHNativeWindow
```
**描述:**
提供对OHNativeWindow的访问功能
### OHNativeWindowBuffer
```
typedef struct NativeWindowBuffer OHNativeWindowBuffer
```
**描述:**
提供对OHNativeWindowBuffer的访问功能
### Region
```
typedef struct Region Region
```
**描述:**
表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区)
## 枚举类型说明 ## 枚举类型说明
...@@ -80,82 +115,98 @@ ...@@ -80,82 +115,98 @@
### NativeWindowOperation ### NativeWindowOperation
``` ```
enum NativeWindowOperation enum NativeWindowOperation
``` ```
**描述** **描述:**
OH_NativeWindow_NativeWindowHandleOpt函数中的操作码 OH_NativeWindow_NativeWindowHandleOpt函数中的操作码
| 枚举值 | 说明 | | 枚举值 | 描述 |
| -------- | -------- | | -------- | -------- |
| SET_BUFFER_GEOMETRY | 设置本地窗口缓冲区几何图形, 函数中的可变参数是 [输入] int32_t height,[输入] int32_t width。 | | SET_BUFFER_GEOMETRY | 设置本地窗口缓冲区几何图形, 函数中的可变参数是 [输入] int32_t height,[输入] int32_t width。 |
| GET_BUFFER_GEOMETRY | 获取本地窗口缓冲区几何图形, 函数中的可变参数是 [输出] int32_t \*height, [输出] int32_t \*width。 | | GET_BUFFER_GEOMETRY | 获取本地窗口缓冲区几何图形, 函数中的可变参数是 [输出] int32_t \*height, [输出] int32_t \*width。 |
| GET_FORMAT | 获取本地窗口缓冲区格式, 函数中的可变参数是 [输出] int32_t \*format。 | | GET_FORMAT | 获取本地窗口缓冲区格式, 函数中的可变参数是 [输出] int32_t \*format。 |
| SET_FORMAT | 设置本地窗口缓冲区格式, 函数中的可变参数是 [输入] int32_t format。 | | SET_FORMAT | 设置本地窗口缓冲区格式, 函数中的可变参数是 [输入] int32_t format。 |
| GET_USAGE | 获取本地窗口缓冲区格式, 函数中的可变参数是 [输出] int32_t \*usage。 | | GET_USAGE | 获取本地窗口读写方式, 函数中的可变参数是 [输出] int32_t \*usage。 |
| SET_USAGE | 设置本地窗口缓冲区使用方式, 函数中的可变参数是 [输入] int32_t usage。 | | SET_USAGE | 设置本地窗口缓冲区读写方式, 函数中的可变参数是 [输入] int32_t usage。 |
| SET_STRIDE | 设置本地窗口缓冲区步幅, 函数中的可变参数是 [输入] int32_t stride。 | | SET_STRIDE | 设置本地窗口缓冲区步幅, 函数中的可变参数是 [输入] int32_t stride。 |
| GET_STRIDE | 获取本地窗口缓冲区步幅, 函数中的可变参数是 [输出] int32_t \*stride。 | | GET_STRIDE | 获取本地窗口缓冲区步幅, 函数中的可变参数是 [输出] int32_t \*stride。 |
| SET_SWAP_INTERVAL | 设置本地窗口缓冲区交换间隔, 函数中的可变参数是 [输入] int32_t interval。 | | SET_SWAP_INTERVAL | 设置本地窗口缓冲区交换间隔, 函数中的可变参数是 [输入] int32_t interval。 |
| GET_SWAP_INTERVAL | 获取本地窗口缓冲区交换间隔, 函数中的可变参数是 [输出] int32_t \*interval。 | | GET_SWAP_INTERVAL | 获取本地窗口缓冲区交换间隔, 函数中的可变参数是 [输出] int32_t \*interval。 |
| SET_TIMEOUT | 设置请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输入] int32_t timeout。 | | SET_TIMEOUT | 设置请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输入] int32_t timeout。 |
| GET_TIMEOUT | 获取请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输出] int32_t \*timeout。 | | GET_TIMEOUT | 获取请求本地窗口缓冲区的超时等待时间, 函数中的可变参数是 [输出] int32_t \*timeout。 |
| SET_COLOR_GAMUT | 设置本地窗口缓冲区色彩空间, 函数中的可变参数是 [输入] int32_t colorGamut。 | | SET_COLOR_GAMUT | 设置本地窗口缓冲区色彩空间, 函数中的可变参数是 [输入] int32_t colorGamut。 |
| GET_COLOR_GAMUT | 获取本地窗口缓冲区色彩空间, 函数中的可变参数是 [out int32_t \*colorGamut]。 | | GET_COLOR_GAMUT | 获取本地窗口缓冲区色彩空间, 函数中的可变参数是 [out int32_t \*colorGamut]。 |
| SET_TRANSFORM | 设置本地窗口缓冲区变换, 函数中的可变参数是 [输入] int32_t transform。 | | SET_TRANSFORM | 设置本地窗口缓冲区变换, 函数中的可变参数是 [输入] int32_t transform。 |
| GET_TRANSFORM | 获取本地窗口缓冲区变换, 函数中的可变参数是 [输出] int32_t \*transform。 | | GET_TRANSFORM | 获取本地窗口缓冲区变换, 函数中的可变参数是 [输出] int32_t \*transform。 |
| SET_UI_TIMESTAMP | 设置本地窗口缓冲区UI时间戳, 函数中的可变参数是 [输入] uint64_t uiTimestamp。 | | SET_UI_TIMESTAMP | 设置本地窗口缓冲区UI时间戳, 函数中的可变参数是 [输入] uint64_t uiTimestamp。 |
### OHHDRMetadataKey<sup>(deprecated) ### OHHDRMetadataKey
``` ```
enum OHHDRMetadataKey enum OHHDRMetadataKey
``` ```
**描述:** **描述:**
枚举HDR元数据关键字
枚举HDR元数据关键字,从API9开始废弃,预计API14删除 **起始版本:**
| 枚举值 | 描述 | 9
**弃用:**
从API version 10开始废弃,不再提供替代接口
| 枚举值 | 描述 |
| -------- | -------- | | -------- | -------- |
| OH_METAKEY_RED_PRIMARY_X | 红基色X坐标 | | OH_METAKEY_RED_PRIMARY_X | 红基色X坐标 |
| OH_METAKEY_RED_PRIMARY_Y | 红基色Y坐标 | | OH_METAKEY_RED_PRIMARY_Y | 红基色Y坐标 |
| OH_METAKEY_GREEN_PRIMARY_X | 绿基色X坐标 | | OH_METAKEY_GREEN_PRIMARY_X | 绿基色X坐标 |
| OH_METAKEY_GREEN_PRIMARY_Y | 绿基色Y坐标 | | OH_METAKEY_GREEN_PRIMARY_Y | 绿基色Y坐标 |
| OH_METAKEY_BLUE_PRIMARY_X | 蓝基色X坐标 | | OH_METAKEY_BLUE_PRIMARY_X | 蓝基色X坐标 |
| OH_METAKEY_BLUE_PRIMARY_Y | 蓝基色Y坐标 | | OH_METAKEY_BLUE_PRIMARY_Y | 蓝基色Y坐标 |
| OH_METAKEY_WHITE_PRIMARY_X | 白点X坐标 | | OH_METAKEY_WHITE_PRIMARY_X | 白点X坐标 |
| OH_METAKEY_WHITE_PRIMARY_Y | 白点Y坐标 | | OH_METAKEY_WHITE_PRIMARY_Y | 白点Y坐标 |
| OH_METAKEY_MAX_LUMINANCE | 最大的光亮度 | | OH_METAKEY_MAX_LUMINANCE | 最大的光亮度 |
| OH_METAKEY_MIN_LUMINANCE | 最小的光亮度 | | OH_METAKEY_MIN_LUMINANCE | 最小的光亮度 |
| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | 最大的内容亮度水平 | | OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | 最大的内容亮度水平 |
| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | 最大的帧平均亮度水平 | | OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | 最大的帧平均亮度水平 |
| OH_METAKEY_HDR10_PLUS | HDR10 Plus | | OH_METAKEY_HDR10_PLUS | HDR10 Plus |
| OH_METAKEY_HDR_VIVID | Vivid | | OH_METAKEY_HDR_VIVID | Vivid |
### OHScalingMode<sup>(deprecated) ### OHScalingMode
``` ```
enum OHScalingMode enum OHScalingMode
``` ```
**描述:** **描述:**
缩放模式 Scaling Mode
**起始版本:**
9
**弃用:**
缩放模式 Scaling Mode,从API9开始废弃,预计API14删除 从API version 10开始废弃,不再提供替代接口
| 枚举值 | 描述 | | 枚举值 | 描述 |
| -------- | -------- | | -------- | -------- |
| OH_SCALING_MODE_FREEZE | 在接收到窗口大小的缓冲区之前,不可以更新窗口内容 | | OH_SCALING_MODE_FREEZE | 在接收到窗口大小的缓冲区之前,不可以更新窗口内容 |
| OH_SCALING_MODE_SCALE_TO_WINDOW | 缓冲区在二维中缩放以匹配窗口大小 | | OH_SCALING_MODE_SCALE_TO_WINDOW | 缓冲区在二维中缩放以匹配窗口大小 |
| OH_SCALING_MODE_SCALE_CROP | 缓冲区被统一缩放,使得缓冲区的较小尺寸与窗口大小匹配 | | OH_SCALING_MODE_SCALE_CROP | 缓冲区被统一缩放,使得缓冲区的较小尺寸与窗口大小匹配 |
| OH_SCALING_MODE_NO_SCALE_CROP | 窗口被裁剪为缓冲区裁剪矩形的大小,裁剪矩形之外的像素被视为完全透明 | | OH_SCALING_MODE_NO_SCALE_CROP | 窗口被裁剪为缓冲区裁剪矩形的大小,裁剪矩形之外的像素被视为完全透明 |
## 函数说明 ## 函数说明
...@@ -163,461 +214,425 @@ enum OHScalingMode ...@@ -163,461 +214,425 @@ enum OHScalingMode
### OH_NativeWindow_CreateNativeWindow() ### OH_NativeWindow_CreateNativeWindow()
``` ```
OHNativeWindow* OH_NativeWindow_CreateNativeWindow (void * pSurface) OHNativeWindow* OH_NativeWindow_CreateNativeWindow (void * pSurface)
``` ```
**描述** **描述:**
创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例 创建OHNativeWindow实例,每次调用都会产生一个新的OHNativeWindow实例
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| pSurface | 参数是一个指向生产者ProduceSurface的指针,类型为sptr&lt;OHOS::Surface&gt; | | pSurface | 一个指向生产者ProduceSurface的指针,类型为sptr&lt;OHOS::Surface&gt; |
**返回:**
返回一个指针,指向NativeWindow的结构体实例
**起始版本:** **返回:**
8 返回一个指针,指向OHNativeWindow的结构体实例
### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() ### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer()
``` ```
OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer) OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer)
``` ```
**描述** **描述:**
创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例 创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| pSurfaceBuffer | 参数是一个指向生产者buffer的指针,类型为sptr&lt;OHOS::SurfaceBuffer&gt; | | pSurfaceBuffer | 一个指向生产者buffer的指针,类型为sptr&lt;OHOS::SurfaceBuffer&gt; |
**返回** **返回:**
返回一个指针,指向NativeWindowBuffer的结构体实例 返回一个指针,指向OHNativeWindowBuffer的结构体实例
**起始版本:**
8
### OH_NativeWindow_DestroyNativeWindow() ### OH_NativeWindow_DestroyNativeWindow()
``` ```
void OH_NativeWindow_DestroyNativeWindow (OHNativeWindow * window) void OH_NativeWindow_DestroyNativeWindow (OHNativeWindow * window)
``` ```
**描述** **描述:**
NativeWindow对象的引用计数减1,当引用计数为0的时候,该NativeWindow对象会被析构掉 OHNativeWindow对象的引用计数减1,当引用计数为0的时候,该OHNativeWindow对象会被析构掉
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
**起始版本:**
8
### OH_NativeWindow_DestroyNativeWindowBuffer() ### OH_NativeWindow_DestroyNativeWindowBuffer()
``` ```
void OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer * buffer) void OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer * buffer)
``` ```
**描述** **描述:**
NativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该NativeWindowBuffer对象会被析构掉 OHNativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该OHNativeWindowBuffer对象会被析构掉
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 | | buffer | 一个OHNativeWindowBuffer的结构体实例的指针 |
**起始版本:**
8
### OH_NativeWindow_GetBufferHandleFromNative() ### OH_NativeWindow_GetBufferHandleFromNative()
``` ```
BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer * buffer) BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer * buffer)
``` ```
**描述** **描述:**
通过NativeWindowBuffer获取该buffer的BufferHandle指针 通过OHNativeWindowBuffer获取该buffer的BufferHandle指针
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 | | buffer | 一个OHNativeWindowBuffer的结构体实例的指针 |
**返回** **返回:**
BufferHandle 返回一个指针,指向BufferHandle的结构体实例 BufferHandle 返回一个指针,指向BufferHandle的结构体实例
**起始版本:**
8
### OH_NativeWindow_GetNativeObjectMagic() ### OH_NativeWindow_GetNativeObjectMagic()
``` ```
int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj) int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj)
``` ```
**描述** **描述:**
获取NativeObject的MagicId 获取NativeObject的MagicId
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 | | obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针 |
**返回** **返回:**
MagicId 返回值为魔鬼数字,每个NativeObject唯一 MagicId 返回值为魔鬼数字,每个NativeObject唯一
**起始版本:**
8
### OH_NativeWindow_NativeObjectReference() ### OH_NativeWindow_NativeObjectReference()
``` ```
int32_t OH_NativeWindow_NativeObjectReference (void * obj) int32_t OH_NativeWindow_NativeObjectReference (void * obj)
``` ```
**描述** **描述:**
增加一个NativeObject的引用计数 增加一个NativeObject的引用计数
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 | | obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本:**
8
### OH_NativeWindow_NativeObjectUnreference() ### OH_NativeWindow_NativeObjectUnreference()
``` ```
int32_t OH_NativeWindow_NativeObjectUnreference (void * obj) int32_t OH_NativeWindow_NativeObjectUnreference (void * obj)
``` ```
**描述** **描述:**
减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| obj | 参数是一个NativeWindow or NativeWindowBuffer的结构体实例的指针 | | obj | 一个OHNativeWindow或者OHNativeWindowBuffer的结构体实例的指针 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本:**
8
### OH_NativeWindow_NativeWindowAbortBuffer() ### OH_NativeWindow_NativeWindowAbortBuffer()
``` ```
int32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer ) int32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer )
``` ```
**描述** **描述:**
通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中,供下次再申请 通过OHNativeWindow将之前申请出来的OHNativeWindowBuffer返还到Buffer队列中,供下次再申请
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 | | buffer | 一个OHNativeWindowBuffer的结构体实例的指针 |
**返回:**
GSError 返回值为错误码 **返回:**
**起始版本:** 返回值为0表示执行成功
8
### OH_NativeWindow_NativeWindowFlushBuffer() ### OH_NativeWindow_NativeWindowFlushBuffer()
``` ```
int32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer, int fenceFd, Region region ) int32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer, int fenceFd, Region region )
``` ```
**描述** **描述:**
通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中,用以内容消费 通过OHNativeWindow将生产好内容的OHNativeWindowBuffer放回到Buffer队列中,用以内容消费
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的指针 | | buffer | 一个OHNativeWindowBuffer的结构体实例的指针 |
| fenceFd | 参数是一个文件描述符句柄,用以同步时序 | | fenceFd | 一个文件描述符句柄,用以同步时序 |
| region | 参数表示一块脏区域,该区域有内容更新 | | region | 表示一块脏区域,该区域有内容更新 |
**返回:**
GSError 返回值为错误码 **返回:**
**起始版本:** 返回值为0表示执行成功
8
### OH_NativeWindow_NativeWindowHandleOpt() ### OH_NativeWindow_NativeWindowHandleOpt()
``` ```
int32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow * window, int code, ... ) int32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow * window, int code, ... )
``` ```
**描述** **描述:**
设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等 设置/获取OHNativeWindow的属性,包括设置/获取宽高、内容格式等
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| code | 表示操作码,详见[NativeWindowOperation](#nativewindowoperation) | | code | 表示操作码,详见[NativeWindowOperation](#nativewindowoperation) |
| ... | 可变参数,必须与操作码一一对应 | | ... | 可变参数,必须与操作码一一对应 |
**返回:**
GSError 返回值为错误码 **返回:**
**起始版本:** 返回值为0表示执行成功
8
### OH_NativeWindow_NativeWindowRequestBuffer() ### OH_NativeWindow_NativeWindowRequestBuffer()
``` ```
int32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow * window, OHNativeWindowBuffer ** buffer, int * fenceFd ) int32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow * window, OHNativeWindowBuffer ** buffer, int * fenceFd )
``` ```
**描述** **描述:**
通过NativeWindow对象申请一块NativeWindowBuffer,用以内容生产 通过OHNativeWindow对象申请一块OHNativeWindowBuffer,用以内容生产
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| buffer | 参数是一个NativeWindowBuffer的结构体实例的二级指针 | | buffer | 一个OHNativeWindowBuffer的结构体实例的二级指针 |
| fenceFd | 参数是一个文件描述符句柄 | | fenceFd | 一个文件描述符句柄 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本:**
8
### OH_NativeWindow_NativeWindowSetMetaData()
### OH_NativeWindow_NativeWindowSetMetaData()<sup>(deprecated)
``` ```
int32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow * window, uint32_t sequence, int32_t size, const OHHDRMetaData * metaData ) int32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow * window, uint32_t sequence, int32_t size, const OHHDRMetaData * metaData )
``` ```
**描述** **描述:**
设置NativeWindow的元数据。 设置OHNativeWindow的元数据
从API9开始废弃,预计API14删除。
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| sequence | 生产缓冲区的序列 | | sequence | 生产缓冲区的序列 |
| size | OHHDRMetaData数组的大小 | | size | OHHDRMetaData数组的大小 |
| metaDate | 指向OHHDRMetaData数组的指针 | | metaDate | 指向OHHDRMetaData数组的指针 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本** **起始版本:**
9 9
**弃用:**
从API version 10开始废弃,不再提供替代接口
### OH_NativeWindow_NativeWindowSetMetaDataSet()
### OH_NativeWindow_NativeWindowSetMetaDataSet()<sup>(deprecated)
``` ```
int32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow * window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t * metaData ) int32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow * window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t * metaData )
``` ```
**描述** **描述:**
设置NativeWindow的元数据集。 设置OHNativeWindow的元数据集。
从API9开始废弃,预计API14删除。
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针。 | | window | 一个OHNativeWindow的结构体实例的指针。 |
| sequence | 生产缓冲区的序列。 | | sequence | 生产缓冲区的序列。 |
| key | 枚举值OHHDRMetadataKey | | key | 枚举值OHHDRMetadataKey |
| size | uint8_t向量的大小 | | size | uint8_t向量的大小 |
| metaDate | 指向uint8_t向量的指针 | | metaDate | 指向uint8_t向量的指针 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本** **起始版本:**
9 9
**弃用:**
从API version 10开始废弃,不再提供替代接口
### OH_NativeWindow_NativeWindowSetScalingMode()
### OH_NativeWindow_NativeWindowSetScalingMode()<sup>(deprecated)
``` ```
int32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow * window, uint32_t sequence, OHScalingMode scalingMode ) int32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow * window, uint32_t sequence, OHScalingMode scalingMode )
``` ```
**描述** **描述:**
设置NativeWindow的ScalingMode。 设置OHNativeWindow的ScalingMode
从API9开始废弃,预计API14删除。
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| sequence | 生产缓冲区的序列 | | sequence | 生产缓冲区的序列 |
| scalingMode | 枚举值OHScalingMode | | scalingMode | 枚举值OHScalingMode |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本** **起始版本:**
9 9
**弃用:**
从API version 10开始废弃,不再提供替代接口
### OH_NativeWindow_NativeWindowSetTunnelHandle()
### OH_NativeWindow_NativeWindowSetTunnelHandle()<sup>(deprecated)
``` ```
int32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow * window, const OHExtDataHandle * handle ) int32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow * window, const OHExtDataHandle * handle )
``` ```
**描述** **描述:**
设置NativeWindow的TunnelHandle。 设置OHNativeWindow的TunnelHandle。
从API9开始废弃,预计API14删除。
\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow \@syscap SystemCapability.Graphic.Graphic2D.NativeWindow
**参数** **参数:**
| 名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| window | 参数是一个NativeWindow的结构体实例的指针 | | window | 一个OHNativeWindow的结构体实例的指针 |
| handle | 指向OHExtDataHandle的指针 | | handle | 指向OHExtDataHandle的指针 |
**返回** **返回:**
GSError 返回值为错误码 返回值为0表示执行成功
**起始版本** **起始版本:**
9 9
**弃用:**
从API version 10开始废弃,不再提供替代接口
# OH_NativeBuffer # OH_NativeBuffer
提供NativeBuffer功能 ## 概述
提供NativeBuffer功能,通过提供的接口,可以实现共享内存的申请、使用、属性查询、释放等操作。
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**起始版本:**
**起始版本:**
9 9
...@@ -18,32 +17,51 @@ ...@@ -18,32 +17,51 @@
### 文件 ### 文件
| 文件名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [native_buffer.h](native__buffer_8h.md) | 定义获取和使用NativeBuffer的相关函数<br>引用文件:<native_buffer/native_buffer.h> | | [native_buffer.h](native__buffer_8h.md) | 定义获取和使用NativeBuffer的相关函数<br/>引用文件:&lt;native_buffer/native_buffer.h&gt; |
### 结构体 ### 结构体
| 结构体名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性 | | [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性。 |
### 类型定义
| 名称 | 描述 |
| -------- | -------- |
| [OH_NativeBuffer](#oh_nativebuffer) | 提供OH_NativeBuffer结构体声明。 |
### 函数 ### 函数
| 函数名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeBuffer_Alloc](#oh_nativebuffer_alloc) (const [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例 | | [OH_NativeBuffer_Alloc](#oh_nativebuffer_alloc) (const [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例。 |
| [OH_NativeBuffer_Reference](#oh_nativebuffer_reference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数加1 | | [OH_NativeBuffer_Reference](#oh_nativebuffer_reference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | 将OH_NativeBuffer对象的引用计数加1。 |
| [OH_NativeBuffer_Unreference](#oh_nativebuffer_unreference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉 | | [OH_NativeBuffer_Unreference](#oh_nativebuffer_unreference) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉。 |
| [OH_NativeBuffer_GetConfig](#oh_nativebuffer_getconfig) (OH_NativeBuffer \*buffer, [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 用于获取OH_NativeBuffer的属性 | | [OH_NativeBuffer_GetConfig](#oh_nativebuffer_getconfig) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 用于获取OH_NativeBuffer的属性。 |
| [OH_NativeBuffer_Map](#oh_nativebuffer_map) (OH_NativeBuffer \*buffer, void \*\*virAddr) | 将OH_NativeBuffer对应的ION内存映射到进程空间 | | [OH_NativeBuffer_Map](#oh_nativebuffer_map) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer, void \*\*virAddr) | 将OH_NativeBuffer对应的ION内存映射到进程空间。 |
| [OH_NativeBuffer_Unmap](#oh_nativebuffer_unmap) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对应的ION内存从进程空间移除 | | [OH_NativeBuffer_Unmap](#oh_nativebuffer_unmap) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | 将OH_NativeBuffer对应的ION内存从进程空间移除。 |
| [OH_NativeBuffer_GetSeqNum](#oh_nativebuffer_getseqnum) (OH_NativeBuffer \*buffer) | 获取OH_NativeBuffer的序列号 | | [OH_NativeBuffer_GetSeqNum](#oh_nativebuffer_getseqnum) ([OH_NativeBuffer](#oh_nativebuffer) \*buffer) | 获取OH_NativeBuffer的序列号。 |
## 类型定义说明
### OH_NativeBuffer
## 详细描述
```
typedef struct OH_NativeBuffer OH_NativeBuffer
```
**描述:**
提供OH_NativeBuffer结构体声明。
## 函数说明 ## 函数说明
...@@ -56,25 +74,21 @@ ...@@ -56,25 +74,21 @@
OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config) OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config)
``` ```
**描述** **描述:**
通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| config | 参数是一个指向OH_NativeBuffer属性的指针,类型为OH_NativeBuffer_Config | | config | 一个指向OH_NativeBuffer_Config类型的指针。 |
**返回** **返回:**
创建成功则返回一个指向OH_NativeBuffer结构体实例的指针,否则返回NULL 创建成功则返回一个指向OH_NativeBuffer结构体实例的指针,否则返回NULL。
**起始版本:**
9
### OH_NativeBuffer_GetConfig() ### OH_NativeBuffer_GetConfig()
...@@ -84,22 +98,18 @@ OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config) ...@@ -84,22 +98,18 @@ OH_NativeBuffer* OH_NativeBuffer_Alloc (const OH_NativeBuffer_Config * config)
void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config * config ) void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config * config )
``` ```
**描述** **描述:**
用于获取OH_NativeBuffer的属性 用于获取OH_NativeBuffer的属性
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
| config | 参数是一个指向OH_NativeBuffer_Config的指针,用于接收OH_NativeBuffer的属性 | | config | 一个指向OH_NativeBuffer_Config的指针,用于接收OH_NativeBuffer的属性。 |
**起始版本:**
9
### OH_NativeBuffer_GetSeqNum() ### OH_NativeBuffer_GetSeqNum()
...@@ -109,25 +119,21 @@ void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config ...@@ -109,25 +119,21 @@ void OH_NativeBuffer_GetConfig (OH_NativeBuffer * buffer, OH_NativeBuffer_Config
uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer) uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer)
``` ```
**描述** **描述:**
获取OH_NativeBuffer的序列号 获取OH_NativeBuffer的序列号
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
**返回:**
返回对应OH_NativeBuffer的唯一序列号 **返回:**
**起始版本:** 返回对应OH_NativeBuffer的唯一序列号。
9
### OH_NativeBuffer_Map() ### OH_NativeBuffer_Map()
...@@ -137,26 +143,22 @@ uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer) ...@@ -137,26 +143,22 @@ uint32_t OH_NativeBuffer_GetSeqNum (OH_NativeBuffer * buffer)
int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr ) int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr )
``` ```
**描述** **描述:**
将OH_NativeBuffer对应的ION内存映射到进程空间 将OH_NativeBuffer对应的ION内存映射到进程空间
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
| virAddr | 参数是一个二级指针,二级指针指向虚拟内存的地址 | | virAddr | 一个二级指针,二级指针指向映射到当前进程的虚拟内存的地址。 |
**返回** **返回:**
返回一个由GSError定义的int32_t类型的错误码 返回值为0表示执行成功。
**起始版本:**
9
### OH_NativeBuffer_Reference() ### OH_NativeBuffer_Reference()
...@@ -166,25 +168,21 @@ int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr ) ...@@ -166,25 +168,21 @@ int32_t OH_NativeBuffer_Map (OH_NativeBuffer * buffer, void ** virAddr )
int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer) int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer)
``` ```
**描述** **描述:**
将OH_NativeBuffer对象的引用计数加1 将OH_NativeBuffer对象的引用计数加1
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
**返回** **返回:**
返回一个由GSError定义的int32_t类型的错误码 返回值为0表示执行成功。
**起始版本:**
9
### OH_NativeBuffer_Unmap() ### OH_NativeBuffer_Unmap()
...@@ -194,25 +192,21 @@ int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer) ...@@ -194,25 +192,21 @@ int32_t OH_NativeBuffer_Reference (OH_NativeBuffer * buffer)
int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer) int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer)
``` ```
**描述** **描述:**
将OH_NativeBuffer对应的ION内存从进程空间移除 将OH_NativeBuffer对应的ION内存从进程空间移除
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
**返回:**
返回一个由GSError定义的int32_t类型的错误码
**起始版本:** **返回:**
9 返回值为0表示执行成功。
### OH_NativeBuffer_Unreference() ### OH_NativeBuffer_Unreference()
...@@ -222,22 +216,18 @@ int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer) ...@@ -222,22 +216,18 @@ int32_t OH_NativeBuffer_Unmap (OH_NativeBuffer * buffer)
int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer * buffer) int32_t OH_NativeBuffer_Unreference (OH_NativeBuffer * buffer)
``` ```
**描述** **描述:**
将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| buffer | 参数是一个指向OH_NativeBuffer实例的指针 | | buffer | 一个指向OH_NativeBuffer实例的指针。 |
**返回:**
返回一个由GSError定义的int32_t类型的错误码 **返回:**
**起始版本:** 返回值为0表示执行成功。
9
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性。 OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性。
**起始版本:** \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer
**起始版本:**
9 9
**相关模块** **相关模块:**
[OH_NativeBuffer](_o_h___native_buffer.md) [OH_NativeBuffer](_o_h___native_buffer.md)
...@@ -19,9 +21,9 @@ OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查 ...@@ -19,9 +21,9 @@ OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查
### 成员变量 ### 成员变量
| 成员变量名称 | 描述 | | 成员变量名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| width | 宽度(像素) | | width | 宽度(像素)。 |
| height | 高度(像素) | | height | 高度(像素)。 |
| format | 像素格式 | | format | 像素格式。 |
| usage | buffer的用途说明 | | usage | buffer的用途说明。 |
# OH_NativeImage # OH_NativeImage
提供NativeImage功能。 ## 概述
提供NativeImage功能,作为数据消费者,主要用来将数据和OpenGL纹理对接,需在OpenGL环境下使用
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**起始版本:**
**起始版本:**
9 9
...@@ -18,26 +17,58 @@ ...@@ -18,26 +17,58 @@
### 文件 ### 文件
| 文件名称 | 描述 | | 名称 | 描述 |
| -------- | -------- |
| [native_image.h](native__image_8h.md) | 定义获取和使用NativeImage的相关函数<br/>引用文件:&lt;native_image/native_image.h&gt; |
### 类型定义
| 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [native_image.h](native__image_8h.md) | 定义获取和使用NativeImage的相关函数。<br>引用文件:<native_image/native_image.h> | | [OH_NativeImage](#oh_nativeimage) | 提供OH_NativeImage结构体声明 |
| [OHNativeWindow](#ohnativewindow) | 提供对NativeWindow的访问功能 |
### 函数 ### 函数
| 函数名称 | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeImage_Create]( #oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | 创建一个**OH_NativeImage**实例,该实例与OPENGL ES的纹理ID和纹理目标相关联。 | | [OH_NativeImage_Create](#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | 创建一个**OH_NativeImage**实例,该实例与OpenGL ES的纹理ID和纹理目标相关联 |
| [OH_NativeImage_AcquireNativeWindow]( #oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用 OH_NativeWindow_DestroyNativeWindow释放。 | | [OH_NativeImage_AcquireNativeWindow](#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用<br/>OH_NativeWindow_DestroyNativeWindow释放 |
| [OH_NativeImage_AttachContext]( #oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OPENGL ES上下文, 且该OPENGL ES纹理会绑定到 GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新。 | | [OH_NativeImage_AttachContext](#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OpenGL ES上下文, 且该OpenGL ES纹理会绑定到<br/>GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新 |
| [OH_NativeImage_DetachContext]( #oh_nativeimage_detachcontext) (OH_NativeImage \*image) | 将OH_NativeImage实例从当前OPENGL ES上下文分离。 | | [OH_NativeImage_DetachContext](#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | 将OH_NativeImage实例从当前OpenGL ES上下文分离 |
| [OH_NativeImage_UpdateSurfaceImage]( #oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | 通过OH_NativeImage获取最新帧更新相关联的OPENGL ES纹理。 | | [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | 通过OH_NativeImage获取最新帧更新相关联的OpenGL ES纹理 |
| [OH_NativeImage_GetTimestamp]( #oh_nativeimage_gettimestamp) (OH_NativeImage \*image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳。 | | [OH_NativeImage_GetTimestamp](#oh_nativeimage_gettimestamp) (OH_NativeImage*image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳 |
| [OH_NativeImage_GetTransformMatrix]( #oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵。 | | [OH_NativeImage_GetTransformMatrix](#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵 |
| [OH_NativeImage_Destroy]( #oh_nativeimage_destroy) (OH_NativeImage \*\*image) | 销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该 **OH_NativeImage**指针会被赋值为空。 | | [OH_NativeImage_Destroy](#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | 销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该<br/>**OH_NativeImage**指针会被赋值为空 |
## 详细描述 ## 类型定义说明
### OH_NativeImage
```
typedef struct OH_NativeImage OH_NativeImage
```
**描述:**
提供OH_NativeImage结构体声明
### OHNativeWindow
```
typedef struct NativeWindow OHNativeWindow
```
**描述:**
提供对NativeWindow的访问功能
## 函数说明 ## 函数说明
...@@ -50,25 +81,23 @@ ...@@ -50,25 +81,23 @@
OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image) OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image)
``` ```
**描述:** **描述:**
获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用
获取与OH_NativeImage相关联的OHNativeWindow指针。该OHNativeWindow后续不再需要时需要调用 OH_NativeWindow_DestroyNativeWindow释放。 OH_NativeWindow_DestroyNativeWindow释放
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
**返回** **返回:**
成功则返回一个指向OHNativeWindow实例的指针,否则返回**NULL** 成功则返回一个指向OHNativeWindow实例的指针,否则返回**NULL**
**起始版本:**
9
### OH_NativeImage_AttachContext() ### OH_NativeImage_AttachContext()
...@@ -78,26 +107,24 @@ OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image) ...@@ -78,26 +107,24 @@ OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image)
int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId ) int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId )
``` ```
**描述** **描述:**
将OH_NativeImage实例附加到当前OPENGL ES上下文,且该OPENGL ES纹理会绑定到 GL_TEXTURE_EXTERNAL_OES,并通过OH_NativeImage进行更新。 将OH_NativeImage实例附加到当前OpenGL ES上下文, 且该OpenGL ES纹理会绑定到
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新
**参数:** \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
| Name | 描述 | **参数:**
| 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
| textureId | OH_NativeImage要附加到的OPENGL ES纹理的id。 | | textureId | OH_NativeImage要附加到的OpenGL ES纹理的id。 |
**返回:**
返回一个由**SurfaceError**定义的int32_t类型的错误码。
**起始版本:** **返回:**
9 返回值为0表示执行成功
### OH_NativeImage_Create() ### OH_NativeImage_Create()
...@@ -107,26 +134,22 @@ int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId ...@@ -107,26 +134,22 @@ int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId
OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget ) OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget )
``` ```
**描述** **描述:**
创建一个**OH_NativeImage**实例,该实例与OPENGL ES的纹理ID和纹理目标相关联。 创建一个**OH_NativeImage**实例,该实例与OpenGL ES的纹理ID和纹理目标相关联
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| textureId | OPENGL ES的纹理ID,OH_NativeImage实例会与之相关联。 | | textureId | OpenGL ES的纹理ID,OH_NativeImage实例会与之相关联 |
| textureTarget | OPENGL ES的纹理目标。 | | textureTarget | OpenGL ES的纹理目标 |
**返回:**
返回一个指向**OH_NativeImage**实例的指针,否则返回**NULL**
**起始版本:** **返回:**
9 返回一个指向**OH_NativeImage**实例的指针 returns **NULL** otherwise
### OH_NativeImage_Destroy() ### OH_NativeImage_Destroy()
...@@ -136,15 +159,17 @@ OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarge ...@@ -136,15 +159,17 @@ OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarge
void OH_NativeImage_Destroy (OH_NativeImage ** image) void OH_NativeImage_Destroy (OH_NativeImage ** image)
``` ```
**描述:** **描述:**
销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该
销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该 **OH_NativeImage**指针会被赋值为空. **OH_NativeImage**指针会被赋值为空
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
...@@ -156,25 +181,21 @@ void OH_NativeImage_Destroy (OH_NativeImage ** image) ...@@ -156,25 +181,21 @@ void OH_NativeImage_Destroy (OH_NativeImage ** image)
int32_t OH_NativeImage_DetachContext (OH_NativeImage * image) int32_t OH_NativeImage_DetachContext (OH_NativeImage * image)
``` ```
**描述** **描述:**
将OH_NativeImage实例从当前OPENGL ES上下文分离。 将OH_NativeImage实例从当前OpenGL ES上下文分离
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
**返回** **返回:**
返回一个由**SurfaceError**定义的int32_t类型的错误码。 返回值为0表示执行成功
**起始版本:**
9
### OH_NativeImage_GetTimestamp() ### OH_NativeImage_GetTimestamp()
...@@ -184,25 +205,21 @@ int32_t OH_NativeImage_DetachContext (OH_NativeImage * image) ...@@ -184,25 +205,21 @@ int32_t OH_NativeImage_DetachContext (OH_NativeImage * image)
int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image) int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image)
``` ```
**描述** **描述:**
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
**返回:** **返回:**
返回纹理图像的相关时间戳。
**起始版本:** 返回纹理图像的相关时间戳
9
### OH_NativeImage_GetTransformMatrix() ### OH_NativeImage_GetTransformMatrix()
...@@ -212,26 +229,22 @@ int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image) ...@@ -212,26 +229,22 @@ int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image)
int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] ) int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] )
``` ```
**描述** **描述:**
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
| matrix | 用来存储要获取的4\*4的变化矩阵。 | | matrix | 用来存储要获取的4\*4的变化矩阵。 |
**返回** **返回:**
返回一个由**SurfaceError**定义的int32_t类型的错误码。 返回值为0表示执行成功
**起始版本:**
9
### OH_NativeImage_UpdateSurfaceImage() ### OH_NativeImage_UpdateSurfaceImage()
...@@ -241,22 +254,18 @@ int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[ ...@@ -241,22 +254,18 @@ int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[
int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image) int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image)
``` ```
**描述** **描述:**
通过OH_NativeImage获取最新帧更新相关联的OPENGL ES纹理。 通过OH_NativeImage获取最新帧更新相关联的OpenGL ES纹理
@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage \@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
**参数** **参数:**
| Name | 描述 | | 名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 | | image | 指向OH_NativeImage实例的指针。 |
**返回:** **返回:**
返回一个由**SurfaceError**定义的int32_t类型的错误码。
**起始版本:** 返回值为0表示执行成功
9
...@@ -3,9 +3,17 @@ ...@@ -3,9 +3,17 @@
## 概述 ## 概述
扩展数据句柄结构体定义 扩展数据句柄结构体定义
**相关模块:** **起始版本:**
9
**弃用:**
从API version 10开始废弃,不再提供替代接口
**相关模块:**
[NativeWindow](_native_window.md) [NativeWindow](_native_window.md)
...@@ -15,11 +23,11 @@ ...@@ -15,11 +23,11 @@
### 成员变量 ### 成员变量
| 成员变量名称 | 描述 | | 成员变量名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [fd](#fd) | 句柄 Fd, -1代表不支持 | | [fd](#fd) | 句柄 Fd, -1代表不支持 |
| [reserveInts](#reserveints) | Reserve数组的个数 | | [reserveInts](#reserveints) | Reserve数组的个数 |
| [reserve](#reserve) [0] | Reserve数组 | | [reserve](#reserve) [0] | Reserve数组 |
## 结构体成员变量说明 ## 结构体成员变量说明
...@@ -27,35 +35,35 @@ ...@@ -27,35 +35,35 @@
### fd ### fd
``` ```
int32_t OHExtDataHandle::fd int32_t OHExtDataHandle::fd
``` ```
**描述** **描述:**
句柄 Fd, -1代表不支持 句柄 Fd, -1代表不支持
### reserve ### reserve
``` ```
int32_t OHExtDataHandle::reserve[0] int32_t OHExtDataHandle::reserve[0]
``` ```
**描述** **描述:**
Reserve数组 Reserve数组
### reserveInts ### reserveInts
``` ```
uint32_t OHExtDataHandle::reserveInts uint32_t OHExtDataHandle::reserveInts
``` ```
**描述** **描述:**
Reserve数组的个数 Reserve数组的个数
...@@ -3,9 +3,17 @@ ...@@ -3,9 +3,17 @@
## 概述 ## 概述
扩展数据句柄结构体定义。 HDR元数据结构体定义
**相关模块:** **起始版本:**
9
**弃用:**
从API version 10开始废弃,不再提供替代接口
**相关模块:**
[NativeWindow](_native_window.md) [NativeWindow](_native_window.md)
...@@ -15,10 +23,10 @@ ...@@ -15,10 +23,10 @@
### 成员变量 ### 成员变量
| 成员变量名称 | 描述 | | 成员变量名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [key](#key) | HDR元数据关键字 | | [key](#key) | HDR元数据关键字 |
| [value](#value) | 关键字对应的值 | | [value](#value) | 关键字对应的值 |
## 结构体成员变量说明 ## 结构体成员变量说明
...@@ -26,23 +34,23 @@ ...@@ -26,23 +34,23 @@
### key ### key
``` ```
OHHDRMetadataKey OHHDRMetaData::key OHHDRMetadataKey OHHDRMetaData::key
``` ```
**描述** **描述:**
HDR元数据关键字 HDR元数据关键字
### value ### value
``` ```
float OHHDRMetaData::value float OHHDRMetaData::value
``` ```
**描述** **描述:**
关键字对应的值 关键字对应的值
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
矩形区域。 矩形区域。
**起始版本:**
8
**相关模块:** **相关模块:**
[NativeWindow](_native_window.md) [NativeWindow](_native_window.md)
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
表示本地窗口NativeWindow需要更新内容的矩形区域(脏区)。 表示本地窗口NativeWindow需要更新内容的矩形区域(脏区)。
**起始版本:**
8
**相关模块:** **相关模块:**
[NativeWindow](_native_window.md) [NativeWindow](_native_window.md)
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
## 概述 ## 概述
定义获取和使用NativeWindow的相关函数 定义获取和使用NativeWindow的相关函数
**起始版本** **起始版本:**
8 8
**相关模块** **相关模块:**
[NativeWindow](_native_window.md) [NativeWindow](_native_window.md)
...@@ -19,49 +19,49 @@ ...@@ -19,49 +19,49 @@
### 结构体 ### 结构体
| 结构体名称 | 描述 | | 结构体名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [Region](_region.md) | 表示本地窗口NativeWindow需要更新内容的矩形区域(脏区)。 | | [Region](_region.md) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区) |
| [Region::Rect](_rect.md) | 矩形区域。 | | [Region::Rect](_rect.md) | 矩形区域 |
| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | HDR元数据结构体定义 。 | | [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | HDR元数据结构体定义 |
| [OHExtDataHandle](_o_h_ext_data_handle.md) | 扩展数据句柄结构体定义 。 | | [OHExtDataHandle](_o_h_ext_data_handle.md) | 扩展数据句柄结构体定义 |
### 类型定义 ### 类型定义
| 类型定义名称 | 描述 | | 类型名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| OHNativeWindow | 提供对NativeWindow的访问功能 | | [OHNativeWindow](_native_window.md#ohnativewindow) | 提供对OHNativeWindow的访问功能 |
| OHNativeWindowBuffer | 提供对NativeWindowBuffer的访问功能 | | [OHNativeWindowBuffer](_native_window.md#ohnativewindowbuffer) | 提供对OHNativeWindowBuffer的访问功能 |
| [Region](_region.md) | 表示本地窗口NativeWindow需要更新内容的矩形区域(脏区) | | [Region](_native_window.md#region) | 表示本地窗口OHNativeWindow需要更新内容的矩形区域(脏区) |
### 枚举 ### 枚举
| 枚举名称 | 描述 | | 枚举名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [NativeWindowOperation](_native_window.md#nativewindowoperation) { SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT, GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE, SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT, SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM, SET_UI_TIMESTAMP } | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码 | | [NativeWindowOperation](_native_window.md#nativewindowoperation) {<br/>[SET_BUFFER_GEOMETRY](_native_window.md), [GET_BUFFER_GEOMETRY](_native_window.md), [GET_FORMAT](_native_window.md), [SET_FORMAT](_native_window.md),<br/>[GET_USAGE](_native_window.md), [SET_USAGE](_native_window.md), [SET_STRIDE](_native_window.md), [GET_STRIDE](_native_window.md),<br/>[SET_SWAP_INTERVAL](_native_window.md), [GET_SWAP_INTERVAL](_native_window.md), [SET_TIMEOUT](_native_window.md), [GET_TIMEOUT](_native_window.md),<br/>[SET_COLOR_GAMUT](_native_window.md), [GET_COLOR_GAMUT](_native_window.md), [SET_TRANSFORM](_native_window.md), [GET_TRANSFORM](_native_window.md),<br/>[SET_UI_TIMESTAMP](_native_window.md)<br/>} | OH_NativeWindow_NativeWindowHandleOpt函数中的操作码 |
| [OHScalingMode](_native_window.md#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | 缩放模式 Scaling Mode | | [OHScalingMode](_native_window.md#ohscalingmode) { [OH_SCALING_MODE_FREEZE](_native_window.md) = 0, [OH_SCALING_MODE_SCALE_TO_WINDOW](_native_window.md), [OH_SCALING_MODE_SCALE_CROP](_native_window.md), [OH_SCALING_MODE_NO_SCALE_CROP](_native_window.md) } | 缩放模式 Scaling Mode |
| [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) { OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3, OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7, OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13 } | 枚举HDR元数据关键字 | | [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) {<br/>[OH_METAKEY_RED_PRIMARY_X](_native_window.md) = 0, [OH_METAKEY_RED_PRIMARY_Y](_native_window.md) = 1, [OH_METAKEY_GREEN_PRIMARY_X](_native_window.md) = 2, [OH_METAKEY_GREEN_PRIMARY_Y](_native_window.md) = 3,<br/>[OH_METAKEY_BLUE_PRIMARY_X](_native_window.md) = 4, [OH_METAKEY_BLUE_PRIMARY_Y](_native_window.md) = 5, [OH_METAKEY_WHITE_PRIMARY_X](_native_window.md) = 6, [OH_METAKEY_WHITE_PRIMARY_Y](_native_window.md) = 7,<br/>[OH_METAKEY_MAX_LUMINANCE](_native_window.md) = 8, [OH_METAKEY_MIN_LUMINANCE](_native_window.md) = 9, [OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL](_native_window.md) = 10, [OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL](_native_window.md) = 11,<br/>[OH_METAKEY_HDR10_PLUS](_native_window.md) = 12, [OH_METAKEY_HDR_VIVID](_native_window.md) = 13<br/>} | 枚举HDR元数据关键字 |
### 函数 ### 函数
| 函数名称 | 描述 | | 函数名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeWindow_CreateNativeWindow](_native_window.md#oh_nativewindow_createnativewindow) (void \*pSurface) | 创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例 | | [OH_NativeWindow_CreateNativeWindow](_native_window.md#oh_nativewindow_createnativewindow) (void \*pSurface) | 创建OHNativeWindow实例,每次调用都会产生一个新的OHNativeWindow实例 |
| [OH_NativeWindow_DestroyNativeWindow](_native_window.md#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | 将NativeWindow对象的引用计数减1,当引用计数为0的时候,该NativeWindow对象会被析构掉 | | [OH_NativeWindow_DestroyNativeWindow](_native_window.md#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | 将OHNativeWindow对象的引用计数减1,当引用计数为0的时候,该OHNativeWindow对象会被析构掉 |
| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](_native_window.md#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例 | | [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](_native_window.md#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | 创建OHNativeWindowBuffer实例,每次调用都会产生一个新的OHNativeWindowBuffer实例 |
| [OH_NativeWindow_DestroyNativeWindowBuffer](_native_window.md#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | 将NativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该NativeWindowBuffer对象会被析构掉 | | [OH_NativeWindow_DestroyNativeWindowBuffer](_native_window.md#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | 将OHNativeWindowBuffer对象的引用计数减1,当引用计数为0的时候,该OHNativeWindowBuffer对象会被析构掉 |
| [OH_NativeWindow_NativeWindowRequestBuffer](_native_window.md#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | 通过NativeWindow对象申请一块NativeWindowBuffer,用以内容生产 | | [OH_NativeWindow_NativeWindowRequestBuffer](_native_window.md#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | 通过OHNativeWindow对象申请一块OHNativeWindowBuffer,用以内容生产 |
| [OH_NativeWindow_NativeWindowFlushBuffer](_native_window.md#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | 通过NativeWindow将生产好内容的NativeWindowBuffer放回到Buffer队列中,用以内容消费 | | [OH_NativeWindow_NativeWindowFlushBuffer](_native_window.md#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, Region region) | 通过OHNativeWindow将生产好内容的OHNativeWindowBuffer放回到Buffer队列中,用以内容消费 |
| [OH_NativeWindow_NativeWindowAbortBuffer](_native_window.md#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | 通过NativeWindow将之前申请出来的NativeWindowBuffer返还到Buffer队列中,供下次再申请 | | [OH_NativeWindow_NativeWindowAbortBuffer](_native_window.md#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | 通过OHNativeWindow将之前申请出来的OHNativeWindowBuffer返还到Buffer队列中,供下次再申请 |
| [OH_NativeWindow_NativeWindowHandleOpt](_native_window.md#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | 设置/获取NativeWindow的属性,包括设置/获取宽高、内容格式等 | | [OH_NativeWindow_NativeWindowHandleOpt](_native_window.md#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow*window, int code,...) | 设置/获取OHNativeWindow的属性,包括设置/获取宽高、内容格式等 |
| [OH_NativeWindow_GetBufferHandleFromNative](_native_window.md#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | 通过NativeWindowBuffer获取该buffer的BufferHandle指针 | | [OH_NativeWindow_GetBufferHandleFromNative](_native_window.md#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | 通过OHNativeWindowBuffer获取该buffer的BufferHandle指针 |
| [OH_NativeWindow_NativeObjectReference](_native_window.md#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数 | | [OH_NativeWindow_NativeObjectReference](_native_window.md#oh_nativewindow_nativeobjectreference) (void \*obj) | 增加一个NativeObject的引用计数 |
| [OH_NativeWindow_NativeObjectUnreference](_native_window.md#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构掉 | | [OH_NativeWindow_NativeObjectUnreference](_native_window.md#oh_nativewindow_nativeobjectunreference) (void \*obj) | 减少一个NativeObject的引用计数,当引用计数减少为0时,该NativeObject将被析构 |
| [OH_NativeWindow_GetNativeObjectMagic](_native_window.md#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId | | [OH_NativeWindow_GetNativeObjectMagic](_native_window.md#oh_nativewindow_getnativeobjectmagic) (void \*obj) | 获取NativeObject的MagicId |
| [OH_NativeWindow_NativeWindowSetScalingMode](_native_window.md#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, [OHScalingMode](_native_window.md#ohscalingmode) scalingMode) | 设置NativeWindow的ScalingMode | | [OH_NativeWindow_NativeWindowSetScalingMode](_native_window.md#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindownative_window.md#ohscalingmode) scalingMode) | 设置OHNativeWindow的ScalingMode |
| [OH_NativeWindow_NativeWindowSetMetaData](_native_window.md#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | 设置NativeWindow的元数据 | | [OH_NativeWindow_NativeWindowSetMetaData](_native_window.md#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const OHHDRMetaData \*metaData) | 设置OHNativeWindow的元数据 |
| [OH_NativeWindow_NativeWindowSetMetaDataSet](_native_window.md#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | 设置NativeWindow的元数据集。 | | [OH_NativeWindow_NativeWindowSetMetaDataSet](_native_window.md#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t \*metaData) | 设置OHNativeWindow的元数据集。 |
| [OH_NativeWindow_NativeWindowSetTunnelHandle](_native_window.md#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | 设置NativeWindow的TunnelHandle。 | | [OH_NativeWindow_NativeWindowSetTunnelHandle](_native_window.md#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const OHExtDataHandle \*handle) | 设置OHNativeWindow的TunnelHandle。 |
\ No newline at end of file
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
## 概述 ## 概述
定义获取和使用NativeBuffer的相关函数 定义获取和使用NativeBuffer的相关函数
**起始版本** **起始版本:**
9 9
**相关模块** **相关模块:**
[OH_NativeBuffer](_o_h___native_buffer.md) [OH_NativeBuffer](_o_h___native_buffer.md)
...@@ -21,17 +21,24 @@ ...@@ -21,17 +21,24 @@
| 结构体名称 | 描述 | | 结构体名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性。 | | [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) | OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性 |
### 类型定义
| 类型名称 | 描述 |
| -------- | -------- |
| [OH_NativeBuffer](_o_h___native_buffer.md#oh_nativebuffer) | 提供OH_NativeBuffer结构体声明 |
### 函数 ### 函数
| 函数名称 | 描述 | | 函数名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeBuffer_Alloc](_o_h___native_buffer.md#oh_nativebuffer_alloc) (const [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例。 | | [OH_NativeBuffer_Alloc](_o_h___native_buffer.md#oh_nativebuffer_alloc) (const OH_NativeBuffer_Config \*config) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例 |
| [OH_NativeBuffer_Reference](_o_h___native_buffer.md#oh_nativebuffer_reference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数加1 | | [OH_NativeBuffer_Reference](_o_h___native_buffer.md#oh_nativebuffer_reference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数加1 |
| [OH_NativeBuffer_Unreference](_o_h___native_buffer.md#oh_nativebuffer_unreference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉 | | [OH_NativeBuffer_Unreference](_o_h___native_buffer.md#oh_nativebuffer_unreference) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉 |
| [OH_NativeBuffer_GetConfig](_o_h___native_buffer.md#oh_nativebuffer_getconfig) (OH_NativeBuffer \*buffer, [OH_NativeBuffer_Config](_o_h___native_buffer___config.md) \*config) | 用于获取OH_NativeBuffer的属性。 | | [OH_NativeBuffer_GetConfig](_o_h___native_buffer.md#oh_nativebuffer_getconfig) (OH_NativeBuffer \*buffer, OH_NativeBuffer_Config \*config) | 用于获取OH_NativeBuffer的属性 |
| [OH_NativeBuffer_Map](_o_h___native_buffer.md#oh_nativebuffer_map) (OH_NativeBuffer \*buffer, void \*\*virAddr) | 将OH_NativeBuffer对应的ION内存映射到进程空间 | | [OH_NativeBuffer_Map](_o_h___native_buffer.md#oh_nativebuffer_map) (OH_NativeBuffer \*buffer, void \*\*virAddr) | 将OH_NativeBuffer对应的ION内存映射到进程空间 |
| [OH_NativeBuffer_Unmap](_o_h___native_buffer.md#oh_nativebuffer_unmap) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对应的ION内存从进程空间移除 | | [OH_NativeBuffer_Unmap](_o_h___native_buffer.md#oh_nativebuffer_unmap) (OH_NativeBuffer \*buffer) | 将OH_NativeBuffer对应的ION内存从进程空间移除 |
| [OH_NativeBuffer_GetSeqNum](_o_h___native_buffer.md#oh_nativebuffer_getseqnum) (OH_NativeBuffer \*buffer) | 获取OH_NativeBuffer的序列号 | | [OH_NativeBuffer_GetSeqNum](_o_h___native_buffer.md#oh_nativebuffer_getseqnum) (OH_NativeBuffer \*buffer) | 获取OH_NativeBuffer的序列号 |
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
## 概述 ## 概述
定义获取和使用NativeImage的相关函数 定义获取和使用NativeImage的相关函数
**起始版本** **起始版本:**
9 9
**相关模块** **相关模块:**
[OH_NativeImage](_o_h___native_image.md) [OH_NativeImage](_o_h___native_image.md)
...@@ -17,15 +17,23 @@ ...@@ -17,15 +17,23 @@
## 汇总 ## 汇总
### 类型定义
| 类型名称 | 描述 |
| -------- | -------- |
| [OH_NativeImage](_o_h___native_image.md#oh_nativeimage) | 提供OH_NativeImage结构体声明 |
| [OHNativeWindow](_o_h___native_image.md#ohnativewindow) | 提供对NativeWindow的访问功能 |
### 函数 ### 函数
| 函数名称 | 描述 | | 函数名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeImage_Create](_o_h___native_image.md#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | 创建一个**OH_NativeImage**实例,该实例与OPENGL ES的纹理ID和纹理目标相关联. | | [OH_NativeImage_Create](_o_h___native_image.md#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | 创建一个**OH_NativeImage**实例,该实例与OpenGL ES的纹理ID和纹理目标相关联 |
| [OH_NativeImage_AcquireNativeWindow](_o_h___native_image.md#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用 OH_NativeWindow_DestroyNativeWindow释放. | | [OH_NativeImage_AcquireNativeWindow](_o_h___native_image.md#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用<br/>OH_NativeWindow_DestroyNativeWindow释放 |
| [OH_NativeImage_AttachContext](_o_h___native_image.md#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OPENGL ES上下文, 且该OPENGL ES纹理会绑定到 GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新. | | [OH_NativeImage_AttachContext](_o_h___native_image.md#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OpenGL ES上下文, 且该OpenGL ES纹理会绑定到<br/>GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新 |
| [OH_NativeImage_DetachContext](_o_h___native_image.md#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | 将OH_NativeImage实例从当前OPENGL ES上下文分离. | | [OH_NativeImage_DetachContext](_o_h___native_image.md#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | 将OH_NativeImage实例从当前OpenGL ES上下文分离 |
| [OH_NativeImage_UpdateSurfaceImage](_o_h___native_image.md#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | 通过OH_NativeImage获取最新帧更新相关联的OPENGL ES纹理. | | [OH_NativeImage_UpdateSurfaceImage](_o_h___native_image.md#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | 通过OH_NativeImage获取最新帧更新相关联的OpenGL ES纹理 |
| [OH_NativeImage_GetTimestamp](_o_h___native_image.md#oh_nativeimage_gettimestamp) (OH_NativeImage \*image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳. | | [OH_NativeImage_GetTimestamp](_o_h___native_image.md#oh_nativeimage_gettimestamp) (OH_NativeImage \*image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳 |
| [OH_NativeImage_GetTransformMatrix](_o_h___native_image.md#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵. | | [OH_NativeImage_GetTransformMatrix](_o_h___native_image.md#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵 |
| [OH_NativeImage_Destroy](_o_h___native_image.md#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | 销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该 **OH_NativeImage**指针会被赋值为空. | | [OH_NativeImage_Destroy](_o_h___native_image.md#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | 销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该<br/>**OH_NativeImage**指针会被赋值为空 |
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
## 概述 ## 概述
定义获取和使用NativeVsync的相关函数 定义获取和使用NativeVsync的相关函数
**起始版本** **起始版本:**
8 9
**相关模块** **相关模块:**
[NativeVsync](_native_vsync.md) [NativeVsync](_native_vsync.md)
...@@ -17,10 +17,18 @@ ...@@ -17,10 +17,18 @@
## 汇总 ## 汇总
### 类型定义
| 类型名称 | 描述 |
| -------- | -------- |
| [OH_NativeVSync](_native_vsync.md#oh_nativevsync) | 提供OH_NativeVSync结构体声明 |
| (\*[OH_NativeVSync_FrameCallback](_native_vsync.md#oh_nativevsync_framecallback)) (long long timestamp, void \*data) | VSync回调函数类型 |
### 函数 ### 函数
| 函数名称 | 描述 | | 函数名称 | 描述 |
| -------- | -------- | | -------- | -------- |
| [OH_NativeVSync_Create](_native_vsync.md#oh_nativevsync_create) (const char \*name, unsigned int length) | 创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例 | | [OH_NativeVSync_Create](_native_vsync.md#oh_nativevsync_create) (const char \*name, unsigned int length) | 创建一个OH_NativeVSync实例,每次调用都会产生一个新的实例 |
| [OH_NativeVSync_Destroy](_native_vsync.md#oh_nativevsync_destroy) (OH_NativeVSync \*nativeVsync) | 销毁OH_NativeVSync实例 | | [OH_NativeVSync_Destroy](_native_vsync.md#oh_nativevsync_destroy) (OH_NativeVSync \*nativeVsync) | 销毁OH_NativeVSync实例 |
| [OH_NativeVSync_RequestFrame](_native_vsync.md#oh_nativevsync_requestframe) (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | 请求下一次vsync信号,当信号到来时,调用回调函数callback | | [OH_NativeVSync_RequestFrame](_native_vsync.md#oh_nativevsync_requestframe) (OH_NativeVSync \*nativeVsync, OH_NativeVSync_FrameCallback callback, void \*data) | 请求下一次vsync信号,当信号到来时,调用回调函数callback |
...@@ -359,6 +359,14 @@ GNSS硬件相关能力 ...@@ -359,6 +359,14 @@ GNSS硬件相关能力
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 | | 是 | 否 | 是 | 是 | 否 | 是 | 否 | 否 |
## SystemCapability.PowerManager.DisplayPowerManager.Lite
轻设备系统显示能效管理
| Default | 运动表 | 智能表 | 平板 | 车机 | 智慧屏 | Smart-Vision | Router |
| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ |
| 是 | 是 | 是 | 是 | 否 | 是 | 否 | 否 |
## SystemCapability.PowerManager.ThermalManager ## SystemCapability.PowerManager.ThermalManager
温控服务 温控服务
......
# ArkUI子系统ChangeLog
## cl.arkui.1 uiAppearance部分谓词由公共接口变更为系统接口
命名空间uiAppearance及其内部DarkMode枚举谓词由公共接口变更为系统接口。
**变更影响**
无影响。规范性整改,命名空间uiAppearance及其内部DarkMode枚举类型修改前后均只被系统接口使用
**关键接口/组件变更**
如下接口添加系统接口systemapi说明:
- declare namespace uiAppearance
- enum DarkMode
- ALWAYS_DARK = 0
- ALWAYS_LIGHT = 1
\ No newline at end of file
...@@ -33,3 +33,86 @@ struct Example { ...@@ -33,3 +33,86 @@ struct Example {
**适配指导** **适配指导**
当事件参数设置为undefined,将会禁用该事件,依据实际应用开发场景进行参数设置即可。 当事件参数设置为undefined,将会禁用该事件,依据实际应用开发场景进行参数设置即可。
## cl.arkui.2 @Prop/@BuilderParam 状态变量需要初始化或从父组件传值
**示例:**
```ts
// xxx.ets
@Entry
@Component
struct Parent {
@State message: string = 'Parent'
build() {
Column() {
Child() // 编译报错
}
}
}
@Component
struct Child {
@Prop message: string
build() {
Column() {
}
}
}
```
**变更影响**
当@Prop/@BuilderParam 状态变量未初始化且未从父组件传值时,编译无法通过。
**关键的接口/组件变更**
不涉及。
**适配指导**
对@Prop/@BuilderParam 状态变量做初始化赋值或从父组件调用子组件时传入。
## cl.arkui.3 @BuilderParam 状态变量初始化赋值必须为@Builder函数/方法
**示例:**
```ts
// xxx.ets
@Builder
function builderFunction() {
Text('Hello Builder')
}
function normal () {
}
@Component
struct Index {
@BuilderParam builderParam: ()=>void = builderFunction
@BuilderParam builderParam2: ()=>void = normal // 编译报错
build() {
Column() {
}
}
}
```
**变更影响**
@BuilderParam 状态变量初始化赋值非@Builder方法时,编译无法通过。
**关键的接口/组件变更**
不涉及。
**适配指导**
@BuilderParam 状态变量初始化赋值传入@Builder方法。
...@@ -64,3 +64,35 @@ import bundleManager from '@ohos.bundle.bundleManager'; ...@@ -64,3 +64,35 @@ import bundleManager from '@ohos.bundle.bundleManager';
2. 该权限为user_grant类型的,安装时默认不会授权,需要应用调用弹框接口由用户选择是否授权或者使用预授权进行授权。 2. 该权限为user_grant类型的,安装时默认不会授权,需要应用调用弹框接口由用户选择是否授权或者使用预授权进行授权。
3. 使用弹框授权方式可以参考[向用户申请授权](../../../application-dev/security/accesstoken-guidelines.md#向用户申请授权) 3. 使用弹框授权方式可以参考[向用户申请授权](../../../application-dev/security/accesstoken-guidelines.md#向用户申请授权)
4. 使用预授权方式可以参考[权限预授权](../../../application-dev/security/accesstoken-guidelines.md#user_grant权限预授权) 4. 使用预授权方式可以参考[权限预授权](../../../application-dev/security/accesstoken-guidelines.md#user_grant权限预授权)
## cl.bundlemanager.5 包管理@ohos.bundle.installer.d.ts中getSpecifiedDistributionType接口移动到@ohos.bundle.bundleManager.d.ts中。
包管理@ohos.bundle.installer.d.ts中getSpecifiedDistributionType接口移动到@ohos.bundle.bundleManager.d.ts中。
**变更影响**<br>
升级新版本SDK后,包管理@ohos.bundle.installer.d.ts中getSpecifiedDistributionType接口移动到@ohos.bundle.bundleManager.d.ts中。
**关键的接口/组件变更**<br>
包管理@ohos.bundle.installer.d.ts中getSpecifiedDistributionType接口移动到@ohos.bundle.bundleManager.d.ts中。
**适配指导**<br>
1. 修改导入模块,使用bundleManager中的getSpecifiedDistributionType
```ets
import bundleManager form '@ohos.bundle.bundleManager'
```
## cl.bundlemanager.6 包管理@ohos.bundle.installer.d.ts中getAdditionalInfo接口移动到@ohos.bundle.bundleManager.d.ts中。
包管理@ohos.bundle.installer.d.ts中getAdditionalInfo接口移动到@ohos.bundle.bundleManager.d.ts中。
**变更影响**<br>
升级新版本SDK后,包管理@ohos.bundle.installer.d.ts中getAdditionalInfo接口移动到@ohos.bundle.bundleManager.d.ts中。
**关键的接口/组件变更**<br>
包管理@ohos.bundle.installer.d.ts中getAdditionalInfo接口移动到@ohos.bundle.bundleManager.d.ts中。
**适配指导**<br>
1. 修改导入模块,使用bundleManager中的getAdditionalInfo
```ets
import bundleManager form '@ohos.bundle.bundleManager'
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册