diff --git a/en/application-dev/application-models/application-context-stage.md b/en/application-dev/application-models/application-context-stage.md index 8c26d7fbb70a19db0ab07ada99f4df8cc0b290df..17fe99577ab5cd782bcd4154274555bb8064da24 100644 --- a/en/application-dev/application-models/application-context-stage.md +++ b/en/application-dev/application-models/application-context-stage.md @@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different. | Name| Path| | -------- | -------- | - | bundleCodeDir | /el1/bundle/| - | cacheDir | //base/cache/| - | filesDir | //base/files/| - | preferencesDir | //base/preferences/| - | tempDir | //base/temp/| - | databaseDir | //database/| - | distributedFilesDir | /el2/distributedFiles/| + | bundleCodeDir | \/el1/bundle/| + | cacheDir | \/\/base/cache/| + | filesDir | \/\/base/files/| + | preferencesDir | \/\/base/preferences/| + | tempDir | \/\/base/temp/| + | databaseDir | \/\/database/| + | distributedFilesDir | \/el2/distributedFiles/| The sample code is as follows: @@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different. | Name| Path| | -------- | -------- | - | bundleCodeDir | /el1/bundle/| - | cacheDir | //base/**haps/\**/cache/| - | filesDir | //base/**haps/\**/files/| - | preferencesDir | //base/**haps/\**/preferences/| - | tempDir | //base/**haps/\**/temp/| - | databaseDir | //database/**\**/| - | distributedFilesDir | /el2/distributedFiles/**\**/| + | bundleCodeDir | \/el1/bundle/| + | cacheDir | \/\/base/**haps/\**/cache/| + | filesDir | \/\/base/**haps/\**/files/| + | preferencesDir | \/\/base/**haps/\**/preferences/| + | tempDir | \/\/base/**haps/\**/temp/| + | databaseDir | \/\/database/**\**/| + | distributedFilesDir | \/el2/distributedFiles/**\**/| The sample code is as follows: diff --git a/en/application-dev/application-models/atomic-services-support-sharing.md b/en/application-dev/application-models/atomic-services-support-sharing.md index 99feea4719836f576762c3a43b0323c6bf2388cc..ba99573b28c4e25ef5ed2c8ca472e559a00f4713 100644 --- a/en/application-dev/application-models/atomic-services-support-sharing.md +++ b/en/application-dev/application-models/atomic-services-support-sharing.md @@ -1,27 +1,21 @@ # Setting Atomic Services to Support Sharing -By means of sharing, users can quickly access atomic services and use their features. - ## How to Develop -In the sharing scenario, there are two parties involved: a target application that shares data and an application that obtains the shared data. The two can be physically the same. The target application uses the **onShare()** lifecycle callback to set the data to share. After the target application is started, you can run the **hdc shell aa dump -a** command to check the started services and processes and find its mission ID. After the current application is started, call the **abilityManager.acquireShareData()** API with the mission ID passed in to obtain the shared data. -> **NOTE** -> -> The mission ID of the target application can also be obtained by calling [missionManager.getMissionInfos()](../reference/apis/js-apis-app-ability-missionManager.md#getmissioninfos). -1. The target application calls **UIAbility.onShare()** provided by the UIAbility component to set the data to share. **ohos.extra.param.key.contentTitle** indicates the title of the content to share in the sharing box, **ohos.extra.param.key.shareAbstract** provides an abstract description of the content, and **ohos.extra.param.key.shareUrl** indicates the online address of the service. You need to set these three items as objects, with the key set to **title**, **abstract**, and **url**, respectively. +1. An application calls [UIAbility.onShare()](../reference/apis/js-apis-app-ability-uiAbility.md#onshare), a lifecycle callback provided by the UIAbility component, to set the data to share. In this lifecycle callback, **ohos.extra.param.key.contentTitle** indicates the title of the content to share in the sharing box, **ohos.extra.param.key.shareAbstract** provides an abstract description of the content, and **ohos.extra.param.key.shareUrl** indicates the online address of the service. You need to set these three items as objects, with the key set to **title**, **abstract**, and **url**, respectively. ```ts import AbilityConstant from '@ohos.app.ability.AbilityConstant'; class MyUIAbility extends UIAbility { onShare(wantParams) { console.log('onShare'); - wantParams['ohos.extra.param.key.contentTitle'] = {title: "W3"}; - wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for huawei employee"}; - wantParams['ohos.extra.param.key.shareUrl'] = {url: "w3.huawei.com"}; + wantParams['ohos.extra.param.key.contentTitle'] = {title: "OA"}; + wantParams['ohos.extra.param.key.shareAbstract'] = {abstract: "communication for company employee"}; + wantParams['ohos.extra.param.key.shareUrl'] = {url: "oa.example.com"}; } } ``` -2. The current application calls **abilityManager.acquireShareData()** to obtain the data shared by the target application. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the **missionManager.getMissionInfos()** API after the target application is started. **wantParam** indicates the data shared by the target application through the **UIAbility.onShare()** lifecycle callback. +2. A system dialog box calls [abilityManager.acquireShareData()](../reference/apis/js-apis-app-ability-abilityManager.md#acquiresharedata) to obtain data shared through atomic service sharing. Specifically, the system finds the UIAbility based on the mission ID and calls the **OnShare()** lifecycle of the UIAbility to obtain the shared data. ```ts import abilityManager from '@ohos.app.ability.abilityManager'; diff --git a/en/application-dev/device/vibrator-guidelines.md b/en/application-dev/device/vibrator-guidelines.md index c028f5be4890c476bab762cfc8b0f0d12d9fdda8..cfa6e7cd1d26d5781a850384aa4be148ebb247e2 100644 --- a/en/application-dev/device/vibrator-guidelines.md +++ b/en/application-dev/device/vibrator-guidelines.md @@ -18,8 +18,85 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md | ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. | | ohos.vibrator | stopVibration(): Promise<void> | Stops vibration in all modes. This API uses a promise to return the result. | | ohos.vibrator | stopVibration(callback: AsyncCallback<void>): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. | -| ohos.vibrator | isSupportEffect(effectId: string): Promise<boolean> | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | -| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. | +| ohos.vibrator | isSupportEffect(effectId: string): Promise<boolean> | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.| +| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite.| + + +## Custom Vibration Format + +Custom vibration enables you to design desired vibration effects by customizing a vibration configuration file and orchestrating vibration forms based on the corresponding rules. + +The custom vibration configuration file is in JSON format. An example file is as follows: + +```json +{ + "MetaData": { + "Create": "2023-01-09", + "Description": "a haptic case", + "Version": 1.0, + "ChannelNumber": 1 + }, + "Channels": [ + { + "Parameters": { + "Index": 1 + }, + "Pattern": [ + { + "Event": { + "Type": "transient", + "StartTime": 0, + "Parameters": { + "Intensity": 100, + "Frequency": 31 + } + } + }, + { + "Event": { + "Type": "continuous", + "StartTime": 100, + "Duration": 54, + "Parameters": { + "Intensity": 38, + "Frequency": 30 + } + } + } + ] + } + ] +} +``` + +This JSON file contains two attributes: **MetaData** and **Channels**. +- **MetaData** contains information about the file header. You can add the following attributes under **MetaData**: + - **Version**: version number of the file format, which is forward compatible. Currently, only version 1.0 is supported. This parameter is mandatory. + - **ChannelNumber**: number of channels for vibration. Currently, only one channel is supported, and the value is fixed at **1**. This parameter is mandatory. + - **Create**: time when the file was created. This parameter is optional. + - **Description**: additional information such as the vibration effect and creation information. This parameter is optional. +- **Channels** provides information about the vibration channel. It is a JSON array that holds information about each channel. It contains two attributes: **Parameters** and **Pattern**. +- **Parameters** provides parameters related to the channel. Under it, **Index** indicates the channel ID. The value is fixed at **1** for a single channel. This parameter is mandatory. + - **Pattern** indicates the vibration sequence. It is a JSON array. Under it, **Event** indicates a vibration event, which can be either of the following types: + - **transient**: short vibration + - **continuous**: long vibration + +The table below describes the parameters under **Event**. + +| Parameter| Description| Value or Value Range| +| --- | ------------------------ | ---| +| Type | Type of the vibration event. This parameter is mandatory.| **transient** or **continuous**| +| StartTime | Start time of the vibration. This parameter is mandatory.| [0, 1800 000], in ms, without overlapping| +| Duration | Duration of the vibration. This parameter is valid only when **Type** is **continuous**.| (10, 1600), in ms| +| Intensity | Intensity of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration strength.| +| Frequency | Frequency of the vibration. This parameter is mandatory.| [0, 100], a relative value that does not represent the actual vibration frequency| + +The following requirements must be met: + +| Item| Description | +| -------- | ------------------------ | +| Number of vibration events| No more than 128| +| Length of the vibration configuration file| Not greater than 64 KB| ## How to Develop @@ -54,19 +131,19 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md ```js import vibrator from '@ohos.vibrator'; try { - // Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission. - vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) { - if (error) { - console.log('error.code' + error.code + 'error.message' + error.message); - return; - } - console.log('Callback returned to indicate successful.'); - }) + // Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission. + vibrator.stopVibration(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_TIME, function (error) { + if (error) { + console.log('error.code' + error.code + 'error.message' + error.message); + return; + } + console.log('Callback returned to indicate successful.'); + }) } catch (err) { - console.info('errCode: ' + err.code + ' ,msg: ' + err.message); + console.info('errCode: ' + err.code + ' ,msg: ' + err.message); } ``` - + 4. Stop vibration in all modes. ```js @@ -135,3 +212,63 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md console.error('Exception in, error:' + JSON.stringify(error)); } ``` + +6. Start and stop custom vibration. + + ```js + import vibrator from '@ohos.vibrator'; + import resourceManager from '@ohos.resourceManager'; + + const FILE_NAME = "xxx.json"; + + async function openResource(fileName) { + let fileDescriptor = undefined; + let mgr = await resourceManager.getResourceManager(); + await mgr.getRawFd(fileName).then(value => { + fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}; + console.log('openResource success fileName: ' + fileName); + }).catch(error => { + console.log('openResource err: ' + error); + }); + return fileDescriptor; + } + + async function closeResource(fileName) { + let mgr = await resourceManager.getResourceManager(); + await mgr.closeRawFd(fileName).then(()=> { + console.log('closeResource success fileName: ' + fileName); + }).catch(error => { + console.log('closeResource err: ' + error); + }); + } + + // Obtain the file descriptor of the vibration configuration file. + let rawFd = openResource(FILE_NAME); + // To use startVibration and stopVibration, you must configure the ohos.permission.VIBRATE permission. + try { + // Start custom vibration. + vibrator.startVibration({ + type: "file", + hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length } + }, { + usage: "alarm" + }).then(() => { + console.info('startVibration success'); + }, (error) => { + console.info('startVibration error'); + }); + // Stop vibration in all modes. + vibrator.stopVibration(function (error) { + if (error) { + console.log('error.code' + error.code + 'error.message' + error.message); + return; + } + console.log('Callback returned to indicate successful.'); + }) + } catch (error) { + console.info('errCode: ' + error.code + ' ,msg: ' + error.message); + } + // Close the vibration configuration file. + closeResource(FILE_NAME); + ``` + diff --git a/en/application-dev/dfx/hilog-guidelines.md b/en/application-dev/dfx/hilog-guidelines.md index a399a520ba96aa3a64eea8968ed359c05da5440b..25b4a7f9cc5c92d9f20ed6582299d5dd65b937d0 100644 --- a/en/application-dev/dfx/hilog-guidelines.md +++ b/en/application-dev/dfx/hilog-guidelines.md @@ -38,7 +38,7 @@ Log level. | Name | Value | Description | | ----- | ------ | ------------------------------------------------------------ | | DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.| -| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,
Log level used to record information about unexpected exceptions, such as network signal loss and login failure.
These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| +| INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running as well as information about unexpected exceptions, such as network signal loss and login failure.
These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| | WARN | 5 | Log level used to record severe, unexpected faults that have little impact on users and can be rectified by the programs themselves or through simple operations.| | ERROR | 6 | Log level used to record program or functional errors that affect the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data.| | FATAL | 7 | Log level used to record program or functionality crashes that cannot be rectified. diff --git a/en/application-dev/media/image-transformation-native.md b/en/application-dev/media/image-transformation-native.md index 06d342d8092744d7c565d02d0e62c13b71cc12d2..fbe7bed8cac71bdae20b90f9781a5329da3d0dcf 100644 --- a/en/application-dev/media/image-transformation-native.md +++ b/en/application-dev/media/image-transformation-native.md @@ -1,6 +1,6 @@ # Image Transformation (Native) -You will learn how to use native image APIs to process images, including cropping, rotating, scaling, flipping, translating, and opacity setting. +You will learn how to use native image APIs to process images. ## How to Develop @@ -22,9 +22,9 @@ Open the **src/main/cpp/hello.cpp** file and add the following API mappings to t static napi_value Init(napi_env env, napi_value exports) { napi_property_descriptor desc[] = { - { "createPixelMap", nullptr, CreatePixelMap, nullptr, nullptr, nullptr, napi_default, nullptr }, - { "createAlphaPixelMap", nullptr, CreateAlphaPixelMap, nullptr, nullptr, nullptr, napi_default, nullptr }, - { "transform", nullptr, Transform, nullptr, nullptr, nullptr, napi_default, nullptr } + { "testGetImageInfo", nullptr, TestGetImageInfo, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "testAccessPixels", nullptr, TestAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "testUnAccessPixels", nullptr, TestUnAccessPixels, nullptr, nullptr, nullptr, napi_default, nullptr }, }; napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); @@ -40,159 +40,56 @@ For details about the APIs, see [Image API Reference](../reference/native-apis/i Obtain the JS resource object from the **hello.cpp** file and convert it to a native resource object. Then you can call native APIs. The sample code is as follows: -1. Create a **PixelMap** object based on a pixel array. - - ```c++ - // Create a PixelMap object. - napi_value CreatePixelMap(napi_env env, napi_callback_info info) +1. Obtain the **PixelMap** information and store the information to the **OhosPixelMapInfo** struct. + ```c++ + static napi_value TestGetImageInfo(napi_env env, napi_callback_info info) { - napi_value udfVar = nullptr; - napi_value thisVar = nullptr; - napi_value argValue[2] = {0}; - size_t argCount = 2; + napi_value result = nullptr; + napi_get_undefined(env, &result); - void* buffer = nullptr; - size_t bufferSize = 0; - struct OhosPixelMapCreateOps createOps; - napi_value pixelmap = nullptr; + napi_value thisVar = nullptr; + napi_value argValue[1] = {0}; + size_t argCount = 1; - napi_get_undefined(env, &udfVar); napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); - if (napi_get_arraybuffer_info(env, argValue[0], &buffer, &bufferSize) != napi_ok || - buffer == nullptr || bufferSize == 0) { - return udfVar; - } - - createOps.width = 4; - createOps.height = 6; - createOps.pixelFormat = 4; - createOps.alphaType = 0; - int32_t res = OH_PixelMap_CreatePixelMap(env, createOps, (uint8_t *)buffer, bufferSize, &pixelmap); - if (res != OHOS_IMAGE_RESULT_SUCCESS || pixelmap == nullptr) { - return udfVar; - } - return pixelmap; + + OHOS::Media::OhosPixelMapInfo pixelMapInfo; + OHOS::Media::OH_GetImageInfo(env, argValue[0], &pixelMapInfo); + return result; } - - // Create a PixelMap object that contains only the alpha channel. - napi_value CreateAlphaPixelMap(napi_env env, napi_callback_info info) + ``` +2. Obtain the memory address of a **PixelMap** object and lock the memory. + ```c++ + static napi_value TestAccessPixels(napi_env env, napi_callback_info info) { - napi_value udfVar = nullptr; + napi_value result = nullptr; + napi_get_undefined(env, &result); + napi_value thisVar = nullptr; napi_value argValue[1] = {0}; size_t argCount = 1; - napi_value alphaPixelmap = nullptr; - - napi_get_undefined(env, &udfVar); + napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); - if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || - argCount < 1 || argValue[0] == nullptr) { - return udfVar; - } - int32_t res = OH_PixelMap_CreateAlphaPixelMap(env, argValue[0], &alphaPixelmap); - if (res != OHOS_IMAGE_RESULT_SUCCESS || alphaPixelmap == nullptr) { - return udfVar; - } - return alphaPixelmap; + void* addrPtr = nullptr; + OHOS::Media::OH_AccessPixels(env, argValue[0], &addrPtr); + return result; } ``` - -2. Perform image transformation. For details about the operation, read the comments in the sample code below. - +3. Unlock the memory of the **PixelMap** object. ```c++ - napi_value Transform(napi_env env, napi_callback_info info) + static napi_value TestUnAccessPixels(napi_env env, napi_callback_info info) { - napi_value thisVar = nullptr; - napi_value argValue[1] = {0}; - size_t argCount = 1; - - if (napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr) != napi_ok || - argCount < 1 || argValue[0] == nullptr) { - return nullptr; - } napi_value result = nullptr; napi_get_undefined(env, &result); - NativePixelMap* native = OH_PixelMap_InitNativePixelMap(env, argValue[0]); - if (native == nullptr) { - return result; - } + napi_value thisVar = nullptr; + napi_value argValue[1] = {0}; + size_t argCount = 1; - // Obtain image information. - struct OhosPixelMapInfo pixelmapInfo; - OH_PixelMap_GetImageInfo(native, &pixelmapInfo); - - // Obtain the number of bytes per row of the PixelMap object. - int32_t rowBytes; - OH_PixelMap_GetBytesNumberPerRow(native, &rowBytes); - - // Check whether the PixelMap object is editable. - int32_t editable = 0; - OH_PixelMap_GetIsEditable(native, &editable); - - // Check whether the PixelMap object supports alpha channels. - int32_t supportAlpha = 0; - OH_PixelMap_IsSupportAlpha(native, &supportAlpha); - - // Set an alpha channel for the PixelMap object. - int32_t alphaAble = 0; - OH_PixelMap_SetAlphaAble(native, alphaAble); - - // Obtain the pixel density of the PixelMap object. - int32_t densityG; - OH_PixelMap_GetDensity(native, &densityG); - - // Set the pixel density for the PixelMap object. - int32_t densityS = 100; - OH_PixelMap_SetDensity(native, densityS); - - // Set the opacity for the PixelMap object. - float opacity = 0.5; - OH_PixelMap_SetOpacity(native, opacity); - - // Scale the image. - // scaleX: The width of the image after scaling is 0.5 of the original width. - // scaleY: The height of the image after scaling is 0.5 of the original height. - float scaleX = 0.5; - float scaleY = 0.5; - OH_PixelMap_Scale(native, scaleX, scaleY); - - // Translate the image. - // translateX: Translate the image by 50 units downwards. - // translateY: Translate the image by 50 units rightwards. - float translateX = 50; - float translateY = 50; - OH_PixelMap_Translate(native, translateX, translateY); - - // Rate the image clockwise by 90°. - float angle = 90; - OH_PixelMap_Rotate(native, angle); - - // Flip the image. - // flipX: whether to flip the image horizontally. The value 1 means to flip the image and 0 means the opposite. - // flipY: whether to flip the image vertically. The value 1 means to flip the image and 0 means the opposite. - int32_t flipX = 0; - int32_t flipY = 1; - OH_PixelMap_Flip(native, flipX, flipY); - - // Crop the image. - // cropX: x-axis coordinate of the start point for cropping (0). - // cropY: y-axis coordinate of the start point for cropping (0). - // cropH: height after cropping (10), cropping from top to bottom. - // cropW: width after cropping (10), cropping from left to right. - int32_t cropX = 1; - int32_t cropY = 1; - int32_t cropW = 10; - int32_t cropH = 10; - OH_PixelMap_Crop(native, cropX, cropY, cropW, cropH); - - uint8_t* pixelAddr = nullptr; - // Obtain the memory address of the PixelMap object and lock the memory. - OH_PixelMap_AccessPixels(native, &pixelAddr); - // Unlock the memory of the PixelMap object. - OH_PixelMap_UnAccessPixels(native); + napi_get_cb_info(env, info, &argCount, argValue, &thisVar, nullptr); + OHOS::Media::OH_UnAccessPixels(env, argValue[0]); return result; } ``` @@ -205,37 +102,41 @@ Obtain the JS resource object from the **hello.cpp** file and convert it to a na ```js import testNapi from 'libentry.so' - import image from '@ohos.multimedia.image' + import image from '@ohos.multimedia.image'; @Entry @Component struct Index { - @State _pixelMap: image.PixelMap = undefined; - build() { - Row() { - Column() { - Button("PixelMap") - .width(100) - .height(100) - .onClick(() => { - const color = new ArrayBuffer(96); - var bufferArr = new Uint8Array(color); - for (var i = 0; i < bufferArr.length; i++) { - bufferArr[i] = 0x80; - } - - this._pixelMap = testNapi.createPixelMap(color); - testNapi.transform(this._pixelMap); + @State message: string = 'IMAGE' + @State _PixelMap: image.PixelMap = undefined + + build() { + Row() { + Column() { + Button(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + const color = new ArrayBuffer(96); + let opts = { alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: { height: 4, width: 6 } } + image.createPixelMap(color, opts) + .then( pixelmap => { + this._PixelMap = pixelmap; }) - Image(this._pixelMap) - .width(500) - .height(500) - .objectFit(ImageFit.Cover) - } - .width('100%') - } - .height('100%') + testNapi.testGetImageInfo(this._PixelMap); + console.info("Test GetImageInfo success"); + + testNapi.testAccessPixels(this._PixelMap); + console.info("Test AccessPixels success"); + + testNapi.testUnAccessPixels(this._PixelMap); + console.info("Test UnAccessPixels success"); + }) } + .width('100%') + } + .height('100%') + } } ``` diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md index 5148a2b5ce3cf73bbd68e96ba2d15449f86a0990..162a07f752491d75d2bf17a3c90520155fd3672f 100644 --- a/en/application-dev/napi/Readme-EN.md +++ b/en/application-dev/napi/Readme-EN.md @@ -5,5 +5,6 @@ - [Raw File Development](rawfile-guidelines.md) - [Native Window Development](native-window-guidelines.md) - [Using MindSpore Lite for Model Inference](mindspore-lite-guidelines.md) +- [Using MindSpore Lite for Offline Model Conversion and Inference](mindspore-lite-offline-model-guidelines.md) - [Connecting the Neural Network Runtime to an AI Inference Framework](neural-network-runtime-guidelines.md) - [Purgeable Memory Development](purgeable-memory-guidelines.md) diff --git a/en/application-dev/napi/mindspore-lite-offline-model-guidelines.md b/en/application-dev/napi/mindspore-lite-offline-model-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..0f149d197cd7ec4f22bb715d75994c09d7577497 --- /dev/null +++ b/en/application-dev/napi/mindspore-lite-offline-model-guidelines.md @@ -0,0 +1,112 @@ +# Using MindSpore Lite for Offline Model Conversion and Inference + +## Basic Concepts + +- MindSpore Lite: a built-in AI inference engine of OpenHarmony that provides inference deployment for deep learning models. + +- Neural Network Runtime (NNRt): a bridge that connects the upper-layer AI inference framework to the bottom-layer acceleration chip to implement cross-chip inference and computing of AI models. + +- Offline model: a model obtained using the offline model conversion tool of the AI hardware vendor. The hardware vendor is responsible for parsing and inference of AI models. + +## When to Use + +The common process for MindSpore Lite AI model deployment is as follows: +- Use the MindSpore Lite model conversion tool to convert third-party models (such as ONNX and CAFFE) to `.ms` models. +- Call APIs of the MindSpore Lite inference engine to perform model inference. By specifying NNRt as the inference device, you can then use the AI hardware in the system to accelerate inference. + +When MindSpore Lite + NNRt inference is used, dynamic image composition in the initial phase will introduce a certain model loading delay. + +If you want to reduce the loading delay to meet the requirements of the deployment scenario, you can use offline model-based inference as an alternative. The operation procedure is as follows: +- Use the offline model conversion tool provided by the AI hardware vendor to compile an offline model in advance. +- Use the MindSpore Lite conversion tool to encapsulate the offline model as a black box into the `.ms` model. +- Pass the `.ms` model to MindSpore Lite for inference. + +During inference, MindSpore Lite directly sends the offline model to the AI hardware connected to NNRt. This way, the model can be loaded without the need for online image composition, greatly reducing the model loading delay. In addition, MindSpore Lite can provide additional hardware-specific information to assist the AI hardware in model inference. + +The following sections describe the offline model inference and conversion process in detail. + +## Constraints + +- Offline model inference can only be implemented at the NNRt backend. The AI hardware needs to connect to NNRt and supports offline model inference. + +## Offline Model Conversion + + +### 1. Building the MindSpore Lite Release Package + +Obtain the [MindSpore Lite source code](https://gitee.com/openharmony/third_party_mindspore). The source code is managed in "compressed package + patch" mode. Run the following commands to decompress the source code package and install the patch: +```bash +cd mindspore +python3 build_helper.py --in_zip_path=./mindspore-v1.8.1.zip --patch_dir=./patches/ --out_src_path=./mindspore-src +``` +If the command execution is successful, the complete MindSpore Lite source code is generated in `mindspore-src/source/`. + +Run the following commands to start building: +```bash +cd mindspore-src/source/ +bash build.sh -I x86_64 -j 8 +``` + +After the building is complete, you can obtain the MindSpore Lite release package from the `output/` directory in the root directory of the source code. + + +### 2. Writing Extended Configuration File of the Conversion Tool + +The offline model comes as a black box and cannot be parsed by the conversion tool to obtain its input and output tensor information. Therefore, you need to manually configure the tensor information in the extended configuration file of the conversion tool. Based on the extended configuration, the conversion tool can then generate the `.ms` model file for encapsulating the offline model. + +An example of the extended configuration is as follows: +- `[third_party_model]` in the first line is a fixed keyword that indicates the section of offline model configuration. +- The following lines exhibit the name, data type, shape, and memory format of the input and output tensors of the model respectively. Each field occupies a line and is expressed in the key-value pair format. The sequence of fields is not limited. +- Among the fields, data type and shape are mandatory, and other parameters are optional. +- Extended parameters are also provided. They are used to encapsulate custom configuration of the offline model into an `.ms` file in the the key-value pair format. The `.ms` file is passed to the AI hardware by NNRt during inference. + +```text +[third_party_model] +input_names=in_0;in_1 +input_dtypes=float32;float32 +input_shapes=8,256,256;8,256,256,3 +input_formats=NCHW;NCHW +output_names=out_0 +output_dtypes=float32 +output_shapes=8,64 +output_formats=NCHW +extended_parameters=key_foo:value_foo;key_bar:value_bar +``` + +The related fields are described as follows: + +- `input_names` (optional): model input name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them. +- `input_dtypes` (mandatory): model input data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them. +- `input_shapes` (mandatory): model input shape, which is in the integer array format. If multiple input shapes are specified, use a semicolon (`;`) to separate them. +- `input_formats` (optional): model input memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`. +- `output_names` (optional): model output name, which is in the string format. If multiple names are specified, use a semicolon (`;`) to separate them. +- `output_dtypes` (mandatory): model output data type, which is in the type format. If multiple data types are specified, use a semicolon (`;`) to separate them. +- `output_shapes` (mandatory): model output shape, which is in the integer array format. If multiple output shapes are specified, use a semicolon (`;`) to separate them. +- `output_formats` (optional): model output memory format, which is in the string format. If multiple formats are specified, use a semicolon (`;`) to separate them. The default value is `NHWC`. +- `extended_parameters` (optional): custom configuration of the inference hardware, which is in the key-value pair format. It is passed to the AI hardware through the NNRt backend during inference. + +### 3. Converting an Offline Model + +Decompress the MindSpore Lite release package obtained in step 1. Go to the directory where the conversion tool is located (that is, `tools/converter/converter/`), and run the following commands: + +```bash +export LD_LIBRARY_PATH=${PWD}/../lib +./converter_lite --fmk=THIRDPARTY --modelFile=/path/to/your_model --configFile=/path/to/your_config --outputFile=/path/to/output_model +``` +The offline model conversion is complete. + +The related parameters are described as follows: +- `--fmk`: original format of the input model. `THIRDPARTY` indicates an offline model. +- `--modelFile`: path of the input model. +- `--configFile`: path of the extended configuration file. The file is used to configure offline model information. +- `--outputFile`: path of the output model. You do not need to add the file name extension. The `.ms` suffix is generated automatically. + +> **NOTE** +> +> If `fmk` is set to `THIRDPARTY`, offline model conversion is performed. In this case, only the preceding four parameters and the extended configuration file take effect. + +## Offline Model Inference + +Offline model inference is the same as common MindSpore Lite model inference except that only NNRt devices can be added to the inference context. + +For details about the MindSpore Lite model inference process, see [Using MindSpore Lite for Model Inference](./mindspore-lite-guidelines.md). diff --git a/en/application-dev/napi/purgeable-memory-guidelines.md b/en/application-dev/napi/purgeable-memory-guidelines.md index ffc2ff72ddd045d61da55c41f07434a8d4e31c28..706786d429b492f79f86c4c108cf8e3e63940def 100644 --- a/en/application-dev/napi/purgeable-memory-guidelines.md +++ b/en/application-dev/napi/purgeable-memory-guidelines.md @@ -12,12 +12,12 @@ The following scenarios are common for native purgeable memory development: ## Available APIs -| API| Description| +| API| Description| | -------- | -------- | -| OH_PurgeableMemory \*OH_PurgeableMemory_Create(size_t size, OH_PurgeableMemory_ModifyFunc func, void \*funcPara) | Creates a **PurgeableMemory** object. A new **PurgeableMemory** object is generated each time this API is called.| -| bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory \*purgObj) | Destroys a **PurgeableMemory** object.| -| bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory \*purgObj) | Begins a read operation on a **PurgeableMemory** object.| -| void OH_PurgeableMemory_EndRead(OH_PurgeableMemory \*purgObj) | Ends a read operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.| +| OH_PurgeableMemory \*OH_PurgeableMemory_Create(size_t size, OH_PurgeableMemory_ModifyFunc func, void \*funcPara) | Creates a **PurgeableMemory** object. A new **PurgeableMemory** object is generated each time this API is called.| +| bool OH_PurgeableMemory_Destroy(OH_PurgeableMemory \*purgObj) | Destroys a **PurgeableMemory** object.| +| bool OH_PurgeableMemory_BeginRead(OH_PurgeableMemory \*purgObj) | Begins a read operation on a **PurgeableMemory** object.| +| void OH_PurgeableMemory_EndRead(OH_PurgeableMemory \*purgObj) | Ends a read operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.| |bool OH_PurgeableMemory_BeginWrite(OH_PurgeableMemory \*purgObj) | Begins a write operation on a **PurgeableMemory** object.| |void OH_PurgeableMemory_EndWrite(OH_PurgeableMemory \*purgObj)|Ends a write operation on a **PurgeableMemory** object and decreases the reference count of the object by 1. When the reference count reaches 0, the object can be reclaimed by the system.| |void \*OH_PurgeableMemory_GetContent(OH_PurgeableMemory \*purgObj)|Obtains the memory data of a **PurgeableMemory** object.| @@ -35,34 +35,32 @@ The following steps describe how to use the native purgeable memory APIs to appl struct ParaData{ int start; int end; - } + }; // Declare a function for modifying the object. bool FactorialFunc(void* data, size_t size, void* param){ - bool ret = true; - int oriData = *(int*)(data); - int i = param->start; - while(iend){ - oriData *= i; - } - *data = oriData; - if(oriData < 0) - ret = false; - return ret; + bool ret = true; + ParaData *pdata = (ParaData*) param; + int* oriData = (int*)data; + int i = pdata->start; + while(iend){ + *oriData *= i; + } + return ret; } // Declare the parameters of the extended function for modifying the object. struct AppendParaData{ int newPara; - } + }; // Declare the extended function for modifying the object. bool AddFunc(void* data, size_t size, void* param){ - bool ret = true; - int oriData = *(int*)(data); - oriData += param->newPara; - *data = oriData; - return ret; + bool ret = true; + int *oriDatap = (int*) data; + AppendParaData* apData = (AppendParaData*)param; + *oriDatap += apData->newPara; + return ret; } ``` 2. Create a **PurgeableMemory** object. @@ -74,11 +72,14 @@ The following steps describe how to use the native purgeable memory APIs to appl struct ParaData pdata = {1,2}; // Create a PurgeableMemory object. - OH_PurgableMmory* pPurgmem = OH_PurgableMmory_Create(DATASIZE, FactorialFunc, &pdata); + OH_PurgeableMemory* pPurgmem = OH_PurgeableMemory_Create(DATASIZE, FactorialFunc, &pdata); ``` 3. Perfrom a read operation on the **PurgeableMemory** object. ```c++ + // Define an object type based on the service requirements. + class ReqObj; + // Begin a read operation on the object. OH_PurgeableMemory_BeginRead(pPurgmem); @@ -94,8 +95,11 @@ The following steps describe how to use the native purgeable memory APIs to appl 4. Perform a write operation on the **PurgeableMemory** object. ```c++ + // Define an object type based on the service requirements. + class ReqObj; + // Begin a write operation on the object. - OH_PurgeableMemory_BeginWrite(pPurgmem) + OH_PurgeableMemory_BeginWrite(pPurgmem); // Obtain the object data. ReqObj* pReqObj = (ReqObj*) OH_PurgeableMemory_GetContent(pPurgmem); diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 37bf36f22b5089789f6315e37a18947918501ff4..95713286ff3115e23e4733f63e84d77d3fecdc94 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -86,8 +86,10 @@ - [AppStateData](js-apis-inner-application-appStateData.md) - [BaseContext](js-apis-inner-application-baseContext.md) - [Context](js-apis-inner-application-context.md) + - [ContinuableInfo](js-apis-inner-application-continuableInfo.md) - [ContinueCallback](js-apis-inner-application-continueCallback.md) - [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo.md) + - [ContinueMissionInfo](js-apis-inner-application-continueMissionInfo.md) - [ErrorObserver](js-apis-inner-application-errorObserver.md) - [ExtensionContext](js-apis-inner-application-extensionContext.md) - [ExtensionRunningInfo](js-apis-inner-application-extensionRunningInfo.md) @@ -194,8 +196,7 @@ - [@ohos.router (Page Routing)](js-apis-router.md) - [@ohos.measure (Text Measurement)](js-apis-measure.md) - [@ohos.uiAppearance (UI Appearance)](js-apis-uiappearance.md) - -- Graphics +- Graphics - [@ohos.animation.windowAnimationManager (Window Animation Management)](js-apis-windowAnimationManager.md) - [@ohos.application.WindowExtensionAbility (WindowExtensionAbility)](js-apis-application-windowExtensionAbility.md) - [@ohos.display (Display)](js-apis-display.md) @@ -207,7 +208,6 @@ - webgl - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) - - Multimedia - [@ohos.multimedia.audio (Audio Management)](js-apis-audio.md) - [@ohos.multimedia.avsession (AVSession Management)](js-apis-avsession.md) @@ -347,6 +347,7 @@ - [@ohos.brightness (Screen Brightness)](js-apis-brightness.md) - [@ohos.charger (Charging Type)](js-apis-charger.md) - [@ohos.cooperate (Screen Hopping)](js-apis-devicestatus-cooperate.md) + - [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md) - [@ohos.deviceInfo (Device Information)](js-apis-device-info.md) - [@ohos.distributedHardware.deviceManager (Device Management)](js-apis-device-manager.md) - [@ohos.geoLocationManager (Geolocation Manager)](js-apis-geoLocationManager.md) @@ -356,6 +357,7 @@ - [@ohos.multimodalInput.inputEvent (Input Event)](js-apis-inputevent.md) - [@ohos.multimodalInput.inputEventClient (Key Event Injection)](js-apis-inputeventclient.md) - [@ohos.multimodalInput.inputMonitor (Input Monitor)](js-apis-inputmonitor.md) + - [@ohos.multimodalInput.intentionCode (Intention Code)](js-apis-intentioncode.md) - [@ohos.multimodalInput.keyCode (Key Code)](js-apis-keycode.md) - [@ohos.multimodalInput.keyEvent (Key Event)](js-apis-keyevent.md) - [@ohos.multimodalInput.mouseEvent (Mouse Event)](js-apis-mouseevent.md) @@ -364,6 +366,7 @@ - [@ohos.multimodalInput.shortKey (Shortcut Key)](js-apis-shortKey.md) - [@ohos.power (System Power Management)](js-apis-power.md) - [@ohos.runningLock (Runninglock)](js-apis-runninglock.md) + - [@ohos.resourceschedule.deviceStandby (Device Standby)](js-apis-resourceschedule-deviceStandby.md) - [@ohos.sensor (Sensor)](js-apis-sensor.md) - [@ohos.settings (Data Item Settings)](js-apis-settings.md) - [@ohos.stationary (Device Status Awareness Framework)](js-apis-stationary.md) @@ -378,7 +381,7 @@ - [@ohos.account.appAccount (App Account Management)](js-apis-appAccount.md) - [@ohos.account.distributedAccount (Distributed Account Management)](js-apis-distributed-account.md) - [@ohos.account.osAccount (OS Account Management)](js-apis-osAccount.md) - + - Customization - [@ohos.configPolicy (Configuration Policy)](js-apis-configPolicy.md) @@ -421,7 +424,6 @@ - Test - [@ohos.application.testRunner (TestRunner)](js-apis-application-testRunner.md) - - [@ohos.deviceAttest (Device Attestation)](js-apis-deviceAttest.md) - [@ohos.uitest (UiTest)](js-apis-uitest.md) - APIs No Longer Maintained diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md index ed56fca0dd96bdd53e0bc66548c72c028a0ddf4f..a19759144290c86e6af1f6812569683e39d74bae 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md @@ -388,7 +388,7 @@ abilityManager.getTopAbility().then((data) => { acquireShareData(missionId: number, callback: AsyncCallback<{[key: string]: Object}>): void; -Acquires the shared data of the target application. This API uses an asynchronous callback to return the result. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the [missionManager.getMissionInfos()](js-apis-app-ability-missionManager.md#getmissioninfos) API after the target application is started. **callback** indicates the data shared by the target application through the [UIAbility.onShare()](js-apis-app-ability-uiAbility.md#onshare) lifecycle callback. +Called by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -429,10 +429,16 @@ try { acquireShareData(missionId: number): Promise<{[key: string]: Object}>; -Acquires the shared data of the target application. This API uses a promise to return the result. **missionId** indicates the target application's mission ID, which can be obtained by running the **hdc shell aa dump -a** command or calling the [missionManager.getMissionInfos()](js-apis-app-ability-missionManager.md#getmissioninfos) API after the target application is started. **Promise<{[key: string]: Object}>** indicates the data shared by the target application through the [UIAbility.onShare()](js-apis-app-ability-uiAbility.md#onshare) lifecycle callback. +Called by a system dialog box to obtain shared data, which is set by the target UIAbility through **onShare()**. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**Parameters** + +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------------- | ---- | -------------- | +| missionId | number | Yes| Mission ID on the target application. The maximum value is 231-1.| + **Return value** | Type | Description | diff --git a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md index dbef711c25369d3eac61ca1b6516a7c43d8ecbc2..1f8af971be9c75fc3781d7a66422c38466f29aa4 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md @@ -1,4 +1,4 @@ -# @ohos.application.formBindingData (formBindingData) +# @ohos.app.form.formBindingData (formBindingData) The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information. @@ -12,6 +12,19 @@ The **FormBindingData** module provides APIs for widget data binding. You can us import formBindingData from '@ohos.app.form.formBindingData'; ``` + +## ProxyData10+ + +Defines the subscription information about the widget update by proxy. + +**System capability**: SystemCapability.Ability.Form + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | string | Yes| Subscriber ID of the widget update by proxy. The value is the same as that of the data publisher.| +| subscriberId | string | No| Subscription condition of the widget update by proxy. The default value is the current widget ID (specified by **formId**).| + + ## FormBindingData Describes a **FormBindingData** object. @@ -21,7 +34,7 @@ Describes a **FormBindingData** object. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | data | Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.| - +| proxies10+ | Array<[ProxyData](#proxydata)> | No| Subscription information of the widget update by proxy. The default value is an empty array.| ## createFormBindingData @@ -62,3 +75,14 @@ try { console.error(`catch error, code: ${error.code}, message: ${error.message}`); } ``` + +## ProxyData + +Defines the widget proxy data. + +**System capability**: SystemCapability.Ability.Form + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | string | Yes| Key of the proxy. The value depends on the data publisher.| +| subscriberId | string | No| Subscriber ID. The value depends on the data publisher. The default value is the current widget ID.| diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index 0cd79c938c8bb74f7fb919c7e6dc2e1afaa97cd8..f9012db2add74f9810baa032b103a4eff48dbd04 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -379,15 +379,15 @@ Replaces all elements in this container with new elements, and returns the new o | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for the replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| arrlist | ArrayList<T> | No| Instance that invokes the **replaceAllElements** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| arrlist | ArrayList<T> | No| Instance that calls the **replaceAllElements** API. The default value is this instance.| **Error codes** @@ -425,15 +425,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for the replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| arrlist | ArrayList<T> | No| Instance that invokes the **forEach** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is 0.| +| arrlist | ArrayList<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** @@ -468,7 +468,7 @@ Sorts elements in this container. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| comparator | function | No| Callback invoked for sorting.| +| comparator | function | No| Callback invoked for sorting. The default value is the callback function for sorting elements in ascending order.| comparator diff --git a/en/application-dev/reference/apis/js-apis-buffer.md b/en/application-dev/reference/apis/js-apis-buffer.md index 737c9f1dbf05e30e2f84e185b89e804642b0c39f..f50bdfe83cca98808fbb79237bd21194ec30b7a4 100644 --- a/en/application-dev/reference/apis/js-apis-buffer.md +++ b/en/application-dev/reference/apis/js-apis-buffer.md @@ -204,7 +204,7 @@ Concatenates an array of **Buffer** instances of the specified length into a new | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | list | Buffer[] \| Uint8Array[] | Yes| Array of instances to concatenate.| -| totalLength | number | No| Total length of bytes to be copied.| +| totalLength | number | No| Total length of bytes to be copied. The default value is **0**.| **Return value** @@ -1915,7 +1915,7 @@ Converts the data at the specified position in this **Buffer** instance into a s | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| encoding | string | No| Encoding format of the string. The default value is **utf-8**.| +| encoding | string | No| Encoding format (valid only when **value** is a string). The default value is **utf-8**.| | start | number | No| Offset to the start position of the data to convert. The default value is **0**.| | end | number | No| Offset to the end position of the data to convert. The default value is the length of this **Buffer** instance.| diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md index 7242e7dabbf12e7e44a98fa23bc44b9ead440a1e..24a211683113a62ae975f77ea86d5139c4aeffc8 100644 --- a/en/application-dev/reference/apis/js-apis-deque.md +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -242,15 +242,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| deque | Deque<T> | No| Instance that invokes the **forEach** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| deque | Deque<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-hashmap.md b/en/application-dev/reference/apis/js-apis-hashmap.md index c880644673fd9a8cd9d15ac05ec01afc9785bf3e..fc0a1e56470f7fb3a66a5feb1ad168b2c0fcea4a 100644 --- a/en/application-dev/reference/apis/js-apis-hashmap.md +++ b/en/application-dev/reference/apis/js-apis-hashmap.md @@ -459,14 +459,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | V | No| Value of the element that is currently traversed.| -| key | K | No| Key of the element that is currently traversed.| -| map | HashMap | No| Instance that invokes the **forEach** method.| +| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.| +| map | HashMap | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md index df65bfcb4a3167ed9c9f2292065554a505e9f4e1..e396f5e4e5256a946c508b549cb183e35b439715 100644 --- a/en/application-dev/reference/apis/js-apis-hashset.md +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -282,14 +282,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | T | No| Value of the element that is currently traversed.| -| key | T | No| Key of the element that is currently traversed (same as **value**).| -| set | HashSet<T> | No| Instance that invokes the **forEach** API.| +| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key | T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.| +| set | HashSet<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-lightweightmap.md b/en/application-dev/reference/apis/js-apis-lightweightmap.md index ed1848ad8df12b8a5526699908347ade635a9041..af435ce52e23abbca6d5f3777f2dadc82c4701d4 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/en/application-dev/reference/apis/js-apis-lightweightmap.md @@ -724,14 +724,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | V | No| Value of the element that is currently traversed.| -| key | K | No| Key of the element that is currently traversed.| -| map | LightWeightMap | No| Instance that invokes the **forEach** method.| +| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.| +| map | LightWeightMap | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md index 05eba80d96783d32a427f1181bdc5b71bdab596b..7446c334dfa3022b943d1155e9bdab10e8e1e0a9 100644 --- a/en/application-dev/reference/apis/js-apis-lightweightset.md +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -588,14 +588,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | T | No| Value of the element that is currently traversed.| -| key| T | No| Key of the element that is currently traversed (same as **value**).| -| set | LightWeightSet<T> | No| Instance that invokes the **forEach** method.| +| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key| T | No| Key of the element that is currently traversed (same as **value**). The default value is the key of the first key-value pair.| +| set | LightWeightSet<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-linkedlist.md b/en/application-dev/reference/apis/js-apis-linkedlist.md index 14382577e7b3fb1881e74527b8ec31ab87a89169..fa13281b52c968658e016fd7ee82be77e570fd60 100644 --- a/en/application-dev/reference/apis/js-apis-linkedlist.md +++ b/en/application-dev/reference/apis/js-apis-linkedlist.md @@ -607,15 +607,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| LinkedList | LinkedList<T> | No| Instance that invokes the **forEach** API.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| LinkedList | LinkedList<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index b7618d64c1d61a52324ada111347f666e7095c73..a9dd535c30efa333db867f444e28502f65ab8537 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -427,15 +427,15 @@ Replaces all elements in this container with new elements, and returns the new o | Name| Value Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for the replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Value Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| list | List<T> | No| Instance that invokes the **replaceAllElements** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| list | List<T> | No| Instance that calls the **replaceAllElements** API. The default value is this instance.| **Error codes** @@ -473,15 +473,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Value Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for the replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Value Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| List | List<T> | No| Instance that invokes the **forEach** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| List | List<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-plainarray.md b/en/application-dev/reference/apis/js-apis-plainarray.md index 14f73f6d4b11059551b376f7fcb9e56ee4e1ab84..5ce7718cc4bcb677a35f83079d9392d2b9d0ba0c 100644 --- a/en/application-dev/reference/apis/js-apis-plainarray.md +++ b/en/application-dev/reference/apis/js-apis-plainarray.md @@ -597,14 +597,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type | Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Key of the element that is currently traversed.| -| PlainArray | PlainArray<T>| No| Instance that invokes the **forEach** API.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| PlainArray | PlainArray<T>| No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md index c926b741543cd384f6c4b7649c2e8f1881883a55..ff4639e830aee3ba615858a38e3b8a84b12575a5 100644 --- a/en/application-dev/reference/apis/js-apis-queue.md +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -176,15 +176,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| Queue | Queue<T> | No| Instance that invokes the **forEach** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| Queue | Queue<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-reminderAgent.md b/en/application-dev/reference/apis/js-apis-reminderAgent.md index 0c7fa19432c45e801f82b2892d47fa9ed384ea4e..a817d3bc82a541c9937c05aec30b2ecd0bb830ff 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgent.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgent.md @@ -371,7 +371,7 @@ reminderAgent.addNotificationSlot(mySlot).then(() => { ## reminderAgent.removeNotificationSlot(deprecated) -removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void +removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\): void Removes a notification slot of a specified type. This API uses an asynchronous callback to return the result. @@ -401,7 +401,7 @@ reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, ## reminderAgent.removeNotificationSlot(deprecated) -removeNotificationSlot(slotType: notification.SlotType): Promise +removeNotificationSlot(slotType: notification.SlotType): Promise\ Removes a notification slot of a specified type. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md index 87a8ea3167b1cc125eb8e2bf5e30b4cfe54cc5a3..644759435975c722de9fd274b704ecd01804d2fd 100644 --- a/en/application-dev/reference/apis/js-apis-reminderAgentManager.md +++ b/en/application-dev/reference/apis/js-apis-reminderAgentManager.md @@ -611,7 +611,7 @@ Defines the reminder to publish. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| -| actionButton10+ | [ActionButton](#actionbutton) | No| Button displayed for the reminder in the notification panel. For common applications, a maximum of two buttons are supported. For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| +| actionButton | [ActionButton](#actionbutton) | No| Buttons displayed for the reminder in the notification panel.
- For common applications, a maximum of two buttons are supported.
- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| | wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| | maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is automatically started when the reminder arrives. If the device is in use, a notification will be displayed.| | ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| diff --git a/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md new file mode 100644 index 0000000000000000000000000000000000000000..116d4af987fb061f516d6ec37053794737f65c84 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md @@ -0,0 +1,382 @@ +# @ohos.resourceschedule.deviceStandby (Device Standby) +A device enters standby mode if it is unused for a long period of time or after the Power button is pressed. The standby mode prolongs the battery life without affecting the use of applications. The **deviceStandby** module provides APIs for you to check whether a device is in standby mode and request or cancel standby resource control for an application. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import deviceStandby from '@ohos.resourceschedule.deviceStandby'; +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(callback: AsyncCallback<boolean>): void; + +Checks whether the device is in standby mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the device is standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby((err, res) => { + if (err) { + console.log('DEVICE_STANDBY isDeviceInStandby callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY isDeviceInStandby callback succeeded, result: ' + JSON.stringify(res)); + } + }); +} catch(error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.isDeviceInStandby + +isDeviceInStandby(): Promise<boolean> + +Checks whether the device is in standby mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise<boolean> | Promise used to return whether the device is in standby mode.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.isDeviceInStandby().then( res => { + console.log('DEVICE_STANDBY isDeviceInStandby promise succeeded, result: ' + JSON.stringify(res)); +}).catch( err => { + console.log('DEVICE_STANDBY isDeviceInStandby promise failed. code is: ' + err.code + ',message is: ' + err.message); + }); +} catch (error) { +console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number, callback: AsyncCallback): void; + +Obtains the list of applications that can still use resources of the specified types when the device is in standby mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes | Types of resources that can be used.| +| callback | AsyncCallback | Yes |Callback used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes, (err, res) => { + if (err) { + console.log('DEVICE_STANDBY getExemptedApps callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY getExemptedApps callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps callback result ' + JSON.stringify(res[i])); + } + } +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.getExemptedApps + +getExemptedApps(resourceTypes: number): Promise; + +Obtains the list of applications that can still use resources of the specified type when the device is in standby mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| [ResourceTypes](#resourcetype)|number | Yes |Types of resources that can be used.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------------------------------- | +| Promise | Promise used to return the exempted application information.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 201 | Permission denied. | +| 202 | Not System App. | +| 401 | Parameter error. | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +try{ +deviceStandby.getExemptedApps(resourceTypes).then( res => { + console.log('DEVICE_STANDBY getExemptedApps promise success.'); + for (let i = 0; i < res.length; i++) { + console.log('DEVICE_STANDBY getExemptedApps promise result ' + JSON.stringify(res[i])); + } +}).catch( err => { + console.log('DEVICE_STANDBY getExemptedApps promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.requestExemptionResource + +requestExemptionResource(request: ResourceRequest): void; + +Requests exemption, so that the application can use restricted resources when the device is in standby mode. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.example.app", + duration:10, + reason:"apply", +}; +// Promise mode +try{ +deviceStandby.requestExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY requestExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.requestExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY requestExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY requestExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## deviceStandby.releaseExemptionResource + +releaseExemptionResource(request: ResourceRequest): void; + +Cancels exemption for the application. + +**System capability**: SystemCapability.ResourceSchedule.DeviceStandby.Exemption + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | ------------------------------ | +| request |[ResourceRequest](#resourcerequest)| Yes | Request body.| + +**Error codes** + +For details about the error codes, see [Background Task Management Error Codes](../errorcodes/errorcode-backgroundTaskMgr.md). + +| ID | Error Message | +| ---- | --------------------- | +| 9800001 | Memory operation failed. | +| 9800002 | Parcel operation failed. | +| 9800003 | Inner transact failed. | +| 9800004 | System service operation failed. | +| 18700001 | Caller information verification failed. | + +**Example** + +```js +let resRequest = { + resourceTypes: 1, + uid:10003, + name:"com.demo.app", + duration:10, + reason:"unapply", +}; +// Promise mode +try{ +deviceStandby.releaseExemptionResource(resRequest).then( () => { + console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.'); +}).catch( err => { + console.log('DEVICE_STANDBY releaseExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message); +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} + +// Asynchronous callback mode +try{ +deviceStandby.releaseExemptionResource(resRequest, (err) => { + if (err) { + console.log('DEVICE_STANDBY releaseExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message); + } else { + console.log('DEVICE_STANDBY releaseExemptionResource callback succeeded.'); + } +}); +} catch (error) { +console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message); +} +``` + +## ResourceType + +Enumerates the types of resources that can be used by exempted applications. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Value |Description| +| ------------ | ------------ |--------------| +|NETWORK |1 |Network access resource.| +|RUNNING_LOCK |2 |CPU running lock resource.| +|TIMER |4 | Timer task resource.| +|WORK_SCHEDULER |8 | Work task resource.| +|AUTO_SYNC |16 | Automatic synchronization resource.| +|PUSH |32 | Push kit resource.| +|FREEZE |64 | Freezing application resource.| + +## ExemptedAppInfo + +Defines the information about an exempted application. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------ | ------------ | +|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. | +|name |string | Yes | Name of the application. | +|duration | number | Yes | Exemption duration.| + +## ResourceRequest + +Defines the message used to request to be an exempted application. + +**Required permissions**: ohos.permission.DEVICE_STANDBY_EXEMPTION + +**System API**: This is a system API. + +|Name |Type | Mandatory |Description | +| ------------ | ------------ |------------| ------------ | +|[resourceTypes](#resourcetype) | number | Yes |Types of resources that can be used. | +|uid | number | Yes |UID of the application. | +|name |string | Yes | Name of the application. | +|duration | number | Yes | Exemption duration.| +|reason |string | Yes | Reason for the request. | diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index e633bf43d4a8879701dd4d3f63f66f51a0f20425..c1136e75989e9dd2cfe00de84a9dee9c23bfb3cd 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -220,7 +220,7 @@ screenlock.lock().then((data) => { onSystemEvent(callback: Callback<SystemEvent>): boolean -Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications. +Registers a callback for system events related to screen locking. This API can be called only by screen lock applications. **System capability**: SystemCapability.MiscServices.ScreenLock @@ -264,7 +264,7 @@ try { sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void -Sends an event to the screen lock service. This API uses an asynchronous callback to return the result. +Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock @@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { sendScreenLockEvent(event: String, parameter: number): Promise<boolean> -Sends an event to the screen lock service. This API uses a promise to return the result. +Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index 39f79224b6d4514a91ef34967dd06ba90adee457..4cea6beaaec94d89b21a3e59743e54cb3d7b87d8 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -1766,7 +1766,7 @@ promise.then(() => { setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\): void -Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses an asynchronous callback to return the result. +Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Communication.NetStack @@ -1818,7 +1818,7 @@ tls.setExtraOptions({ setExtraOptions(options: TCPExtraOptions): Promise\ -Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses a promise to return the result. +Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses a promise to return the result. **System capability**: SystemCapability.Communication.NetStack diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md index 9ecf69bced25271e1c68299bb78e2a19bbaab756..998d202a759c605a87b43997132a023a68188373 100644 --- a/en/application-dev/reference/apis/js-apis-stack.md +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -214,15 +214,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| stack | Stack<T> | No| Instance that invokes the **forEach** method.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| stack | Stack<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-stationary.md b/en/application-dev/reference/apis/js-apis-stationary.md index 7f732445123bce8a0fafde50b26a36548be0eb8e..4e563fc6c366e5296dc9966cfa8ec292f632af1f 100644 --- a/en/application-dev/reference/apis/js-apis-stationary.md +++ b/en/application-dev/reference/apis/js-apis-stationary.md @@ -123,7 +123,7 @@ Unsubscribes from the device status. | -------------------- | -------------------------------------------------- | ---- | ---------------------------- | | activity | [ActivityType](#activitytype) | Yes | Device status type. | | event | [ActivityEvent](#activityevent) | Yes | Event type. | -| callback | Callback<[ActivityResponse](#activityresponse)\> | No | Callback used to receive reported data. If this parameter is not passed, all callbacks associated with the specified event in the process will be unregistered. | +| callback | Callback:\<[ActivityResponse](#activityresponse)> | No | Callback used to receive reported data, If the callback parameter is not passed or the type passed is undefined, all callbacks associated with the specified event in the process will be unregistered. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-battery.md b/en/application-dev/reference/apis/js-apis-system-battery.md index 8eef0562cdedb91214d4eb9e688445eb6d8ff9b8..ec63058c998fcbaeb278a7a7c3ef7fcbc4620f2d 100644 --- a/en/application-dev/reference/apis/js-apis-system-battery.md +++ b/en/application-dev/reference/apis/js-apis-system-battery.md @@ -21,7 +21,7 @@ getStatus(options?: GetStatusOptions): void; Obtains the current charging state and battery level. -**System capability**: SystemCapability.PowerManager.BatteryManager.Core +**System capability**: SystemCapability.PowerManager.BatteryManager.Lite **Parameters** @@ -46,7 +46,7 @@ battery.getStatus({ Object that contains the API calling result. -**System capability**: SystemCapability.PowerManager.BatteryManager.Core +**System capability**: SystemCapability.PowerManager.BatteryManager.Lite | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | @@ -58,7 +58,7 @@ Object that contains the API calling result. Defines a response that returns the charging status and remaining power of the device. -**System capability**: SystemCapability.PowerManager.BatteryManager.Core +**System capability**: SystemCapability.PowerManager.BatteryManager.Lite | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-system-brightness.md b/en/application-dev/reference/apis/js-apis-system-brightness.md index 01a1defec2d87411735e0ffcf30b08beb93faccf..55b0bdee44b6f421863162c3d078bd092fcfb95a 100644 --- a/en/application-dev/reference/apis/js-apis-system-brightness.md +++ b/en/application-dev/reference/apis/js-apis-system-brightness.md @@ -22,7 +22,7 @@ getValue(options?: GetBrightnessOptions): void Obtains the current screen brightness. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite **Parameters** @@ -50,7 +50,7 @@ setValue(options?: SetBrightnessOptions): void Sets the screen brightness. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite **Parameters** @@ -79,7 +79,7 @@ getMode(options?: GetBrightnessModeOptions): void Obtains the screen brightness adjustment mode. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite **Parameters** @@ -107,7 +107,7 @@ setMode(options?: SetBrightnessModeOptions): void Sets the screen brightness adjustment mode. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite **Parameters** | Name| Type| Mandatory| Description| @@ -137,7 +137,7 @@ setKeepScreenOn(options?: SetKeepScreenOnOptions): void Sets whether to always keep the screen on. Call this API in **onShow()**. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite **Parameters** @@ -162,7 +162,7 @@ Sets whether to always keep the screen on. Call this API in **onShow()**. Defines the options for obtaining the screen brightness. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name | Type | Mandatory| Description | | -------- | --------------------------------------------------------- | ---- | ------------------------------------------------------------ | @@ -174,7 +174,7 @@ Defines the options for obtaining the screen brightness. Defines the options for setting the screen brightness. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------------ | @@ -187,7 +187,7 @@ Defines the options for setting the screen brightness. Defines a response that returns the screen brightness. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | @@ -197,7 +197,7 @@ Defines a response that returns the screen brightness. Defines the options for obtaining the screen brightness mode. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | @@ -209,7 +209,7 @@ Defines the options for obtaining the screen brightness mode. Defines the options for setting the screen brightness mode. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name | Type | Mandatory| Description | | -------- | ------------------------------------ | ---- | ------------------------------------------------------ | @@ -222,7 +222,7 @@ Defines the options for setting the screen brightness mode. Defines a response that returns the screen brightness mode. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | @@ -232,7 +232,7 @@ Defines a response that returns the screen brightness mode. Defines the options for setting the screen to be steady on. -**System capability**: SystemCapability.PowerManager.DisplayPowerManager +**System capability**: SystemCapability.PowerManager.DisplayPowerManager.Lite | Name | Type | Mandatory| Description | | ------------ | ------------------------------------ | ---- | ------------------------------------------------------ | diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md index f05edc6533e92d21c49cf1dd2c91b7e9aa12ff0a..38f3d0525c9d7a35b33a808e0ae8fd38ea58bf4d 100644 --- a/en/application-dev/reference/apis/js-apis-treemap.md +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -48,7 +48,7 @@ A constructor used to create a **TreeMap** instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| comparator | function | No| Custom comparator.| +| comparator | function | No| Custom comparator. The default value is **hole** (a blank placeholder), indicating that no comparator. is provided.| **Error codes** @@ -611,14 +611,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | V | No| Value of the element that is currently traversed.| -| key | K | No| Key of the element that is currently traversed.| -| map | TreeMap | No| Instance that invokes the **forEach** method.| +| value | V | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key | K | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.| +| map | TreeMap | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md index b3259d3ccbf19fab20c027accad98c6519bf7f52..fafe6553d2469bd19badd9ec5ce0814b12b02299 100644 --- a/en/application-dev/reference/apis/js-apis-treeset.md +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -44,7 +44,7 @@ A constructor used to create a **TreeSet** instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| comparator | function | No| Custom comparator.| +| comparator | function | No| Custom comparator. The default value is **hole** (a blank placeholder), indicating that no comparator. is provided.| **Error codes** @@ -484,14 +484,14 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked to traverse the elements in the container.| -| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | T | No| Value of the element that is currently traversed.| -| key | T | No| Key of the element that is currently traversed.| -| set | TreeSet<T> | No| Instance that invokes the **forEach** method.| +| value | T | No| Value of the element that is currently traversed. The default value is the value of the first key-value pair.| +| key | T | No| Key of the element that is currently traversed. The default value is the key of the first key-value pair.| +| set | TreeSet<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 6600939a007d9ac3abd1ad964f3270445cec3a7e..c049c8f2a2a4a3cc3a37bc47c5672da9cb4bb3fe 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -586,7 +586,7 @@ result = textEncoder.encodeInto("\uD800¥¥"); ### encodeIntoUint8Array9+ -encodeIntoUint8Array(input: string, dest: Uint8Array, ): { read: number; written: number } +encodeIntoUint8Array(input: string, dest: Uint8Array): { read: number; written: number } Stores the UTF-8 encoded text. @@ -617,7 +617,7 @@ result = that.encodeIntoUint8Array('abcd', dest) ### encodeInto(deprecated) -encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } +encodeInto(input: string, dest: Uint8Array): { read: number; written: number } Stores the UTF-8 encoded text. @@ -1100,7 +1100,7 @@ A constructor used to create a **LruCache** instance. The default capacity of th | Name | Type | Mandatory| Description | | -------- | ------ | ---- | ---------------------------- | -| capacity | number | No | Capacity of the **LruCache** to create.| +| capacity | number | No | Capacity of the **LruCache** to create. The default value is **64**.| **Example** @@ -3400,7 +3400,7 @@ A constructor used to create a **LruBuffer** instance. The default capacity of t | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| capacity | number | No| Capacity of the **LruBuffer** to create.| +| capacity | number | No| Capacity of the **LruBuffer** to create. The default value is **64**.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 7e59a7685b38a014a76065ee04255b106c9d8133..137cf7bfffa33bc4035ec80d10c7e09075b00ae1 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -304,15 +304,15 @@ Replaces all elements in this container with new elements, and returns the new o | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| vector | Vector<T> | No| Instance that invokes the **replaceAllElements** API.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| vector | Vector<T> | No| Instance that calls the **replaceAllElements** API. The default value is this instance.| **Example** @@ -342,15 +342,15 @@ Uses a callback to traverse the elements in this container and obtain their posi | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | callbackFn | function | Yes| Callback invoked for replacement.| -| thisArg | Object | No| Value to use when the callback is invoked.| +| thisArg | Object | No| Value of **this** to use when **callbackFn** is invoked. The default value is this instance.| -callbackfn +callbackFn | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | value | T | Yes| Value of the element that is currently traversed.| -| index | number | No| Position index of the element that is currently traversed.| -| vector | Vector<T> | No| Instance that invokes the **forEach** API.| +| index | number | No| Position index of the element that is currently traversed. The default value is **0**.| +| vector | Vector<T> | No| Instance that calls the **forEach** API. The default value is this instance.| **Example** @@ -378,7 +378,7 @@ Sorts elements in this container. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| comparator | function | No| Callback invoked for sorting.| +| comparator | function | No| Callback invoked for sorting. The default value is this instance.| comparator diff --git a/en/application-dev/reference/apis/js-apis-vibrator.md b/en/application-dev/reference/apis/js-apis-vibrator.md index 46e6f69db5327502add3c26ba6fd6b897868fc0c..c0e2de3e09ae03dfb4a5e76c0e727e37856e807c 100644 --- a/en/application-dev/reference/apis/js-apis-vibrator.md +++ b/en/application-dev/reference/apis/js-apis-vibrator.md @@ -460,8 +460,9 @@ Describes the vibration effect. | Type | Description | | -------------------------------- | ------------------------------ | -| [VibrateTime](#vibratetime9) | Triggers vibration with the specified duration. This API uses a promise to return the result.| +| [VibrateTime](#vibratetime9) | Vibration with the specified duration.| | [VibratePreset](#vibratepreset9) | Vibration with a preset effect.| +| [VibrateFromFile10+](#vibratefromfile10) | Vibration according to a custom vibration configuration file.| ## VibrateTime9+ @@ -469,10 +470,10 @@ Describes the vibration with the specified duration. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Value| Description | -| -------- | ------ | ------------------------------ | -| type | "time" | Vibration with the specified duration.| -| duration | - | Vibration duration, in ms. | +| Name | Type | Mandatory| Description | +| -------- | ------ | ----- | ------------------------------ | +| type | string | Yes | The value **time** means vibration with the specified duration.| +| duration | number | Yes | Vibration duration, in ms. | ## VibratePreset9+ @@ -480,11 +481,34 @@ Describes the vibration with a preset effect. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Value | Description | -| -------- | -------- | ------------------------------ | -| type | "preset" | Vibration with the specified effect.| -| effectId | - | Preset vibration effect ID. | -| count | - | Number of vibrations to repeat. | +| Name | Type | Mandatory| Description | +| -------- | -------- | ---- |------------------------------ | +| type | string | Yes | The value **preset** means vibration with the specified effect.| +| effectId | string | Yes | Preset vibration effect ID. | +| count | number | Yes | Number of vibrations to repeat. | + +## VibrateFromFile10+ + +Describes the custom vibration type, which is supported only by certain devices. + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Type | Mandatory| Description | +| -------- | -------- | ---- | ------------------------------ | +| type | string | Yes | The value **file** means vibration according to a vibration configuration file.| +| hapticFd | [HapticFileDescriptor](#hapticfiledescriptor10) | Yes| File descriptor (FD) of the vibration configuration file.| + +## HapticFileDescriptor10+ + +Describes the FD of a custom vibration configuration file. Ensure that the file is available, and the parameters in it can be obtained from the sandbox path through the [file management API](js-apis-file-fs.md#fsopen) or from the HAP resource through the [resource management API](js-apis-resource-manager.md#getrawfd9). The use case is as follows: The system triggers vibration according to the sequence set in a configuration file, based on the specified offset and length. For details about the storage format of the vibration sequence, see [Custom Vibration Format](../../device/vibrator-guidelines.md#custom-vibration-format). + +**System capability**: SystemCapability.Sensors.MiscDevice + +| Name | Type | Mandatory | Description | +| -------- | -------- |--------| ------------------------------| +| fd | number | Yes | FD of the custom vibration configuration file. | +| offset | number | No | Offset from the start position of the file, in bytes. The default value is the start position of the file, and the value cannot exceed the valid range of the file.| +| length | number | No | Resource length, in bytes. The default value is the length from the offset position to the end of the file, and the value cannot exceed the valid range of the file.| ## VibrateAttribute9+ @@ -492,10 +516,10 @@ Describes the vibration attribute. **System capability**: SystemCapability.Sensors.MiscDevice -| Name | Value| Description | -| ----- | ------ | -------------- | -| id | 0 | Vibrator ID. | -| usage | - | Vibration scenario.| +| Name | Type| Mandatory| Description | +| ----- | ------ | ---- | -------------- | +| id | number | No| Vibrator ID. The default value is 0. | +| usage | [Usage](#usage9) | Yes| Vibration scenario.| ## Usage9+ diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index f8e8f0fff5917b56be67e1f3ab0b21ac949e7ee3..9554f5b07dd9f131c81c7ef8e30df9813cc303e9 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -381,6 +381,7 @@ Creates and returns an **XmlPullParser** object. **Example** ```js +import util from '@ohos.util'; let strXml = '' + ']>' + @@ -432,6 +433,7 @@ Parses XML information. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -499,6 +501,7 @@ Obtains the column line number, starting from 1. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -542,6 +545,7 @@ Obtains the depth of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -588,6 +592,7 @@ Obtains the current line number, starting from 1. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -631,6 +636,7 @@ Obtains the name of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -673,6 +679,7 @@ Obtains the namespace of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -715,6 +722,7 @@ Obtains the prefix of this element. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -758,6 +766,7 @@ Obtains the text of the current event. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -800,6 +809,7 @@ Checks whether the current element is empty. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -842,6 +852,7 @@ Checks whether the current text event contains only whitespace characters. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + @@ -883,6 +894,7 @@ Obtains the number of attributes for the current start tag. **Example** ```js +import util from '@ohos.util'; let strXml = '' + '' + diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md index f2c85939598b88cf371efdb21c6f7389992e7ee5..7428f4d9be2f17a6c591527137341fcbb46be3aa 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -26,7 +26,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | ----------- | ---------- | ------------------ | | vertical | boolean | Whether a vertical divider is used. **false**: A horizontal divider is used.
**true**: A vertical divider is used.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| | color | [ResourceColor](ts-types.md#resourcecolor) | Color of the divider.
Default value: **'\#33182431'**
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | number \| string | Width of the divider.
Default value: **1**
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.| +| strokeWidth | number \| string | Width of the divider.
Default value: **1px**
Unit: vp
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute cannot be set to a percentage. The priority of this attribute is lower than that of the universal attribute [height](ts-universal-attributes-size.md). If the value of this attribute is greater than that of the universal attribute, cropping is performed based on the universal attribute settings.| | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the divider.
Default value: **LineCapStyle.Butt**
Since API version 9, this API is supported in ArkTS widgets.| diff --git a/en/application-dev/reference/arkui-ts/ts-components-summary.md b/en/application-dev/reference/arkui-ts/ts-components-summary.md index 19bc1f97eec987ec2e7b97f4507b3e8fc107f29d..d6195e588c8874f362faf3c1c88d4943bced4ad4 100644 --- a/en/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/en/application-dev/reference/arkui-ts/ts-components-summary.md @@ -22,7 +22,7 @@ ## Stack, Flex, and Grid -- [Stack](ts-container-stack.md) +- [Stack](ts-container-stack.md) A container where child components are successively stacked and the latter one overwrites the previous one. - [Flex](ts-container-flex.md) @@ -63,7 +63,7 @@ ## Scroll and Swipe -- [Scroll](ts-container-scroll.md) +- [Scroll](ts-container-scroll.md) A container that scrolls the content when the layout size of a component exceeds the size of its parent component. - [Swiper](ts-container-swiper.md) @@ -79,9 +79,9 @@ ## Navigation -- [Navigator](ts-container-navigator.md) +- [Navigator](ts-container-navigator.md) - A container that provides redirection. + A container that provides redirection. - [Navigation](ts-basic-components-navigation.md) A container that typically functions as the root container of a page and displays the title bar, toolbar, and navigation bar based on the attribute settings. @@ -293,7 +293,7 @@ A component that is used to display widgets. - [Menu](ts-basic-components-menu.md) - A component that is used to present a vertical list of items to the user. + A component that is used to present a vertical list of items to the user. - [MenuItem](ts-basic-components-menuitem.md) A component that is used to represent an item in a menu. diff --git a/en/application-dev/reference/native-apis/Readme-EN.md b/en/application-dev/reference/native-apis/Readme-EN.md index ee896c67409995bce0420d9b762ba232d270de01..7b6840f6392866ec1183a618034f80d7670ea89e 100644 --- a/en/application-dev/reference/native-apis/Readme-EN.md +++ b/en/application-dev/reference/native-apis/Readme-EN.md @@ -7,6 +7,7 @@ - [Drawing](_drawing.md) - [Image](image.md) - [Rawfile](rawfile.md) + - [RDB](_r_d_b.md) - [MindSpore](_mind_spore.md) - [NeuralNeworkRuntime](_neural_nework_runtime.md) - [AudioDecoder](_audio_decoder.md) @@ -58,6 +59,12 @@ - [native_huks_api.h](native__huks__api_8h.md) - [native_huks_param.h](native__huks__param_8h.md) - [native_huks_type.h](native__huks__type_8h.md) + - [oh_cursor.h](oh__cursor_8h.md) + - [oh_predicates.h](oh__predicates_8h.md) + - [oh_value_object.h](oh__value__object_8h.md) + - [oh_values_bucket.h](oh__values__bucket_8h.md) + - [relational_store_error_code.h](relational__store__error__code_8h.md) + - [relational_store.h](relational__store_8h.md) - [syscap_ndk.h](syscap__ndk_8h.md) - [purgeable_memory.h](purgeable__memory_8h.md) - Structs @@ -95,3 +102,9 @@ - [OH_Huks_ParamSet](_o_h___huks___param_set.md) - [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md) - [OH_Huks_Result](_o_h___huks___result.md) + - [OH_Cursor](_o_h___cursor.md) + - [OH_Predicates](_o_h___predicates.md) + - [OH_Rdb_Config](_o_h___rdb___config.md) + - [OH_Rdb_Store](_o_h___rdb___store.md) + - [OH_VBucket](_o_h___v_bucket.md) + - [OH_VObject](_o_h___v_object.md) diff --git a/en/application-dev/reference/native-apis/_mind_spore.md b/en/application-dev/reference/native-apis/_mind_spore.md index ded41297291a904a08793bd2cd94e2ab667a10a0..e52fc4f327ea142c3f8a0c5777c5b8ce8de67ec0 100644 --- a/en/application-dev/reference/native-apis/_mind_spore.md +++ b/en/application-dev/reference/native-apis/_mind_spore.md @@ -7,125 +7,146 @@ Provides APIs related to MindSpore Lite model inference. \@Syscap SystemCapability.Ai.MindSpore -**Since:** +**Since** + 9 + ## Summary -### Files +### File -| Name | Description | -| -------- | -------- | -| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information.
File to Include: | -| [data_type.h](data__type_8h.md) | Declares tensor data types.
File to Include: | -| [format.h](format_8h.md) | Declares tensor data formats.
File to Include: | -| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference.
File to Include: | -| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite.
File to Include: | -| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information.
File to Include: | -| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite.
File to Include: | +| Name | Description | +| ------------------------------- | ------------------------------------------------------------ | +| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information.
File to include: \| +| [data_type.h](data__type_8h.md) | Declares tensor data types.
File to include: \| +| [format.h](format_8h.md) | Declares tensor data formats.
File to include: \ | +| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference.
File to include: \| +| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite.
File to include: \| +| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information.
File to include: \| +| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite.
File to include: \| ### Structs -| Name | Description | -| -------- | -------- | -| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | -| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | -| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. | +| Name | Description | +| ------------------------------------------------------------ | ---------------------------------------------------- | +| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.| +| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | +| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. | -### Macros - -| Name | Description | -| -------- | -------- | -| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | +### Macro Definition +| Name | Description | +| ------------------------------------------------ | -------------------------------------------- | +| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**.| ### Types -| Name | Description | -| -------- | -------- | -| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | -| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | -| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. | -| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. | -| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. | -| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | -| **OH_AI_ShapeInfo** | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | -| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. | -| [OH_AI_KernelCallBack](#oh_ai_kernelcallback)) (const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) outputs, const [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) kernel_Info) | Defines the pointer to a callback. | -| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. | -| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. | -| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. | -| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. | +| Name | Description | +| ------------------------------------------------------------ | -------------------------------------------------- | +| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | +| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | +| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. | +| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. | +| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. | +| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.| +| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | +| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. | +| [OH_AI_KernelCallBack](#oh_ai_kernelcallback) | Defines the pointer to a callback. | +| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. | +| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. | +| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. | +| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. | +| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) | Defines NNRt device types. | +| [OH_AI_PerformanceMode](#oh_ai_performancemode) | Defines performance modes of the NNRt device. | +| [OH_AI_Priority](#oh_ai_priority) | Defines NNRt inference task priorities. | +| [NNRTDeviceDesc](#nnrtdevicedesc) | Defines the NNRt device information, including the device ID and device name. | ### Enums -| Name | Description | -| -------- | -------- | -| [OH_AI_DataType](#oh_ai_datatype) {
OH_AI_DATATYPE_UNKNOWN = 0, OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,
OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29, OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30, OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,
OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,
OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39, OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, OH_AI_DATATYPE_NUMBERTYPE_END = 46, OH_AI_DataTypeInvalid = INT32_MAX
} | Declares data types supported by MSTensor. | -| [OH_AI_Format](#oh_ai_format) {
OH_AI_FORMAT_NCHW = 0, OH_AI_FORMAT_NHWC = 1, OH_AI_FORMAT_NHWC4 = 2, OH_AI_FORMAT_HWKC = 3,
OH_AI_FORMAT_HWCK = 4, OH_AI_FORMAT_KCHW = 5, OH_AI_FORMAT_CKHW = 6, OH_AI_FORMAT_KHWC = 7,
OH_AI_FORMAT_CHWK = 8, OH_AI_FORMAT_HW = 9, OH_AI_FORMAT_HW4 = 10, OH_AI_FORMAT_NC = 11,
OH_AI_FORMAT_NC4 = 12, OH_AI_FORMAT_NC4HW4 = 13, OH_AI_FORMAT_NCDHW = 15, OH_AI_FORMAT_NWC = 16,
OH_AI_FORMAT_NCW = 17
} | Declares data formats supported by MSTensor. | -| [OH_AI_CompCode](#oh_ai_compcode) { OH_AI_COMPCODE_CORE = 0x00000000u, OH_AI_COMPCODE_LITE = 0xF0000000u } | Defines MinSpore component codes. | -| [OH_AI_Status](#oh_ai_status) {
OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -2),
OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -6),
OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -100),
OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -300),
OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -400),
OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID
} | Defines MindSpore status codes. | -| [OH_AI_ModelType](#oh_ai_modeltype) { OH_AI_MODELTYPE_MINDIR = 0, OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF } | Defines model file types. | -| [OH_AI_DeviceType](#oh_ai_devicetype) {
OH_AI_DEVICETYPE_CPU = 0, OH_AI_DEVICETYPE_GPU, OH_AI_DEVICETYPE_KIRIN_NPU, OH_AI_DEVICETYPE_NNRT = 60,
OH_AI_DEVICETYPE_INVALID = 100
} | Defines the supported device types. | +| Name | Description | +| ------------------------------------------------------------ | ---------------------------------------- | +| [OH_AI_DataType](#oh_ai_datatype-1) {
OH_AI_DATATYPE_UNKNOWN = 0,
OH_AI_DATATYPE_OBJECTTYPE_STRING = 12,
OH_AI_DATATYPE_OBJECTTYPE_LIST = 13,
OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,
OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17,
OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29,
OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30,
OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,
OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33,
OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34,
OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35,
OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,
OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38,
OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39,
OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44,
OH_AI_DATATYPE_NUMBERTYPE_END = 46,
OH_AI_DataTypeInvalid = INT32_MAX
} | Declares data types supported by MSTensor. | +| [OH_AI_Format](#oh_ai_format-1) {
OH_AI_FORMAT_NCHW = 0,
OH_AI_FORMAT_NHWC = 1,
OH_AI_FORMAT_NHWC4 = 2,
OH_AI_FORMAT_HWKC = 3,
OH_AI_FORMAT_HWCK = 4,
OH_AI_FORMAT_KCHW = 5,
OH_AI_FORMAT_CKHW = 6,
OH_AI_FORMAT_KHWC = 7,
OH_AI_FORMAT_CHWK = 8,
OH_AI_FORMAT_HW = 9,
OH_AI_FORMAT_HW4 = 10,
OH_AI_FORMAT_NC = 11,
OH_AI_FORMAT_NC4 = 12,
OH_AI_FORMAT_NC4HW4 = 13,
OH_AI_FORMAT_NCDHW = 15,
OH_AI_FORMAT_NWC = 16,
OH_AI_FORMAT_NCW = 17
} | Declares data formats supported by MSTensor. | +| [OH_AI_CompCode](#oh_ai_compcode) {
OH_AI_COMPCODE_CORE = 0x00000000u,
OH_AI_COMPCODE_LITE = 0xF0000000u
} | Defines MindSpore component codes. | +| [OH_AI_Status](#oh_ai_status-1) {
OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -2),
OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -6),
OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -100),
OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -300),
OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -400),
OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID
} | Defines MindSpore status codes. | +| [OH_AI_ModelType](#oh_ai_modeltype-1) {
OH_AI_MODELTYPE_MINDIR = 0,
OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF
} | Defines model file types. | +| [OH_AI_DeviceType](#oh_ai_devicetype-1) {
OH_AI_DEVICETYPE_CPU = 0,
OH_AI_DEVICETYPE_GPU,
OH_AI_DEVICETYPE_KIRIN_NPU,
OH_AI_DEVICETYPE_NNRT = 60,
OH_AI_DEVICETYPE_INVALID = 100
} | Defines the supported device types.| +| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype-1) {
OH_AI_NNRTDEVICE_OTHERS = 0,
OH_AI_NNRTDEVICE_CPU = 1,
OH_AI_NNRTDEVICE_GPU = 2,
OH_AI_NNRTDEVICE_ACCELERATOR = 3
} | Defines NNRt device types. | +| [OH_AI_PerformanceMode](#oh_ai_performancemode-1) {
OH_AI_PERFORMANCE_NONE = 0,
OH_AI_PERFORMANCE_LOW = 1,
OH_AI_PERFORMANCE_MEDIUM = 2,
OH_AI_PERFORMANCE_HIGH = 3,
OH_AI_PERFORMANCE_EXTREME = 4
} | Defines performance modes of the NNRt device. | +| [OH_AI_Priority](#oh_ai_priority-1) {
OH_AI_PRIORITY_NONE = 0,
OH_AI_PRIORITY_LOW = 1,
OH_AI_PRIORITY_MEDIUM = 2,
OH_AI_PRIORITY_HIGH = 3
} | Defines NNRt inference task priorities. | ### Functions -| Name | Description | -| -------- | -------- | -| [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. | -| [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. | -| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | -| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. | -| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | -| [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | -| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | -| [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | -| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | -| [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | -| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | -| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. | -| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | -| [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | -| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | -| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | -| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | -| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | -| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | -| [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | -| [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | -| [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | -| [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. | -| [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. | -| [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | -| [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | -| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | -| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | -| [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | -| [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | -| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. | -| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. | -| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. | -| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | -| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. | -| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. | -| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. | -| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. | -| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | -| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | -| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | -| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | -| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | -| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | +| Name | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. | +| [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. | +| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | +| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. | +| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.| +| [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | +| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | +| [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | +| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available. | +| [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | +| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context. | +| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. | +| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually. | +| [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name. | +| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | +| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | +| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | +| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the device type. | +| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU and GPU devices. | +| [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices. | +| [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system. | +| [OH_AI_DestroyAllNNRTDeviceDescs](#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| +| [OH_AI_GetNameFromNNRTDeviceDesc](#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description. | +| [OH_AI_GetTypeFromNNRTDeviceDesc](#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description. | +| [OH_AI_CreateNNRTDeviceInfoByName](#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_CreateNNRTDeviceInfoByType](#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_DeviceInfoSetDeviceId](#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetDeviceId](#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPerformanceMode](#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPerformanceMode](#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPriority](#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPriority](#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices. | +| [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | +| [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | +| [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | +| [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | +| [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. | +| [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. | +| [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | +| [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | +| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | +| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | +| [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | +| [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | +| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Deeply copies a tensor. | +| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the tensor name. | +| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor name. | +| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | +| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor type. | +| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the tensor shape. | +| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the tensor shape. | +| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. | +| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | +| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | +| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | +| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | +| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | +| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | ## Macro Description @@ -133,84 +154,116 @@ Provides APIs related to MindSpore Lite model inference. ### OH_AI_MAX_SHAPE_NUM - + ``` #define OH_AI_MAX_SHAPE_NUM 32 ``` -**Description**
+ +**Description** + Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. ## Type Description +### NNRTDeviceDesc + + +``` +typedef struct NNRTDeviceDesc NNRTDeviceDesc +``` + +**Description** + +Defines the NNRt device information, including the device ID and device name. + +**Since** + +10 + + ### OH_AI_CallBackParam - + ``` -typedef struct OH_AI_CallBackParamOH_AI_CallBackParam +typedef struct OH_AI_CallBackParam OH_AI_CallBackParam ``` -**Description**
+ +**Description** + Defines the operator information passed in a callback. ### OH_AI_ContextHandle - + ``` typedef void* OH_AI_ContextHandle ``` -**Description**
-Defines the pointer to the MindSpore context. + +**Description** + +Defines the pointer to the MindSpore context. ### OH_AI_DataType - + ``` -typedef enum OH_AI_DataTypeOH_AI_DataType +typedef enum OH_AI_DataType OH_AI_DataType ``` -**Description**
+ +**Description** + Declares data types supported by MSTensor. ### OH_AI_DeviceInfoHandle - + ``` typedef void* OH_AI_DeviceInfoHandle ``` -**Description**
+ +**Description** + Defines the pointer to the MindSpore device information. ### OH_AI_DeviceType - + ``` -typedef enum OH_AI_DeviceTypeOH_AI_DeviceType +typedef enum OH_AI_DeviceType OH_AI_DeviceType ``` -**Description**
+ +**Description** + Defines the supported device types. ### OH_AI_Format - + ``` -typedef enum OH_AI_FormatOH_AI_Format +typedef enum OH_AI_Format OH_AI_Format ``` -**Description**
+ +**Description** + Declares data formats supported by MSTensor. ### OH_AI_KernelCallBack - + ``` typedef bool(* OH_AI_KernelCallBack) (const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, const OH_AI_CallBackParam kernel_Info) ``` -**Description**
+ +**Description** + Defines the pointer to a callback. This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#oh_ai_modelpredict). Each callback function must contain three parameters, where **inputs** and **outputs** indicate the input and output tensors of the operator, and **kernel_Info** indicates information about the current operator. You can use the callback functions to monitor the operator execution status, for example, operator execution time and the operator correctness. @@ -218,51 +271,109 @@ This pointer is used to set the two callback functions in [OH_AI_ModelPredict](# ### OH_AI_ModelHandle - + ``` typedef void* OH_AI_ModelHandle ``` -**Description**
+ +**Description** + Defines the pointer to a model object. ### OH_AI_ModelType - + ``` -typedef enum OH_AI_ModelTypeOH_AI_ModelType +typedef enum OH_AI_ModelType OH_AI_ModelType ``` -**Description**
+ +**Description** + Defines model file types. +### OH_AI_NNRTDeviceType + + +``` +typedef enum OH_AI_NNRTDeviceType OH_AI_NNRTDeviceType +``` + +**Description** + +Defines NNRt device types. + +**Since** + +10 + + +### OH_AI_PerformanceMode + + +``` +typedef enum OH_AI_PerformanceMode OH_AI_PerformanceMode +``` + +**Description** + +Defines performance modes of the NNRt device. + +**Since** + +10 + + +### OH_AI_Priority + + +``` +typedef enum OH_AI_Priority OH_AI_Priority +``` + +**Description** + +Defines NNRt inference task priorities. + +**Since** + +10 + + ### OH_AI_Status - + ``` -typedef enum OH_AI_StatusOH_AI_Status +typedef enum OH_AI_Status OH_AI_Status ``` -**Description**
+ +**Description** + Defines MindSpore status codes. ### OH_AI_TensorHandle - + ``` typedef void* OH_AI_TensorHandle ``` -**Description**
+ +**Description** + Defines the handle of a tensor object. ### OH_AI_TensorHandleArray - + ``` -typedef struct OH_AI_TensorHandleArrayOH_AI_TensorHandleArray +typedef struct OH_AI_TensorHandleArray OH_AI_TensorHandleArray ``` -**Description**
+ +**Description** + Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. @@ -271,215 +382,304 @@ Defines the tensor array structure, which is used to store the tensor array poin ### OH_AI_CompCode - + ``` enum OH_AI_CompCode ``` -**Description**
-Defines MinSpore component codes. -| Name | Description | -| -------- | -------- | -| OH_AI_COMPCODE_CORE | MindSpore Core code | -| OH_AI_COMPCODE_LITE | MindSpore Lite code | +**Description** + +Defines MindSpore component codes. + +| Value | Description | +| ------------------- | --------------------- | +| OH_AI_COMPCODE_CORE | MindSpore Core code| +| OH_AI_COMPCODE_LITE | MindSpore Lite code| ### OH_AI_DataType - + ``` enum OH_AI_DataType ``` -**Description**
+ +**Description** + Declares data types supported by MSTensor. -| Name | Description | -| -------- | -------- | -| OH_AI_DATATYPE_UNKNOWN | Unknown data type | -| OH_AI_DATATYPE_OBJECTTYPE_STRING | String data type | -| OH_AI_DATATYPE_OBJECTTYPE_LIST | List data type | -| OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data type | -| OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data type | -| OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type | -| OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type | -| OH_AI_DataTypeInvalid | Invalid data type | +| Value | Description | +| --------------------------------- | ---------------------- | +| OH_AI_DATATYPE_UNKNOWN | Unknown data type. | +| OH_AI_DATATYPE_OBJECTTYPE_STRING | String data. | +| OH_AI_DATATYPE_OBJECTTYPE_LIST | List data. | +| OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data. | +| OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data. | +| OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type. | +| OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data . | +| OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type.| +| OH_AI_DataTypeInvalid | Invalid data type. | ### OH_AI_DeviceType - + ``` enum OH_AI_DeviceType ``` -**Description**
+ +**Description** + Defines the supported device types. -| Name | Description | -| -------- | -------- | -| OH_AI_DEVICETYPE_CPU | Device type: CPU
since 9 | -| OH_AI_DEVICETYPE_GPU | Device type: GPU
Reserved, not support yet.
since 9 | -| OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU
Reserved, not support yet.
since 9 | -| OH_AI_DEVICETYPE_NNRT | Device type: NNRt
OHOS-only device range[60,80).
since 9 | -| OH_AI_DEVICETYPE_INVALID | Invalid device type
since 9 | +| Value | Description | +| -------------------------- | --------------------------------------- | +| OH_AI_DEVICETYPE_CPU | Device type: CPU | +| OH_AI_DEVICETYPE_GPU | Device type: GPU Reserved | +| OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU Reserved| +| OH_AI_DEVICETYPE_NNRT | Device type: NNRt OHOS device range: [60, 80)| +| OH_AI_DEVICETYPE_INVALID | Invalid device type | ### OH_AI_Format - + ``` enum OH_AI_Format ``` -**Description**
+ +**Description** + Declares data formats supported by MSTensor. -| Name | Description | -| -------- | -------- | -| OH_AI_FORMAT_NCHW | NCHW format | -| OH_AI_FORMAT_NHWC | NHWC format | -| OH_AI_FORMAT_NHWC4 | NHWC4 format | -| OH_AI_FORMAT_HWKC | HWKC format | -| OH_AI_FORMAT_HWCK | HWCK format | -| OH_AI_FORMAT_KCHW | KCHW format | -| OH_AI_FORMAT_CKHW | CKHW format | -| OH_AI_FORMAT_KHWC | KHWC format | -| OH_AI_FORMAT_CHWK | CHWK format | -| OH_AI_FORMAT_HW | HW format | -| OH_AI_FORMAT_HW4 | HW4 format | -| OH_AI_FORMAT_NC | NC format | -| OH_AI_FORMAT_NC4 | NC4 format | -| OH_AI_FORMAT_NC4HW4 | NC4HW4 format | -| OH_AI_FORMAT_NCDHW | NCDHW format | -| OH_AI_FORMAT_NWC | NWC format | -| OH_AI_FORMAT_NCW | NCW format | +| Value | Description | +| ------------------- | ---------------- | +| OH_AI_FORMAT_NCHW | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. | +| OH_AI_FORMAT_NHWC | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. | +| OH_AI_FORMAT_NHWC4 | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. The C axis is 4-byte aligned. | +| OH_AI_FORMAT_HWKC | Tensor data is stored in the sequence of height H, width W, core count K, and channel C. | +| OH_AI_FORMAT_HWCK | Tensor data is stored in the sequence of height H, width W, channel C, and core count K. | +| OH_AI_FORMAT_KCHW | Tensor data is stored in the sequence of core count K, channel C, height H, and width W. | +| OH_AI_FORMAT_CKHW | Tensor data is stored in the sequence of channel C, core count K, height H, and width W. | +| OH_AI_FORMAT_KHWC | Tensor data is stored in the sequence of core count K, height H, width W, and channel C. | +| OH_AI_FORMAT_CHWK | Tensor data is stored in the sequence of channel C, height H, width W, and core count K. | +| OH_AI_FORMAT_HW | Tensor data is stored in the sequence of height H and width W. | +| OH_AI_FORMAT_HW4 | Tensor data is stored in the sequence of height H and width W. The W axis is 4-byte aligned. | +| OH_AI_FORMAT_NC | Tensor data is stored in the sequence of batch number N and channel C. | +| OH_AI_FORMAT_NC4 | Tensor data is stored in the sequence of batch number N and channel C. The C axis is 4-byte aligned. | +| OH_AI_FORMAT_NC4HW4 | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. The C axis and W axis are 4-byte aligned.| +| OH_AI_FORMAT_NCDHW | Tensor data is stored in the sequence of batch number N, channel C, depth D, height H, and width W. | +| OH_AI_FORMAT_NWC | Tensor data is stored in the sequence of batch number N, width W, and channel C. | +| OH_AI_FORMAT_NCW | Tensor data is stored in the sequence of batch number N, channel C, and width W. | ### OH_AI_ModelType - + ``` enum OH_AI_ModelType ``` -**Description**
+ +**Description** + Defines model file types. -| Name | Description | -| -------- | -------- | -| OH_AI_MODELTYPE_MINDIR | Model type: MindIR
since 9 | -| OH_AI_MODELTYPE_INVALID | Invalid model type
since 9 | +| Value | Description | +| ----------------------- | ------------------ | +| OH_AI_MODELTYPE_MINDIR | Model type of MindIR. The extension of the model file name is **.ms**.| +| OH_AI_MODELTYPE_INVALID | Invalid model type. | + + +### OH_AI_NNRTDeviceType + + +``` +enum OH_AI_NNRTDeviceType +``` + +**Description** + +Defines NNRt device types. + +**Since** + +10 + +| Value | Description | +| ---------------------------- | ----------------------------------- | +| OH_AI_NNRTDEVICE_OTHERS | Others (any device type except the following three types).| +| OH_AI_NNRTDEVICE_CPU | CPU. | +| OH_AI_NNRTDEVICE_GPU | GPU. | +| OH_AI_NNRTDEVICE_ACCELERATOR | Specific acceleration device. | + + +### OH_AI_PerformanceMode + + +``` +enum OH_AI_PerformanceMode +``` + +**Description** + +Defines performance modes of the NNRt device. + +**Since** + +10 + +| Value | Description | +| ------------------------- | ------------------- | +| OH_AI_PERFORMANCE_NONE | No special settings. | +| OH_AI_PERFORMANCE_LOW | Low power consumption. | +| OH_AI_PERFORMANCE_MEDIUM | Power consumption and performance balancing.| +| OH_AI_PERFORMANCE_HIGH | High performance. | +| OH_AI_PERFORMANCE_EXTREME | Ultimate performance. | + + +### OH_AI_Priority + + +``` +enum OH_AI_Priority +``` + +**Description** + +Defines NNRt inference task priorities. + +**Since** + +10 + +| Value | Description | +| --------------------- | -------------- | +| OH_AI_PRIORITY_NONE | No priority preference.| +| OH_AI_PRIORITY_LOW | Low priority.| +| OH_AI_PRIORITY_MEDIUM | Medium priority| +| OH_AI_PRIORITY_HIGH | High priority. | ### OH_AI_Status - + ``` enum OH_AI_Status ``` -**Description**
-Defines MindSpore status codes. -| Name | Description | -| -------- | -------- | -| OH_AI_STATUS_SUCCESS | Success | -| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure | -| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error | -| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer | -| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters | -| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change | -| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors | -| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure | -| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported | -| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error | -| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized | -| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow | -| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error | -| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error | -| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error | -| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found | -| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators | -| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters | -| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure | -| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error | -| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error | -| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference | -| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters | +**Description** + +Defines MindSpore status codes. +| Value | Description | +| ------------------------------------- | ----------------------------------------- | +| OH_AI_STATUS_SUCCESS | Success. | +| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure. | +| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error. | +| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer. | +| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters. | +| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change. | +| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors.| +| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure. | +| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported. | +| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error. | +| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized. | +| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow. | +| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error. | +| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error. | +| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error. | +| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found. | +| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators. | +| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters. | +| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure. | +| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error. | +| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error. | +| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference. | +| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters.| ## Function Description ### OH_AI_ContextAddDeviceInfo() - + ``` OH_AI_API void OH_AI_ContextAddDeviceInfo (OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info ) ``` -**Description**
-Adds information about a running device. - **Parameters** +**Description** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +Attaches the custom device information to the inference context. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| ### OH_AI_ContextCreate() - + ``` OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate () ``` -**Description**
+ +**Description** + Creates a context object. **Returns** -[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context. +[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. ### OH_AI_ContextDestroy() - + ``` OH_AI_API void OH_AI_ContextDestroy (OH_AI_ContextHandle * context) ``` -**Description**
+ +**Description** + Destroys a context object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. | ### OH_AI_ContextGetEnableParallel() - + ``` OH_AI_API bool OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Checks whether parallelism between operators is supported. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** @@ -488,59 +688,65 @@ Whether parallelism between operators is supported. The value **true** means tha ### OH_AI_ContextGetThreadAffinityCoreList() - + ``` OH_AI_API const int32_t* OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t * core_num ) ``` -**Description**
+ +**Description** + Obtains the list of bound CPU cores. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| core_num | Number of CPU cores. | +| Name | Description | +| -------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| core_num | Number of CPU cores. | **Returns** -List of bound CPU cores. +Specifies the CPU core binding list. This list is managed by [OH_AI_ContextHandle](#oh_ai_contexthandle). The caller does not need to destroy it manually. ### OH_AI_ContextGetThreadAffinityMode() - + ``` OH_AI_API int OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Obtains the affinity mode for binding runtime threads to CPU cores. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** -Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first +Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first ### OH_AI_ContextGetThreadNum() - + ``` OH_AI_API int32_t OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Obtains the number of threads. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** @@ -549,125 +755,239 @@ Number of threads. ### OH_AI_ContextSetEnableParallel() - + ``` OH_AI_API void OH_AI_ContextSetEnableParallel (OH_AI_ContextHandle context, bool is_parallel ) ``` -**Description**
-Sets whether to enable parallelism between operators. - **Parameters** +**Description** + +Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available. -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| is_parallel | Whether to enable parallelism between operators. The value **true** means to enable parallelism between operators, and the value **false** means the opposite. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| is_parallel | Whether parallelism between operators is supported. The value **true** means that parallelism between operators is supported, and the value **false** means the opposite. | ### OH_AI_ContextSetThreadAffinityCoreList() - + ``` OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t * core_list, size_t core_num ) ``` -**Description**
+ +**Description** + Sets the list of CPU cores bound to a runtime thread. For example, if **core_list** is set to **[2,6,8]**, threads run on the 2nd, 6th, and 8th CPU cores. If [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) and [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) are called for the same context object, the **core_list** parameter of [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) takes effect, but the **mode** parameter of [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) does not. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| core_list | List of bound CPU cores. | -| core_num | Number of cores, which indicates the length of **core_list**. | +| Name | Description | +| --------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| core_list | List of bound CPU cores. | +| core_num | Number of cores, which indicates the length of **core_list**. | ### OH_AI_ContextSetThreadAffinityMode() - + ``` OH_AI_API void OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode ) ``` -**Description**
-Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. - **Parameters** +**Description** + +Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores. + +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first| ### OH_AI_ContextSetThreadNum() - + ``` OH_AI_API void OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num ) ``` -**Description**
+ +**Description** + Sets the number of runtime threads. - **Parameters** +**Parameters** + +| Name | Description | +| ---------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| thread_num | Number of runtime threads. | + + +### OH_AI_CreateNNRTDeviceInfoByName() + + +``` +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName (const char * name) +``` + +**Description** + +Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device. + +**Parameters** + +| Name| Description | +| ---- | ---------------- | +| name | Name of the NNRt device.| + +**Returns** + +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. + +**Since** + +10 + + +### OH_AI_CreateNNRTDeviceInfoByType() + + +``` +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType (OH_AI_NNRTDeviceType type) +``` + +**Description** + +Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device. + +**Parameters** + +| Name| Description | +| ---- | ------------------------------------------------------------ | +| type | NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype).| + +**Returns** + +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. + +**Since** + +10 + + +### OH_AI_DestroyAllNNRTDeviceDescs() + + +``` +OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs (NNRTDeviceDesc ** desc) +``` + +**Description** + +Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs). + +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| thread_num | Number of runtime threads. | +| Name| Description | +| ---- | ------------------------------------------------------------ | +| desc | Double pointer to the array of the NNRt device descriptions. After the operation is complete, the content pointed to by **desc** is set to **NULL**.| + +**Since** + +10 ### OH_AI_DeviceInfoCreate() - + ``` OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type) ``` -**Description**
+ +**Description** + Creates a device information object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_type | Device type. For details, see [OH_AI_DeviceType](#oh_ai_devicetype). | +| Name | Description | +| ----------- | ------------------------------------------------------- | +| device_type | Device type, which is specified by [OH_AI_DeviceType](#oh_ai_devicetype).| **Returns** -[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to the device information instance. +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. ### OH_AI_DeviceInfoDestroy() - + ``` OH_AI_API void OH_AI_DeviceInfoDestroy (OH_AI_DeviceInfoHandle * device_info) ``` -**Description**
-Destroys a device information instance. - **Parameters** +**Description** + +Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + + +### OH_AI_DeviceInfoGetDeviceId() + + +``` +OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** + +Obtains the ID of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NNRt device ID. + +**Since** + +10 ### OH_AI_DeviceInfoGetDeviceType() - + ``` OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Obtains the type of a provider device. - **Parameters** +**Description** + +Obtains the device type. -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -676,18 +996,20 @@ Type of the provider device. ### OH_AI_DeviceInfoGetEnableFP16() - + ``` OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16 (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. - **Parameters** +**Description** + +Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -696,38 +1018,94 @@ Whether float16 inference is enabled. ### OH_AI_DeviceInfoGetFrequency() - + ``` OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Obtains the NPU frequency type. This function is available only for NPU devices. - **Parameters** +**Description** + +Obtains the NPU frequency type. This API is available only for NPU devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NPU frequency type. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance + + +### OH_AI_DeviceInfoGetPerformanceMode() + + +``` +OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** + +Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode). + +**Since** + +10 + + +### OH_AI_DeviceInfoGetPriority() + + +``` +OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +Obtains the priority of an NNRT task. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** -Frequency type of the NPU. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance +NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority). + +**Since** + +10 ### OH_AI_DeviceInfoGetProvider() - + ``` OH_AI_API const char* OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
+ +**Description** + Obtains the provider name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -736,150 +1114,339 @@ Provider name. ### OH_AI_DeviceInfoGetProviderDevice() - + ``` OH_AI_API const char* OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
+ +**Description** + Obtains the name of a provider device. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** Name of the provider device. +### OH_AI_DeviceInfoSetDeviceId() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetDeviceId (OH_AI_DeviceInfoHandle device_info, size_t device_id ) +``` + +**Description** + +Sets the ID of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| device_id | NNRt device ID. | + +**Since** + +10 + + ### OH_AI_DeviceInfoSetEnableFP16() - + ``` OH_AI_API void OH_AI_DeviceInfoSetEnableFP16 (OH_AI_DeviceInfoHandle device_info, bool is_fp16 ) ``` -**Description**
-Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. - **Parameters** +**Description** + +Sets whether to enable float16 inference. This function is available only for CPU and GPU devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| is_fp16 | Whether to enable float16 inference. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| is_fp16 | Whether to enable the float16 inference mode. | ### OH_AI_DeviceInfoSetFrequency() - + ``` OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency ) ``` -**Description**
+ +**Description** + Sets the NPU frequency type. This function is available only for NPU devices. - **Parameters** +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance| + + +### OH_AI_DeviceInfoSetPerformanceMode() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode (OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode ) +``` + +**Description** + +Sets the performance mode of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| mode | NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode).| + +**Since** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance | +10 + + +### OH_AI_DeviceInfoSetPriority() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetPriority (OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority ) +``` + +**Description** + +Sets the priority of an NNRt task. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| priority | NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority). | + +**Since** + +10 ### OH_AI_DeviceInfoSetProvider() - + ``` OH_AI_API void OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char * provider ) ``` -**Description**
-Sets the name of a provider. - **Parameters** +**Description** + +Sets the provider name. -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| provider | Provider name. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| provider | Provider name. | ### OH_AI_DeviceInfoSetProviderDevice() - + ``` OH_AI_API void OH_AI_DeviceInfoSetProviderDevice (OH_AI_DeviceInfoHandle device_info, const char * device ) ``` -**Description**
+ +**Description** + Sets the name of a provider device. - **Parameters** +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| device | Name of the provider device, for example, CPU. | + + +### OH_AI_GetAllNNRTDeviceDescs() + + +``` +OH_AI_API NNRTDeviceDesc* OH_AI_GetAllNNRTDeviceDescs (size_t * num) +``` + +**Description** + +Obtains the descriptions of all NNRt devices in the system. + +**Parameters** + +| Name| Description | +| ---- | ------------------------ | +| num | Number of NNRt devices.| + +**Returns** + +Pointer to the array of the NNRt device descriptions. If the operation fails, **NULL** is returned. + +**Since** + +10 + + +### OH_AI_GetDeviceIdFromNNRTDeviceDesc() + + +``` +OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| device | Name of the provider device, for example, CPU. | +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device ID. + +**Since** + +10 + + +### OH_AI_GetNameFromNNRTDeviceDesc() + + +``` +OH_AI_API const char* OH_AI_GetNameFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device name from the specified NNRt device description. + +**Parameters** + +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device name. The value is a pointer that points to a constant string, which is held by **desc**. The caller does not need to destroy it separately. + +**Since** + +10 + + +### OH_AI_GetTypeFromNNRTDeviceDesc() + + +``` +OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device type from the specified NNRt device description. + +**Parameters** + +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype). + +**Since** + +10 ### OH_AI_ModelBuild() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelBuild (OH_AI_ModelHandle model, const void * model_data, size_t data_size, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) ``` -**Description**
+ +**Description** + Loads and builds a MindSpore model from the memory buffer. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| model_data | Address of the loaded model data in the memory. | -| data_size | Length of the model data. | -| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | -| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | +| Name | Description | +| ------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| model_data | Address of the loaded model data in the memory. | +| data_size | Length of the model data. | +| model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). | +| model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).| **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelBuildFromFile() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile (OH_AI_ModelHandle model, const char * model_path, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) ``` -**Description**
+ +**Description** + Loads and builds a MindSpore model from a model file. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| model_path | Path of the model file. | -| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | -| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | +| Name | Description | +| ------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| model_path | Path of the model file. | +| model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). | +| model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).| **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelCreate() - + ``` OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate () ``` -**Description**
+ +**Description** + Creates a model object. **Returns** @@ -889,35 +1456,39 @@ Pointer to the model object. ### OH_AI_ModelDestroy() - + ``` OH_AI_API void OH_AI_ModelDestroy (OH_AI_ModelHandle * model) ``` -**Description**
+ +**Description** + Destroys a model object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| ### OH_AI_ModelGetInputByTensorName() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) ``` -**Description**
+ +**Description** + Obtains the input tensor of a model by tensor name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| tensor_name | Tensor name. | +| Name | Description | +| ----------- | -------------- | +| model | Pointer to the model object.| +| tensor_name | Tensor name. | **Returns** @@ -926,18 +1497,20 @@ Pointer to the input tensor indicated by **tensor_name**. If the tensor does not ### OH_AI_ModelGetInputs() - + ``` OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs (const OH_AI_ModelHandle model) ``` -**Description**
+ +**Description** + Obtains the input tensor array structure of a model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| **Returns** @@ -946,39 +1519,43 @@ Tensor array structure corresponding to the model input. ### OH_AI_ModelGetOutputByTensorName() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) ``` -**Description**
+ +**Description** + Obtains the output tensor of a model by tensor name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| tensor_name | Tensor name. | +| Name | Description | +| ----------- | -------------- | +| model | Pointer to the model object.| +| tensor_name | Tensor name. | **Returns** -Pointer to the output tensor indicated by **tensor_name**. If the tensor does not exist in the input, **null** will be returned. +Pointer to the input tensor indicated by **tensor_name**. If the tensor does not exist, **null** will be returned. ### OH_AI_ModelGetOutputs() - + ``` OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs (const OH_AI_ModelHandle model) ``` -**Description**
+ +**Description** + Obtains the output tensor array structure of a model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| **Returns** @@ -987,126 +1564,138 @@ Tensor array structure corresponding to the model output. ### OH_AI_ModelPredict() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelPredict (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_TensorHandleArray * outputs, const OH_AI_KernelCallBack before, const OH_AI_KernelCallBack after ) ``` -**Description**
+ +**Description** + Performs model inference. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| inputs | Tensor array structure corresponding to the model input. | -| outputs | Pointer to the tensor array structure corresponding to the model output. | -| before | Callback function executed before model inference. | -| after | Callback function executed after model inference. | +| Name | Description | +| ------- | ------------------------------------ | +| model | Pointer to the model object. | +| inputs | Tensor array structure corresponding to the model input. | +| outputs | Pointer to the tensor array structure corresponding to the model output.| +| before | Callback function executed before model inference. | +| after | Callback function executed after model inference. | **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelResize() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelResize (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_ShapeInfo * shape_infos, size_t shape_info_num ) ``` -**Description**
+ +**Description** + Adjusts the input tensor shapes of a built model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| inputs | Tensor array structure corresponding to the model input. | -| shape_infos | Input shape array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence. | -| shape_info_num | Length of the input shape array. | +| Name | Description | +| -------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| inputs | Tensor array structure corresponding to the model input. | +| shape_infos | Input shape information array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence.| +| shape_info_num | Length of the shape information array. | **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_TensorClone() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone (OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Clones a tensor. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Pointer to the tensor to clone. | +| Name | Description | +| ------ | ------------------ | +| tensor | Pointer to the tensor to clone.| **Returns** -Handle of the new tensor object. +Defines the handle of a tensor object. ### OH_AI_TensorCreate() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate (const char * name, OH_AI_DataType type, const int64_t * shape, size_t shape_num, const void * data, size_t data_len ) ``` -**Description**
+ +**Description** + Creates a tensor object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| name | Tensor name. | -| type | Tensor data type. | -| shape | Tensor dimension array. | -| shape_num | Length of the tensor dimension array. | -| data | Data pointer. | -| data_len | Data length. | +| Name | Description | +| --------- | ------------------ | +| name | Tensor name. | +| type | Tensor data type. | +| shape | Tensor dimension array. | +| shape_num | Length of the tensor dimension array.| +| data | Data pointer. | +| data_len | Data length. | **Returns** -Handle of the tensor object. +Defines the handle of a tensor object. ### OH_AI_TensorDestroy() - + ``` OH_AI_API void OH_AI_TensorDestroy (OH_AI_TensorHandle * tensor) ``` -**Description**
+ +**Description** + Destroys a tensor object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Level-2 pointer to the tensor handle. | +| Name | Description | +| ------ | ------------------------ | +| tensor | Level-2 pointer to the tensor handle.| ### OH_AI_TensorGetData() - + ``` OH_AI_API const void* OH_AI_TensorGetData (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the pointer to tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1115,18 +1704,20 @@ Pointer to tensor data. ### OH_AI_TensorGetDataSize() - + ``` OH_AI_API size_t OH_AI_TensorGetDataSize (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the number of bytes of the tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1135,38 +1726,42 @@ Number of bytes of the tensor data. ### OH_AI_TensorGetDataType() - + ``` OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType (const OH_AI_TensorHandle tensor) ``` -**Description**
-Obtains the data type of a tensor. - **Parameters** +**Description** + +Obtains the tensor type. -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +**Parameters** + +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** -Data type of the tensor. +Tensor data type. ### OH_AI_TensorGetElementNum() - + ``` OH_AI_API int64_t OH_AI_TensorGetElementNum (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the number of tensor elements. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1175,18 +1770,20 @@ Number of tensor elements. ### OH_AI_TensorGetFormat() - + ``` OH_AI_API OH_AI_Format OH_AI_TensorGetFormat (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the tensor data format. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1195,38 +1792,42 @@ Tensor data format. ### OH_AI_TensorGetMutableData() - + ``` OH_AI_API void* OH_AI_TensorGetMutableData (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** -Pointer to variable tensor data. +Pointer to tensor data. ### OH_AI_TensorGetName() - + ``` OH_AI_API const char* OH_AI_TensorGetName (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the name of a tensor. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1235,106 +1836,118 @@ Tensor name. ### OH_AI_TensorGetShape() - + ``` OH_AI_API const int64_t* OH_AI_TensorGetShape (const OH_AI_TensorHandle tensor, size_t * shape_num ) ``` -**Description**
-Obtains the shape of a tensor. - **Parameters** +**Description** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| shape_num | Length of the tensor shape array. | +Obtains the tensor shape. + +**Parameters** + +| Name | Description | +| --------- | ---------------------------------------------- | +| tensor | Handle of the tensor object. | +| shape_num | Length of the tensor shape array.| **Returns** -Tensor shape array. +Shape array. ### OH_AI_TensorSetData() - + ``` OH_AI_API void OH_AI_TensorSetData (OH_AI_TensorHandle tensor, void * data ) ``` -**Description**
+ +**Description** + Sets the tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| data | Data pointer. | +| Name | Description | +| ------ | ---------------- | +| tensor | Handle of the tensor object. | +| data | Data pointer.| ### OH_AI_TensorSetDataType() - + ``` OH_AI_API void OH_AI_TensorSetDataType (OH_AI_TensorHandle tensor, OH_AI_DataType type ) ``` -**Description**
-Sets the data type of a tensor. - **Parameters** +**Description** + +Sets the tensor data type. -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| type | Data type. For details, see [OH_AI_DataType](#oh_ai_datatype). | +**Parameters** + +| Name | Description | +| ------ | --------------------------------------------------- | +| tensor | Handle of the tensor object. | +| type | Data type, which is specified by [OH_AI_DataType](#oh_ai_datatype).| ### OH_AI_TensorSetFormat() - + ``` OH_AI_API void OH_AI_TensorSetFormat (OH_AI_TensorHandle tensor, OH_AI_Format format ) ``` -**Description**
+ +**Description** + Sets the tensor data format. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| format | Tensor data format. | +| Name | Description | +| ------ | ------------------ | +| tensor | Handle of the tensor object. | +| format | Tensor data format.| ### OH_AI_TensorSetName() - + ``` -OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char * name ) +OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char *name ) ``` -**Description**
-Sets the name of a tensor. - **Parameters** +**Description** + +Sets the tensor name. + +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| name | Tensor name. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| +| name | Tensor name. | ### OH_AI_TensorSetShape() - + ``` OH_AI_API void OH_AI_TensorSetShape (OH_AI_TensorHandle tensor, const int64_t * shape, size_t shape_num ) ``` -**Description**
-Sets the shape of a tensor. - **Parameters** +**Description** + +Sets the tensor shape. + +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| shape | Tensor shape array. | -| shape_num | Length of the tensor shape array. | +| Name | Description | +| --------- | ------------------ | +| tensor | Handle of the tensor object. | +| shape | Shape array. | +| shape_num | Length of the tensor shape array.| diff --git a/en/application-dev/reference/native-apis/_o_h___cursor.md b/en/application-dev/reference/native-apis/_o_h___cursor.md new file mode 100644 index 0000000000000000000000000000000000000000..d2574c8aba7d46bc93c9ed77920d6990562834c8 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___cursor.md @@ -0,0 +1,39 @@ +# OH_Cursor + + +## Overview + +Defines a result set. + +It provides APIs to access the result set obtained by querying the RDB store. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [id](_r_d_b.md) | Unique identifier of the **OH_Cursor** struct.| +| [getColumnCount](_r_d_b.md#getcolumncount) | Pointer to the function used to obtain the number of columns in the result set.| +| [getColumnType](_r_d_b.md#getcolumntype) | Pointer to the function used to obtain the column type based on the specified column index.| +| [getColumnIndex](_r_d_b.md#getcolumnindex) | Pointer to the function used to obtain the column index based on the specified column name.| +| [getColumnName](_r_d_b.md#getcolumnname) | Pointer to the function used to obtain the column name based on the specified column index.| +| [getRowCount](_r_d_b.md#getrowcount) | Pointer to the function used to obtain the number of rows in the result set.| +| [goToNextRow](_r_d_b.md#gotonextrow) | Pointer to the function used to go to the next row of the result set.| +| [getSize](_r_d_b.md#getsize) | Pointer to the function used to obtain information about the memory required when the column data type in the result set is **BLOB** or **TEXT**.| +| [getText](_r_d_b.md#gettext) | Pointer to the function used to obtain the value in the form of a string based on the specified column and the current row.| +| [getInt64](_r_d_b.md#getint64) | Pointer to the function used to obtain the value of the int64_t type based on the specified column and the current row.| +| [getReal](_r_d_b.md#getreal) | Pointer to the function used to obtain the value of the double type based on the specified column and the current row.| +| [getBlob](_r_d_b.md#getblob) | Pointer to the function used to obtain the value in the form of a byte array based on the specified column and the current row.| +| [isNull](_r_d_b.md#isnull-12) | Pointer to the function used to check whether the value in the specified column is null.| +| [close](_r_d_b.md#close) | Pointer to the function used to close a result set.| diff --git a/en/application-dev/reference/native-apis/_o_h___predicates.md b/en/application-dev/reference/native-apis/_o_h___predicates.md new file mode 100644 index 0000000000000000000000000000000000000000..c02ac4d93e38e7bd4437eb2f697724c29234812c --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___predicates.md @@ -0,0 +1,48 @@ +# OH_Predicates + + +## Overview + +Defines the predicates. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [id](_r_d_b.md#id-14) | Unique identifier of the **OH_Predicates** struct.| +| [equalTo](_r_d_b.md#equalto) | Pointer to the function used to set a predicates object to match the field whose value is equal to the specified value.| +| [notEqualTo](_r_d_b.md#notequalto) | Pointer to the function used to set a predicates object to match the field whose value is not equal to the specified value.| +| [beginWrap](_r_d_b.md#beginwrap) | Pointer to the function used to add a left parenthesis to the predicates.| +| [endWrap](_r_d_b.md#endwrap) | Pointer to the function used to add a right parenthesis to the predicates.| +| [orOperate](_r_d_b.md#oroperate) | Pointer to the function used to add the OR operator to the predicates.| +| [andOperate](_r_d_b.md#andoperate) | Pointer to the function used to add the AND operator to the predicates.| +| [isNull](_r_d_b.md#isnull-22) | Pointer to the function used to set a predicates object to match the field whose value is null.| +| [isNotNull](_r_d_b.md#isnotnull) | Pointer to the function used to set a predicates object to match the field whose value is not null.| +| [like](_r_d_b.md#like) | Pointer to the function used to set a predicates object to match a string that is similar to the specified value.| +| [between](_r_d_b.md#between) | Pointer to the function used to set a predicates object to match the field whose value is within the specified range.| +| [notBetween](_r_d_b.md#notbetween) | Pointer to the function used to set a predicates object to match the field whose value is out of the specified range.| +| [greaterThan](_r_d_b.md#greaterthan) | Pointer to the function used to set a predicates object to match the field with value greater than the specified value.| +| [lessThan](_r_d_b.md#lessthan) | Pointer to the function used to set a predicates object to match the field with value less than the specified value.| +| [greaterThanOrEqualTo](_r_d_b.md#greaterthanorequalto) | Pointer to the function used to set a predicates object to match the field with value greater than or equal to the specified value.| +| [lessThanOrEqualTo](_r_d_b.md#lessthanorequalto) | Pointer to the function used to set a predicates object to match the field with value less than or equal to the specified value.| +| [orderBy](_r_d_b.md#orderby) | Pointer to the function used to set a predicates object to sort the values in a column in ascending or descending order.| +| [distinct](_r_d_b.md#distinct) | Pointer to the function used to set a predicates object to filter out duplicate records.| +| [limit](_r_d_b.md#limit) | Pointer to the function used to set a predicates object to specify the maximum number of records.| +| [offset](_r_d_b.md#offset) | Pointer to the function used to set a predicates object to specify the start position of the returned result.| +| [groupBy](_r_d_b.md#groupby) | Pointer to the function used to set a predicates object to group rows that have the same value into summary rows.| +| [in](_r_d_b.md#in) | Pointer to the function used to set a predicates object to match the field with the value within the specified range.| +| [notIn](_r_d_b.md#notin) | Pointer to the function used to set a predicates object to match the field with the value out of the specified range.| +| [clear](_r_d_b.md#clear-12) | Pointer to the function used to clear a predicates instance.| +| [destroyPredicates](_r_d_b.md#destroypredicates) | Destroys an **OH_Predicates** object and reclaims the memory occupied.| diff --git a/en/application-dev/reference/native-apis/_o_h___rdb___config.md b/en/application-dev/reference/native-apis/_o_h___rdb___config.md new file mode 100644 index 0000000000000000000000000000000000000000..dd038af19093f2130667e78a7b38e0dc43d9c448 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___rdb___config.md @@ -0,0 +1,26 @@ +# OH_Rdb_Config + + +## Overview + +Defines the RDB store configuration. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [path](_r_d_b.md#path) | Path of the database file.| +| [isEncrypt](_r_d_b.md#isencrypt) | Whether to encrypt the RDB store.| +| [securityLevel](_r_d_b.md#securitylevel) | RDB store security level [OH_Rdb_SecurityLevel](_r_d_b.md#oh_rdb_securitylevel).| diff --git a/en/application-dev/reference/native-apis/_o_h___rdb___store.md b/en/application-dev/reference/native-apis/_o_h___rdb___store.md new file mode 100644 index 0000000000000000000000000000000000000000..c57ebe39dbf8739ce7b1f62340e0a404454e4926 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___rdb___store.md @@ -0,0 +1,24 @@ +# OH_Rdb_Store + + +## Overview + +Defines the RDB store type. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [id](_r_d_b.md#id-44) | Unique identifier of the **OH_Rdb_Store** struct.| diff --git a/en/application-dev/reference/native-apis/_o_h___v_bucket.md b/en/application-dev/reference/native-apis/_o_h___v_bucket.md new file mode 100644 index 0000000000000000000000000000000000000000..ff0386db852df79e82e58139dfb1177a26b79036 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___v_bucket.md @@ -0,0 +1,32 @@ +# OH_VBucket + + +## Overview + +Defines the types of the key and value in a KV pair. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [id](_r_d_b.md#id-34) | Unique identifier of the **OH_VBucket** struct.| +| [capability](_r_d_b.md#capability) | Number of the KV pairs in the struct.| +| [putText](_r_d_b.md#puttext-12) | Puts a char value into the **OH_VBucket** object in the given column.| +| [putInt64](_r_d_b.md#putint64-12) | Puts an int64_t value into the **OH_VBucket** object in the given column.| +| [putReal](_r_d_b.md#putreal) | Puts a double value into the **OH_VBucket** object in the given column.| +| [putBlob](_r_d_b.md#putblob) | Puts a const uint8_t value into the **OH_VBucket** object in the given column.| +| [putNull](_r_d_b.md#putnull) | Puts a null value into the **OH_VBucket** object in the given column.| +| [clear](_r_d_b.md#clear-22) | Clears an **OH_VBucket** object.| +| [destroyValuesBucket](_r_d_b.md#destroyvaluesbucket) | Destroys an **OH_VBucket** object and reclaims the memory occupied.| diff --git a/en/application-dev/reference/native-apis/_o_h___v_object.md b/en/application-dev/reference/native-apis/_o_h___v_object.md new file mode 100644 index 0000000000000000000000000000000000000000..4c6232eecf485ea13ba9496e32265ff2af56a461 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___v_object.md @@ -0,0 +1,29 @@ +# OH_VObject + + +## Overview + +Defines the allowed data field types. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Member Variables + +| Name| Description| +| -------- | -------- | +| [id](_r_d_b.md#id-24) | Unique identifier of the **OH_VObject** struct.| +| [putInt64](_r_d_b.md#putint64-22) | Converts a single parameter or an array of the int64 type into a value of the OH_VObject type.| +| [putDouble](_r_d_b.md#putdouble) | Converts a single parameter or an array of the int64 type into a value of the OH_VObject type.| +| [putText](_r_d_b.md#puttext-22) | Converts a character array of the char type to a value of the OH_VObject type.| +| [putTexts](_r_d_b.md#puttexts) | Converts a string array of the char type to a value of the OH_VObject type.| +| [destroyValueObject](_r_d_b.md#destroyvalueobject) | Destroys an OH_VObject object and reclaims the memory occupied.| diff --git a/en/application-dev/reference/native-apis/_r_d_b.md b/en/application-dev/reference/native-apis/_r_d_b.md new file mode 100644 index 0000000000000000000000000000000000000000..48b4394514d3da53f00cfc0272496f8b864220e2 --- /dev/null +++ b/en/application-dev/reference/native-apis/_r_d_b.md @@ -0,0 +1,2323 @@ +# RDB + + +## Overview + +The relational database (RDB) store manages data based on relational models. The RDB store provides a complete mechanism for managing local databases based on the underlying SQLite. It provides a series of methods for performing operations, such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements to satisfy different needs in complicated scenarios. + +\@syscap SystemCapability.DistributedDataManager.RelationalStore.Core + +**Since** + +10 + + +## Summary + + +### Files + +| Name| Description| +| -------- | -------- | +| [oh_cursor.h](oh__cursor_8h.md) | Provides APIs to access the result set obtained by querying the RDB store.
File to include: \| +| [oh_predicates.h](oh__predicates_8h.md) | Defines the predicates for RDB stores.
File to include: \| +| [oh_value_object.h](oh__value__object_8h.md) | Provides type conversion methods.
File to include: \| +| [oh_values_bucket.h](oh__values__bucket_8h.md) | Defines the types of the key and value in a key-value (KV) pair.
File to include: \| +| [relational_store.h](relational__store_8h.md) | Provides APIs to manage an RDB store.
File to include: \| +| [relational_store_error_code.h](relational__store__error__code_8h.md) | Declares the error codes used for RDB stores.
File to include: \| + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_Cursor](_o_h___cursor.md) | Defines a result set.| +| [OH_Predicates](_o_h___predicates.md) | Defines a **predicates** object.| +| [OH_VObject](_o_h___v_object.md) | Defines the allowed data field types.| +| [OH_VBucket](_o_h___v_bucket.md) | Defines the types of the key and value in a KV pair.| +| [OH_Rdb_Config](_o_h___rdb___config.md) | Defines the RDB store configuration.| +| [OH_Rdb_Store](_o_h___rdb___store.md) | Defines the RDB store type.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_Cursor](#oh_cursor) | Indicates a result set.| +| [OH_Predicates](#oh_predicates) | Indicates a **predicates** object.| +| [OH_VObject](#oh_vobject) | Indicates the allowed data field types.| +| [OH_VBucket](#oh_vbucket) | Indicates the types of the key and value in a KV pair.| +| [OH_Rdb_ErrCode](#oh_rdb_errcode) | Indicates error codes.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_ColumnType](#oh_columntype) {
TYPE_NULL = 0, TYPE_INT64, TYPE_REAL, TYPE_TEXT,
TYPE_BLOB
} | Enumerates the field types in an RDB store.| +| [OH_OrderType](#oh_ordertype) { ASC = 0, DESC = 1 } | Enumerates the sorting types.| +| [OH_Rdb_SecurityLevel](#oh_rdb_securitylevel) { S1 = 1, S2, S3, S4 } | Enumerates the RDB store security levels.| +| [OH_Rdb_ErrCode](#oh_rdb_errcode) {
RDB_ERR = -1, RDB_OK = 0, E_BASE = 14800000, RDB_E_NOT_SUPPORTED = 801,
RDB_E_ERROR = E_BASE, RDB_E_INVALID_ARGS = (E_BASE + 1), RDB_E_CANNOT_UPDATE_READONLY = (E_BASE + 2), RDB_E_REMOVE_FILE = (E_BASE + 3),
RDB_E_EMPTY_TABLE_NAME = (E_BASE + 5), RDB_E_EMPTY_VALUES_BUCKET = (E_BASE + 6), RDB_E_EXECUTE_IN_STEP_QUERY = (E_BASE + 7), RDB_E_INVALID_COLUMN_INDEX = (E_BASE + 8),
RDB_E_INVALID_COLUMN_TYPE = (E_BASE + 9), RDB_E_EMPTY_FILE_NAME = (E_BASE + 10), RDB_E_INVALID_FILE_PATH = (E_BASE + 11), RDB_E_TRANSACTION_IN_EXECUTE = (E_BASE + 12),
RDB_E_INVALID_STATEMENT = (E_BASE + 13), RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION = (E_BASE + 14), RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION = (E_BASE + 15), RDB_E_NO_TRANSACTION_IN_SESSION = (E_BASE + 16),
RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION = (E_BASE + 17), RDB_E_NO_ROW_IN_QUERY = (E_BASE + 18), RDB_E_INVALID_BIND_ARGS_COUNT = (E_BASE + 19), RDB_E_INVALID_OBJECT_TYPE = (E_BASE + 20),
RDB_E_INVALID_CONFLICT_FLAG = (E_BASE + 21), RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY = (E_BASE + 22), RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET = (E_BASE + 23), RDB_E_STEP_RESULT_SET_CROSS_THREADS = (E_BASE + 24),
RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED = (E_BASE + 25), RDB_E_STEP_RESULT_IS_AFTER_LAST = (E_BASE + 26), RDB_E_STEP_RESULT_QUERY_EXCEEDED = (E_BASE + 27), RDB_E_STATEMENT_NOT_PREPARED = (E_BASE + 28),
RDB_E_EXECUTE_RESULT_INCORRECT = (E_BASE + 29), RDB_E_STEP_RESULT_CLOSED = (E_BASE + 30), RDB_E_RELATIVE_PATH = (E_BASE + 31), RDB_E_EMPTY_NEW_ENCRYPT_KEY = (E_BASE + 32),
RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED = (E_BASE + 33), RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY = (E_BASE + 34), RDB_E_STEP_STATEMENT_NOT_INIT = (E_BASE + 35), RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE = (E_BASE + 36),
RDB_E_CREATE_FOLDER_FAIL = (E_BASE + 37), RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL = (E_BASE + 38), RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY = (E_BASE + 39), RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION = (E_BASE + 40),
RDB_E_NOT_SUPPORT = (E_BASE + 41), RDB_E_INVALID_PARCEL = (E_BASE + 42), RDB_E_QUERY_IN_EXECUTE = (E_BASE + 43), RDB_E_SET_PERSIST_WAL = (E_BASE + 44),
RDB_E_DB_NOT_EXIST = (E_BASE + 45), RDB_E_ARGS_READ_CON_OVERLOAD = (E_BASE + 46), RDB_E_WAL_SIZE_OVER_LIMIT = (E_BASE + 47), RDB_E_CON_OVER_LIMIT = (E_BASE + 48)
} | Enumerates the RDB store error codes.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Rdb_CreateValueObject](#oh_rdb_createvalueobject) (void) | Creates an [OH_VObject](_o_h___v_object.md) instance.| +| [OH_Rdb_CreateValuesBucket](#oh_rdb_createvaluesbucket) (void) | Creates an [OH_VBucket](_o_h___v_bucket.md) instance.| +| [OH_Rdb_CreatePredicates](#oh_rdb_createpredicates) (const char \*table) | Creates an [OH_Predicates](_o_h___predicates.md) instance.| +| [OH_Rdb_GetOrOpen](#oh_rdb_getoropen) (const [OH_Rdb_Config](_o_h___rdb___config.md) \*config, int \*errCode) | Obtains an [OH_Rdb_Store](_o_h___rdb___store.md) instance for RDB store operations.| +| [OH_Rdb_CloseStore](#oh_rdb_closestore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Destroys an [OH_Rdb_Store](_o_h___rdb___store.md) object and reclaims the memory occupied by the object.| +| [OH_Rdb_DeleteStore](#oh_rdb_deletestore) (const char \*path) | Deletes an RDB store with the specified database file configuration.| +| [OH_Rdb_Insert](#oh_rdb_insert) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*table, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket) | Inserts a row of data into a table.| +| [OH_Rdb_Update](#oh_rdb_update) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket, [OH_Predicates](_o_h___predicates.md) \*predicates) | Updates data in an RDB store based on specified conditions.| +| [OH_Rdb_Delete](#oh_rdb_delete) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates) | Deletes data from an RDB store based on specified conditions.| +| [OH_Rdb_Query](#oh_rdb_query) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates, const char \*const \*columnNames, int length) | Queries data in an RDB store based on specified conditions.| +| [OH_Rdb_Execute](#oh_rdb_execute) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Executes an SQL statement but returns no value.| +| [OH_Rdb_ExecuteQuery](#oh_rdb_executequery) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Executes the SQL statement to query data in an RDB store.| +| [OH_Rdb_BeginTransaction](#oh_rdb_begintransaction) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Starts the transaction before executing the SQL statement.| +| [OH_Rdb_RollBack](#oh_rdb_rollback) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Rolls back the SQL statements executed.| +| [OH_Rdb_Commit](#oh_rdb_commit) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Commits the executed SQL statements.| +| [OH_Rdb_Backup](#oh_rdb_backup) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Backs up an RDB store in the specified directory.| +| [OH_Rdb_Restore](#oh_rdb_restore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Restores an RDB store from the specified database backup file.| +| [OH_Rdb_GetVersion](#oh_rdb_getversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int \*version) | Obtains the RDB store version.| +| [OH_Rdb_SetVersion](#oh_rdb_setversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int version) | Sets the RDB store version.| + + +### Variables + +| Name| Description| +| -------- | -------- | +| OH_Cursor::id | Unique identifier of the **OH_Cursor** struct.| +| [OH_Cursor::getColumnCount](#getcolumncount) | Pointer to the function used to obtain the number of columns in the result set.| +| [OH_Cursor::getColumnType](#getcolumntype) | Pointer to the function used to obtain the column type based on the specified column index.| +| [OH_Cursor::getColumnIndex](#getcolumnindex) | Pointer to the function used to obtain the column index based on the specified column name.| +| [OH_Cursor::getColumnName](#getcolumnname) | Pointer to the function used to obtain the column name based on the specified column index.| +| [OH_Cursor::getRowCount](#getrowcount) | Pointer to the function used to obtain the number of rows in the result set.| +| [OH_Cursor::goToNextRow](#gotonextrow) | Pointer to the function used to go to the next row of the result set.| +| [OH_Cursor::getSize](#getsize) | Pointer to the function used to obtain information about the memory required when the column data type in the result set is **BLOB** or **TEXT**.| +| [OH_Cursor::getText](#gettext) | Pointer to the function used to obtain the value in the form of a string based on the specified column and the current row.| +| [OH_Cursor::getInt64](#getint64) | Pointer to the function used to obtain the value of the int64_t type based on the specified column and the current row.| +| [OH_Cursor::getReal](#getreal) | Pointer to the function used to obtain the value of the double type based on the specified column and the current row.| +| [OH_Cursor::getBlob](#getblob) | Pointer to the function used to obtain the value in the form of a byte array based on the specified column and the current row.| +| [OH_Cursor::isNull](#isnull-12) | Pointer to the function used to check whether the value in the specified column is null.| +| [OH_Cursor::close](#close) | Pointer to the function used to close a result set. | +| [OH_Predicates::id](#id-14) | Unique identifier of the **OH_Predicates** struct.| +| [OH_Predicates::equalTo](#equalto) | Pointer to the function used to set a predicates object to match the field whose value is equal to the specified value.| +| [OH_Predicates::notEqualTo](#notequalto) | Pointer to the function used to set a predicates object to match the field whose value is not equal to the specified value.| +| [OH_Predicates::beginWrap](#beginwrap) | Pointer to the function used to add a left parenthesis to the predicates.| +| [OH_Predicates::endWrap](#endwrap) | Pointer to the function used to add a right parenthesis to the predicates.| +| [OH_Predicates::orOperate](#oroperate) | Pointer to the function used to add the OR operator to the predicates.| +| [OH_Predicates::andOperate](#andoperate) | Pointer to the function used to add the AND operator to the predicates.| +| [OH_Predicates::isNull](#isnull-22) | Pointer to the function used to set a predicates object to match the field whose value is null.| +| [OH_Predicates::isNotNull](#isnotnull) | Pointer to the function used to set a predicates object to match the field whose value is not null.| +| [OH_Predicates::like](#like) | Pointer to the function used to set a predicates object to match a string that is similar to the specified value.| +| [OH_Predicates::between](#between) | Pointer to the function used to set a predicates object to match the field whose value is within the specified range.| +| [OH_Predicates::notBetween](#notbetween) | Pointer to the function used to set a predicates object to match the field whose value is out of the specified range.| +| [OH_Predicates::greaterThan](#greaterthan) | Pointer to the function used to set a predicates object to match the field with value greater than the specified value.| +| [OH_Predicates::lessThan](#lessthan) | Pointer to the function used to set a predicates object to match the field with value less than the specified value.| +| [OH_Predicates::greaterThanOrEqualTo](#greaterthanorequalto) | Pointer to the function used to set a predicates object to match the field with value greater than or equal to the specified value.| +| [OH_Predicates::lessThanOrEqualTo](#lessthanorequalto) | Pointer to the function used to set a predicates object to match the field with value less than or equal to the specified value.| +| [OH_Predicates::orderBy](#orderby) | Pointer to the function used to set a predicates object to sort the values in a column in ascending or descending order.| +| [OH_Predicates::distinct](#distinct) | Pointer to the function used to set a predicates object to filter out duplicate records.| +| [OH_Predicates::limit](#limit) | Pointer to the function used to set a predicates object to specify the maximum number of records.| +| [OH_Predicates::offset](#offset) | Pointer to the function used to set a predicates object to specify the start position of the returned result.| +| [OH_Predicates::groupBy](#groupby) | Pointer to the function used to set a predicates object to group rows that have the same value into summary rows.| +| [OH_Predicates::in](#in) | Pointer to the function used to set a predicates object to match the field with the value within the specified range.| +| [OH_Predicates::notIn](#notin) | Pointer to the function used to set a predicates object to match the field with the value out of the specified range.| +| [OH_Predicates::clear](#clear-12) | Pointer to the function used to clear a predicates instance.| +| [OH_Predicates::destroyPredicates](#destroypredicates) | Destroys an [OH_Predicates](_o_h___predicates.md) object and reclaims the memory occupied.| +| [OH_VObject::id](#id-24) | Unique identifier of the **OH_VObject** struct.| +| [OH_VObject::putInt64](#putint64-22) | Converts a single parameter or an array of the int64 type into a value of the [OH_VObject](_o_h___v_object.md) type.| +| [OH_VObject::putDouble](#putdouble) | Converts a single parameter or an array of the double type into a value of the [OH_VObject](_o_h___v_object.md) type.| +| [OH_VObject::putText](#puttext-22) | Converts a character array of the char type to a value of the [OH_VObject](_o_h___v_object.md) type.| +| [OH_VObject::putTexts](#puttexts) | Converts a string array of the char type to a value of the [OH_VObject](_o_h___v_object.md) type.| +| [OH_VObject::destroyValueObject](#destroyvalueobject) | Destroys an [OH_VObject](_o_h___v_object.md) object and reclaims the memory occupied.| +| [OH_VBucket::id](#id-34) | Unique identifier of the **OH_VBucket** struct.| +| [OH_VBucket::capability](#capability) | Number of the KV pairs in the struct.| +| [OH_VBucket::putText](#puttext-12) | Puts a char value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column.| +| [OH_VBucket::putInt64](#putint64-12) | Puts an int64_t value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column.| +| [OH_VBucket::putReal](#putreal) | Puts a double value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column.| +| [OH_VBucket::putBlob](#putblob) | Puts a const uint8_t value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column.| +| [OH_VBucket::putNull](#putnull) | Puts a null value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column.| +| [OH_VBucket::clear](#clear-22) | Clears an [OH_VBucket](_o_h___v_bucket.md) object.| +| [OH_VBucket::destroyValuesBucket](#destroyvaluesbucket) | Destroys an [OH_VBucket](_o_h___v_bucket.md) object and reclaims the memory occupied.| +| [OH_Rdb_Config::path](#path) | Path of the database file.| +| [OH_Rdb_Config::isEncrypt](#isencrypt) | Whether to encrypt the RDB store.| +| [OH_Rdb_Config::securityLevel](#securitylevel) | Set the RDB store security level [OH_Rdb_SecurityLevel](#oh_rdb_securitylevel).| +| [OH_Rdb_Store::id](#id-44) | Unique identifier of the **OH_Rdb_Store** struct.| + + +## Type Description + + +### OH_Cursor + + +``` +typedef struct OH_Cursor OH_Cursor +``` + +**Description** + +Indicates a result set. + +It provides APIs to access the result set obtained by querying the RDB store. + + +### OH_Predicates + + +``` +typedef struct OH_Predicates OH_Predicates +``` + +**Description** + +Indicates a **predicates** object. + + +### OH_Rdb_ErrCode + + +``` +typedef enum OH_Rdb_ErrCode OH_Rdb_ErrCode +``` + +**Description** + +Indicates an error code. + + +### OH_VBucket + + +``` +typedef struct OH_VBucket OH_VBucket +``` + +**Description** + +Indicates the types of the key and value in a KV pair. + + +### OH_VObject + + +``` +typedef struct OH_VObject OH_VObject +``` + +**Description** + +Indicates the allowed data field types. + + +## Enum Description + + +### OH_ColumnType + + +``` +enum OH_ColumnType +``` + +**Description** + +Enumerates the field types in an RDB store. + +| Value| Description| +| -------- | -------- | +| TYPE_NULL | NULL type.| +| TYPE_INT64 | INT64 type.| +| TYPE_REAL | REAL type.| +| TYPE_TEXT | TEXT type.| +| TYPE_BLOB | BLOB type.| + + +### OH_OrderType + + +``` +enum OH_OrderType +``` + +**Description** + +Enumerates the sorting types. + +| Value| Description| +| -------- | -------- | +| ASC | Ascending order.| +| DESC | Descending order.| + + +### OH_Rdb_ErrCode + + +``` +enum OH_Rdb_ErrCode +``` + +**Description** + +Enumerates the error codes. + +| Value| Description| +| -------- | -------- | +| RDB_ERR | Execution failed.| +| RDB_OK | Execution successful.| +| E_BASE | Base of the error code.| +| RDB_E_NOT_SUPPORTED | The RDB store does not have this capability.| +| RDB_E_ERROR | Common exception.| +| RDB_E_INVALID_ARGS | Invalid parameter.| +| RDB_E_CANNOT_UPDATE_READONLY | Failed to update data because the RDB store is read-only.| +| RDB_E_REMOVE_FILE | Failed to delete the file.| +| RDB_E_EMPTY_TABLE_NAME | The table name is empty.| +| RDB_E_EMPTY_VALUES_BUCKET | The content of the KV pair is empty.| +| RDB_E_EXECUTE_IN_STEP_QUERY | The SQL statement executed during the query is incorrect.| +| RDB_E_INVALID_COLUMN_INDEX | The column index is invalid.| +| RDB_E_INVALID_COLUMN_TYPE | The column type is invalid.| +| RDB_E_EMPTY_FILE_NAME | The file name is empty.| +| RDB_E_INVALID_FILE_PATH | The file path is invalid.| +| RDB_E_TRANSACTION_IN_EXECUTE | Failed to start the transaction.| +| RDB_E_INVALID_STATEMENT | Failed to precompile the SQL statement.| +| RDB_E_EXECUTE_WRITE_IN_READ_CONNECTION | Failed to perform a write operation in a read connection.| +| RDB_E_BEGIN_TRANSACTION_IN_READ_CONNECTION | Failed to start the transaction in a read connection.| +| RDB_E_NO_TRANSACTION_IN_SESSION | The transaction to start does not exist in the database session.| +| RDB_E_MORE_STEP_QUERY_IN_ONE_SESSION | Multiple queries are executed in a database session.| +| RDB_E_NO_ROW_IN_QUERY | The result set does not contain any record.| +| RDB_E_INVALID_BIND_ARGS_COUNT | The number of parameters bound in the SQL statement is invalid.| +| RDB_E_INVALID_OBJECT_TYPE | The object type is invalid.| +| RDB_E_INVALID_CONFLICT_FLAG | The conflict resolution type is invalid.| +| RDB_E_HAVING_CLAUSE_NOT_IN_GROUP_BY | The HAVING keyword can be used only after GROUP BY.| +| RDB_E_NOT_SUPPORTED_BY_STEP_RESULT_SET | The result set by step is not supported.| +| RDB_E_STEP_RESULT_SET_CROSS_THREADS | Failed to obtain the result set.| +| RDB_E_STEP_RESULT_QUERY_NOT_EXECUTED | The result set query statement is not executed.| +| RDB_E_STEP_RESULT_IS_AFTER_LAST | The cursor of the result set is already in the last row.| +| RDB_E_STEP_RESULT_QUERY_EXCEEDED | The number of result set query times exceeds the limit.| +| RDB_E_STATEMENT_NOT_PREPARED | The SQL statement is not precompiled.| +| RDB_E_EXECUTE_RESULT_INCORRECT | The database execution result is incorrect.| +| RDB_E_STEP_RESULT_CLOSED | The result set has been closed.| +| RDB_E_RELATIVE_PATH | The file path is a relative path.| +| RDB_E_EMPTY_NEW_ENCRYPT_KEY | The new encrypt key is empty.| +| RDB_E_CHANGE_UNENCRYPTED_TO_ENCRYPTED | The RDB store is non-encrypted and cannot be changed.| +| RDB_E_CHANGE_ENCRYPT_KEY_IN_BUSY | The database does not respond when the database key is updated.| +| RDB_E_STEP_STATEMENT_NOT_INIT | The precompiled SQL statement is not initialized.| +| RDB_E_NOT_SUPPORTED_ATTACH_IN_WAL_MODE | The WAL mode does not support the ATTACH operation.| +| RDB_E_CREATE_FOLDER_FAIL | Failed to create the folder.| +| RDB_E_SQLITE_SQL_BUILDER_NORMALIZE_FAIL | Failed to build the SQL statement.| +| RDB_E_STORE_SESSION_NOT_GIVE_CONNECTION_TEMPORARILY | The database session does not provide a connection.| +| RDB_E_STORE_SESSION_NO_CURRENT_TRANSACTION | The transaction does not exist in the database session.| +| RDB_E_NOT_SUPPORT | The current operation is not supported.| +| RDB_E_INVALID_PARCEL | The current PARCEL is invalid.| +| RDB_E_QUERY_IN_EXECUTE | Failed to execute query.| +| RDB_E_SET_PERSIST_WAL | Failed to set the persistence of the database file in WAL mode.| +| RDB_E_DB_NOT_EXIST | The database does not exist.| +| RDB_E_ARGS_READ_CON_OVERLOAD | The number of read connections to set is greater than the limit.| +| RDB_E_WAL_SIZE_OVER_LIMIT | The WAL log file size exceeds the default value.| +| RDB_E_CON_OVER_LIMIT | The number of database connections has reached the limit.| + + +### OH_Rdb_SecurityLevel + + +``` +enum OH_Rdb_SecurityLevel +``` + +**Description** + +Enumerates the RDB store security levels. + +| Value| Description| +| -------- | -------- | +| S1 | The security level of the RDB store is low.
If data leakage occurs, minor impact will be caused.| +| S2 | The security level of the RDB store is medium.
If data leakage occurs, moderate impact will be caused.| +| S3 | The security level of the RDB store is high.
If data leakage occurs, major impact will be caused.| +| S4 | The security level of the RDB store is critical.
If data leakage occurs, critical impact will be caused.| + + +## Function Description + + +### OH_Rdb_Backup() + + +``` +int OH_Rdb_Backup (OH_Rdb_Store * store, const char * databasePath ) +``` + +**Description** + +Backs up an RDB store in the specified directory. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| databasePath | Pointer to the destination directory in which the RDB store is backed up.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_BeginTransaction() + + +``` +int OH_Rdb_BeginTransaction (OH_Rdb_Store * store) +``` + +**Description** + +Starts the transaction before executing the SQL statement. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_CloseStore() + + +``` +int OH_Rdb_CloseStore (OH_Rdb_Store * store) +``` + +**Description** + +Destroys an [OH_Rdb_Store](_o_h___rdb___store.md) object and reclaims the memory occupied. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_Commit() + + +``` +int OH_Rdb_Commit (OH_Rdb_Store * store) +``` + +**Description** + +Commits the executed SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_CreatePredicates() + + +``` +OH_Predicates* OH_Rdb_CreatePredicates (const char * table) +``` + +**Description** + +Creates an [OH_Predicates](_o_h___predicates.md) instance. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| table | Pointer to the name of the database table.| + +**Returns** + +Returns the pointer to the [OH_Predicates](_o_h___predicates.md) instance created if the operation is successful; returns null otherwise. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### OH_Rdb_CreateValueObject() + + +``` +OH_VObject* OH_Rdb_CreateValueObject (void ) +``` + +**Description** + +Creates an [OH_VObject](_o_h___v_object.md) instance. + +**Returns** + +Returns the pointer to the [OH_VObject](_o_h___v_object.md) instance created if the operation is successful; returns null otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### OH_Rdb_CreateValuesBucket() + + +``` +OH_VBucket* OH_Rdb_CreateValuesBucket (void ) +``` + +**Description** + +Creates an [OH_VBucket](_o_h___v_bucket.md) instance. + +**Returns** + +Returns the pointer to the [OH_VBucket](_o_h___v_bucket.md) instance created if the operation is successful; returns null otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### OH_Rdb_Delete() + + +``` +int OH_Rdb_Delete (OH_Rdb_Store * store, OH_Predicates * predicates ) +``` + +**Description** + +Deletes data from an RDB store based on specified conditions. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance, which specifies the deletion conditions.| + +**Returns** + +Returns the number of affected rows if the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md), [OH_Predicates](_o_h___predicates.md). + + +### OH_Rdb_DeleteStore() + + +``` +int OH_Rdb_DeleteStore (const char * path) +``` + +**Description** + +Deletes an RDB store with the specified database file configuration. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| path | Pointer to the database path.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + + +### OH_Rdb_Execute() + + +``` +int OH_Rdb_Execute (OH_Rdb_Store * store, const char * sql ) +``` + +**Description** + +Executes an SQL statement but returns no value. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| sql | Pointer to the SQL statement to execute.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_ExecuteQuery() + + +``` +OH_Cursor* OH_Rdb_ExecuteQuery (OH_Rdb_Store * store, const char * sql ) +``` + +**Description** + +Executes the SQL statement to query data in an RDB store. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| sql | Pointer to the SQL statement to execute.| + +**Returns** + +Returns the pointer to the [OH_Cursor](_o_h___cursor.md) instance if the operation is successful; returns null otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_GetOrOpen() + + +``` +OH_Rdb_Store* OH_Rdb_GetOrOpen (const OH_Rdb_Config * config, int * errCode ) +``` + +**Description** + +Obtains an [OH_Rdb_Store](_o_h___rdb___store.md) instance for RDB store operations. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| config | Pointer to the [OH_Rdb_Config](_o_h___rdb___config.md) instance, which specifies the database configuration.| +| errCode | Function execution status.| + +**Returns** + +Returns the pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance created if the operation is successful; returns null otherwise. + +**See** + +[OH_Rdb_Config](_o_h___rdb___config.md), [OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_GetVersion() + + +``` +int OH_Rdb_GetVersion (OH_Rdb_Store * store, int * version ) +``` + +**Description** + +Obtains the RDB store version. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| version | Pointer to the version number.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_Insert() + + +``` +int OH_Rdb_Insert (OH_Rdb_Store * store, const char * table, OH_VBucket * valuesBucket ) +``` + +**Description** + +Inserts a row of data into a table. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| table | Pointer to the target table.| +| valuesBucket | Pointer to the data [OH_VBucket](_o_h___v_bucket.md) to insert.| + +**Returns** + +Returns the row ID if the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md), [OH_VBucket](_o_h___v_bucket.md). + + +### OH_Rdb_Query() + + +``` +OH_Cursor* OH_Rdb_Query (OH_Rdb_Store * store, OH_Predicates * predicates, const char *const * columnNames, int length ) +``` + +**Description** + +Queries data in an RDB store based on specified conditions. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance, which specifies the query conditions.| +| columnNames | Pointer to the columns to query. If this parameter is not specified, data of columns will be queried.| +| length | Length of the **columnNames** array.| + +**Returns** + +Returns the pointer to the [OH_Cursor](_o_h___cursor.md) instance if the operation is successful; returns null otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md), [OH_Predicates](_o_h___predicates.md), [OH_Cursor](_o_h___cursor.md). + + +### OH_Rdb_Restore() + + +``` +int OH_Rdb_Restore (OH_Rdb_Store * store, const char * databasePath ) +``` + +**Description** + +Restores an RDB store from the specified database backup file. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| databasePath | Pointer to the path of the RDB store backup file.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_RollBack() + + +``` +int OH_Rdb_RollBack (OH_Rdb_Store * store) +``` + +**Description** + +Rolls back the SQL statements executed. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_SetVersion() + + +``` +int OH_Rdb_SetVersion (OH_Rdb_Store * store, int version ) +``` + +**Description** + +Sets the RDB store version. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| version | Version number to set.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md). + + +### OH_Rdb_Update() + + +``` +int OH_Rdb_Update (OH_Rdb_Store * store, OH_VBucket * valuesBucket, OH_Predicates * predicates ) +``` + +**Description** + +Updates data in an RDB store based on specified conditions. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| store | Pointer to the [OH_Rdb_Store](_o_h___rdb___store.md) instance.| +| valuesBucket | Pointer to the new data [OH_VBucket](_o_h___v_bucket.md) to be updated to the table.| +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance, specifying the update conditions.| + +**Returns** + +Returns the number of affected rows if the operation is successful; returns an error code otherwise. + +**See** + +[OH_Rdb_Store](_o_h___rdb___store.md), OH_Bucket, [OH_Predicates](_o_h___predicates.md). + + +## Variable Description + + +### andOperate + + +``` +OH_Predicates*(* OH_Predicates::andOperate) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to add the AND operator to the predicates. + +This method is equivalent to **AND** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the predicates with the AND operator. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### beginWrap + + +``` +OH_Predicates*(* OH_Predicates::beginWrap) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to add a left parenthesis to the predicates. + +This method is equivalent to "(" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the predicates with a left parenthesis. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### between + + +``` +OH_Predicates*(* OH_Predicates::between) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is within the specified range. + +This method is equivalent to **BETWEEN** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the start and end values.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### capability + + +``` +uint16_t OH_VBucket::capability +``` + +**Description** + +Number of the KV pairs in the struct. + + +### clear [1/2] + + +``` +OH_Predicates*(* OH_Predicates::clear) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to clear a predicates instance. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the cleared predicates. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### clear [2/2] + + +``` +int(* OH_VBucket::clear) (OH_VBucket *bucket) +``` + +**Description** + +Clears an [OH_VBucket](_o_h___v_bucket.md) object. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### close + + +``` +int(* OH_Cursor::close) (OH_Cursor *cursor) +``` + +**Description** + +Pointer to the function used to close a result set. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### destroyPredicates + + +``` +int(* OH_Predicates::destroyPredicates) (OH_Predicates *predicates) +``` + +**Description** + +Destroys an [OH_Predicates](_o_h___predicates.md) object and reclaims the memory occupied. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### destroyValueObject + + +``` +int(* OH_VObject::destroyValueObject) (OH_VObject *valueObject) +``` + +**Description** + +Destroys an [OH_VObject](_o_h___v_object.md) object and reclaims the memory occupied. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### destroyValuesBucket + + +``` +int(* OH_VBucket::destroyValuesBucket) (OH_VBucket *bucket) +``` + +**Description** + +Destroys an [OH_VBucket](_o_h___v_bucket.md) object and reclaims the memory occupied. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### distinct + + +``` +OH_Predicates*(* OH_Predicates::distinct) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to set a predicates object to filter out duplicate records. + +This method is equivalent to **DISTINCT** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### endWrap + + +``` +OH_Predicates*(* OH_Predicates::endWrap) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to add a right parenthesis to the predicates. + +This method is equivalent to ")" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the predicates object with a right parenthesis. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### equalTo + + +``` +OH_Predicates*(* OH_Predicates::equalTo) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is equal to the specified value. + +This method is equivalent to "=" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### getBlob + + +``` +int(* OH_Cursor::getBlob) (OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length) +``` + +**Description** + +Pointer to the function used to obtain the value in the form of a byte array based on the specified column and the current row. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| value | Pointer to the value in the form of a byte array obtained.| +| length | Length of the value, which can be obtained by **getSize()**.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getColumnCount + + +``` +int(* OH_Cursor::getColumnCount) (OH_Cursor *cursor, int *count) +``` + +**Description** + +Pointer to the function used to obtain the number of columns in the result set. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| count | Pointer to the number of columns in the result set obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getColumnIndex + + +``` +int(* OH_Cursor::getColumnIndex) (OH_Cursor *cursor, const char *name, int *columnIndex) +``` + +**Description** + +Pointer to the function used to obtain the column index based on the specified column name. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| name | Pointer to the column name in the result set.| +| columnIndex | Pointer to the column index obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getColumnName + + +``` +int(* OH_Cursor::getColumnName) (OH_Cursor *cursor, int32_t columnIndex, char *name, int length) +``` + +**Description** + +Pointer to the function used to obtain the column name based on the specified column index. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| name | Pointer to the column name obtained.| +| length | Length of a column name.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getColumnType + + +``` +int(* OH_Cursor::getColumnType) (OH_Cursor *cursor, int32_t columnIndex, OH_ColumnType *columnType) +``` + +**Description** + +Pointer to the function used to obtain the column type based on the specified column index. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| columnType | Pointer to the [OH_ColumnType](#oh_columntype) obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md), [OH_ColumnType](#oh_columntype). + + +### getInt64 + + +``` +int(* OH_Cursor::getInt64) (OH_Cursor *cursor, int32_t columnIndex, int64_t *value) +``` + +**Description** + +Pointer to the function used to obtain the value of the int64_t type based on the specified column and the current row. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| value | Pointer to the value obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getReal + + +``` +int(* OH_Cursor::getReal) (OH_Cursor *cursor, int32_t columnIndex, double *value) +``` + +**Description** + +Pointer to the function used to obtain the value of the double type based on the specified column and the current row. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| value | Pointer to the value obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getRowCount + + +``` +int(* OH_Cursor::getRowCount) (OH_Cursor *cursor, int *count) +``` + +**Description** + +Pointer to the function used to obtain the number of rows in the result set. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| count | Pointer to the number of columns in the result set obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getSize + + +``` +int(* OH_Cursor::getSize) (OH_Cursor *cursor, int32_t columnIndex, size_t *size) +``` + +**Description** + +Pointer to the function used to obtain information about the memory required when the column data type in the result set is **BLOB** or **TEXT**. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| size | Pointer to the memory size obtained.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### getText + + +``` +int(* OH_Cursor::getText) (OH_Cursor *cursor, int32_t columnIndex, char *value, int length) +``` + +**Description** + +Pointer to the function used to obtain the value in the form of a string based on the specified column and the current row. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| value | Pointer to the value in the form of a string obtained.| +| length | Length of the value, which can be obtained by **getSize()**.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### goToNextRow + + +``` +int(* OH_Cursor::goToNextRow) (OH_Cursor *cursor) +``` + +**Description** + +Pointer to the function used to go to the next row of the result set. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### greaterThan + + +``` +OH_Predicates*(* OH_Predicates::greaterThan) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with value greater than the specified value. + +This method is equivalent to ">" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### greaterThanOrEqualTo + + +``` +OH_Predicates*(* OH_Predicates::greaterThanOrEqualTo) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with value greater than or equal to the specified value. + +This method is equivalent to ">=" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### groupBy + + +``` +OH_Predicates*(* OH_Predicates::groupBy) (OH_Predicates *predicates, char const *const *fields, int length) +``` + +**Description** + +Pointer to the function used to set a predicates object to group rows that have the same value into summary rows. + +This method is equivalent to **GROUP BY** in the SQL statement. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| fields | Pointer to the names of the columns by which the records are grouped.| +| length | Length of the **fields** value.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### id [1/4] + + +``` +int64_t OH_Predicates::id +``` + +**Description** + +Unique identifier of the **OH_Predicates** struct. + + +### id [2/4] + + +``` +int64_t OH_VObject::id +``` + +**Description** + +Unique identifier of the **OH_VObject** struct. + + +### id [3/4] + + +``` +int64_t OH_VBucket::id +``` + +**Description** + +Unique identifier of the **OH_VBucket** struct. + + +### id [4/4] + + +``` +int64_t OH_Rdb_Store::id +``` + +**Description** + +Unique identifier of the **OH_Rdb_Store** struct. + + +### in + + +``` +OH_Predicates*(* OH_Predicates::in) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with the value within the specified range. + +This method is equivalent to **IN** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value range.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### isEncrypt + + +``` +bool OH_Rdb_Config::isEncrypt +``` + +**Description** + +Whether to encrypt the RDB store. + + +### isNotNull + + +``` +OH_Predicates*(* OH_Predicates::isNotNull) (OH_Predicates *predicates, const char *field) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is not null. + +This method is equivalent to **IS NOT NULL** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### isNull [1/2] + + +``` +int(* OH_Cursor::isNull) (OH_Cursor *cursor, int32_t columnIndex, bool *isNull) +``` + +**Description** + +Pointer to the function used to check whether the value in the specified column is null. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| cursor | Pointer to the [OH_Cursor](_o_h___cursor.md) instance.| +| columnIndex | Column index.| +| isNull | Pointer to the value returned. The value **true** means the value is null; the value **false** means the opposite.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_Cursor](_o_h___cursor.md). + + +### isNull [2/2] + + +``` +OH_Predicates*(* OH_Predicates::isNull) (OH_Predicates *predicates, const char *field) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is null. + +This method is equivalent to **IS NULL** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### lessThan + + +``` +OH_Predicates*(* OH_Predicates::lessThan) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with value less than the specified value. + +This method is equivalent to "<" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### lessThanOrEqualTo + + +``` +OH_Predicates*(* OH_Predicates::lessThanOrEqualTo) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with value less than or equal to the specified value. + +This method is equivalent to "<=" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### like + + +``` +OH_Predicates*(* OH_Predicates::like) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match a string that is similar to the specified value. + +This method is equivalent to **LIKE** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### limit + + +``` +OH_Predicates*(* OH_Predicates::limit) (OH_Predicates *predicates, unsigned int value) +``` + +**Description** + +Pointer to the function used to set a predicates object to specify the maximum number of records. + +This method is equivalent to **LIMIT** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| value | Maximum number of data records.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### notBetween + + +``` +OH_Predicates*(* OH_Predicates::notBetween) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is out of the specified range. + +This method is equivalent to **NOT BETWEEN** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### notEqualTo + + +``` +OH_Predicates*(* OH_Predicates::notEqualTo) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field whose value is not equal to the specified value. + +This method is equivalent to "!=" in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### notIn + + +``` +OH_Predicates*(* OH_Predicates::notIn) (OH_Predicates *predicates, const char *field, OH_VObject *valueObject) +``` + +**Description** + +Pointer to the function used to set a predicates object to match the field with the value out of the specified range. + +This method is equivalent to **NOT IN** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance, which specifies the value range to match.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_VObject](_o_h___v_object.md). + + +### offset + + +``` +OH_Predicates*(* OH_Predicates::offset) (OH_Predicates *predicates, unsigned int rowOffset) +``` + +**Description** + +Pointer to the function used to set a predicates object to specify the start position of the returned result. + +This method is equivalent to **OFFSET** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| rowOffset | Start position of the returned result. The value is a positive integer.| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### orderBy + + +``` +OH_Predicates*(* OH_Predicates::orderBy) (OH_Predicates *predicates, const char *field, OH_OrderType type) +``` + +**Description** + +Pointer to the function used to set a predicates object to sort the values in a column in ascending or descending order. + +This method is equivalent to **ORDER BY** in the SQL statement. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| +| field | Pointer to the column name in the database table.| +| type | Sorting type [OH_OrderType](#oh_ordertype).| + +**Returns** + +Returns the predicates created. + +**See** + +[OH_Predicates](_o_h___predicates.md), [OH_OrderType](#oh_ordertype). + + +### orOperate + + +``` +OH_Predicates*(* OH_Predicates::orOperate) (OH_Predicates *predicates) +``` + +**Description** + +Pointer to the function used to add the OR operator to the predicates. + +This method is equivalent to **OR** in SQL statements. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| predicates | Pointer to the [OH_Predicates](_o_h___predicates.md) instance.| + +**Returns** + +Returns the predicates with the OR operator. + +**See** + +[OH_Predicates](_o_h___predicates.md). + + +### path + + +``` +const char* OH_Rdb_Config::path +``` + +**Description** + +Path of the database file. + + +### putBlob + + +``` +int(* OH_VBucket::putBlob) (OH_VBucket *bucket, const char *field, const uint8_t *value, uint32_t size) +``` + +**Description** + +Puts a const uint8_t value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| +| field | Pointer to the column name in the database table.| +| value | Pointer to the value to put.| +| size | Length of the value.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### putDouble + + +``` +int(* OH_VObject::putDouble) (OH_VObject *valueObject, double *value, uint32_t count) +``` + +**Description** + +Converts a single parameter or an array of the double type into a value of the [OH_VObject](_o_h___v_object.md) type. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance.| +| value | Pointer to the data to covert.| +| count | If **value** points to a single parameter, **count** is **1**. If **value** points to an array, **count** specifies the length of the array.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### putInt64 [1/2] + + +``` +int(* OH_VBucket::putInt64) (OH_VBucket *bucket, const char *field, int64_t value) +``` + +**Description** + +Puts an int64_t value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| +| field | Pointer to the column name in the database table.| +| value | Value to put.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### putInt64 [2/2] + + +``` +int(* OH_VObject::putInt64) (OH_VObject *valueObject, int64_t *value, uint32_t count) +``` + +**Description** + +Converts a single parameter or an array of the int64 type into a value of the [OH_VObject](_o_h___v_object.md) type. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance.| +| value | Pointer to the data to covert.| +| count | If **value** points to a single parameter, **count** is **1**. If **value** points to an array, **count** specifies the length of the array.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### putNull + + +``` +int(* OH_VBucket::putNull) (OH_VBucket *bucket, const char *field) +``` + +**Description** + +Puts a null value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| +| field | Pointer to the column name in the database table.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### putReal + + +``` +int(* OH_VBucket::putReal) (OH_VBucket *bucket, const char *field, double value) +``` + +**Description** + +Puts the double value into the {OH_VBucket} object of the given column name. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| +| field | Pointer to the column name in the database table.| +| value | Value to put.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### putText [1/2] + + +``` +int(* OH_VBucket::putText) (OH_VBucket *bucket, const char *field, const char *value) +``` + +**Description** + +Puts a char value into the [OH_VBucket](_o_h___v_bucket.md) object in the given column. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| bucket | Pointer to the [OH_VBucket](_o_h___v_bucket.md) instance.| +| field | Pointer to the column name in the database table.| +| value | Pointer to the char value to put.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VBucket](_o_h___v_bucket.md). + + +### putText [2/2] + + +``` +int(* OH_VObject::putText) (OH_VObject *valueObject, const char *value) +``` + +**Description** + +Converts a character array of the char type to a value of the [OH_VObject](_o_h___v_object.md) type. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance.| +| value | Pointer to the character array to convert.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### putTexts + + +``` +int(* OH_VObject::putTexts) (OH_VObject *valueObject, const char **value, uint32_t count) +``` + +**Description** + +Converts a string array of the char type to a value of the [OH_VObject](_o_h___v_object.md) type. + +**Parameters** + +| Name| Description| +| -------- | -------- | +| valueObject | Pointer to the [OH_VObject](_o_h___v_object.md) instance.| +| value | Pointer to the string array to convert.| +| count | Length of the string array to convert.| + +**Returns** + +Returns **RDB_OK** is the operation is successful; returns an error code otherwise. + +**See** + +[OH_VObject](_o_h___v_object.md). + + +### securityLevel + + +``` +enum OH_Rdb_SecurityLevel OH_Rdb_Config::securityLevel +``` + +**Description** + +Set the RDB store security level [OH_Rdb_SecurityLevel](#oh_rdb_securitylevel). diff --git a/en/application-dev/reference/native-apis/context_8h.md b/en/application-dev/reference/native-apis/context_8h.md index f73e70d24871b35a026b39befa08fbebeee5380a..743fdbc9dbfe3d3d4b3b464b0301999631980790 100644 --- a/en/application-dev/reference/native-apis/context_8h.md +++ b/en/application-dev/reference/native-apis/context_8h.md @@ -5,10 +5,11 @@ Provides **Context** APIs for configuring runtime information. -**Since:** +**Since** + 9 -**Related Modules:** +**Related Modules** [MindSpore](_mind_spore.md) @@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | -| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | +| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | +| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object. | -| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object. | -| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | -| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads. | -| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | -| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | -| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | -| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | -| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | -| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | -| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | -| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object. | -| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | -| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | -| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | -| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | -| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | -| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | -| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object.| +| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object.| +| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads.| +| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads.| +| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.| +| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores.| +| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread.| +| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores.| +| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available.| +| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported.| +| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context.| +| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object.| +| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually.| +| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name.| +| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name.| +| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device.| +| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device.| +| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the device type.| +| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.| +| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.| +| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices.| +| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices.| +| [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system.| +| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| +| [OH_AI_GetNameFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description.| +| [OH_AI_GetTypeFromNNRTDeviceDesc](_mind_spore.md#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description.| +| [OH_AI_CreateNNRTDeviceInfoByName](_mind_spore.md#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_CreateNNRTDeviceInfoByType](_mind_spore.md#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](_mind_spore.md#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_DeviceInfoSetDeviceId](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices.| diff --git a/en/application-dev/reference/native-apis/oh__cursor_8h.md b/en/application-dev/reference/native-apis/oh__cursor_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d51368c059814c2f7e4f0daa34e7cc0e6484254b --- /dev/null +++ b/en/application-dev/reference/native-apis/oh__cursor_8h.md @@ -0,0 +1,40 @@ +# oh_cursor.h + + +## Overview + +Provides APIs to access the result set obtained by querying the RDB store. + +A result set is a set of results returned by **query()**. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_Cursor](_o_h___cursor.md) | Defines a result set.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_Cursor](_r_d_b.md#oh_cursor) | Indicates a result set.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_ColumnType](_r_d_b.md#oh_columntype) {
TYPE_NULL = 0, TYPE_INT64, TYPE_REAL, TYPE_TEXT,
TYPE_BLOB
} | Enumerates the field types in an RDB store.| diff --git a/en/application-dev/reference/native-apis/oh__predicates_8h.md b/en/application-dev/reference/native-apis/oh__predicates_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7da0125f074e26e2a21e3d5d16a8e10dc15a48ec --- /dev/null +++ b/en/application-dev/reference/native-apis/oh__predicates_8h.md @@ -0,0 +1,38 @@ +# oh_predicates.h + + +## Overview + +Defines the predicates for RDB stores. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_Predicates](_o_h___predicates.md) | Defines a **predicates** object. | + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_Predicates](_r_d_b.md#oh_predicates) | Indicates a **predicates** object. | + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_OrderType](_r_d_b.md#oh_ordertype) { ASC = 0, DESC = 1 } | Enumerates the sorting types.| diff --git a/en/application-dev/reference/native-apis/oh__value__object_8h.md b/en/application-dev/reference/native-apis/oh__value__object_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..26e733a794d1b18de4b3787129763662da086468 --- /dev/null +++ b/en/application-dev/reference/native-apis/oh__value__object_8h.md @@ -0,0 +1,32 @@ +# oh_value_object.h + + +## Overview + +Provides type conversion methods. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_VObject](_o_h___v_object.md) | Defines the allowed data field types.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_VObject](_r_d_b.md#oh_vobject) | Indicates the allowed data field types. | + diff --git a/en/application-dev/reference/native-apis/oh__values__bucket_8h.md b/en/application-dev/reference/native-apis/oh__values__bucket_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..e6b7fc7a03d69d5099aaf1e03c90779c0ac2d7a6 --- /dev/null +++ b/en/application-dev/reference/native-apis/oh__values__bucket_8h.md @@ -0,0 +1,32 @@ +# oh_values_bucket.h + + +## Overview + +Defines the types of the key and value in a key-value (KV) pair. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_VBucket](_o_h___v_bucket.md) | Defines the types of the key and value in a KV pair.| + + +### Types + +| Name| Description| +| -------- | -------- | +| [OH_VBucket](_r_d_b.md#oh_vbucket) | Indicates the types of the key and value in a KV pair. | + diff --git a/en/application-dev/reference/native-apis/relational__store_8h.md b/en/application-dev/reference/native-apis/relational__store_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..6336866e5364f0294bd9c0a678d7cfe02e15d283 --- /dev/null +++ b/en/application-dev/reference/native-apis/relational__store_8h.md @@ -0,0 +1,57 @@ +# relation_store.h + + +## Overview + +Provides APIs to manage a relational database (RDB) store. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Structs + +| Name| Description| +| -------- | -------- | +| [OH_Rdb_Config](_o_h___rdb___config.md) | Defines the RDB store configuration.| +| [OH_Rdb_Store](_o_h___rdb___store.md) | Defines the RDB store type.| + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_Rdb_SecurityLevel](_r_d_b.md#oh_rdb_securitylevel) { S1 = 1, S2, S3, S4 } | Enumerates the RDB store security levels.| + + +### Functions + +| Name| Description| +| -------- | -------- | +| [OH_Rdb_CreateValueObject](_r_d_b.md#oh_rdb_createvalueobject) (void) | Creates an [OH_VObject](_o_h___v_object.md) instance.| +| [OH_Rdb_CreateValuesBucket](_r_d_b.md#oh_rdb_createvaluesbucket) (void) | Creates an [OH_VBucket](_o_h___v_bucket.md) instance.| +| [OH_Rdb_CreatePredicates](_r_d_b.md#oh_rdb_createpredicates) (const char \*table) | Creates an [OH_Predicates](_o_h___predicates.md) instance.| +| [OH_Rdb_GetOrOpen](_r_d_b.md#oh_rdb_getoropen) (const [OH_Rdb_Config](_o_h___rdb___config.md) \*config, int \*errCode) | Obtains an [OH_Rdb_Store](_o_h___rdb___store.md) instance for RDB store operations.| +| [OH_Rdb_CloseStore](_r_d_b.md#oh_rdb_closestore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Destroys an [OH_Rdb_Store](_o_h___rdb___store.md) object and reclaims the memory occupied by the object.| +| [OH_Rdb_DeleteStore](_r_d_b.md#oh_rdb_deletestore) (const char \*path) | Deletes an RDB store with the specified database file configuration.| +| [OH_Rdb_Insert](_r_d_b.md#oh_rdb_insert) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*table, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket) | Inserts a row of data into a table.| +| [OH_Rdb_Update](_r_d_b.md#oh_rdb_update) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_VBucket](_o_h___v_bucket.md) \*valuesBucket, [OH_Predicates](_o_h___predicates.md) \*predicates) | Updates data in an RDB store based on specified conditions.| +| [OH_Rdb_Delete](_r_d_b.md#oh_rdb_delete) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates) | Deletes data from an RDB store based on specified conditions.| +| [OH_Rdb_Query](_r_d_b.md#oh_rdb_query) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, [OH_Predicates](_o_h___predicates.md) \*predicates, const char \*const \*columnNames, int length) | Queries data in an RDB store based on specified conditions.| +| [OH_Rdb_Execute](_r_d_b.md#oh_rdb_execute) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Executes the SQL statement that returns no value.| +| [OH_Rdb_ExecuteQuery](_r_d_b.md#oh_rdb_executequery) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*sql) | Queries data in an RDB store based on the SQL statements executed.| +| [OH_Rdb_BeginTransaction](_r_d_b.md#oh_rdb_begintransaction) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Starts the transaction before executing the SQL statements.| +| [OH_Rdb_RollBack](_r_d_b.md#oh_rdb_rollback) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Rolls back the SQL statements executed. | +| [OH_Rdb_Commit](_r_d_b.md#oh_rdb_commit) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store) | Commits the executed SQL statements.| +| [OH_Rdb_Backup](_r_d_b.md#oh_rdb_backup) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Backs up the RDB store in the specified path.| +| [OH_Rdb_Restore](_r_d_b.md#oh_rdb_restore) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, const char \*databasePath) | Restores an RDB store from the specified database backup file.| +| [OH_Rdb_GetVersion](_r_d_b.md#oh_rdb_getversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int \*version) | Obtains the RDB store version.| +| [OH_Rdb_SetVersion](_r_d_b.md#oh_rdb_setversion) ([OH_Rdb_Store](_o_h___rdb___store.md) \*store, int version) | Sets the RDB store version.| diff --git a/en/application-dev/reference/native-apis/relational__store__error__code_8h.md b/en/application-dev/reference/native-apis/relational__store__error__code_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..8b1cae8744922650a10d9632e107c16b7fb644d8 --- /dev/null +++ b/en/application-dev/reference/native-apis/relational__store__error__code_8h.md @@ -0,0 +1,24 @@ +# relation_error_code.h + + +## Overview + +Declares the error codes used for relational database (RDB) stores. + +**Since** + +10 + +**Related Modules** + +[RDB](_r_d_b.md) + + +## Summary + + +### Enums + +| Name| Description| +| -------- | -------- | +| [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode) { RDB_ERR_INVALID_ARGS = -2, RDB_ERR = -1, RDB_ERR_OK = 0 } | Enumerates the RDB store error codes. | diff --git a/en/application-dev/reference/syscap-list.md b/en/application-dev/reference/syscap-list.md index f550259f41ac46bd6841083f87c412ba4e6c9a0f..bf294b95d9b536f5a71c41618896c26b893ab2fe 100644 --- a/en/application-dev/reference/syscap-list.md +++ b/en/application-dev/reference/syscap-list.md @@ -359,6 +359,14 @@ Power management display | ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | | Yes | No | Yes | Yes | No | Yes | No | No | +## SystemCapability.PowerManager.DisplayPowerManager.Lite + +Lite device capabilities of the system power management display + +| Default | Sports Watch| Smart Watch| Tablet| Head Unit| Smart TV| Smart Vision | Router | +| ------- | ------ | ------ | ---- | ---- | ------ | ------------ | ------ | +| Yes | Yes | Yes | Yes | No | Yes | No | No | + ## SystemCapability.PowerManager.ThermalManager Temperature control diff --git a/en/application-dev/task-management/background-task-overview.md b/en/application-dev/task-management/background-task-overview.md index c17f1b3827430f5b0aa2408fb4289276c63942a9..3132796740f148f69af750ff7982af4b9fe54133 100644 --- a/en/application-dev/task-management/background-task-overview.md +++ b/en/application-dev/task-management/background-task-overview.md @@ -46,9 +46,11 @@ Adhere to the following constraints and rules when using transient tasks: - **Quota mechanism**: To prevent abuse of the keepalive, each application has a certain quota every day (dynamically adjusted based on user habits). The default quota for a single day is 10 minutes, and the maximum quota for each request is 3 minutes. After using up the quota, an application cannot request transient tasks. Therefore, applications should cancel their request immediately after the transient tasks are complete, to avoid quota consumption. (Note: The quota refers to the requested duration and does not include the time when the application runs in the background.) ## Continuous Tasks + Continuous tasks provide background running lifecycle support for services that can be directly perceived by users and need to run in the background. For example, if a service needs to play audio or continue with navigation and positioning in the background, which can be perceived by users, it can execute a continuous task in the respective background mode. ### Background Mode Classification + OpenHarmony provides 9 background modes for services that require continuous task execution. **Table 1** Background modes for continuous tasks @@ -66,6 +68,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas | taskKeeping | Computing task | A computing task is running | Effective only for specific devices | ### Restrictions on Using Continuous Tasks + - If a user triggers a perceivable task, such as broadcasting and navigation, the corresponding background mode is triggered. When the task is started, the system forcibly displays a notification to the user. - If the task is complete, the application should exit the background mode. If the system detects that an application is not using the resources in the corresponding background mode when the application is running in the background, the application is suspended. - Ensure that the requested continuous task background mode matches the application type. If the background mode does not match the application type, the system will suspend the task once it detects the issue. @@ -73,6 +76,7 @@ OpenHarmony provides 9 background modes for services that require continuous tas - An ability can request only one continuous task at a time. If an application has multiple abilities, you can request a continuous task for each ability. ## Work Scheduler Tasks + The Work Scheduler provides a mechanism for an application to execute a non-real-time task, for example, data learning, when the system is idle. The system places the Work Scheduler tasks requested by applications in a queue and determines the optimal scheduling time of each task based on the storage space, power consumption, temperature, and more. Persistence is supported. This means that a requested Work Scheduler task can be triggered when the application exits or the device restarts. ### Restrictions on Using Work Scheduler Tasks @@ -103,6 +107,7 @@ The use of the Work Scheduler must comply with the following restrictions and ru - The carried parameters can be of the number, string, or boolean type. ## Efficiency Resources + Efficiency resources are classified into software (WORK_SCHEDULER, COMMON_EVENT, and TIMER) and hardware resources (CPU, GPS, BLUETOOTH, and AUDIO). An application can perform different operations based on the requested efficiency resources. @@ -126,6 +131,7 @@ An application can perform different operations based on the requested efficienc | AUDIO | 64 | AUDIO resources, which prevent audio resources from being proxied when the application is suspended. | ### Restrictions on Using Efficiency Resources + - Applications or processes are responsible for requesting and releasing efficiency resources. A process can release the resources requested by itself, whereas an application can release the resources requested by both itself and its processes. For example, an application requests CPU resources, and its process requests CPU and WORK_SCHEDULER resources. If the application initiates CPU resource release, the CPU resources requested by the process are also released. However, the WORK_SCHEDULER resources are not released. If the process initiates CPU resource release, the CPU resources requested by the application are retained until being released by the application. - If persistent resources and non-persistent resources of the same type are requested, the persistent resources overwrite the non-persistent resources and they will not be released upon a timeout. For example, if an application first requests 10-second CPU resources and then requests persistent CPU resources at the 5th second, the CPU resources become persistent and will not be released at the tenth second. If the application releases the CPU resources at the 8th second, both types of CPU resources are released. - The WORK_SCHEDULER resources can be requested and released by applications, but not by processes. diff --git a/en/application-dev/tools/packing-tool.md b/en/application-dev/tools/packing-tool.md index db0f232d6c53cdb7bf47c540010c2aea3f83d06c..dd219250333636f96f715530b3ef8c86f0810223 100644 --- a/en/application-dev/tools/packing-tool.md +++ b/en/application-dev/tools/packing-tool.md @@ -1,7 +1,7 @@ -# Packing and Unpacking Tools +# Packing Tool ## Overview -The packing tool packs compiled files for installation and release. The packing tool supports the generation of application packages (HAP), application sets (APP) to launch to the application market, quick fix packages (HQF), quick fix packages (APPQF) to launch to the application market, static shared libraries (HAR), and dynamic shared libraries (HSP). The unpacking tool is used to unpack the HAP, APP, HQF, APPQF, HAR, and HSP files and parse the HAP, HSP, APP, and APPQF files. Generally, the packing process is automatically carried out in DevEco Studio. However, you can also use the JAR package of the packing tool to pack files. The JAR package is stored in the **toolchains** directory in the SDK path. +The packing tool packs compiled files for installation and release. The packing tool supports the generation of HAP (an application package), APP (application set to launch to the application market), HQF (quick fix package), APPQF (quick fix package to launch to the application market ), HAR (static shared library), and HSP (dynamic shared library) files. The unpacking tool is used to unpack the HAP, APP, HQF, APPQF, HAR, and HSP files and parse the HAP, HSP, APP, and APPQF files. Generally, the packing process is automatically carried out in DevEco Studio. However, you can also use the JAR package of the packing tool to pack files. The JAR package is stored in the **toolchains** directory in the SDK path. ## Packing Commands @@ -15,7 +15,7 @@ You can use the JAR package of the packing tool to generate an HAP file by impor ``` - java -jar app_packing_tool.jar --mode hap --json-path