diff --git a/en/application-dev/device/inputdevice-guidelines.md b/en/application-dev/device/inputdevice-guidelines.md index da6eef71d750b74e01d1ea8a9eaaf49b1bf598cb..c15955d9b01239605d0ce1afa9bfe5f693b22940 100644 --- a/en/application-dev/device/inputdevice-guidelines.md +++ b/en/application-dev/device/inputdevice-guidelines.md @@ -29,7 +29,6 @@ When a user enters text, the input method determines whether to launch the virtu 1. Call the **getDeviceList** API to obtain the list of connected input devices. Call the **getKeyboardType** API to traverse all connected devices to check whether a physical keyboard exists. If a physical keyboard exists, mark the physical keyboard as connected. This step ensures that your application detects all inserted input devices before listening for device hot swap events. 2. Call the **on** API to listen for device hot swap events. If a physical keyboard is inserted, mark the physical keyboard as connected. If a physical keyboard is removed, mark the physical keyboard as disconnected. -3. When a user enters text, check whether a physical keyboard is connected. If a physical keyboard is not connected, launch the virtual keyboard. ```js @@ -65,6 +64,4 @@ try { } catch (error) { console.log(`Execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } - // 3. Determine whether to launch the virtual keyboard based on the value of isPhysicalKeyboardExist. - // TODO ``` diff --git a/en/application-dev/dfx/apprecovery-guidelines.md b/en/application-dev/dfx/apprecovery-guidelines.md index cf31f6ae4c18f0de1e850cad5cb34be2122bc0d0..5c297d3357d83feb0b6c1465f67ec2b085ade7b3 100644 --- a/en/application-dev/dfx/apprecovery-guidelines.md +++ b/en/application-dev/dfx/apprecovery-guidelines.md @@ -125,12 +125,12 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; #### Actively Saving the Application State and Restoring Data -- Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback. +- Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback. For details about its usage, see [errorManager](../reference/apis/js-apis-app-ability-errorManager.md). ```ts var registerId = -1; var callback = { - onUnhandledException: function (errMsg) { + onUnhandledException(errMsg) { console.log(errMsg); appRecovery.saveAppState(); appRecovery.restartApp(); @@ -142,7 +142,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'; console.log("[Demo] EntryAbility onWindowStageCreate") globalThis.registerObserver = (() => { - registerId = errorManager.registerErrorObserver(callback); + registerId = errorManager.on('error', callback); }) windowStage.loadContent("pages/index", null); @@ -158,7 +158,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state, // Ability has called to save app data console.log("[Demo] EntryAbility onSaveState") wantParams["myData"] = "my1234567"; - return AbilityConstant.onSaveResult.ALL_AGREE; + return AbilityConstant.OnSaveResult.ALL_AGREE; } ``` @@ -188,8 +188,8 @@ onWindowStageDestroy() { console.log("[Demo] EntryAbility onWindowStageDestroy") globalThis.unRegisterObserver = (() => { - errorManager.unregisterErrorObserver(registerId, (result) => { - console.log("[Demo] result " + result.code + ";" + result.message) + errorManager.off('error', registerId, (err) => { + console.error("[Demo] err:", err); }); }) } @@ -217,7 +217,7 @@ export default class EntryAbility extends Ability { // Ability has called to save app data console.log("[Demo] EntryAbility onSaveState") wantParams["myData"] = "my1234567"; - return AbilityConstant.onSaveResult.ALL_AGREE; + return AbilityConstant.OnSaveResult.ALL_AGREE; } } ``` diff --git a/en/application-dev/quick-start/app-configuration-file.md b/en/application-dev/quick-start/app-configuration-file.md index f68ec8ee66f92910e0f11c4a8b705bfd7bbfd08d..cbc97f24e80d576f747d69eeeaec89f50c264283 100644 --- a/en/application-dev/quick-start/app-configuration-file.md +++ b/en/application-dev/quick-start/app-configuration-file.md @@ -19,7 +19,9 @@ This document gives an overview of the **app.json5** configuration file. To star "debug": false, "car": { "minAPIVersion": 8, - } + }, + "targetBundleName": "com.application.test", + "targetPriority": 50 }, } ``` @@ -28,11 +30,12 @@ This document gives an overview of the **app.json5** configuration file. To star As shown above, the **app.json5** file contains several tags. -**Table 1** Tags in the app.json5 file + **Table 1** Tags in the app.json5 file | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | bundleName | Bundle name, which uniquely identifies an application. The value must comply with the following rules:
- Consists of letters, digits, underscores (_), and periods (.).
- Starts with a letter.
- Contains 7 to 127 bytes.
You are advised to use the reverse domain name notation, for example, *com.example.demo*, where the first part is the domain suffix **com**, the second part is the vendor/individual name, and the third part is the application name, which can be of multiple levels.
If an application is built with the system source code, you are advised to name it in *com.ohos.demo* notation, where **ohos** signifies that the application is an OpenHarmony system application.| String| No| +| bundleType| Bundle type, which is used to distinguish applications and atomic services.
- **app**: The bundle is a common application.
- **atomicService**: The bundle is an atomic service.
- **shared**: The bundle is a shared object application. | String| Yes (initial value: **"app"**)| | debug | Whether the application can be debugged. This tag is generated during compilation and building in DevEco Studio.
- **true**: The application can be debugged.
- **false**: The application cannot be debugged.| Boolean| Yes (initial value: **false**)| | icon | [Icon of the application](../application-models/application-component-configuration-stage.md). The value is an icon resource index.| String| No| | label | [Name of the application](../application-models/application-component-configuration-stage.md). The value is a string resource index.| String| No| @@ -51,3 +54,5 @@ As shown above, the **app.json5** file contains several tags. | wearable | Wearable-specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.
When running on wearables, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | car | Head unit–specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.
When running on head units, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| | default | Default device–specific configuration, which includes **minAPIVersion** and **distributedNotificationEnabled** attributes.
When running on default devices, the application applies the attribute settings under this tag and ignores the general counterparts.| Object| Yes (initial value: general settings in the **app.json5** file)| +|targetBundleName|Target application name of the bundle. The value rule and range are the same as those of **bundleName**.|String|Yes (if the initial value is used, the target application is not an application with the overlay feature)| +|targetPriority|Priority of the application. When **targetBundleName** is set, the application is an application with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)| diff --git a/en/application-dev/quick-start/application-package-structure-fa.md b/en/application-dev/quick-start/application-package-structure-fa.md index 6909481445ecb1219c30ed3ae425d6b475662805..a9d647385fa9b5e9a47ebcf4ea77e546d4df3108 100644 --- a/en/application-dev/quick-start/application-package-structure-fa.md +++ b/en/application-dev/quick-start/application-package-structure-fa.md @@ -11,7 +11,7 @@ The difference between the application package structures in the FA model and st - The **assets** folder is a collection of all the resource files, library files, and code files in a HAP file. It can be further organized into the **entry** folder and the **js** folder. The **entry** folder stores the **resources** folder and the **resources.index** file. -- The **resources** folder stores resource files (such as strings and images) of the application. +- The **resources** folder stores resource files (such as strings and images) of the application. For details, see [Resource Categories and Access](resource-categories-and-access.md). - The **resources.index** file provides a resource index table, which is generated by DevEco Studio invoking the specific SDK tool. diff --git a/en/application-dev/quick-start/application-package-structure-stage.md b/en/application-dev/quick-start/application-package-structure-stage.md index cb6dc3b12ef12ff249d8afaa9871f901babd9412..0736157fd42b4b6b6a2549e9262a7d25313aa452 100644 --- a/en/application-dev/quick-start/application-package-structure-stage.md +++ b/en/application-dev/quick-start/application-package-structure-stage.md @@ -22,7 +22,7 @@ To develop an application based on the [stage model](application-configuration-f - The HAP file includes folders such as **ets**, **libs**, and **resources** and files such as **resources.index**, **module.json**, and **pack.info**. - The **ets** folder stores bytecode files generated after application code build. - The **libs** folder stores library files, which are .so binary files that contain third-party code on which the OpenHarmony application depends. - - The **resources** folder stores resource files (such as strings and images) of the application. + - The **resources** folder stores resource files (such as strings and images) of the application. For details, see [Resource Categories and Access](resource-categories-and-access.md). - The **resources.index** file provides a resource index table, which is generated when the application project is built in DevEco Studio. - The **module.json** file is the configuration file indispensable in a HAP file. It consists of **module.json5** and **app.json5** in the project configuration. While DevEco Studio provides default configuration, you must modify the configuration as needed. For details about the configuration fields, see [Application Configuration Files in Stage Model](application-configuration-file-overview-stage.md). - The **pack.info** file describes the HAP attributes in the bundle, for example, **bundleName** and **versionCode** in **app** and **name**, **type**, and **abilities** in **module**. The file is automatically generated when DevEco Studio generates the bundle. diff --git a/en/application-dev/quick-start/atomicService.md b/en/application-dev/quick-start/atomicService.md new file mode 100644 index 0000000000000000000000000000000000000000..2c2216bfc22b87411408d2753f04955b89a852f6 --- /dev/null +++ b/en/application-dev/quick-start/atomicService.md @@ -0,0 +1,218 @@ +# Atomic Service + +## Pre-loading by HAP Type + +### HAP File Implementation + +To speed up the initial startup of an atomic service, you can configure it to load on demand with the use of HAP files. HAP files of an atomic service are classified as entry-type or feature-type. The entry-type HAP file contains the page code and related resources required for starting up the atomic service. The feature-type HAP files contain the rest of the code and resources. To start the atomic service, the user only needs to download and install the entry-type HAP file, which minimizes the time for downloading the atomic service. + +#### How to Use + +You create HAP files of an atomic service by creating an atomic service project in DevEco Studio. The basic project directory structure is as follows: + +``` +├── AppScope +| ├── resources +| └── app.json5 +├── entry +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── feature +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── library +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── node_modules +``` + +Note that you must set the **bundleType** field to **atomicService** in the [app.json5](app-configuration-file.md) file, which is located in the **AppScope** folder. The following is an example of the file content: + +```json +{ + "app": { + "bundleName": "com.example.hmservice", + "bundleType":"atomicService", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "targetAPIVersion": 9 + } +} +``` + +For details about HAP files, see [Multi-HAP Design Objectives](multi-hap-objective.md). + +#### Restrictions + +1. The **installationFree** field must be set to **true** in each module-specific configuration file [module.json5](module-configuration-file.md) file. + +2. When packaging an atomic service, comply with the following size rules: + +- The total size of HAP files cannot exceed 10 MB. + +- The size of a HAP file itself and all its dependent [HSP](in-app-hsp.md) cannot exceed 2 MB. + + +### Pre-loading Implementation + +You can configure the system to automatically pre-download required modules when the atomic service enters a module, thereby speeding up module access. + +Currently, pre-loading can be implemented only through configuration, not by invoking APIs. + +#### How to Use + +Pre-loading is triggered after the first frame of the newly accessed module is rendered. You can configure what to pre-load for a module, by setting the **preloads** field under **atomicService** in the [module.json5](module-configuration-file.md) file of the module. The following is an example of the **module.json5** file of the **entry** module, saved in **entry/src/main**: + +```json +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "atomicService": { + "preloads": [ + { + "moduleName": "feature" + } + ] + }, + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} +``` + +In this example, the system automatically pre-loads the **feature** module after the first frame of the **entry** module is rendered. + +#### Restrictions + +[moduleType](../reference/apis/js-apis-bundleManager.md#moduletype) corresponding to moduleName in the **preloads** list cannot be entry. + +## Using Dynamic Shared Packages in Atomic Services + +A [Harmony Shared Package (HSP)](shared-guide.md) is a dynamic shared package for sharing code, C++ libraries, resources, and configuration files among modules. +For details about how to use the HSP within an atomic service, see [In-Application HSP Development](in-app-hsp.md). + +#### How to Use + +Assume that the project directory structure is as follows: +``` +├── AppScope +| ├── resources +| └── app.json5 +├── entry +| └── src/main +| ├── ets +| ├── entryAbility +| └── pages +| └── Index.ets +| ├── resources +| └── module.json5 +├── feature +| └── src/main +| ├── ets +| ├── resources +| └── module.json5 +├── library +| └── src/main +| ├── ets +| └── pages +| └── menu.ets +| ├── resources +| └── module.json5 +├── node_modules +``` + +If you want to add a button in the **entry** module to jump to the menu page (**library/src/main/ets/pages/menu.ets**) in the **library** module, you can write the following code in the **entry/src/main/ets/MainAbility/Index.ets** file of the **entry** module: + +```ts +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + // Add a button to respond to user clicks. + Button() { + Text('click to menu') + .fontSize(30) + .fontWeight(FontWeight.Bold) + } + .type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('40%') + .height('5%') + // Bind click events. + .onClick(() => { + router.pushUrl({ + url: '@bundle:com.example.hmservice/library/ets/pages/menu' + }).then(() => { + console.log("push page success"); + }).catch(err => { + console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`); + }) + } + .width('100%') + } + .height('100%') + } +} +``` + +The input parameter **url** of the **router.pushUrl** API is as follows: +```ets +'@bundle:com.example.hmservice/library/ets/pages/menu' +``` +The **url** content template is as follows: +```ets +'@bundle:bundle name/module name/path/page file name (without the extension .ets)' +``` diff --git a/en/application-dev/quick-start/figures/application_details.jpg b/en/application-dev/quick-start/figures/application_details.jpg new file mode 100644 index 0000000000000000000000000000000000000000..02524b549eaf636e2a8a0f2ec869513d99f1a161 Binary files /dev/null and b/en/application-dev/quick-start/figures/application_details.jpg differ diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md index 8fca81167d6d016376877602de947c4c9cc83bd1..aeb16b360e08d9d89eb3594d28b75cd21f37ca59 100644 --- a/en/application-dev/quick-start/module-configuration-file.md +++ b/en/application-dev/quick-start/module-configuration-file.md @@ -59,7 +59,9 @@ This document gives an overview of the **module.json5** configuration file. To s } } ] - } + }, + "targetModuleName": "feature", + "targetPriority": 50 } ``` @@ -79,7 +81,7 @@ As shown above, the **module.json5** file contains several tags. | mainElement | Name of the entry UIAbility or ExtensionAbility of the module. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)| | [deviceTypes](#devicetypes) | Type of the device on which the module can run.| String array| No (can be left empty)| | deliveryWithInstall | Whether the HAP file of the module will be installed when the user installs the application.
- **true**: The HAP file will be installed when the user installs the application.
- **false**: The HAP file will not be installed when the user installs the application.| Boolean| No| -| installationFree | Whether the module supports the installation-free feature.
- **true**: The module supports the installation-free feature and meets installation-free constraints.
- **false**: The module does not support the installation-free feature.
**NOTE**
- If this tag is set to **true** for an entry-type module, it must also be set to **true** for feature-type modules of the same application.
- If this tag is set to **false** for an entry-type module, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No| +| installationFree | Whether the module supports the installation-free feature.
- **true**: The module supports the installation-free feature and meets installation-free constraints.
- **false**: The module does not support the installation-free feature.
**NOTE**
If this tag is set to **true** for an entry-type module, it must also be set to **true** for feature-type modules of the same application.
If this tag is set to **false** for an entry-type module, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No| | virtualMachine | Type of the target virtual machine (VM) where the module runs. It is used for cloud distribution, such as distribution by the application market and distribution center.
If the target VM type is ArkTS engine, the value is **ark**+*version number*.| String| Yes (initial value: automatically inserted when DevEco Studio builds the HAP file)| | [pages](#pages)| Profile that represents information about each page in the current module. The value can contain a maximum of 255 bytes.| String| No in the UIAbility scenario| | [metadata](#metadata)| Custom metadata of the module. The setting is valid only for the current module, UIAbility, or ExtensionAbility.| Object array| Yes (initial value: left empty)| @@ -87,7 +89,10 @@ As shown above, the **module.json5** file contains several tags. | [extensionAbilities](#extensionabilities) | ExtensionAbility configuration of the module, which is valid only for the current ExtensionAbility component.| Object| Yes (initial value: left empty)| | [requestPermissions](#requestpermissions) | A set of permissions that the application needs to request from the system for running correctly.| Object| Yes (initial value: left empty)| | [testRunner](#testrunner) | Test runner configuration of the module.| Object| Yes (initial value: left empty)| - +| [atomicService](#atomicservice)| Atomic service configuration.| Object| Yes (initial value: left empty) | +| [dependencies](#dependencies)| List of shared libraries on which the current module depends during running.| Object array| Yes (initial value: left empty) | +| targetModuleName | Target module of the bundle. The value is a string with a maximum of 31 bytes. It must be unique in the entire application.|String|Yes (if the initial value is used, the target module is not a module with the overlay feature)| +| targetPriority | Priority of the module. When **targetModuleName** is set, the module is a module with the overlay feature. The value ranges from 1 to 100.|Number|Yes (initial value: **1**)| ## deviceTypes @@ -131,8 +136,21 @@ The **pages** tag is a profile that represents information about specified pages } ``` -Define the **main_pages.json** file under **resources/base/profile** in the development view. The base name of the file (**main_pages** in this example) can be customized, but must be consistent with the information specified by the **pages** tag. The file lists the page information of the current application. +Define the **main_pages.json** file under **resources/base/profile** in the development view. The file name (**main_pages** in this example) can be customized, but must be consistent with the information specified by the **pages** tag. The file lists the page information of the current application, including the route information and the window-related configuration. + + **Table 3** Tags in the pages configuration file +| Name| Description| Data Type| Initial Value Allowed| +| -------- | -------- | -------- | -------- | +| src | Route information about all pages in the JavaScript module, including the page path and page name. The value is an array, each element of which represents a page and the first element represents the home page.| String array| No| +| window | Window-related configuration. | Object| Yes (initial value: left empty)| + + **Table 4** window tag in the pages configuration file + +| Name| Description| Data Type| Initial Value Allowed| +| -------- | -------- | -------- | -------- | +| designWidth | Baseline width for page design. The size of an element is scaled by the actual device width.| Number| Yes (initial value: **720px**)| +| autoDesignWidth | Whether to automatically calculate the baseline width for page design. If it is set to **true**, the **designWidth** attribute becomes invalid. The baseline width is calculated based on the device width and screen density.| Boolean| Yes (initial value: **false**)| ```json { @@ -141,7 +159,11 @@ Define the **main_pages.json** file under **resources/base/profile** in the deve "pages/second/payment", "pages/third/shopping_cart", "pages/four/owner" - ] + ], + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ``` @@ -150,7 +172,7 @@ Define the **main_pages.json** file under **resources/base/profile** in the deve The **metadata** tag represents the custom metadata of the HAP file. The tag value is an array and contains three subtags: **name**, **value**, and **resource**. -**Table 3** metadata +**Table 5** metadata | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -165,7 +187,7 @@ The **metadata** tag represents the custom metadata of the HAP file. The tag val "metadata": [{ "name": "module_metadata", "value": "a test demo for module metadata", - "resource": "$profile:shortcuts_config", + "resource": "$profile:shortcuts_config" }], "abilities": [{ @@ -206,10 +228,13 @@ UIAbility configuration of the module, which is valid only for the current UIAbi The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system uses the icon specified in the **app.json** file as the application icon and displays it on the home screen. -Touching this icon will direct the user to the application details screen in **Settings**. +Touching this icon will direct the user to the application details screen in **Settings**, as shown in Figure 1. To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). +**Objectives**: + +This requirement on application icons is intended to prevent malicious applications from deliberately configuring no icon to block uninstallation attempts. **Setting the application icon to be displayed on the home screen**: @@ -231,40 +256,42 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json }] }], ... - + } } ``` -**Querying an application icon:** -* The HAP file contains ability configuration. - * The application icon is set under **abilities** in the **module.json5** file. +**Display rules of application icons and labels on the home screen:** +* The HAP file contains UIAbility configuration. + * The application icon on the home screen is set under **abilities** in the **module.json5** file. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the icon configured for the ability. - * The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned. - * The returned component name is the component name of the ability. - * When the user touches the home screen icon, the home screen of the ability is displayed. + * The application icon displayed on the home screen is the icon configured for the UIAbility. + * The application label displayed on the home screen is the label configured for the UIAbility. If no label is configured, the bundle name is returned. + * The name of the UIAbility is displayed. + * When the user touches the home screen icon, the home screen of the UIAbility is displayed. * The application has the privilege to hide its icon from the home screen. * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. - * The application icon is not set under **abilities** in the **module.json5** file. + * The application icon on the home screen is not set under **abilities** in the **module.json5** file. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the icon configured under **app**. (The **icon** parameter in the **app.json** file is mandatory.) - * The returned home screen label is the label configured under **app**. (The **label** parameter in the **app.json** file is mandatory.) - * The returned component name is the component name displayed on the application details screen (this component is built in the system). - * Touching the home screen icon will direct the user to the application details screen. + * The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.) + * The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.) + * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. * The application has the privilege to hide its icon from the home screen. * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. -* The HAP file does not contain ability configuration. +* The HAP file does not contain UIAbility configuration. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the icon configured under **app**. (The **icon** parameter in the **app.json** file is mandatory.) - * The returned home screen label is the label configured under **app**. (The **label** parameter in the **app.json** file is mandatory.) - * The returned component name is the component name displayed on the application details screen (this component is built in the system). - * Touching the home screen icon will direct the user to the application details screen. + * The application icon displayed on the home screen is the icon specified under **app**. (The **icon** field in the **app.json** file is mandatory.) + * The application label displayed on the home screen is the label specified under **app**. (The **label** field in the **app.json** file is mandatory.) + * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. * The application has the privilege to hide its icon from the home screen. - * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. + * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen.

+ +**Figure 1** Application details screen +![Application details screen](figures/application_details.jpg) - **Table 4** abilities + + **Table 6** abilities | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -285,14 +312,14 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json | removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the UIAbility component is destroyed.
- **true**: Remove the relevant task from the task list after the UIAbility component is destroyed.
- **false**: Do not remove the relevant task from the task list after the UIAbility component is destroyed.| Boolean| Yes (initial value: **false**)| | orientation | Orientation of the UIAbility component when it is started. The options are as follows:
- **unspecified**: automatically determined by the system.
- **landscape**: landscape mode.
- **portrait**: portrait mode.
- **landscape_inverted**: inverted landscape mode.
- **portrait_inverted**: inverted portrait mode.
- **auto_rotation**: determined by the sensor.
- **auto_rotation_landscape**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes.
- **auto_rotation_portrait**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes.
- **auto_rotation_restricted**: determined by the sensor when the sensor switch is enabled.
- **auto_rotation_landscape_restricted**: determined by the sensor in the horizontal direction, including landscape and inverted landscape modes, when the sensor switch is enabled.
- **auto_rotation_portrait_restricted**: determined by the sensor in the vertical direction, including portrait and inverted portrait modes, when the sensor switch is enabled.
- **locked**: auto rotation disabled.| String| Yes (initial value: **"unspecified"**)| | supportWindowMode | Window mode supported by the UIAbility component. The options are as follows:
- **fullscreen**: full-screen mode.
- **split**: split-screen mode.
- **floating**: floating window mode.| String array| Yes (initial value:
["fullscreen", "split", "floating"])| -| priority | Priority of the UIAbility component. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| Number| Yes (initial value: **0**)| +| priority | Priority of the UIAbility component. In the case of [implicit query](../application-models/explicit-implicit-want-mappings.md), UIAbility components with a higher priority are at the higher place of the returned list. The value is an integer ranging from 0 to 10. The greater the value, the higher the priority.
**NOTE**
This attribute applies only to system applications and does not take effect for third-party applications.| Number| Yes (initial value: **0**)| | maxWindowRatio | Maximum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: maximum aspect ratio supported by the platform)| | minWindowRatio | Minimum aspect ratio supported by the UIAbility component. The minimum value is 0.| Number| Yes (initial value: minimum aspect ratio supported by the platform)| | maxWindowWidth | Maximum window width supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the value of **minWindowWidth** or greater than the maximum window width allowed by the platform. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: maximum window width supported by the platform)| | minWindowWidth | Minimum window width supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the minimum window width allowed by the platform or greater than the value of **maxWindowWidth**. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: minimum window width supported by the platform)| | maxWindowHeight | Maximum window height supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the value of **minWindowHeight** or greater than the maximum window height allowed by the platform. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: maximum window height supported by the platform)| | minWindowHeight | Minimum window height supported by the UIAbility component, in vp. The minimum value is 0, and the value cannot be less than the minimum window height allowed by the platform or greater than the value of **maxWindowHeight**. For details about the window size, see [Constraints](../windowmanager/window-overview.md#constraints).| Number| Yes (initial value: minimum window height supported by the platform)| -| excludeFromMissions | Whether the UIAbility component is displayed in the recent task list.
- **true**: displayed in the recent task list.
- **false**: not displayed in the recent task list.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| Boolean| Yes (initial value: **false**)| +| excludeFromMissions | Whether the UIAbility component is displayed in the recent task list.
- **true**: displayed in the recent task list.
- **false**: not displayed in the recent task list.
**NOTE**
This attribute applies only to system applications and does not take effect for third-party applications.| Boolean| Yes (initial value: **false**)| | recoverable | Whether the application can be recovered to its previous state in case of a detected fault.
- **true**: The application can be recovered to its previous state in case of a detected fault.
- **false**: The application cannot be recovered to its previous state in case of a detected fault.| Boolean| Yes (initial value: **false**)| Example of the **abilities** structure: @@ -348,7 +375,7 @@ Example of the **abilities** structure: The **skills** tag represents the feature set of [wants](../application-models/want-overview.md) that can be received by the UIAbility or ExtensionAbility component. - **Table 5** skills + **Table 7** skills | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -356,7 +383,7 @@ The **skills** tag represents the feature set of [wants](../application-models/w | entities | [Entities](../application-models/actions-entities.md) of wants that can be received.| String array| Yes (initial value: left empty)| |uris | URIs that match the wants.| Object array| Yes (initial value: left empty)| - **Table 6** uris + **Table 8** Internal structure of the uris tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -397,44 +424,11 @@ Example of the **skills** structure: } ``` -**Enhanced implicit query** - -URI-level prefix matching is supported. -When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in. - - - * The query enhancement involves the following APIs: - [@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
- 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
- 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
- 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; - * Configuration requirements
- abilities -> skills -> uris object
- Configuration 1: only **scheme = 'http'**
- Configuration 2: only **(scheme = 'http') + (host = 'example.com')**
- Configuration 3: only **(scheme = 'http') + (host = 'example.com') + (port = '8080')** - * Prefix match
- If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API: - 1. uri = 'https://': No matches
- 2. uri = 'http://': Matches configuration 1
- 3. uri = 'https://example.com': No matches
- 4. uri = 'https://exa.com': No matches
- 5. uri = 'http://exa.com': Matches configuration 1
- 6. uri = 'http://example.com': Matches configuration 1 and configuration 2
- 7. uri = 'https://example.com:8080': No matches
- 8. uri = 'http://exampleaa.com:8080': Matches configuration 1
- 9. uri = 'http://example.com:9180': Matches configuration 1 and configuration 2
- 10. uri = 'http://example.com:8080': Matches configuration 1, configuration 2, and configuration 3
- 11. uri = 'https://example.com:9180/path': No matches
- 12. uri = 'http://exampleap.com:8080/path': Matches configuration 1
- 13. uri = 'http://example.com:9180/path': Matches configuration 1 and configuration 2
- 14. uri = 'http://example.com:8080/path': Matches configuration 1, configuration 2, and configuration 3
- ## extensionAbilities The **extensionAbilities** tag represents the configuration of extensionAbilities, which is valid only for the current extensionAbility. - **Table 7** extensionAbilities + **Table 9** extensionAbilities | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -443,10 +437,10 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie | description | Description of the ExtensionAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description.| String| Yes (initial value: left empty)| | icon | Icon of the ExtensionAbility component. The value is an icon resource index. If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| Yes (initial value: left empty)| | label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.
**NOTE**
If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No| -| type | Type of the ExtensionAbility component. The options are as follows:
- **form**: ExtensionAbility of a widget.
- **workScheduler**: ExtensionAbility of a Work Scheduler task.
- **inputMethod**: ExtensionAbility of an input method.
- **service**: service component running in the background.
- **accessibility**: ExtensionAbility of an accessibility feature.
- **dataShare**: ExtensionAbility for data sharing.
- **fileShare**: ExtensionAbility for file sharing.
- **staticSubscriber**: ExtensionAbility for static broadcast.
- **wallpaper**: ExtensionAbility of the wallpaper.
- **backup**: ExtensionAbility for data backup.
- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.
- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.
- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.
- **print**: ExtensionAbility for the print framework.
**NOTE**
The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No| +| type | Type of the ExtensionAbility component. The options are as follows:
- **form**: ExtensionAbility of a widget.
- **workScheduler**: ExtensionAbility of a Work Scheduler task.
- **inputMethod**: ExtensionAbility of an input method.
- **service**: service component running in the background.
- **accessibility**: ExtensionAbility of an accessibility feature.
- **dataShare**: ExtensionAbility for data sharing.
- **fileShare**: ExtensionAbility for file sharing.
- **staticSubscriber**: ExtensionAbility for static broadcast.
- **wallpaper**: ExtensionAbility of the wallpaper.
- **backup**: ExtensionAbility for data backup.
- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.
- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.
- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.
- **print**: ExtensionAbility for the print framework.
- **driver**: ExtensionAbility for the driver framework.
**NOTE**
The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications.| String| No| | permissions | Permissions required for another application to access the ExtensionAbility component.
The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)| -| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when the type of the **ExtensionAbility** component is set to **dataShare**. | String| Yes (initial value: left empty)| -|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)| +| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when the type of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)| +|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)| | [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)| | exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)| @@ -462,7 +456,7 @@ Example of the **extensionAbilities** structure: "icon": "$media:icon", "label" : "$string:extension_name", "description": "$string:form_description", - "type": "form", + "type": "form", "permissions": ["ohos.abilitydemo.permission.PROVIDER"], "readPermission": "", "writePermission": "", @@ -476,7 +470,7 @@ Example of the **extensionAbilities** structure: "metadata": [ { "name": "ohos.extension.form", - "resource": "$profile:form_config", + "resource": "$profile:form_config", } ] } @@ -494,12 +488,12 @@ The **requestPermissions** tag represents a set of permissions that the applicat > - The permission settings configured in the **requestPermissions** tag apply to the entire application. > - If your application needs to subscribe to an event published by itself and the permissions required for accessing the application are set in the **permissions** tag under **extensionAbilities**, then the application must register the related permissions in the **requestPermissions** tag to receive the event. -**Table 8** requestPermissions +**Table 10** requestPermissions | Name| Description| Data Type| Value Range| Default Value| | -------- | -------- | -------- | -------- | -------- | | name | Permission name. This attribute is mandatory.| String| Custom| –| -| reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.
**NOTE**
If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market, and multi-language adaptation is required.| String| Resource reference of the string type in $string: \*\*\* format| A null value| +| reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.
**NOTE**
If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market. Multi-language adaptation is required.| String| Resource reference of the string type in $string: \*\*\* format| A null value| | usedScene | Scene under which the permission is used. It consists of the **abilities** and **when** sub-attributes. Multiple abilities can be configured.
**NOTE**
This attribute is optional by default. If the permission to request is **user_grant**, the **abilities** sub-attribute is mandatory and **when** is optional.| **abilities**: string array
**when**: string| **abilities**: array of names of UIAbility or ExtensionAbility components
**when**: **inuse** or **always**| **abilities**: null
**when**: null| Example of the **requestPermissions** structure: @@ -534,8 +528,10 @@ The **shortcut** information is identified in **metadata**, where: - **name** indicates the name of the shortcut, identified by **ohos.ability.shortcuts**. - **resource** indicates where the resources of the shortcut are stored. - -| Attribute| Description| Data Type | Default Value| + +**Table 11** shortcuts + +| Name| Description| Data Type | Default Value| | -------- | -------- | -------- | -------- | | shortcutId | ID of the shortcut. The value is a string with a maximum of 63 bytes.| String| No| | label | Label of the shortcut, that is, the text description displayed for the shortcut. The value can be a string or a resource index to the label, with a maximum of 255 bytes.| String| Yes (initial value: left empty)| @@ -544,7 +540,7 @@ The **shortcut** information is identified in **metadata**, where: 1. Configure the **shortcuts_config.json** file in **/resource/base/profile/**. - + ```json { "shortcuts": [ @@ -564,7 +560,7 @@ The **shortcut** information is identified in **metadata**, where: ``` 2. In the **abilities** tag of the **module.json5** file, configure the **metadata** tag for the UIAbility component to which a shortcut needs to be added so that the shortcut configuration file takes effect for the UIAbility. - + ```json { "module": { @@ -601,7 +597,7 @@ The **shortcut** information is identified in **metadata**, where: The **distributionFilter** tag defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover five factors: API version, screen shape, screen size, screen resolution, and country code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional. - **Table 9** distributionFilter + **Table 12** distributionFilter | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -611,28 +607,28 @@ The **distributionFilter** tag defines the rules for distributing HAP files base | countryCode | Code of the country or region to which the application is to be distributed. The value is subject to the ISO-3166-1 standard. Enumerated definitions of multiple countries and regions are supported.| Object array| Yes (initial value: left empty)| - **Table 10** screenShape + **Table 13** Internal structure of the screenShape tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No| | value | Screen shapes. The value can be **circle**, **rect**, or both. Example: Different HAP files can be provided for a smart watch with a circular face and that with a rectangular face.| String array| No| - **Table 11** screenWindow + **Table 14** Internal structure of the screenWindow tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No| | value | Screen width and height, in pixels. The value an array of supported width and height pairs, each in the "width * height" format, for example, **"454 * 454"**.| String array| No| - **Table 12** screenDensity + **Table 15** Internal structure of the screenDensity tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No| | value | Pixel density of the screen, in DPI.| String array| No| - **Table 13** countryCode + **Table 16** Internal structure of the countryCode tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | @@ -699,14 +695,14 @@ Configure **metadata** in the **module** tag in the **module.json5** file. The **testRunner** tag represents the supported test runner. -**Table 14** testRunner +**Table 17** Internal structure of the testRunner tag | Name| Description| Data Type| Initial Value Allowed| | -------- | -------- | -------- | -------- | | name | Name of the test runner object. The value is a string with a maximum of 255 bytes.| String| No| | srcPath | Code path of the test runner. The value is a string with a maximum of 255 bytes.| String| No| -Example of the / structure: +Example of the **testRunner** structure: ```json @@ -720,3 +716,84 @@ Example of the / structure: } } ``` + +## atomicService + +The **atomicService** tag represents the atomic service configuration. It is available only when **bundleType** is set to **atomicService** in the **app.json** file. + +**Table 18** Internal structure of the atomicService tag + +| Name| Description| Data Type| Initial Value Allowed| +| -------- | -------- | -------- | -------- | +| preloads | List of modules to pre-load.| Object array| Yes (initial value: left empty)| + +Example of the **atomicService** structure: + + +```json +{ + "module": { + "atomicService": { + "preloads":[ + { + "moduleName":"feature" + } + ] + } + } +} +``` + +## preloads + +The **preloads** tag represents a list of modules to pre-load in an atomic service. + +**Table 19** Internal structure of the preloads tag + +| Name| Description| Data Type| Initial Value Allowed| +| -------- | -------- | -------- | -------- | +| moduleName | Name of the module to be preloaded when the current module is loaded in the atomic service.| String| No| + +Example of the **preloads** structure: + +```json +{ + "module": { + "atomicService": { + "preloads":[ + { + "moduleName":"feature" + } + ] + } + } +} +``` + +## dependencies + +The **dependencies** tag identifies the list of shared libraries that the module depends on when it is running. + +**Table 20** Internal structure of the dependencies tag + +| Name | Description | Data Type| Initial Value Allowed| +| ----------- | ------------------------------ | -------- | ---------- | +| bundleName | Name of the shared bundle on which the current module depends. | String | Yes| +| moduleName | Module name of the shared bundle on which the current module depends.| String | No| +| versionCode | Version number of the shared bundle. | Number | Yes| + +Example of the **dependencies** structure: + +```json +{ + "module": { + "dependencies": [ + { + "bundleName":"com.share.library", + "moduleName": "library", + "versionCode": 10001 + } + ] + } +} +``` diff --git a/en/application-dev/quick-start/module-structure.md b/en/application-dev/quick-start/module-structure.md index 352a993d5042116105ef5c50ae9138df51c622c9..d4593c12743cff7d6a5da9e10de69c6e4d6b71b5 100644 --- a/en/application-dev/quick-start/module-structure.md +++ b/en/application-dev/quick-start/module-structure.md @@ -192,12 +192,20 @@ Example of the metadata attribute: **By default, application icons cannot be hidden from the home screen in OpenHarmony.** -The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system creates a default icon for the application and displays it on the home screen.
-Touching this icon will direct the user to the application details screen in **Settings**. +The OpenHarmony system imposes a strict rule on the presence of application icons. If no icon is configured in the HAP file of an application, the system creates a default icon for the application and displays it on the home screen. + +Touching this icon will direct the user to the application details screen in **Settings**, as shown in Figure 1. + To hide an application icon from the home screen, you must configure the **AllowAppDesktopIconHide** privilege. For details, see [Application Privilege Configuration Guide](../../device-dev/subsystems/subsys-app-privilege-config-guide.md). +**Objectives**: + +This requirement on application icons is intended to prevent malicious applications from deliberately configuring no icon to block uninstallation attempts. + +**Setting the application icon to be displayed on the home screen**: + +Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. -**Setting the application icon to be displayed on the home screen**:
Set **icon**, **label**, and **skills** under **abilities** in the **config.json** file. In addition, make sure the **skills** configuration contains **ohos.want.action.home** and **entity.system.home**. ``` { "module":{ @@ -220,36 +228,37 @@ To hide an application icon from the home screen, you must configure the **Allow } ``` -**Querying an application icon:** +**Display rules of application icons and labels on the home screen:** * The HAP file contains Page ability configuration. - * The application icon is set under **abilities** in the **config.json** file. + * The application icon on the home screen is set under **abilities** in the **config.json** file. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the icon configured for the ability. - * The returned home screen label is the label configured for the ability. If no label is configured, the bundle name is returned. - * The returned component name is the component name of the ability. - * When the user touches the home screen icon, the home screen of the ability is displayed. + * The application icon displayed on the home screen is the icon configured for the Page ability. + * The application label displayed on the home screen is the label configured for the Page ability. If no label is configured, the bundle name is returned. + * The name of the Page ability is displayed. + * When the user touches the home screen icon, the home screen of the Page ability is displayed. * The application has the privilege to hide its icon from the home screen. * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. - * The application icon is not set under **abilities** in the **config.json** file. + * The application icon on the home screen is not set under **abilities** in the **config.json** file. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the default icon. - *The returned home screen label is the bundle name of the application. - * The returned component name is the component name displayed on the application details screen (this component is built in the system). - * Touching the home screen icon will direct the user to the application details screen. + * The application icon displayed on the home screen is the default icon. + * The application label displayed on the home screen is the bundle name of the application. + * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. * The application has the privilege to hide its icon from the home screen. * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. * The HAP file does not contain Page ability configuration. * The application does not have the privilege to hide its icon from the home screen. - * The returned home screen icon is the default icon. - *The returned home screen label is the bundle name of the application. - * The returned component name is the component name displayed on the application details screen (this component is built in the system). - * Touching the home screen icon will direct the user to the application details screen. + * The application icon displayed on the home screen is the default icon. + * The application label displayed on the home screen is the bundle name of the application. + * Touching the application icon on the home screen will direct the user to the application details screen shown in Figure 1. * The application has the privilege to hide its icon from the home screen. * The information about the application is not returned during home screen information query, and the icon of the application is not displayed on the home screen. -> **NOTE** -> -> The icon and label displayed on the application details page may be different from those displayed on the home screen. For non-Page abilities, they are the entry icon and label set under **abilities**, if any. +Note: The label displayed on the application details screen may be different from that displayed on the home screen. For non-Page abilities, it is the entry label set (if any).

+ +**Figure 1** Application details screen + +![Application details screen](figures/application_details.jpg) + **Table 8** Internal structure of the abilities attribute @@ -412,39 +421,6 @@ Example of the **skills** attribute structure: ] ``` -**Enhanced implicit query** - -URI-level prefix matching is supported. - -When only **scheme** or a combination of **scheme** and **host** or **scheme**, **host**, and **port** are configured in the configuration file, the configuration is successful if a URI prefixed with the configuration file is passed in. - - * The query enhancement involves the following APIs:
- [@ohos.bundle.bundleManager](../reference/apis/js-apis-bundleManager.md#bundlemanagerqueryabilityinfo)
- 1. function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void;
- 2. function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void;
- 3. function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; - * Configuration requirements
- abilities -> skills -> uris object
- Configuration 1: only **scheme = 'http'** - Configuration 2: only **(scheme = 'http') + (host = 'www.example.com')** - Configuration 3: only **(scheme = 'http') + (host = 'www.example.com') + (port = '8080')** - * Prefix match
- If the value of **uri** under [want](../application-models/want-overview.md) is obtained by calling the **queryAbilityInfo** API:
- 1. uri = 'https://': No matches
- 2. uri = 'http://': Matches configuration 1
- 3. uri = 'https://www.example.com': No matches
- 4. uri = 'https://www.exa.com': No matches
- 5. uri = 'http://www.exa.com': Matches configuration 1
- 6. uri = 'http://www.example.com': Matches configuration 1 and configuration 2
- 7. uri = 'https://www.example.com:8080': No matches
- 8. uri = 'http://www.exampleaa.com:8080': Matches configuration 1
- 9. uri = 'http://www.example.com:9180': Matches configuration 1 and configuration 2
- 10. uri = 'http://www.example.com:8080': Matches configuration 1, configuration 2, and configuration 3
- 11. uri = 'https://www.example.com:9180/query/student/name' : No matches
- 12. uri = 'http://www.exampleap.com:8080/query/student/name': Matches configuration 1
- 13. uri = 'http://www.example.com:9180/query/student/name': Matches configuration 1 and configuration 2
- 14. uri = 'http://www.example.com:8080/query/student/name': Matches configuration 1, configuration 2, and configuration 3
- ## Internal Structure of the reqPermissions Attribute **Table 12** Internal structure of the reqPermissions attribute diff --git a/en/application-dev/quick-start/multi-hap-objective.md b/en/application-dev/quick-start/multi-hap-objective.md index ad43c84fd7799be1e3277400c6c5dfb1926d5b7c..ae7bb791b71225cfa15741d4c99975111734709f 100644 --- a/en/application-dev/quick-start/multi-hap-objective.md +++ b/en/application-dev/quick-start/multi-hap-objective.md @@ -1,10 +1,10 @@ # Multi-HAP Design Objectives -- Modular management: A well-designed application is generally managed in a modular manner, where modules are loosely coupled. In light of this, the multi-HAP mechanism is designed, allowing you to divide services into multiple modules and store each module in an independent HAP file. For example, If you are developing a payment application and its home screen consists of multiple modules, such as the scan, pay, messaging, and finance modules, you can implement the logic of the home screen for managing other modules in the entry-type HAP file, and implement specific modules in feature-type HAP files. The feature-type HAP files are independent. You can develop and test each of them separately, and then integrate them with the entry-type HAP file. +- Modular management: A well-designed application is generally managed in a modular manner, where modules are loosely coupled. In light of this, the multi-HAP mechanism is designed, allowing you to divide services into multiple modules and store each module in an independent HAP file. For example, if you are developing a payment application whose home screen consists of multiple modules, such as the scan, pay, messaging, and finance modules, you can implement the HAP files as follows: (1) In the entry-type HAP file, implement the home screen logic for managing modules; (2) in feature-type HAP files, implement specific modules. The feature-type HAP files are independent of each other. You can develop and test each of them separately, and then integrate them with the entry-type HAP file. -- Flexible deployment: You can combine multiple HAP files and deploy them on different devices. Assume that an application contains one entry-type HAP file (**Entry.hap**) and two feature-type HAP files (**Feature1.hap** and **Feature2.hap**). The **Entry.hap** file can be deployed on device A and device B, the **Feature1.hap** file can be deployed only on device A, and the **Feature2.hap** can be deployed only on device B. In this way, you can easily combine the **Entry.hap** and **Feature1.hap** files and deploy them on device A, and combine the **Entry.hap** and **Feature2.hap** files and deploy them on device B. +- Flexible deployment: You can flexibly combine HAP files for device-specific deployment. Assume that an application contains one entry-type HAP file (**entry.hap**) and two feature-type HAP files (**Feature1.hap** and **Feature2.hap**). The **Entry.hap** file can be deployed on device A and device B, the **Feature1.hap** file can be deployed only on device A, and the **Feature2.hap** can be deployed only on device B. This means that you can combine the **Entry.hap** and **Feature1.hap** files and deploy them on device A, and combine the **Entry.hap** and **Feature2.hap** files and deploy them on device B. -- On-demand loading: You can load modules only when they are needed, reducing the package size. Specifically, you can configure some HAP files of an application to be loaded on demand. For example, if some features are not used during application startup, you can configure them to be loaded only when they are needed, rather than being loaded at startup. This can reduce the size of the application package to some extent. +- On-demand loading: You can load modules only when they are needed, reducing the package size. Specifically, you can configure some HAP files of your application to be loaded on demand. For example, if some features are not used during application startup, you can configure them to be loaded only when they are needed, rather than being loaded at startup. This can reduce the size of the application package to some extent. -- Easier resource sharing: The resources (including public resource files and public pages) and shared objects (.so library files) required by multiple HAP files can be stored in an independent HAP file. In this way, other HAP files can obtain the resources and files by accessing the HAP, which reduces the size of the application package to some extent. +- Easier resource sharing: The resources (including public resource files and public pages) and shared objects (.so library files) required by multiple HAP files can be stored in an independent HAP file. In this way, other HAP files can obtain the resources and files by accessing the HAP, which also reduces the size of the application package to some extent. diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 3d791befc09e01d9dda38f359d68485cd97eb2a2..68f91da67fab51d166d53494448531a7d874ff91 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -412,7 +412,6 @@ - [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md) - [@ohos.systemTime (System Time and Time Zone)](js-apis-system-time.md) - [@ohos.usb (USB Management)](js-apis-usb-deprecated.md) - - [@ohos.usbV9 (USB Management)](js-apis-usb.md) - [@system.app (Application Context)](js-apis-system-app.md) - [@system.battery (Battery Information)](js-apis-system-battery.md) - [@system.bluetooth (Bluetooth)](js-apis-system-bluetooth.md) diff --git a/en/application-dev/reference/apis/js-apis-geolocation.md b/en/application-dev/reference/apis/js-apis-geolocation.md index 3bf1e990cd2fcb0f2853c224d0adf70ce5e7b5dc..de7d46dc6b83bb64d24cb5a0e6c5c1857616c329 100644 --- a/en/application-dev/reference/apis/js-apis-geolocation.md +++ b/en/application-dev/reference/apis/js-apis-geolocation.md @@ -4,7 +4,7 @@ The **geolocation** module provides a wide array of location services, including > **NOTE** > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md) instead. +> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md). ## Applying for Permissions @@ -1486,7 +1486,7 @@ Sets the priority of the location request. Enumerates error codes of the location service. > **NOTE**
-> This API is deprecated since API version 9. +> This API is deprecated since API version 9. You are advised to use [geoLocationManager](../errorcodes/errorcode-geoLocationManager.md). **Required permissions**: ohos.permission.LOCATION diff --git a/en/application-dev/reference/apis/js-apis-net-mdns.md b/en/application-dev/reference/apis/js-apis-net-mdns.md index b2e157c03a7afec840f4af21aa729f3c081e540a..2f32a68fea2b56a3acd4458f09ebff0102bcbc16 100644 --- a/en/application-dev/reference/apis/js-apis-net-mdns.md +++ b/en/application-dev/reference/apis/js-apis-net-mdns.md @@ -399,7 +399,7 @@ discoveryService.stopSearchingMDNS(); ### on('discoveryStart') -on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void +on(type: 'discoveryStart', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void Enables listening for **discoveryStart** events. @@ -410,7 +410,7 @@ Enables listening for **discoveryStart** events. | Name | Type | Mandatory| Description | |-------------|--------------|-----------|-----------------------------------------------------| | type | string | Yes |Event type. This field has a fixed value of **discoveryStart**.
**discoveryStart**: event of starting discovery of mDNS services on the LAN.| -| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | Yes | Callback used to return the mDNS service and error information. | +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | Yes | Callback used to return the mDNS service and error information. | **Example** @@ -428,7 +428,7 @@ discoveryService.stopSearchingMDNS(); ### on('discoveryStop') -on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MDNS_ERR}>): void +on(type: 'discoveryStop', callback: Callback<{serviceInfo: LocalServiceInfo, errorCode?: MdnsError}>): void Enables listening for **discoveryStop** events. @@ -439,7 +439,7 @@ Enables listening for **discoveryStop** events. | Name | Type | Mandatory| Description | |-------------|--------------|-----------|-----------------------------------------------------| | type | string | Yes |Event type. This field has a fixed value of **discoveryStop**.
**discoveryStop**: event of stopping discovery of mDNS services on the LAN.| -| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MDNS_ERR](#mdns_err)}> | Yes | Callback used to return the mDNS service and error information. | +| callback | Callback<{serviceInfo: [LocalServiceInfo](#localserviceinfo), errorCode?: [MdnsError](#mdnserror)}> | Yes | Callback used to return the mDNS service and error information. | **Example** @@ -538,7 +538,7 @@ Defines the mDNS service attribute information. | key | string | Yes| mDNS service attribute key. The value contains a maximum of 9 characters. | | value | Array\ | Yes| mDNS service attribute value. | -## MDNS_ERR +## MdnsError Defines the mDNS error information. diff --git a/en/application-dev/reference/apis/js-apis-resource-manager.md b/en/application-dev/reference/apis/js-apis-resource-manager.md index cc24c7ab23912cb3abb8f2ee648c0be026565aac..0cd8b2df9f10074df34a7405be624953b7feb233 100644 --- a/en/application-dev/reference/apis/js-apis-resource-manager.md +++ b/en/application-dev/reference/apis/js-apis-resource-manager.md @@ -13,7 +13,7 @@ The Resource Manager module provides APIs to obtain information about applicatio import resourceManager from '@ohos.resourceManager'; ``` -## Instruction +## How to Use Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object. For details about how to reference context in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md). @@ -78,7 +78,7 @@ Obtains the **ResourceManager** object of an application based on the specified | Name | Type | Mandatory | Description | | ---------- | ---------------------------------------- | ---- | ----------------------------- | -| bundleName | string | Yes | Bundle name of the application. | +| bundleName | string | Yes | Bundle name of the target application. | | callback | AsyncCallback<[ResourceManager](#resourcemanager)> | Yes | Callback used to return the result.| **Example** @@ -135,7 +135,7 @@ Obtains the **ResourceManager** object of an application based on the specified | Name | Type | Mandatory | Description | | ---------- | ------ | ---- | ------------- | -| bundleName | string | Yes | Bundle name of the application.| +| bundleName | string | Yes | Bundle name of the target application.| **Return value** @@ -171,12 +171,12 @@ Enumerates the device types. | Name | Value | Description | | -------------------- | ---- | ---- | -| DEVICE_TYPE_PHONE | 0x00 | Phone | -| DEVICE_TYPE_TABLET | 0x01 | Tablet | -| DEVICE_TYPE_CAR | 0x02 | Head unit | -| DEVICE_TYPE_PC | 0x03 | PC | -| DEVICE_TYPE_TV | 0x04 | TV | -| DEVICE_TYPE_WEARABLE | 0x06 | Wearable | +| DEVICE_TYPE_PHONE | 0x00 | Phone. | +| DEVICE_TYPE_TABLET | 0x01 | Tablet. | +| DEVICE_TYPE_CAR | 0x02 | Head unit. | +| DEVICE_TYPE_PC | 0x03 | PC. | +| DEVICE_TYPE_TV | 0x04 | TV. | +| DEVICE_TYPE_WEARABLE | 0x06 | Wearable. | ## ScreenDensity @@ -278,7 +278,7 @@ Defines the capability of accessing application resources. > **NOTE** > -> - The APIs involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. +> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm. > > - Resource files are defined in the **resources** directory of the project. You can obtain the resource ID using **$r(resource address).id**, for example, **$r('app.string.test').id**. @@ -645,7 +645,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getMediaContent(resId: number, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. +Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -1543,7 +1543,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco ``` -### closeRawFd8+ +### closeRawFd9+ closeRawFd(path: string): Promise<void> @@ -1658,7 +1658,7 @@ Obtains the string corresponding to the specified resource name. This API uses a | Type | Description | | --------------------- | ---------- | -| Promise<string> | String corresponding to the resource name.| +| Promise<string> | Promise used to return the result.| For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). @@ -1770,7 +1770,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getMediaByName(resName: string, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. +Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Global.ResourceManager @@ -2036,7 +2036,7 @@ Obtains the string corresponding to the specified resource ID. This API returns | Type | Description | | ------ | ----------- | -| string | Promise used to return the result.| +| string | String corresponding to the specified resource ID.| For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). @@ -2057,6 +2057,47 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco } ``` +### getStringSync10+ + +getStringSync(resId: number, ...args: Array): string + +Obtains the string corresponding to the specified resource ID and formats the string based on **args**. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| resId | number | Yes | Resource ID.| +| args | Array | No | Arguments for formatting strings.
Supported arguments:
-%d, %f, %s, and %%
Note: %% is used to translate %.
Example: %%d is translated into the %d string.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| string | Formatted string.| + +For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). + +**Error codes** + +| ID| Error Message| +| -------- | ----------------------------------------------- | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | +| 9001007 | If the resource obtained by resId formatting error. | + +**Example** + ```ts + try { + this.context.resourceManager.getStringSync($r('app.string.test').id, "format string", 10, 98.78); + } catch (error) { + console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + ### getStringSync9+ getStringSync(resource: Resource): string @@ -2075,7 +2116,7 @@ Obtains the string corresponding to the specified resource object. This API retu | Type | Description | | ------ | ---------------- | -| string | Promise used to return the result.| +| string | String corresponding to the resource object.| For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). @@ -2101,6 +2142,52 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco } ``` +### getStringSync10+ + +getStringSync(resource: Resource, ...args: Array): string + +Obtains the string corresponding to the specified resource object and formats the string based on **args**. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | ---- | ---- | +| resource | [Resource](#resource9) | Yes | Resource object.| +| args | Array | No | Arguments for formatting strings.
Supported arguments:
-%d, %f, %s, and %%
Note: %% is used to translate %.
Example: %%d is translated into the %d string.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| string | Formatted string.| + +For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). + +**Error codes** + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 9001001 | If the resId invalid. | +| 9001002 | If the resource not found by resId. | +| 9001006 | If the resource re-ref too much. | +| 9001007 | If the resource obtained by resId formatting error. | + +**Example** + ```ts + let resource = { + bundleName: "com.example.myapplication", + moduleName: "entry", + id: $r('app.string.test').id + }; + try { + this.context.resourceManager.getStringSync(resource, "format string", 10, 98.78); + } catch (error) { + console.error(`getStringSync failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + ### getStringByNameSync9+ getStringByNameSync(resName: string): string @@ -2119,7 +2206,7 @@ Obtains the string corresponding to the specified resource name. This API return | Type | Description | | ------ | ---------- | -| string | String corresponding to the specified resource name.| +| string | String corresponding to the resource name.| For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). @@ -2140,6 +2227,47 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco } ``` +### getStringByNameSync10+ + +getStringByNameSync(resName: string, ...args: Array): string + +Obtains the string corresponding to the specified resource name and formats the string based on **args**. This API returns the result synchronously. + +**System capability**: SystemCapability.Global.ResourceManager + +**Parameters** + +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ---- | +| resName | string | Yes | Resource name.| +| args | Array | No | Arguments for formatting strings.
Supported arguments:
-%d, %f, %s, and %%
Note: %% is used to translate %.
Example: %%d is translated into the %d string.| + +**Return value** + +| Type | Description | +| ------ | ---------------------------- | +| string | Formatted string.| + +For details about the error codes, see [Resource Manager Error Codes](../errorcodes/errorcode-resource-manager.md). + +**Error codes** + +| ID| Error Message| +| -------- | ---------------------------------------- | +| 9001003 | If the resName invalid. | +| 9001004 | If the resource not found by resName. | +| 9001006 | If the resource re-ref too much. | +| 9001008 | If the resource obtained by resName formatting error. | + +**Example** + ```ts + try { + this.context.resourceManager.getStringByNameSync("test", "format string", 10, 98.78); + } catch (error) { + console.error(`getStringByNameSync failed, error code: ${error.code}, message: ${error.message}.`) + } + ``` + ### getBoolean9+ getBoolean(resId: number): boolean @@ -2399,7 +2527,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getDrawableDescriptor(resId: number, density?: number): DrawableDescriptor; -Obtains the **DrawableDescriptor** object based on the specified resource ID. This API returns the result synchronously. +Obtains the **DrawableDescriptor** object corresponding to the specified resource ID. This API returns the result synchronously. **System capability**: SystemCapability.Global.ResourceManager @@ -2443,7 +2571,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getDrawableDescriptor(resource: Resource, density?: number): DrawableDescriptor; -Obtains the **DrawableDescriptor** object based on the specified resource. This API returns the result synchronously. +Obtains the **DrawableDescriptor** object corresponding to the specified resource. This API returns the result synchronously. **System capability**: SystemCapability.Global.ResourceManager @@ -2492,7 +2620,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco getDrawableDescriptorByName(resName: string, density?: number): DrawableDescriptor; -Obtains the **DrawableDescriptor** object based on the specified resource name. This API returns the result synchronously. +Obtains the **DrawableDescriptor** object corresponding to the specified resource name. This API returns the result synchronously. **System capability**: SystemCapability.Global.ResourceManager @@ -2666,7 +2794,7 @@ This API is deprecated since API version 9. You are advised to use [getStringArr getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void -Obtains the content of the media file corresponding to the specified resource ID. This API uses an asynchronous callback to return the result. +Obtains the content of the media file corresponding to the specified resource name. This API uses an asynchronous callback to return the result. This API is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9) instead. diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md deleted file mode 100644 index 49bb9b53a08027852baa2614975e6ec9f53d90e9..0000000000000000000000000000000000000000 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ /dev/null @@ -1,952 +0,0 @@ -# @ohos.usbV9 (USB) - -The **usb** module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control on the host side as well as port management, and function switch and query on the device side. - -> **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> -> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [`@ohos.usbManager`](js-apis-usbManager.md). - -## Modules to Import - -```js -import usb from "@ohos.usbV9"; -``` - -## usb.getDevices - -getDevices(): Array<Readonly<USBDevice>> - -Obtains the list of USB devices connected to the host. If no device is connected, an empty list is returned. - -**System capability**: SystemCapability.USB.USBManager - -**Return value** - -| Type | Description | -| ---------------------------------------------------- | ------- | -| Array<Readonly<[USBDevice](#usbdevice)>> | USB device list.| - -**Example** - -```js -let devicesList = usb.getDevices(); -console.log(`devicesList = ${devicesList}`); -// devicesList is a list of USB devices. -// A simple example of devicesList is provided as follows: -[ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subClass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subClass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - }, - ], - }, - ], - }, - ], - }, -] -``` - -## usb.connectDevice - -connectDevice(device: USBDevice): Readonly<USBDevicePipe> - -Connects to the USB device based on the device information returned by **getDevices()**. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device information, and then call [usb.requestRight](#usbrequestright) to request the device access permission. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| device | [USBDevice](#usbdevice) | Yes| USB device information.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| - -**Error codes** - -For details about the error codes, see [USB Error Codes](../errorcodes/errorcode-usb.md). - -| ID| Error Message| -| -------- | -------- | -| 14400001 |Permission denied. Need call requestRight to get permission. | - -**Example** - -```js -let devicesList = usb.getDevices(); -if (devicesList.length == 0) { - console.log(`device list is empty`); -} - -let device = devicesList[0]; -usb.requestRight(device.name); -let devicepipe = usb.connectDevice(device); -console.log(`devicepipe = ${devicepipe}`); -``` - -## usb.hasRight - -hasRight(deviceName: string): boolean - -Checks whether the application has the permission to access the device. - -Checks whether the user, for example, the application or system, has the device access permissions. The value **true** is returned if the user has the device access permissions; the value **false** is returned otherwise. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceName | string | Yes| Device name.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| - -**Example** - -```js -let devicesName="1-1"; -let bool = usb.hasRight(devicesName); -console.log(bool); -``` - -## usb.requestRight - -requestRight(deviceName: string): Promise<boolean> - -Requests the temporary permission for the application to access a USB device. This API uses a promise to return the result. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceName | string | Yes| Device name.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Promise used to return the result. The value **true** indicates that the temporary device access permissions are granted; and the value **false** indicates the opposite.| - -**Example** - -```js -let devicesName="1-1"; -usb.requestRight(devicesName).then((ret) => { - console.log(`requestRight = ${ret}`); -}); -``` - -## usb.removeRight - -removeRight(deviceName: string): boolean - -Removes the permission for the application to access a USB device. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceName | string | Yes| Device name.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| boolean | Permission removal result. The value **true** indicates that the access permission is removed successfully; and the value **false** indicates the opposite.| - -**Example** - -```js -let devicesName="1-1"; -if usb.removeRight(devicesName) { - console.log(`Succeed in removing right`); -} -``` - -## usb.addRight - -addRight(bundleName: string, deviceName: string): boolean - -Adds the permission for the application to access a USB device. - -[requestRight](#usbrequestright) triggers a dialog box to request for user authorization, whereas **addRight** adds the access permission directly without displaying a dialog box. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| deviceName | string | Yes| Device name.| -| bundleName | string | Yes| Bundle name of the application.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| boolean | Permission addition result. The value **true** indicates that the access permission is added successfully; and the value **false** indicates the opposite.| - -**Example** - -```js -let devicesName = "1-1"; -let bundleName = "com.example.hello"; -if usb.addRight(bundleName, devicesName) { - console.log(`Succeed in adding right`); -} -``` - -## usb.claimInterface - -claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number - -Claims a USB interface. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and USB interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| -| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| -| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| - -**Example** - -```js -let ret = usb.claimInterface(devicepipe, interfaces); -console.log(`claimInterface = ${ret}`); -``` - -## usb.releaseInterface - -releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number - -Releases a USB interface. - -Before you do this, ensure that you have claimed the interface by calling [usb.claimInterface](#usbclaiminterface). - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| -| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| - -**Example** - -```js -let ret = usb.releaseInterface(devicepipe, interfaces); -console.log(`releaseInterface = ${ret}`); -``` - -## usb.setConfiguration - -setConfiguration(pipe: USBDevicePipe, config: USBConfig): number - -Sets the device configuration. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device configuration, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| -| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| - -**Example** - -```js -let ret = usb.setConfiguration(devicepipe, config); -console.log(`setConfiguration = ${ret}`); -``` - -## usb.setInterface - -setInterface(pipe: USBDevicePipe, iface: USBInterface): number - -Sets a USB interface. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name | Type | Mandatory | Description | -| ----- | ------------------------------- | --- | ------------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address.| -| iface | [USBInterface](#usbinterface) | Yes | USB interface to set. | - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| - -**Example** - -```js -let ret = usb.setInterface(devicepipe, interfaces); -console.log(`setInterface = ${ret}`); -``` - -## usb.getRawDescriptor - -getRawDescriptor(pipe: USBDevicePipe): Uint8Array - -Obtains the raw USB descriptor. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Uint8Array | Returns the raw USB descriptor if the operation is successful; returns **undefined** otherwise.| - -**Example** - -```js -let ret = usb.getRawDescriptor(devicepipe); -``` - -## usb.getFileDescriptor - -getFileDescriptor(pipe: USBDevicePipe): number - -Obtains the file descriptor. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| - -**Return value** - -| Type | Description | -| ------ | -------------------- | -| number | Returns the file descriptor of the USB device if the operation is successful; returns **-1** otherwise.| - -**Example** - -```js -let ret = usb.getFileDescriptor(devicepipe); -``` - -## usb.controlTransfer - -controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> - -Performs control transfer. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| -| controlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| -| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Promise<number> | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.| - -**Example** - -```js -let param = new usb.USBControlParams(); -usb.controlTransfer(devicepipe, param).then((ret) => { - console.log(`controlTransfer = ${ret}`); -}) -``` - -## usb.bulkTransfer - -bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise<number> - -Performs bulk transfer. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| -| endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| -| buffer | Uint8Array | Yes| Buffer for writing or reading data.| -| timeout | number | No| Timeout duration in ms. This parameter is optional. The default value is **0**, indicating no timeout.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Promise<number> | Promise used to return the result, which is the size of the transmitted or received data block if the transfer is successful, or **-1** if an exception has occurred.| - -**Example** - -```js -// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. -// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. -// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. -usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${ret}`); -}); -``` - -## usb.closePipe - -closePipe(pipe: USBDevicePipe): number - -Closes a USB device pipe. - -Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| - -**Example** - -```js -let ret = usb.closePipe(devicepipe); -console.log(`closePipe = ${ret}`); -``` - -## usb.usbFunctionsFromString - -usbFunctionsFromString(funcs: string): number - -Converts the USB function list in the string format to a numeric mask in Device mode. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ---------------------- | -| funcs | string | Yes | Function list in string format.| - -**Return value** - -| Type | Description | -| ------ | ------------------ | -| number | Function list in numeric mask format.| - -**Example** - -```js -let funcs = "acm"; -let ret = usb.usbFunctionsFromString(funcs); -``` - -## usb.usbFunctionsToString - -usbFunctionsToString(funcs: FunctionType): string - -Converts the USB function list in the numeric mask format to a string in Device mode. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------------------------------ | ---- | ----------------- | -| funcs | [FunctionType](#functiontype) | Yes | USB function list in numeric mask format.| - -**Return value** - -| Type | Description | -| ------ | ------------------------------ | -| string | Function list in string format.| - -**Example** - -```js -let funcs = usb.ACM | usb.ECM; -let ret = usb.usbFunctionsToString(funcs); -``` - -## usb.setCurrentFunctions - -setCurrentFunctions(funcs: FunctionType): Promise\ - -Sets the current USB function list in Device mode. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------------------------------ | ---- | ----------------- | -| funcs | [FunctionType](#functiontype) | Yes | USB function list in numeric mask format.| - -**Return value** - -| Type | Description | -| --------------- | ------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let funcs = usb.HDC; -usb.setCurrentFunctions(funcs).then(() => { - console.info('usb setCurrentFunctions successfully.'); -}).catch(err => { - console.error('usb setCurrentFunctions failed: ' + err.code + ' message: ' + err.message); -}); -``` - -## usb.getCurrentFunctions - -getCurrentFunctions(): FunctionType - -Obtains the numeric mask combination for the USB function list in Device mode. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Return value** - -| Type | Description | -| ------------------------------ | --------------------------------- | -| [FunctionType](#functiontype) | Numeric mask combination for the USB function list.| - -**Example** - -```js -let ret = usb.getCurrentFunctions(); -``` - -## usb.getPorts - -getPorts(): Array\ - -Obtains the list of all physical USB ports. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Return value** - -| Type | Description | -| ----------------------------- | --------------------- | -| [Array\](#usbport) | List of physical USB ports.| - -**Example** - -```js -let ret = usb.getPorts(); -``` - -## usb.getSupportedModes - -getSupportedModes(portId: number): PortModeType - -Obtains the mask combination for the supported mode list of a given USB port. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | -------- | -| portId | number | Yes | Port number.| - -**Return value** - -| Type | Description | -| ------------------------------ | -------------------------- | -| [PortModeType](#portmodetype) | Mask combination for the supported mode list.| - -**Example** - -```js -let ret = usb.getSupportedModes(0); -``` - -## usb.setPortRoles - -setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\ - -Sets the role types supported by a specified port, which can be **powerRole** (for charging) and **dataRole** (for data transfer). - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | -------------------------------- | ---- | ---------------- | -| portId | number | Yes | Port number. | -| powerRole | [PowerRoleType](#powerroletype) | Yes | Role for charging. | -| dataRole | [DataRoleType](#dataroletype) | Yes | Role for data transfer.| - -**Return value** - -| Type | Description | -| --------------- | ------------- | -| Promise\ | Promise used to return the result.| - -**Example** - -```js -let portId = 1; -usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { - console.info('usb setPortRoles successfully.'); -}).catch(err => { - console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); -}); -``` - -## USBEndpoint - -Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through [USBInterface](#usbinterface). - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| ------------- | ------------------------------------------- | ------------- |------------- | -| address | number | Yes|Endpoint address. | -| attributes | number | Yes|Endpoint attributes. | -| interval | number | Yes|Endpoint interval. | -| maxPacketSize | number | Yes|Maximum size of data packets on the endpoint. | -| direction | [USBRequestDirection](#usbrequestdirection) | Yes|Endpoint direction. | -| number | number | Yes|Endpoint number. | -| type | number | Yes|Endpoint type. | -| interfaceId | number | Yes|Unique ID of the interface to which the endpoint belongs.| - -## USBInterface - -Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **USBInterface** instances, each providing a specific function. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| ---------------- | ---------------------------------------- | ------------- |--------------------- | -| id | number | Yes|Unique ID of the USB interface. | -| protocol | number | Yes|Interface protocol. | -| clazz | number | Yes|Device type. | -| subClass | number | Yes|Device subclass. | -| alternateSetting | number | Yes|Settings for alternating between descriptors of the same USB interface.| -| name | string | Yes|Interface name. | -| endpoints | Array<[USBEndpoint](#usbendpoint)> | Yes|Endpoints that belong to the USB interface. | - -## USBConfig - -Represents the USB configuration. One [USBDevice](#usbdevice) can contain multiple **USBConfig** instances. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| -------------- | ------------------------------------------------ | --------------- |--------------- | -| id | number | Yes|Unique ID of the USB configuration. | -| attributes | number | Yes|Configuration attributes. | -| maxPower | number | Yes|Maximum power consumption, in mA. | -| name | string | Yes|Configuration name, which can be left empty. | -| isRemoteWakeup | boolean | Yes|Support for remote wakeup.| -| isSelfPowered | boolean | Yes| Support for independent power supplies.| -| interfaces | Array <[USBInterface](#usbinterface)> | Yes|Supported interface attributes. | - -## USBDevice - -Represents the USB device information. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| ---------------- | ------------------------------------ | ---------- |---------- | -| busNum | number | Yes|Bus address. | -| devAddress | number | Yes|Device address. | -| serial | string | Yes|Sequence number. | -| name | string | Yes|Device name. | -| manufacturerName | string | Yes| Device manufacturer. | -| productName | string | Yes|Product name. | -| version | string | Yes|Version number. | -| vendorId | number | Yes|Vendor ID. | -| productId | number | Yes|Product ID. | -| clazz | number | Yes|Device class. | -| subClass | number | Yes|Device subclass. | -| protocol | number | Yes|Device protocol code. | -| configs | Array<[USBConfig](#usbconfig)> | Yes|Device configuration descriptor information.| - -## USBDevicePipe - -Represents a USB device pipe, which is used to determine a USB device. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| ---------- | ------ | ----- |----- | -| busNum | number |Yes| Bus address.| -| devAddress | number |Yes| Device address.| - -## USBControlParams - -Represents control transfer parameters. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| ------- | ----------------------------------------------- | ---------------- |---------------- | -| request | number | Yes |Request type. | -| target | [USBRequestTargetType](#usbrequesttargettype) | Yes |Request target type. | -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Yes |Control request type. | -| value | number | Yes |Request parameter value. | -| index | number | Yes |Index of the request parameter value.| -| data | Uint8Array | Yes |Buffer for writing or reading data. | - -## USBPort - -Represents a USB port. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type | Mandatory |Description | -| -------------- | ------------------------------- | ------------------- |------------------------ | -| id | number | Yes |Unique identifier of a USB port. | -| supportedModes | [PortModeType](#portmodetype) | Yes |Numeric mask combination for the supported mode list.| -| status | [USBPortStatus](#usbportstatus) | Yes |USB port role. | - -## USBPortStatus - -Enumerates USB port roles. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Type| Mandatory |Description | -| ---------------- | -------- | ---------------- |---------------------- | -| currentMode | number | Yes|Current USB mode. | -| currentPowerRole | number | Yes |Current power role. | -| currentDataRole | number | Yes |Current data role.| - -## USBRequestTargetType - -Enumerates request target types. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| ---------------------------- | ---- | ------ | -| USB_REQUEST_TARGET_DEVICE | 0 | Device| -| USB_REQUEST_TARGET_INTERFACE | 1 | Interface| -| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint| -| USB_REQUEST_TARGET_OTHER | 3 | Other| - -## USBControlRequestType - -Enumerates control request types. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| ------------------------- | ---- | ------ | -| USB_REQUEST_TYPE_STANDARD | 0 | Standard| -| USB_REQUEST_TYPE_CLASS | 1 | Class | -| USB_REQUEST_TYPE_VENDOR | 2 | Vendor| - -## USBRequestDirection - -Enumerates request directions. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| --------------------------- | ---- | ------------------------ | -| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device.| -| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host.| - -## FunctionType - -Enumerates USB device function types. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| ------------ | ---- | ---------- | -| NONE | 0 | No function.| -| ACM | 1 | ACM function. | -| ECM | 2 | ECM function. | -| HDC | 4 | HDC function. | -| MTP | 8 | Not supported currently.| -| PTP | 16 | Not supported currently.| -| RNDIS | 32 | Not supported currently.| -| MIDI | 64 | Not supported currently.| -| AUDIO_SOURCE | 128 | Not supported currently.| -| NCM | 256 | Not supported currently.| - -## PortModeType - -Enumerates USB port mode types. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| --------- | ---- | ---------------------------------------------------- | -| NONE | 0 | None. | -| UFP | 1 | Upstream facing port, which functions as the sink of power supply. | -| DFP | 2 | Downstream facing port, which functions as the source of power supply. | -| DRP | 3 | Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently.| -| NUM_MODES | 4 | Not supported currently. | - -## PowerRoleType - -Enumerates power role types. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| ------ | ---- | ---------- | -| NONE | 0 | None. | -| SOURCE | 1 | External power supply.| -| SINK | 2 | Internal power supply.| - -## DataRoleType - -Enumerates data role types. - -**System API**: This is a system API. - -**System capability**: SystemCapability.USB.USBManager - -| Name | Value | Description | -| ------ | ---- | ------------ | -| NONE | 0 | None. | -| HOST | 1 | USB host.| -| DEVICE | 2 | USB device.| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index 7bb73dc7db50b38fee5e68bd44a254291d27a8fc..b2ab19b168a0415f8ddd82cee4a41faa3282848d 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -21,7 +21,7 @@ Since API version 9, this API is supported in ArkTS widgets. | Name | Type| Mandatory | Description| | --------| --------| ------ | -------- | | name | string | No| Name of the check box.| -| group | string | No| Group name of the check box.| +| group | string | No| Group name of the check box.
**NOTE**
If not used with the **\** component, this parameter is invalid.| ## Attributes @@ -32,6 +32,8 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | ------------- | ------- | -------- | | select | boolean | Whether the check box is selected.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.| | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the check box when it is selected.
Since API version 9, this API is supported in ArkTS widgets.| +| unselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Border color of the check box when it is not selected.| +| mark10+ | [MarkStyle](#markstyle10) | Internal icon style of the check box.| ## Events @@ -41,6 +43,14 @@ In addition to the [universal events](ts-universal-events-click.md), the followi | -------------------------------------------- | ------------------------------------------------------------ | | onChange(callback: (value: boolean) => void) | Triggered when the selected status of the check box changes due to a manual operation.
- The value **true** means that the check box is selected.
- The value **false** means that the check box is not selected.
Since API version 9, this API is supported in ArkTS widgets.| +## MarkStyle10+ + +| Name | Type | Mandatory| Default Value | Description | +| ----------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------------------------ | +| strokeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Color of the internal mark. | +| size | number \| string | No | - | Size of the internal mark, in vp. The default size is the same as the width of the check box.
This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| +| strokeWidth | number \| string | No | 2 | Stroke width of the internal mark, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| + ## Example ```ts diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index 0ff6c9dcf8bdf3c8e0cf55aaf3f68c439bdec48f..d6beb514c6590f6b4f977b37052d78f180ff8f51 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -14,7 +14,7 @@ Not supported CheckboxGroup(options?: { group?: string }) -Creates a check box group so that you can select or deselect all check boxes in the group at the same time. Check boxes and the check box group that share the group name belong to the same group. +Creates a check box group so that you can select or deselect all check boxes in the group at the same time. Check boxes and the check box group that share a group name belong to the same group. Since API version 9, this API is supported in ArkTS widgets. @@ -30,8 +30,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | -| selectAll | boolean | Whether to select all.
Default value: **false**
If **select** is explicitly set for check boxes in the group, the check box settings are prioritized.
Since API version 9, this API is supported in ArkTS widgets.| +| selectAll | boolean | Whether to select all.
Default value: **false**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If the **select** attribute is set for a [\](ts-basic-components-checkbox.md) component in the same group, the setting of the **\** has a higher priority.| | selectedColor | [ResourceColor](ts-types.md#resourcecolor) | Color of the selected check box.
Since API version 9, this API is supported in ArkTS widgets.| +| unselectedColor10+ | [ResourceColor](ts-types.md#resourcecolor) | Border color of the check box when it is not selected.| +| mark10+ | [MarkStyle](#markstyle10) | Internal icon style of the check box.| ## Events @@ -60,6 +62,13 @@ Since API version 9, this API is supported in ArkTS widgets. | Part | Some check boxes in the group are selected.| | None | None of the check boxes in the group are selected.| +## MarkStyle10+ + +| Name | Type | Mandatory| Default Value | Description | +| ----------- | ------------------------------------------ | ---- | ----------- | ------------------------------------------------------------ | +| strokeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Color of the internal mark. | +| size | number \| string | No | - | Size of the internal mark, in vp. The default size is the same as the width of the check box group component.
This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| +| strokeWidth | number \| string | No | 2 | Stroke width of the internal mark, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md index 6b6a994a6f4e5ea976e96c87a366c501479383c4..190118b6a7f136146d6a7d3e5853255439920d43 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -11,6 +11,10 @@ The **\** component is used only in the **\** component. It co This component supports only one child component. +> **NOTE** +> +> System components and custom components can be built in, and rendering control types ([if/else](../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../quick-start/arkts-rendering-control-foreach.md), and [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)) are supported. + ## APIs @@ -23,37 +27,95 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Description| | -------- | -------- | -------- | -| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](ts-types.md)8+ | Content displayed on the tab bar.
**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).
**NOTE**
If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image. | -| tabBar9+ | [SubTabBarStyle](#subtabbarstyle) \| [BottomTabBarStyle](#bottomtabbarstyle) | Content displayed on the tab bar.
**SubTabBarStyle**: subtab style. It takes text as its input parameter.
**BottomTabBarStyle**: bottom and side tab style. It takes text and images as its input parameters.| +| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](ts-types.md)8+ | Content displayed on the tab bar.
**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).
**NOTE**
If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image.
If the content set exceeds the space provided by the tab bar, it will be clipped.| +| tabBar9+ | [SubTabBarStyle](#subtabbarstyle9) \| [BottomTabBarStyle](#bottomtabbarstyle9) | Content displayed on the tab bar.
**SubTabBarStyle**: subtab style. It takes text as its input parameter.
**BottomTabBarStyle**: bottom and side tab style. It takes text and images as its input parameters.
**NOTE**
The bottom tab style does not include an underline.
When an icon display error occurs, a gray blank block is displayed.| > **NOTE** -> - The **\** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **\** component. -> - The **\** component does not support setting of the common height attribute. Its height is determined by the height of the parent **\** component and the **\** component. -> - **\** does not support page scrolling. If page scrolling is required, consider nesting a list. +> +> - The **\** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **\** component. +> - The **\** component does not support setting of the common height attribute. Its height is determined by the height of the parent **\** component and the **\** component. +> - If the **vertical** attribute is **false**, the width and height descriptions are swapped in the preceding two restrictions. +> - **\** does not support page scrolling. If page scrolling is required, consider nesting a list. ## SubTabBarStyle9+ Implements the subtab style. -### constructor9+ +### constructor constructor(content: string | Resource) -A constructor used to create a **SubTabBarStyle** instance. +Constructor used to create a **SubTabBarStyle** instance. **Parameters** | Name| Type | Mandatory| Description| | -------- | -------- | -------- | -------- | -| content | string \| [Resource](ts-types.md#resource) | Yes| Text for the tab.| +| content | string \| [Resource](ts-types.md#resource) | Yes| Text for the tab. Since API version 10, the type of **content** is **ResourceStr**.| + +### of10+ + +static of(content: ResourceStr) + +Static constructor used to create a **SubTabBarStyle** instance. + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------ | ---- | ------------------ | +| content | [ResourceStr](ts-types.md#resourcestr) | Yes | Text for the tab.| + +### Attributes + +The following attributes are supported. + +| Name | Type | Description | +| ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| indicator10+ | [IndicatorStyle](#indicatorstyle10)| Underline indicator style of the selected subtab. It is valid only in the horizontal layout.
| +| selectedMode10+ | [SelectedMode](#selectedmode10) | Display mode of the selected subtab.
Default value: **SelectedMode.INDICATOR**| +| board10+ | [BoardStyle](#boardstyle10) | Board style of the selected subtab.| +| labelStyle10+ | [LabelStyle](#labelstyle10) | Label text and font style of the selected subtab.| + +## IndicatorStyle10+ + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------------------------------- | +| color | [ResourceColor](ts-types.md#resourcecolor) | No| Underline indicator color and board color.
Default value: **#FF007DFF**| +| height | [Length](ts-types.md#length) | No| Height of the underline indicator.
Default value: **2.0**
Unit: vp| +| width | [Length](ts-types.md#length) | No| Width of the underline indicator.
Default value: **0.0**
Unit: vp| +| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the underline indicator.
Default value: **0.0**
Unit: vp| +| marginTop | [Length](ts-types.md#length) | No| Spacing between the underline indicator and text.
Default value: **8.0**
Unit: vp| + +## SelectedMode10+ +| Name | Description | +| ---------- | ------------------------ | +| INDICATOR | Underline indicator mode. | +| BOARD | Board mode. | + +## BoardStyle10+ + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | ------------------------------------ | +| borderRadius | [Length](ts-types.md#length) | No| Radius of the rounded corner of the underline indicator.
Default value: **8.0**
Unit: vp| + +## LabelStyle10+ + +| Name | Type | Mandatory| Description | +| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| overflow | [TextOverflow](ts-appendix-enums.md#textoverflow) | No | Display mode when the label text is too long. By default, an ellipsis (...) is used to represent text overflow.| +| maxLines | number | No | Maximum number of lines in the label text. By default, text is automatically folded. If this attribute is specified, the text will not exceed the specified number of lines. If there is extra text, you can use **textOverflow** to specify how it is displayed.| +| minFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | No | Minimum font size of the label text. For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings.| +| maxFontSize | number \| [ResourceStr](ts-types.md#resourcestr) | No | Maximum font size of the label text. For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings.| +| heightAdaptivePolicy | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | No | How the adaptive height is determined for the label text. | +| font | [Font](ts-types.md#font) | No | Font of the label text. | ## BottomTabBarStyle9+ Implements the bottom and side tab style. -### constructor9+ +### constructor -constructor(icon: string | Resource, text: string | Resource) +constructor(icon: string | Resource, content: string | Resource) A constructor used to create a **BottomTabBarStyle** instance. @@ -61,8 +123,20 @@ A constructor used to create a **BottomTabBarStyle** instance. | Name| Type | Mandatory| Description| | -------- | -------- | -------- | -------- | -| icon | string \| [Resource](ts-types.md#resource) | Yes| Image for the tab.| -| text | string \| [Resource](ts-types.md#resource) | Yes| Text for the tab.| +| icon | string \| [Resource](ts-types.md#resource) | Yes| Image for the tab. Since API version 10, the type of **icon** is **ResourceStr**.| +| text | string \| [Resource](ts-types.md#resource) | Yes| Text for the tab. Since API version 10, the type of **text** is **ResourceStr**.| + +### of10+ + +static of(icon: ResourceStr, text: ResourceStr) +Static constructor used to create a **BottomTabBarStyle** instance. + +**Parameters** + +| Name| Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| icon | [ResourceStr](ts-types.md#resourcestr) | Yes| Image for the tab.| +| text | [ResourceStr](ts-types.md#resourcestr) | Yes| Text for the tab.| ## Example @@ -325,3 +399,4 @@ struct TabBarStyleExample { ``` ![tabbarStyle](figures/TabBarStyle.jpeg) + \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-container-tabs.md b/en/application-dev/reference/arkui-ts/ts-container-tabs.md index e1d90464b363777239c670b679a0cf1e2c5d711d..db9325e998325495db17eb915dbd888f834c4ecc 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-tabs.md +++ b/en/application-dev/reference/arkui-ts/ts-container-tabs.md @@ -2,7 +2,7 @@ The **\** component is a container component that allows users to switch between content views through tabs. Each tab page corresponds to a content view. -> **NOTE**
+> **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -18,47 +18,58 @@ Tabs(value?: {barPosition?: BarPosition, index?: number, controller?: [TabsContr **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| barPosition | BarPosition | No| Position of the **\** component.
Default value: **BarPosition.Start**| -| index | number | No| Initial tab index.
Default value: **0**| -| controller | [TabsController](#tabscontroller) | No| Tab controller.| +| Name | Type | Mandatory | Description | +| ----------- | --------------------------------- | ---- | ---------------------------------------- | +| barPosition | BarPosition | No | Position of the **\** component.
Default value: **BarPosition.Start** | +| index | number | No | Initial tab index.
Default value: **0**
**NOTE**

A value less than 0 evaluates to the default value.
The value ranges from 0 to the number of **\** subnodes minus 1.
When this parameter is set to different values, the slide animation for tab switching is enabled by default. To disable the animation, set **animationDuration** to **0**.| +| controller | [TabsController](#tabscontroller) | No | Tab controller. | ## BarPosition -| Name| Description| -| -------- | -------- | +| Name | Description | +| ----- | ---------------------------------------- | | Start | If the **vertical** attribute is set to **true**, the tab is on the left of the container. If the **vertical** attribute is set to **false**, the tab is on the top of the container.| -| End | If the **vertical** attribute is set to **true**, the tab is on the right of the container. If the **vertical** attribute is set to **false**, the tab is at the bottom of the container.| +| End | If the **vertical** attribute is set to **true**, the tab is on the right of the container. If the **vertical** attribute is set to **false**, the tab is at the bottom of the container.| ## Attributes In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. -| Name| Type| Description| -| -------- | -------- | -------- | -| vertical | boolean | Whether to use vertical tabs. The value **true** means to use vertical tabs, and **false** means to use horizontal tabs.
Default value: **false**| -| scrollable | boolean | Whether the tabs are scrollable. The value **true** means that the tabs are scrollable, and **false** means the opposite.
Default value: **true**| -| barMode | BarMode | Tab bar layout mode. For details, see **BarMode**.
Default value: **BarMode.Fixed**| -| barWidth | number \| Length8+ | Width of the tab bar. | -| barHeight | number \| Length8+ | Height of the tab bar. | -| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **200**| +| Name | Type | Description | +| ------------------------ | ---------------------------------------- | ---------------------------------------- | +| vertical | boolean | Whether to use vertical tabs. The value **true** means to use vertical tabs, and **false** means to use horizontal tabs.
Default value: **false**| +| scrollable | boolean | Whether the tabs are scrollable. The value **true** means that the tabs are scrollable, and **false** means the opposite.
Default value: **true**| +| barMode | BarMode | Tab bar layout mode. For details, see **BarMode**.
Default value: **BarMode.Fixed**| +| barWidth | number \| Length8+ | Width of the tab bar.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| +| barHeight | number \| Length8+ | Height of the tab bar.
**NOTE**

A value less than 0 or greater than the width of the **\** component evaluates to the default value.| +| animationDuration | number | Duration of the slide animation for tab switching. If this parameter is set, the tab switching animation is played when the user switches between tabs by sliding or clicking. If this parameter is not set, the tab switching animation is played only when the user switches between tabs by sliding.
Default value: **300**
**NOTE**
A value less than 0 or in percentage evaluates to the default value. | +| divider10+ | [DividerStyle](#dividerstyle10) \| null | Whether the divider is displayed for the **\** and **\** components and the divider style. By default, the divider is not displayed.
**DividerStyle**: divider style.
**null**: The divider is not displayed.| +| FadingEdge10+ | boolean | Whether the tab fades out when it exceeds the container width.
Default value: **true** | + +## DividerStyle10+ + +| Name | Type | Mandatory | Description | +| ----------- | ---------------------------------------- | ---- | ----------------------------------- | +| strokeWidth | [Length](ts-types.md#length) | Yes | Width of the divider. | +| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the divider.
Default value: **#33182431** | +| startMargin | [Length](ts-types.md#length) | No | Distance between the divider and the top of the sidebar.
Default value: **0.0**
Unit: vp| +| endMargin | [Length](ts-types.md#length) | No | Distance between the divider and the bottom of the sidebar.
Default value: **0.0**
Unit: vp| ## BarMode -| Name| Description| -| -------- | -------- | +| Name | Description | +| ---------- | ---------------------------------------- | | Scrollable | The width of each tab is determined by the actual layout. The tabs are scrollable in the following case: In horizontal layout, the total width exceeds the tab bar width; in horizontal layout, the total height exceeds the tab bar height.| -| Fixed | The width of each tab is determined by equally dividing the number of tabs by the bar width (or the bar height in vertical layout).| +| Fixed | The width of each tab is determined by equally dividing the number of tabs by the bar width (or bar height in the vertical layout).| ## Events In addition to the [universal events](ts-universal-events-click.md), the following events are supported. -| Name| Description| -| -------- | -------- | -| onChange(event: (index: number) => void) | Event triggered when a tab is switched.| +| Name | Description | +| ------------------------------------------- | ------------------------------------------------------------ | +| onChange(event: (index: number) => void) | Triggered when a tab is switched.
- **index**: index of the active tab. The index starts from 0.
This event is triggered when any of the following conditions is met:
1. The **\** component supports sliding, and the user slides on the tab bar.
2. The [Controller](#tabscontroller) API is called.
3. The attribute value is updated using a [state variable](../../quick-start/arkts-state.md).
4. A tab is clicked. | ## TabsController @@ -66,9 +77,8 @@ Defines a tab controller, which is used to control switching of tabs. One **Tabs ### Objects to Import -``` +```ts controller: TabsController = new TabsController() - ``` ### changeIndex @@ -79,9 +89,9 @@ Switches to the specified tab. **Parameters** -| Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| value | number | Yes| Index of the tab. The value starts from 0.| +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ---------------------------------------- | +| value | number | Yes | Index of the tab. The value starts from 0.
**NOTE**

If this parameter is set to a value less than 0 or greater than the maximum number, the event will be invalid.| ## Example @@ -148,3 +158,4 @@ struct TabsExample { ``` ![tabs2](figures/tabs2.gif) + \ No newline at end of file diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index c69ca31dbccaa9f3246500d1b5baa92cc50718bc..47c8c41f78db5961fb831835c0b73fd8b91e129e 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -37,10 +37,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeDashArray | Array<Length> | Stroke dashes.
Default value: **[]**
Since API version 9, this API is supported in ArkTS widgets.| | strokeDashOffset | number \| string | Offset of the start point for drawing the stroke.
Default value: **0**
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | Cap style of the stroke.
Default value: **LineCapStyle.Butt**
Since API version 9, this API is supported in ArkTS widgets.| -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.
Default value: **LineJoinStyle.Miter**
Since API version 9, this API is supported in ArkTS widgets.| +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | Join style of the stroke.
Default value: **LineJoinStyle.Miter**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners.| | strokeMiterLimit | number \| string | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.
Default value: **4**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect for the **\** component, because it does not have a miter join.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| Stroke opacity.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | Stroke width.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | Stroke width.
Default value: **1**
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | Whether anti-aliasing is enabled.
Default value: **true**
Since API version 9, this API is supported in ArkTS widgets.| diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index c8249cf5a97811d42832fd262c1eee1d3bc2e985..95d6e04adb6cdac5a36d57cc6013c3eb98434491 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -37,10 +37,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| | strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect for the **\** component, because it does not have a miter join.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md index a8097c5e449d613a378643fef8902abe41be6bba..fec90d36ae1f8b6ebdd3464142a29dbe9bbfd2e7 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -39,10 +39,10 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeDashArray | Array<Length> | [] | Stroke dashes.
Since API version 9, this API is supported in ArkTS widgets.| | strokeDashOffset | number \| string | 0 | Offset of the start point for drawing the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | Cap style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not work for the **\** component, which does not have corners. | | strokeMiterLimit | number \| string | 4 | Limit value when the sharp angle is drawn as a miter.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
This attribute does not take effect because the **\** component cannot be used to draw a shape with a sharp angle.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| ## Example @@ -58,35 +58,41 @@ struct LineExample { Column({ space: 10 }) { // The coordinates of the start and end points of the line are determined relative to the coordinates of the drawing area of the component. Line() + .width(200) + .height(150) .startPoint([0, 0]) .endPoint([50, 100]) .stroke(Color.Black) .backgroundColor('#F5F5F5') Line() .width(200) - .height(200) + .height(150) .startPoint([50, 50]) .endPoint([150, 150]) .strokeWidth(5) .stroke(Color.Orange) .strokeOpacity(0.5) .backgroundColor('#F5F5F5') - // If the coordinates of a point are beyond the width and height range of the component, the line will exceed the drawing area. - Line({ width: 50, height: 50 }) + // strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered. + Line() + .width(200) + .height(150) .startPoint([0, 0]) .endPoint([100, 100]) .stroke(Color.Black) .strokeWidth(3) .strokeDashArray([10, 3]) + .strokeDashOffset(5) .backgroundColor('#F5F5F5') - // strokeDashOffset is used to define the offset when the associated strokeDashArray array is rendered. - Line({ width: 50, height: 50 }) + // If the coordinates of a point are beyond the width and height range of the component, the line will exceed the drawing area. + Line() + .width(50) + .height(50) .startPoint([0, 0]) .endPoint([100, 100]) .stroke(Color.Black) .strokeWidth(3) .strokeDashArray([10, 3]) - .strokeDashOffset(5) .backgroundColor('#F5F5F5') } } @@ -151,12 +157,16 @@ struct LineExample { build() { Column() { Line() + .width(300) + .height(30) .startPoint([50, 30]) .endPoint([300, 30]) .stroke(Color.Black) .strokeWidth(10) // Set the interval for strokeDashArray to 50. Line() + .width(300) + .height(30) .startPoint([50, 20]) .endPoint([300, 20]) .stroke(Color.Black) @@ -164,6 +174,8 @@ struct LineExample { .strokeDashArray([50]) // Set the interval for strokeDashArray to 50, 10. Line() + .width(300) + .height(30) .startPoint([50, 20]) .endPoint([300, 20]) .stroke(Color.Black) @@ -171,6 +183,8 @@ struct LineExample { .strokeDashArray([50, 10]) // Set the interval for strokeDashArray to 50, 10, 20. Line() + .width(300) + .height(30) .startPoint([50, 20]) .endPoint([300, 20]) .stroke(Color.Black) @@ -178,6 +192,8 @@ struct LineExample { .strokeDashArray([50, 10, 20]) // Set the interval for strokeDashArray to 50, 10, 20, 30. Line() + .width(300) + .height(30) .startPoint([50, 20]) .endPoint([300, 20]) .stroke(Color.Black) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md index 313e416b8be00dff249f60ff55af2337a81c889c..25ba06a014b013ed97219d21cca40cca8f8e90c3 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -41,7 +41,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the stroke.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Width of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Width of the stroke.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| The supported commands are as follows: @@ -74,9 +74,10 @@ struct PathExample { .fontSize(11) .fontColor(0xCCCCCC) .width('90%') - // Draw a straight line whose length is 900 px and width is 3 vp. + // Draw a straight line whose length is 600 px and width is 3 vp. Path() - .height(10) + .width('600px') + .height('10px') .commands('M0 0 L600 0') .stroke(Color.Black) .strokeWidth(3) @@ -88,16 +89,22 @@ struct PathExample { // Draw a straight line. Flex({ justifyContent: FlexAlign.SpaceBetween }) { Path() + .width('210px') + .height('310px') .commands('M100 0 L200 240 L0 240 Z') .fillOpacity(0) .stroke(Color.Black) .strokeWidth(3) Path() + .width('210px') + .height('310px') .commands('M0 0 H200 V200 H0 Z') .fillOpacity(0) .stroke(Color.Black) .strokeWidth(3) Path() + .width('210px') + .height('310px') .commands('M100 0 L0 100 L50 200 L150 200 L200 100 Z') .fillOpacity(0) .stroke(Color.Black) @@ -108,16 +115,22 @@ struct PathExample { // Draw an arc. Flex({ justifyContent: FlexAlign.SpaceBetween }) { Path() + .width('250px') + .height('310px') .commands("M0 300 S100 0 240 300 Z") .fillOpacity(0) .stroke(Color.Black) .strokeWidth(3) Path() + .width('210px') + .height('310px') .commands('M0 150 C0 100 140 0 200 150 L100 300 Z') .fillOpacity(0) .stroke(Color.Black) .strokeWidth(3) Path() + .width('210px') + .height('310px') .commands('M0 100 A30 20 20 0 0 200 100 Z') .fillOpacity(0) .stroke(Color.Black) diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index d126f92b224838ffb413cd58b0ad1f287300d184..8a0450ff17a692d98170a9dca96d7acb65250660 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -42,7 +42,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| ## Point diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index 4e5d746283be0023fe1951fa12a81d8cfdec398a..6681e790aeb02e3bcfb706cf0162e9c0376e7906 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -42,7 +42,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| ## Point diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index f6ce5646c2893449a91080a30eeb635949d42f50..c7fac4fa35067c4e9be6e6e7aca05f0d7e25bdb1 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -48,7 +48,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | Length | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
The value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| diff --git a/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 0444767799d78e070b7d2bb1aec631189587c5b2..d97d69beb73a8ac5c3a0a1c52c701287f056f827 100644 --- a/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/en/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -36,7 +36,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | Name| Type| Default Value| Description| | -------- | -------- | -------- | -------- | -| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | View port of the shape.
Since API version 9, this API is supported in ArkTS widgets.| +| viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | View port of the shape.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.| | fill | [ResourceColor](ts-types.md) | Color.Black | Color of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| | fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Opacity of the fill area.
Since API version 9, this API is supported in ArkTS widgets.| | stroke | [ResourceColor](ts-types.md) | - | Stroke color. If this attribute is not set, the component does not have any stroke.
Since API version 9, this API is supported in ArkTS widgets.| @@ -46,7 +46,7 @@ In addition to the [universal attributes](ts-universal-attributes-size.md), the | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | Join style of the stroke.
Since API version 9, this API is supported in ArkTS widgets.| | strokeMiterLimit | number \| string | 4 | Limit on the ratio of the miter length to the value of **strokeWidth** used to draw a miter join. The miter length indicates the distance from the outer tip to the inner corner of the miter.
**NOTE**
This attribute must be set to a value greater than or equal to 1 and takes effect when **strokeLineJoin** is set to **LineJoinStyle.Miter**.
Since API version 9, this API is supported in ArkTS widgets.| | strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | Stroke opacity.
**NOTE**
The value range is [0.0, 1.0]. If the set value is less than 0.0, **0.0** will be used. If the set value is greater than 1.0, **1.0** will be used.
Since API version 9, this API is supported in ArkTS widgets.| -| strokeWidth | number \| string | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.| +| strokeWidth | number \| string | 1 | Stroke width.
Since API version 9, this API is supported in ArkTS widgets.
**NOTE**
If of the string type, the value cannot be a percentage.| | antiAlias | boolean | true | Whether anti-aliasing is enabled.
Since API version 9, this API is supported in ArkTS widgets.| | mesh8+ | Array<number>,number,number | [],0,0 | Mesh effect. The first parameter is an array of lengths (column + 1) * (row + 1) * 2, which records the position of each vertex of the distorted bitmap. The second parameter is the number of columns in the mesh matrix. The third parameter is the number of rows in the mesh matrix.
Since API version 9, this API is supported in ArkTS widgets.| @@ -70,6 +70,8 @@ struct ShapeExample { Ellipse().width(300).height(50).offset({ x: 0, y: 60 }) Path().width(300).height(10).commands('M0 0 L900 0').offset({ x: 0, y: 120 }) } + .width(350) + .height(140) .viewPort({ x: -2, y: -2, width: 304, height: 130 }) .fill(0x317AF7) .stroke(Color.Black) @@ -83,6 +85,8 @@ struct ShapeExample { Shape() { Rect().width(300).height(50) } + .width(350) + .height(80) .viewPort({ x: 0, y: 0, width: 320, height: 70 }) .fill(0x317AF7) .stroke(Color.Black) @@ -91,6 +95,8 @@ struct ShapeExample { Shape() { Rect().width(300).height(50) } + .width(350) + .height(80) .viewPort({ x: -5, y: -5, width: 320, height: 70 }) .fill(0x317AF7) .stroke(Color.Black) @@ -101,6 +107,8 @@ struct ShapeExample { Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } + .width(350) + .height(20) .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443) .strokeWidth(10) @@ -109,6 +117,8 @@ struct ShapeExample { Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } + .width(350) + .height(20) .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443) .strokeWidth(10) @@ -118,6 +128,8 @@ struct ShapeExample { Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } + .width(350) + .height(20) .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443) .strokeWidth(10) @@ -126,6 +138,8 @@ struct ShapeExample { Shape() { Path().width(300).height(10).commands('M0 0 L900 0') } + .width(350) + .height(20) .viewPort({ x: 0, y: -5, width: 300, height: 20 }) .stroke(0xEE8443) .strokeWidth(10) @@ -135,7 +149,9 @@ struct ShapeExample { Shape() { Path().width(200).height(60).commands('M0 0 L400 0 L400 150 Z') } - .viewPort({ x: -80, y: -5, width: 310, height: 90 }) + .width(300) + .height(200) + .viewPort({ x: -20, y: -5, width: 310, height: 90 }) .fill(0x317AF7) .stroke(0xEE8443) .strokeWidth(10) @@ -147,3 +163,4 @@ struct ShapeExample { ``` ![en-us_image_0000001184628104](figures/en-us_image_0000001184628104.png) + diff --git a/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md b/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md index 73f768ddf45b6f5bf2a729272fdcf2f545d308da..c4a63cc5d1587addfe657df4e78359bd40a2de27 100644 --- a/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md +++ b/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-span.md @@ -23,7 +23,7 @@ The [universal attributes](js-service-widget-common-attributes.md) are supported | Name| Type| Default Value| Mandatory| Description| | -------- | -------- | -------- | -------- | -------- | | color | <color> | - | No| Font color of the modified text.| -| font-size | <length> | 30px | No| Font size of the modified text.| +| font-size | <length> | 16px | No| Font size of the modified text.| | font-style | string | normal | No| Font style of the modified text. For details, see **font-style** of the [**\**](js-service-widget-basic-text.md#styles) component.| | font-weight | number \| string | normal | No| Font weight of the modified text. For details, see **font-weight** of the [**\**](js-service-widget-basic-text.md##styles) component.| | text-decoration | string | none | No| Text decoration of the modified text. For details, see **text-decoration** of the [**\**](js-service-widget-basic-text.md#styles) component.| diff --git a/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md b/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md index 4465c52e7c14c78826e74613c367aedeefb83f23..08c131e01a6494f5cec12e4c2c7d862a1ce8589b 100644 --- a/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md +++ b/en/application-dev/reference/js-service-widget-ui/js-service-widget-basic-text.md @@ -25,7 +25,7 @@ In addition to the [universal styles](js-service-widget-common-styles.md), the f | Name| Type| Default Value| Mandatory| Description| | -------- | -------- | -------- | -------- | -------- | | color | <color> | - | No| Font color.| -| font-size | <length> | 30px | No| Font size.| +| font-size | <length> | 16px | No| Font size.| | letter-spacing | <length> | 0px | No| Character spacing (px).| | font-style | string | normal | No| Font style. Available values are as follows:
- **normal**: standard font style
- **italic**: italic font style| | font-weight | number \| string | normal | No| Font weight. For the number type, the value ranges from 100 to 900. The default value is 400. A larger value indicates a heavier font weight.
The value of the number type must be an integer multiple of 100.
The value of the string type can be **lighter**, **normal**, **bold**, or **bolder**.| diff --git a/en/application-dev/reference/native-apis/Readme-EN.md b/en/application-dev/reference/native-apis/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..1101b441d4dc99531bf9373ebda56f7ef750d49a --- /dev/null +++ b/en/application-dev/reference/native-apis/Readme-EN.md @@ -0,0 +1,93 @@ +# Native API + +- Modules + - [Native XComponent](_o_h___native_x_component.md) + - [HiLog](_hi_log.md) + - [NativeWindow](_native_window.md) + - [Drawing](_drawing.md) + - [Image](image.md) + - [Rawfile](rawfile.md) + - [MindSpore](_mind_spore.md) + - [NeuralNeworkRuntime](_neural_nework_runtime.md) + - [AudioDecoder](_audio_decoder.md) + - [AudioEncoder](_audio_encoder.md) + - [CodecBase](_codec_base.md) + - [VideoDecoder](_video_decoder.md) + - [VideoEncoder](_video_encoder.md) + - [Core](_core.md) + - [HuksKeyApi](_huks_key_api.md) + - [HuksParamSetApi](_huks_param_set_api.md) + - [HuksTypeApi](_huks_type_api.md) +- Header Files + - [drawing_bitmap.h](drawing__bitmap_8h.md) + - [drawing_brush.h](drawing__brush_8h.md) + - [drawing_canvas.h](drawing__canvas_8h.md) + - [drawing_color.h](drawing__color_8h.md) + - [drawing_font_collection.h](drawing__font__collection_8h.md) + - [drawing_path.h](drawing__path_8h.md) + - [drawing_pen.h](drawing__pen_8h.md) + - [drawing_text_declaration.h](drawing__text__declaration_8h.md) + - [drawing_text_typography.h](drawing__text__typography_8h.md) + - [drawing_types.h](drawing__types_8h.md) + - [external_window.h](external__window_8h.md) + - [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) + - [log.h](log_8h.md) + - [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) + - [raw_dir.h](raw__dir_8h.md) + - [raw_file_manager.h](raw__file__manager_8h.md) + - [raw_file.h](raw__file_8h.md) + - [context.h](context_8h.md) + - [data_type.h](data__type_8h.md) + - [format.h](format_8h.md) + - [model.h](model_8h.md) + - [status.h](status_8h.md) + - [tensor.h](tensor_8h.md) + - [types.h](types_8h.md) + - [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) + - [neural_network_runtime.h](neural__network__runtime_8h.md) + - [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) + - [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) + - [native_avcodec_base.h](native__avcodec__base_8h.md) + - [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) + - [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) + - [native_averrors.h](native__averrors_8h.md) + - [native_avformat.h](native__avformat_8h.md) + - [native_avmemory.h](native__avmemory_8h.md) + - [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) +- Structs + - [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) + - [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) + - [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) + - [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) + - [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) + - [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) + - [OHExtDataHandle](_o_h_ext_data_handle.md) + - [OHHDRMetaData](_o_h_h_d_r_meta_data.md) + - [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) + - [OhosPixelMapInfo](_ohos_pixel_map_info.md) + - [RawFileDescriptor](_raw_file_descriptor.md) + - [Region](_region.md) + - [Rect](_rect.md) + - [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) + - [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) + - [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) + - [OH_NN_Memory](_o_h___n_n___memory.md) + - [OH_NN_QuantParam](_o_h___n_n___quant_param.md) + - [OH_NN_Tensor](_o_h___n_n___tensor.md) + - [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) + - [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) + - [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) + - [OH_Huks_Blob](_o_h___huks___blob.md) + - [OH_Huks_CertChain](_o_h___huks___cert_chain.md) + - [OH_Huks_KeyInfo](_o_h___huks___key_info.md) + - [OH_Huks_KeyMaterial25519](_o_h___huks___key_material25519.md) + - [OH_Huks_KeyMaterialDh](_o_h___huks___key_material_dh.md) + - [OH_Huks_KeyMaterialDsa](_o_h___huks___key_material_dsa.md) + - [OH_Huks_KeyMaterialEcc](_o_h___huks___key_material_ecc.md) + - [OH_Huks_KeyMaterialRsa](_o_h___huks___key_material_rsa.md) + - [OH_Huks_Param](_o_h___huks___param.md) + - [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) diff --git a/en/application-dev/reference/native-apis/_audio_decoder.md b/en/application-dev/reference/native-apis/_audio_decoder.md new file mode 100644 index 0000000000000000000000000000000000000000..2e9139ac64dd9cdc27f2099b43be1d680551be0a --- /dev/null +++ b/en/application-dev/reference/native-apis/_audio_decoder.md @@ -0,0 +1,381 @@ +# AudioDecoder + + +## Overview + +Provides the functions for audio decoding. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_avcodec_audiodecoder.h](native__avcodec__audiodecoder_8h.md) | Declares the native APIs used for audio decoding.
File to Include: | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AudioDecoder_CreateByMime](#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioDecoder_CreateByName](#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | +| [OH_AudioDecoder_Destroy](#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | +| [OH_AudioDecoder_SetCallback](#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Configure](#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Prepare](#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | +| [OH_AudioDecoder_Start](#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioDecoder_Stop](#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_AudioDecoder_Flush](#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioDecoder_Reset](#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_AudioDecoder_GetOutputDescription](#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioDecoder_SetParameter](#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_AudioDecoder_PushInputData](#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | +| [OH_AudioDecoder_FreeOutputData](#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | + + +## Function Description + + +### OH_AudioDecoder_Configure() + + +``` +OH_AVErrCode OH_AudioDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the audio track to be decoded. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_CreateByMime() + + +``` +OH_AVCodec* OH_AudioDecoder_CreateByMime (const char * mime) +``` +**Description**
+Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_AudioDecoder_CreateByName() + + +``` +OH_AVCodec* OH_AudioDecoder_CreateByName (const char * name) +``` +**Description**
+Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| name | Indicates the pointer to an audio decoder name. | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_AudioDecoder_Destroy() + + +``` +OH_AVErrCode OH_AudioDecoder_Destroy (OH_AVCodec * codec) +``` +**Description**
+Clears the internal resources of an audio decoder and destroys the audio decoder instance. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_Flush() + + +``` +OH_AVErrCode OH_AudioDecoder_Flush (OH_AVCodec * codec) +``` +**Description**
+Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_FreeOutputData() + + +``` +OH_AVErrCode OH_AudioDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +``` +**Description**
+Frees an output buffer of an audio decoder. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_GetOutputDescription() + + +``` +OH_AVFormat* OH_AudioDecoder_GetOutputDescription (OH_AVCodec * codec) +``` +**Description**
+Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns the handle to an **OH_AVFormat** instance, which must be manually released. + + +### OH_AudioDecoder_Prepare() + + +``` +OH_AVErrCode OH_AudioDecoder_Prepare (OH_AVCodec * codec) +``` +**Description**
+Prepares internal resources for an audio decoder. This API must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_PushInputData() + + +``` +OH_AVErrCode OH_AudioDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +``` +**Description**
+Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_Reset() + + +``` +OH_AVErrCode OH_AudioDecoder_Reset (OH_AVCodec * codec) +``` +**Description**
+Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_SetCallback() + + +``` +OH_AVErrCode OH_AudioDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +``` +**Description**
+Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | +| userData | Indicates the pointer to user-specific data. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_SetParameter() + + +``` +OH_AVErrCode OH_AudioDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_Start() + + +``` +OH_AVErrCode OH_AudioDecoder_Start (OH_AVCodec * codec) +``` +**Description**
+Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioDecoder_Stop() + + +``` +OH_AVErrCode OH_AudioDecoder_Stop (OH_AVCodec * codec) +``` +**Description**
+Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. + +\@syscap SystemCapability.Multimedia.Media.AudioDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. diff --git a/en/application-dev/reference/native-apis/_audio_encoder.md b/en/application-dev/reference/native-apis/_audio_encoder.md new file mode 100644 index 0000000000000000000000000000000000000000..07a727f5b55f808004864c7212b6fd6768da30ea --- /dev/null +++ b/en/application-dev/reference/native-apis/_audio_encoder.md @@ -0,0 +1,381 @@ +# AudioEncoder + + +## Overview + +Provides the functions for audio encoding. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_avcodec_audioencoder.h](native__avcodec__audioencoder_8h.md) | Declares the native APIs used for audio encoding.
File to Include: | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AudioEncoder_CreateByMime](#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioEncoder_CreateByName](#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | +| [OH_AudioEncoder_Destroy](#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | +| [OH_AudioEncoder_SetCallback](#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Configure](#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Prepare](#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | +| [OH_AudioEncoder_Start](#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioEncoder_Stop](#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_AudioEncoder_Flush](#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioEncoder_Reset](#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_AudioEncoder_GetOutputDescription](#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioEncoder_SetParameter](#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_AudioEncoder_PushInputData](#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | +| [OH_AudioEncoder_FreeOutputData](#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | + + +## Function Description + + +### OH_AudioEncoder_Configure() + + +``` +OH_AVErrCode OH_AudioEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_CreateByMime() + + +``` +OH_AVCodec* OH_AudioEncoder_CreateByMime (const char * mime) +``` +**Description**
+Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac). | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_AudioEncoder_CreateByName() + + +``` +OH_AVCodec* OH_AudioEncoder_CreateByName (const char * name) +``` +**Description**
+Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| name | Indicates the pointer to an audio encoder name. | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_AudioEncoder_Destroy() + + +``` +OH_AVErrCode OH_AudioEncoder_Destroy (OH_AVCodec * codec) +``` +**Description**
+Clears the internal resources of an audio encoder and destroys the audio encoder instance. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_Flush() + + +``` +OH_AVErrCode OH_AudioEncoder_Flush (OH_AVCodec * codec) +``` +**Description**
+Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_FreeOutputData() + + +``` +OH_AVErrCode OH_AudioEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +``` +**Description**
+Frees an output buffer of an audio encoder. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_GetOutputDescription() + + +``` +OH_AVFormat* OH_AudioEncoder_GetOutputDescription (OH_AVCodec * codec) +``` +**Description**
+Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns the handle to an **OH_AVFormat** instance, which must be manually released. + + +### OH_AudioEncoder_Prepare() + + +``` +OH_AVErrCode OH_AudioEncoder_Prepare (OH_AVCodec * codec) +``` +**Description**
+Prepares internal resources for an audio encoder. This API must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_PushInputData() + + +``` +OH_AVErrCode OH_AudioEncoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +``` +**Description**
+Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_Reset() + + +``` +OH_AVErrCode OH_AudioEncoder_Reset (OH_AVCodec * codec) +``` +**Description**
+Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_SetCallback() + + +``` +OH_AVErrCode OH_AudioEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +``` +**Description**
+Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | +| userData | Indicates the pointer to user-specific data. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_SetParameter() + + +``` +OH_AVErrCode OH_AudioEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_Start() + + +``` +OH_AVErrCode OH_AudioEncoder_Start (OH_AVCodec * codec) +``` +**Description**
+Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_AudioEncoder_Stop() + + +``` +OH_AVErrCode OH_AudioEncoder_Stop (OH_AVCodec * codec) +``` +**Description**
+Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. + +\@syscap SystemCapability.Multimedia.Media.AudioEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. diff --git a/en/application-dev/reference/native-apis/_codec_base.md b/en/application-dev/reference/native-apis/_codec_base.md new file mode 100644 index 0000000000000000000000000000000000000000..c908c604e4cb448ddf2bef4f071c5d588a0cbb89 --- /dev/null +++ b/en/application-dev/reference/native-apis/_codec_base.md @@ -0,0 +1,567 @@ +# CodecBase + + +## Overview + +Provides the common structs, character constants, and enums for running **OH_AVCodec** instances. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| [OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | +| [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | +| [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_MediaType](#oh_mediatype) | Enumerates the media types. | +| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles. | +| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {
**AVCODEC_BUFFER_FLAGS_NONE** = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_MediaType](#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types. | +| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles. | +| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles. | + + +### Variables + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferAttr::pts](#pts) | Presentation timestamp of the buffer, in microseconds. | +| [OH_AVCodecBufferAttr::size](#size) | Size of the data contained in the buffer, in bytes. | +| [OH_AVCodecBufferAttr::offset](#offset) | Start offset of valid data in the buffer. | +| [OH_AVCodecBufferAttr::flags](#flags) | Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). | +| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). | +| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). | +| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. | +| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. | +| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. | +| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string. | +| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t. | +| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. | +| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. | +| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. | +| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. | +| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). | +| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. | +| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. | +| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). | +| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). | +| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. | +| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. | +| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | +| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | + + +## Type Description + + +### OH_AACProfile + + +``` +typedef enum OH_AACProfileOH_AACProfile +``` +**Description**
+Enumerates the AAC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCodecAsyncCallback + + +``` +typedef struct OH_AVCodecAsyncCallbackOH_AVCodecAsyncCallback +``` +**Description**
+Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + **Parameters** + +| Name | Description | +| -------- | -------- | +| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror). | +| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged). | +| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata). | +| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata). | + + +### OH_AVCodecBufferAttr + + +``` +typedef struct OH_AVCodecBufferAttrOH_AVCodecBufferAttr +``` +**Description**
+Defines the buffer attributes of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCodecBufferFlags + + +``` +typedef enum OH_AVCodecBufferFlagsOH_AVCodecBufferFlags +``` +**Description**
+Enumerates the buffer flags of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCodecOnError + + +``` +typedef void(* OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *userData) +``` +**Description**
+Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| errorCode | Indicates an error code. | +| userData | Indicates the pointer to user-specific data. | + + +### OH_AVCodecOnNeedInputData + + +``` +typedef void(* OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData) +``` +**Description**
+Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| data | Indicates the pointer to the new input data. | +| userData | Indicates the pointer to user-specific data. | + + +### OH_AVCodecOnNewOutputData + + +``` +typedef void(* OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData) +``` +**Description**
+Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of a new output buffer. | +| data | Indicates the pointer to the new output data. | +| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md). | +| userData | Indicates the pointer to user-specific data. | +| userData | specified data | + + +### OH_AVCodecOnStreamChanged + + +``` +typedef void(* OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *format, void *userData) +``` +**Description**
+Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to the attributes of the new output stream. | +| userData | Indicates the pointer to user-specific data. | + + +### OH_AVCProfile + + +``` +typedef enum OH_AVCProfileOH_AVCProfile +``` +**Description**
+Enumerates the AVC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MediaType + + +``` +typedef enum OH_MediaTypeOH_MediaType +``` +**Description**
+Enumerates the media types. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +## Enum Description + + +### OH_AACProfile + + +``` +enum OH_AACProfile +``` +**Description**
+Enumerates the AAC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCodecBufferFlags + + +``` +enum OH_AVCodecBufferFlags +``` +**Description**
+Enumerates the buffer flags of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +| Name | Description | +| -------- | -------- | +| AVCODEC_BUFFER_FLAGS_EOS | The buffer contains an end-of-stream frame. | +| AVCODEC_BUFFER_FLAGS_SYNC_FRAME | The buffer contains a sync frame. | +| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME | The buffer contains part of a frame. | +| AVCODEC_BUFFER_FLAGS_CODEC_DATA | The buffer contains codec-specific data. | + + +### OH_AVCProfile + + +``` +enum OH_AVCProfile +``` +**Description**
+Enumerates the AVC profiles. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MediaType + + +``` +enum OH_MediaType +``` +**Description**
+Enumerates the media types. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +| Name | Description | +| -------- | -------- | +| MEDIA_TYPE_AUD | Audio track. | +| MEDIA_TYPE_VID | Video track. | + + +## Variable Description + + +### flags + + +``` +uint32_t OH_AVCodecBufferAttr::flags +``` +**Description**
+Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags). + + +### offset + + +``` +int32_t OH_AVCodecBufferAttr::offset +``` +**Description**
+Start offset of valid data in the buffer. + + +### OH_AVCODEC_MIMETYPE_AUDIO_AAC + + +``` +const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC +``` +**Description**
+Defines the MIME type for Advanced Audio Coding (AAC). + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_AVCODEC_MIMETYPE_VIDEO_AVC + + +``` +const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC +``` +**Description**
+Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_ED_KEY_EOS + + +``` +const char* OH_ED_KEY_EOS +``` +**Description**
+Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool. + + +### OH_ED_KEY_TIME_STAMP + + +``` +const char* OH_ED_KEY_TIME_STAMP +``` +**Description**
+Provides unified character descriptors for the auxiliary data of the surface buffer. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MD_KEY_AUD_CHANNEL_COUNT + + +``` +const char* OH_MD_KEY_AUD_CHANNEL_COUNT +``` +**Description**
+Character descriptor of the number of audio channels. The value type is uint32_t. + + +### OH_MD_KEY_AUD_SAMPLE_RATE + + +``` +const char* OH_MD_KEY_AUD_SAMPLE_RATE +``` +**Description**
+Character descriptor of the audio sampling rate. The value type is uint32_t. + + +### OH_MD_KEY_AUDIO_SAMPLE_FORMAT + + +``` +const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT +``` +**Description**
+Character descriptor of the audio sample format. The value type is uint32_t. + + +### OH_MD_KEY_BITRATE + + +``` +const char* OH_MD_KEY_BITRATE +``` +**Description**
+Character descriptor of the bit rate. The value type is uint32_t. + + +### OH_MD_KEY_CODEC_MIME + + +``` +const char* OH_MD_KEY_CODEC_MIME +``` +**Description**
+Character descriptor of the MIME type. The value type is string. + + +### OH_MD_KEY_DURATION + + +``` +const char* OH_MD_KEY_DURATION +``` +**Description**
+Character descriptor of duration. The value type is int64_t. + + +### OH_MD_KEY_FRAME_RATE + + +``` +const char* OH_MD_KEY_FRAME_RATE +``` +**Description**
+Character descriptor of the video frame rate. The value type is double. + + +### OH_MD_KEY_HEIGHT + + +``` +const char* OH_MD_KEY_HEIGHT +``` +**Description**
+Character descriptor of the video height. The value type is uint32_t. + + +### OH_MD_KEY_I_FRAME_INTERVAL + + +``` +const char* OH_MD_KEY_I_FRAME_INTERVAL +``` +**Description**
+Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. + + +### OH_MD_KEY_MAX_INPUT_SIZE + + +``` +const char* OH_MD_KEY_MAX_INPUT_SIZE +``` +**Description**
+Character descriptor of the maximum input size. The value type is uint32_t. + + +### OH_MD_KEY_PIXEL_FORMAT + + +``` +const char* OH_MD_KEY_PIXEL_FORMAT +``` +**Description**
+Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat). + + +### OH_MD_KEY_PROFILE + + +``` +const char* OH_MD_KEY_PROFILE +``` +**Description**
+Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile). + + +### OH_MD_KEY_ROTATION + + +``` +const char* OH_MD_KEY_ROTATION +``` +**Description**
+Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. + + +### OH_MD_KEY_TRACK_TYPE + + +``` +const char* OH_MD_KEY_TRACK_TYPE +``` +**Description**
+Provides unified character descriptors for the media playback framework. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + + +### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE + + +``` +const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE +``` +**Description**
+Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode). + + +### OH_MD_KEY_WIDTH + + +``` +const char* OH_MD_KEY_WIDTH +``` +**Description**
+Character descriptor of the video width. The value type is uint32_t. + + +### pts + + +``` +int64_t OH_AVCodecBufferAttr::pts +``` +**Description**
+Presentation timestamp of the buffer, in microseconds. + + +### size + + +``` +int32_t OH_AVCodecBufferAttr::size +``` +**Description**
+Size of the data contained in the buffer, in bytes. diff --git a/en/application-dev/reference/native-apis/_core.md b/en/application-dev/reference/native-apis/_core.md new file mode 100644 index 0000000000000000000000000000000000000000..711afe087588ead0b547251bf97f398d699f8c75 --- /dev/null +++ b/en/application-dev/reference/native-apis/_core.md @@ -0,0 +1,589 @@ +# Core + + +## Overview + +Provides the basic backbone capabilities for the media playback framework, including functions related to the memory, error code, and format carrier. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_averrors.h](native__averrors_8h.md) | Declares the error codes used by the media playback framework.
File to Include: | +| [native_avformat.h](native__avformat_8h.md) | Declares the format-related functions and enums.
File to Include: | +| [native_avmemory.h](native__avmemory_8h.md) | Declares the memory-related functions.
File to Include: | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AVErrCode](#oh_averrcode) | Enumerates the audio and video error codes. | +| [OH_AVPixelFormat](#oh_avpixelformat) | Enumerates the audio and video pixel formats. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AVErrCode](#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes. | +| [OH_AVPixelFormat](#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the audio and video pixel formats. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AVFormat_Create](#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading and writing data. | +| [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. | +| [OH_AVFormat_Copy](#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. | +| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. | +| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. | +| [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an**OH_AVFormat** instance as a string. | +| [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. | +| [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. | + + +## Type Description + + +### OH_AVErrCode + + +``` +typedef enum OH_AVErrCodeOH_AVErrCode +``` +**Description**
+Enumerates the audio and video error codes. + +\@syscap SystemCapability.Multimedia.Media.Core + + +### OH_AVPixelFormat + + +``` +typedef enum OH_AVPixelFormatOH_AVPixelFormat +``` +**Description**
+Enumerates the audio and video pixel formats. + +\@syscap SystemCapability.Multimedia.Media.Core + + +## Enum Description + + +### OH_AVErrCode + + +``` +enum OH_AVErrCode +``` +**Description**
+Enumerates the audio and video error codes. + +\@syscap SystemCapability.Multimedia.Media.Core + +| Name | Description | +| -------- | -------- | +| AV_ERR_OK | Operation successful. | +| AV_ERR_NO_MEMORY | No memory. | +| AV_ERR_OPERATE_NOT_PERMIT | Invalid parameter. | +| AV_ERR_INVALID_VAL | Invalid value. | +| AV_ERR_IO | I/O error. | +| AV_ERR_TIMEOUT | Timeout. | +| AV_ERR_UNKNOWN | Unknown error. | +| AV_ERR_SERVICE_DIED | Unavailable media service. | +| AV_ERR_INVALID_STATE | Unsupported operation in this state. | +| AV_ERR_UNSUPPORT | Unsupported API. | +| AV_ERR_EXTEND_START | Initial value for extended error codes. | + + +### OH_AVPixelFormat + + +``` +enum OH_AVPixelFormat +``` +**Description**
+Enumerates the audio and video pixel formats. + +\@syscap SystemCapability.Multimedia.Media.Core + +| Name | Description | +| -------- | -------- | +| AV_PIXEL_FORMAT_YUVI420 | YUV 420 Planar. | +| AV_PIXEL_FORMAT_NV12 | NV12. YUV 420 Semi-planar. | +| AV_PIXEL_FORMAT_NV21 | NV21. YVU 420 Semi-planar. | +| AV_PIXEL_FORMAT_SURFACE_FORMAT | Surface. | +| AV_PIXEL_FORMAT_RGBA | RGBA8888. | + + +## Function Description + + +### OH_AVFormat_Copy() + + +``` +bool OH_AVFormat_Copy (struct OH_AVFormat * to, struct OH_AVFormat * from ) +``` +**Description**
+Copies the resources from an **OH_AVFormat** instance to another. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| to | Indicates the handle to the **OH_AVFormat** instance to which the data will be copied. | +| from | Indicates the handle to the **OH_AVFormat** instance from which the data will be copied. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_Create() + + +``` +struct OH_AVFormat* OH_AVFormat_Create (void ) +``` +**Description**
+Creates an **OH_AVFormat** instance for reading and writing data. + +\@syscap SystemCapability.Multimedia.Media.Core + +**Returns** + +Returns the handle to an **OH_AVFormat** instance. + + +### OH_AVFormat_Destroy() + + +``` +void OH_AVFormat_Destroy (struct OH_AVFormat * format) +``` +**Description**
+Destroys an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +void + + +### OH_AVFormat_DumpInfo() + + +``` +const char* OH_AVFormat_DumpInfo (struct OH_AVFormat * format) +``` +**Description**
+Dumps the information contained in an**OH_AVFormat** instance as a string. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns the pointer to a collect of strings, each of which consists of a key and value. + + +### OH_AVFormat_GetBuffer() + + +``` +bool OH_AVFormat_GetBuffer (struct OH_AVFormat * format, const char * key, uint8_t ** addr, size_t * size ) +``` +**Description**
+Reads data with a specified size from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| addr | Indicates the double pointer to the address where the data read is stored. The data read is destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. | +| size | Indicates the pointer to the size of the data read. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_GetDoubleValue() + + +``` +bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat * format, const char * key, double * out ) +``` +**Description**
+Reads data of the double type from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| out | Indicates the pointer to the data read. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_GetFloatValue() + + +``` +bool OH_AVFormat_GetFloatValue (struct OH_AVFormat * format, const char * key, float * out ) +``` +**Description**
+Reads data of the float type from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| out | Indicates the pointer to the data read. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_GetIntValue() + + +``` +bool OH_AVFormat_GetIntValue (struct OH_AVFormat * format, const char * key, int32_t * out ) +``` +**Description**
+Reads data of the int type from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| out | Indicates the pointer to the data read. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_GetLongValue() + + +``` +bool OH_AVFormat_GetLongValue (struct OH_AVFormat * format, const char * key, int64_t * out ) +``` +**Description**
+Reads data of the long type from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| out | Indicates the pointer to the data read. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_GetStringValue() + + +``` +bool OH_AVFormat_GetStringValue (struct OH_AVFormat * format, const char * key, const char ** out ) +``` +**Description**
+Reads data of the double type from an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to read. | +| out | Indicates the double pointer to the data read. The data read is updated when **GetString** is called and destroyed when the **OH_AVFormat** instance is destroyed. To hold the data for an extended period of time, copy it to the memory. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetBuffer() + + +``` +bool OH_AVFormat_SetBuffer (struct OH_AVFormat * format, const char * key, const uint8_t * addr, size_t size ) +``` +**Description**
+Writes data with a specified size to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| addr | Indicates the pointer to the address where the data is written. | +| size | Indicates the size of the data written. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetDoubleValue() + + +``` +bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat * format, const char * key, double value ) +``` +**Description**
+Writes data of the double type to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| value | Indicates the value of the data to write. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetFloatValue() + + +``` +bool OH_AVFormat_SetFloatValue (struct OH_AVFormat * format, const char * key, float value ) +``` +**Description**
+Writes data of the float type to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| value | Indicates the value of the data to write. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetIntValue() + + +``` +bool OH_AVFormat_SetIntValue (struct OH_AVFormat * format, const char * key, int32_t value ) +``` +**Description**
+Writes data of the int type to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| value | Indicates the value of the data to write. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetLongValue() + + +``` +bool OH_AVFormat_SetLongValue (struct OH_AVFormat * format, const char * key, int64_t value ) +``` +**Description**
+Writes data of the long type to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| value | Indicates the value of the data to write. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVFormat_SetStringValue() + + +``` +bool OH_AVFormat_SetStringValue (struct OH_AVFormat * format, const char * key, const char * value ) +``` +**Description**
+Writes data of the string type to an **OH_AVFormat** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| format | Indicates the handle to an **OH_AVFormat** instance. | +| key | Indicates the pointer to the key of the data to write. | +| value | Indicates the pointer to the value of the data to write. | + +**Returns** + +Returns **TRUE** if the operation is successful. + +Returns **FALSE** if the operation fails. + + +### OH_AVMemory_GetAddr() + + +``` +uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory * mem) +``` +**Description**
+Obtains the virtual memory address of an **OH_AVMemory** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mem | Indicates the pointer to an **OH_AVMemory** instance. | + +**Returns** + +Returns the virtual address if the memory is valid. + +Returns a null pointer if the memory is invalid. + + +### OH_AVMemory_GetSize() + + +``` +int32_t OH_AVMemory_GetSize (struct OH_AVMemory * mem) +``` +**Description**
+Obtains the memory size of an **OH_AVMemory** instance. + +\@syscap SystemCapability.Multimedia.Media.Core + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mem | Indicates the pointer to an **OH_AVMemory** instance. | + +**Returns** + +Returns the size if the memory is valid. + +Returns **-1** if the memory is invalid. diff --git a/en/application-dev/reference/native-apis/_drawing.md b/en/application-dev/reference/native-apis/_drawing.md new file mode 100644 index 0000000000000000000000000000000000000000..b13498d1331c95a744edadfc4743f6382c67f1b8 --- /dev/null +++ b/en/application-dev/reference/native-apis/_drawing.md @@ -0,0 +1,2066 @@ +# Drawing + + +## Overview + +Provides functions such as 2D graphics rendering, text drawing, and image display. + +Provides the 2D drawing capability. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Since:** +8 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [drawing_bitmap.h](drawing__bitmap_8h.md) | Declares functions related to the **bitmap** object in the drawing module.
File to Include: | +| [drawing_brush.h](drawing__brush_8h.md) | Declares functions related to the **brush** object in the drawing module.
File to Include: | +| [drawing_canvas.h](drawing__canvas_8h.md) | Declares functions related to the **canvas** object in the drawing module.
File to Include: | +| [drawing_color.h](drawing__color_8h.md) | Declares functions related to the **color** object in the drawing module.
File to Include: | +| [drawing_font_collection.h](drawing__font__collection_8h.md) | Declares functions related to **FontCollection** in the drawing module.
File to Include: | +| [drawing_path.h](drawing__path_8h.md) | Declares functions related to the **path** object in the drawing module.
File to Include: | +| [drawing_pen.h](drawing__pen_8h.md) | Declares functions related to the **pen** object in the drawing module.
File to Include: | +| [drawing_text_declaration.h](drawing__text__declaration_8h.md) | Declares the data structure related to text in 2D drawing.
File to Include: | +| [drawing_text_typography.h](drawing__text__typography_8h.md) | Declares functions related to **typography** in the drawing module.
File to Include: | +| [drawing_types.h](drawing__types_8h.md) | Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Defines the pixel format of a bitmap, including the color type and alpha type. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_FontCollection](#oh_drawing_fontcollection) | Defines an **OH_Drawing_FontCollection**, which is used to load fonts. | +| [OH_Drawing_Typography](#oh_drawing_typography) | Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. | +| [OH_Drawing_TextStyle](#oh_drawing_textstyle) | Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. | +| [OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) | Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. | +| [OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) | Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. | +| [OH_Drawing_Canvas](#oh_drawing_canvas) | Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. | +| [OH_Drawing_Pen](#oh_drawing_pen) | Defines a pen, which is used to describe the style and color to outline a shape. | +| [OH_Drawing_Brush](#oh_drawing_brush) | Defines as a brush, which is used to describe the style and color to fill in a shape. | +| [OH_Drawing_Path](#oh_drawing_path) | Defines a path, which is used to customize various shapes. | +| [OH_Drawing_Bitmap](#oh_drawing_bitmap) | Defines a bitmap, which is a memory that contains the pixel data of a shape. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle) { LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP } | Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. | +| [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle) { LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN } | Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. | +| [OH_Drawing_TextDirection](#oh_drawing_textdirection) { TEXT_DIRECTION_RTL, TEXT_DIRECTION_LTR } | Enumerates text directions. | +| [OH_Drawing_TextAlign](#oh_drawing_textalign) {
TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER, TEXT_ALIGN_JUSTIFY,
TEXT_ALIGN_START, TEXT_ALIGN_END
} | Enumerates text alignment modes. | +| [OH_Drawing_FontWeight](#oh_drawing_fontweight) {
FONT_WEIGHT_100, FONT_WEIGHT_200, FONT_WEIGHT_300, FONT_WEIGHT_400,
FONT_WEIGHT_500, FONT_WEIGHT_600, FONT_WEIGHT_700, FONT_WEIGHT_800,
FONT_WEIGHT_900
} | Enumerates font weights. | +| [OH_Drawing_TextBaseline](#oh_drawing_textbaseline) { TEXT_BASELINE_ALPHABETIC, TEXT_BASELINE_IDEOGRAPHIC } | Enumerates text baselines. | +| [OH_Drawing_TextDecoration](#oh_drawing_textdecoration) { TEXT_DECORATION_NONE = 0x0, TEXT_DECORATION_UNDERLINE = 0x1, TEXT_DECORATION_OVERLINE = 0x2, TEXT_DECORATION_LINE_THROUGH = 0x4 } | Enumerates text decorations. | +| [OH_Drawing_FontStyle](#oh_drawing_fontstyle) { FONT_STYLE_NORMAL, FONT_STYLE_ITALIC } | Enumerates font styles. | +| [OH_Drawing_ColorFormat](#oh_drawing_colorformat) {
COLOR_FORMAT_UNKNOWN, COLOR_FORMAT_ALPHA_8, COLOR_FORMAT_RGB_565, COLOR_FORMAT_ARGB_4444,
COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888
} | Enumerates storage formats of bitmap pixels. | +| [OH_Drawing_AlphaFormat](#oh_drawing_alphaformat) { ALPHA_FORMAT_UNKNOWN, ALPHA_FORMAT_OPAQUE, ALPHA_FORMAT_PREMUL, ALPHA_FORMAT_UNPREMUL } | Enumerates alpha formats of bitmap pixels. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_BitmapCreate](#oh_drawing_bitmapcreate) (void) | Creates an **OH_Drawing_Bitmap** object. | +| [OH_Drawing_BitmapDestroy](#oh_drawing_bitmapdestroy) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. | +| [OH_Drawing_BitmapBuild](#oh_drawing_bitmapbuild) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*, const uint32_t width, const uint32_t height, const [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) \*) | Initializes the width and height of an **OH_Drawing_Bitmap** object and sets the pixel format for the bitmap. | +| [OH_Drawing_BitmapGetWidth](#oh_drawing_bitmapgetwidth) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the width of a bitmap. | +| [OH_Drawing_BitmapGetHeight](#oh_drawing_bitmapgetheight) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the height of a bitmap. | +| [OH_Drawing_BitmapGetPixels](#oh_drawing_bitmapgetpixels) ([OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. | +| [OH_Drawing_BrushCreate](#oh_drawing_brushcreate) (void) | Creates an **OH_Drawing_Brush** object. | +| [OH_Drawing_BrushDestroy](#oh_drawing_brushdestroy) ([OH_Drawing_Brush](#oh_drawing_brush) \*) | Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. | +| [OH_Drawing_BrushIsAntiAlias](#oh_drawing_brushisantialias) (const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_BrushSetAntiAlias](#oh_drawing_brushsetantialias) ([OH_Drawing_Brush](#oh_drawing_brush) \*, bool) | Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_BrushGetColor](#oh_drawing_brushgetcolor) (const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Obtains the color of a brush. The color is used by the brush to fill in a shape. | +| [OH_Drawing_BrushSetColor](#oh_drawing_brushsetcolor) ([OH_Drawing_Brush](#oh_drawing_brush) \*, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape. | +| [OH_Drawing_CanvasCreate](#oh_drawing_canvascreate) (void) | Creates an **OH_Drawing_Canvas** object. | +| [OH_Drawing_CanvasDestroy](#oh_drawing_canvasdestroy) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. | +| [OH_Drawing_CanvasBind](#oh_drawing_canvasbind) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, [OH_Drawing_Bitmap](#oh_drawing_bitmap) \*) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering). | +| [OH_Drawing_CanvasAttachPen](#oh_drawing_canvasattachpen) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. | +| [OH_Drawing_CanvasDetachPen](#oh_drawing_canvasdetachpen) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. | +| [OH_Drawing_CanvasAttachBrush](#oh_drawing_canvasattachbrush) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Brush](#oh_drawing_brush) \*) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. | +| [OH_Drawing_CanvasDetachBrush](#oh_drawing_canvasdetachbrush) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. | +| [OH_Drawing_CanvasSave](#oh_drawing_canvassave) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Saves the current canvas status (canvas matrix) to the top of the stack. | +| [OH_Drawing_CanvasRestore](#oh_drawing_canvasrestore) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*) | Restores the canvas status (canvas matrix) saved on the top of the stack. | +| [OH_Drawing_CanvasDrawLine](#oh_drawing_canvasdrawline) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, float x1, float y1, float x2, float y2) | Draws a line segment. | +| [OH_Drawing_CanvasDrawPath](#oh_drawing_canvasdrawpath) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, const [OH_Drawing_Path](#oh_drawing_path) \*) | Draws a path. | +| [OH_Drawing_CanvasClear](#oh_drawing_canvasclear) ([OH_Drawing_Canvas](#oh_drawing_canvas) \*, uint32_t color) | Clears a canvas by using a specified color. | +| [OH_Drawing_ColorSetArgb](#oh_drawing_colorsetargb) (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) | Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. | +| [OH_Drawing_CreateFontCollection](#oh_drawing_createfontcollection) (void) | Creates an **OH_Drawing_FontCollection** object. | +| [OH_Drawing_DestroyFontCollection](#oh_drawing_destroyfontcollection) ([OH_Drawing_FontCollection](#oh_drawing_fontcollection) \*) | Releases the memory occupied by an **OH_Drawing_FontCollection** object. | +| [OH_Drawing_PathCreate](#oh_drawing_pathcreate) (void) | Creates an **OH_Drawing_Path** object. | +| [OH_Drawing_PathDestroy](#oh_drawing_pathdestroy) ([OH_Drawing_Path](#oh_drawing_path) \*) | Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. | +| [OH_Drawing_PathMoveTo](#oh_drawing_pathmoveto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x, float y) | Sets the start point of a path. | +| [OH_Drawing_PathLineTo](#oh_drawing_pathlineto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x, float y) | Draws a line segment from the last point of a path to the target point. | +| [OH_Drawing_PathArcTo](#oh_drawing_patharcto) ([OH_Drawing_Path](#oh_drawing_path) \*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) | Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. | +| [OH_Drawing_PathQuadTo](#oh_drawing_pathquadto) ([OH_Drawing_Path](#oh_drawing_path) \*, float ctrlX, float ctrlY, float endX, float endY) | Draws a quadratic Bezier curve from the last point of a path to the target point. | +| [OH_Drawing_PathCubicTo](#oh_drawing_pathcubicto) ([OH_Drawing_Path](#oh_drawing_path) \*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) | Draws a cubic Bezier curve from the last point of a path to the target point. | +| [OH_Drawing_PathClose](#oh_drawing_pathclose) ([OH_Drawing_Path](#oh_drawing_path) \*) | Closes a path. A line segment from the start point to the last point of the path is added. | +| [OH_Drawing_PathReset](#oh_drawing_pathreset) ([OH_Drawing_Path](#oh_drawing_path) \*) | Resets path data. | +| [OH_Drawing_PenCreate](#oh_drawing_pencreate) (void) | Creates an **OH_Drawing_Pen** object. | +| [OH_Drawing_PenDestroy](#oh_drawing_pendestroy) ([OH_Drawing_Pen](#oh_drawing_pen) \*) | Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. | +| [OH_Drawing_PenIsAntiAlias](#oh_drawing_penisantialias) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_PenSetAntiAlias](#oh_drawing_pensetantialias) ([OH_Drawing_Pen](#oh_drawing_pen) \*, bool) | Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_PenGetColor](#oh_drawing_pengetcolor) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the color of a pen. The color is used by the pen to outline a shape. | +| [OH_Drawing_PenSetColor](#oh_drawing_pensetcolor) ([OH_Drawing_Pen](#oh_drawing_pen) \*, uint32_t color) | Sets the color for a pen. The color is used by the pen to outline a shape. | +| [OH_Drawing_PenGetWidth](#oh_drawing_pengetwidth) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. | +| [OH_Drawing_PenSetWidth](#oh_drawing_pensetwidth) ([OH_Drawing_Pen](#oh_drawing_pen) \*, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape. | +| [OH_Drawing_PenGetMiterLimit](#oh_drawing_pengetmiterlimit) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. | +| [OH_Drawing_PenSetMiterLimit](#oh_drawing_pensetmiterlimit) ([OH_Drawing_Pen](#oh_drawing_pen) \*, float miter) | Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. | +| [OH_Drawing_PenGetCap](#oh_drawing_pengetcap) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line cap style of a pen. | +| [OH_Drawing_PenSetCap](#oh_drawing_pensetcap) ([OH_Drawing_Pen](#oh_drawing_pen) \*, [OH_Drawing_PenLineCapStyle](#oh_drawing_penlinecapstyle)) | Sets the line cap style for a pen. | +| [OH_Drawing_PenGetJoin](#oh_drawing_pengetjoin) (const [OH_Drawing_Pen](#oh_drawing_pen) \*) | Obtains the line join style of a pen. | +| [OH_Drawing_PenSetJoin](#oh_drawing_pensetjoin) ([OH_Drawing_Pen](#oh_drawing_pen) \*, [OH_Drawing_PenLineJoinStyle](#oh_drawing_penlinejoinstyle)) | Sets the line join style for a pen. | +| [OH_Drawing_CreateTypographyStyle](#oh_drawing_createtypographystyle) (void) | Creates an **OH_Drawing_TypographyStyle** object. | +| [OH_Drawing_DestroyTypographyStyle](#oh_drawing_destroytypographystyle) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*) | Releases the memory occupied by an **OH_Drawing_TypographyStyle** object. | +| [OH_Drawing_SetTypographyTextDirection](#oh_drawing_settypographytextdirection) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the text direction. | +| [OH_Drawing_SetTypographyTextAlign](#oh_drawing_settypographytextalign) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the text alignment mode. | +| [OH_Drawing_SetTypographyTextMaxLines](#oh_drawing_settypographytextmaxlines) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, int) | Sets the maximum number of lines in a text file. | +| [OH_Drawing_CreateTextStyle](#oh_drawing_createtextstyle) (void) | Creates an **OH_Drawing_TextStyle** object. | +| [OH_Drawing_DestroyTextStyle](#oh_drawing_destroytextstyle) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*) | Releases the memory occupied by an **OH_Drawing_TextStyle** object. | +| [OH_Drawing_SetTextStyleColor](#oh_drawing_settextstylecolor) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, uint32_t) | Sets the text color. | +| [OH_Drawing_SetTextStyleFontSize](#oh_drawing_settextstylefontsize) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, double) | Sets the font size. | +| [OH_Drawing_SetTextStyleFontWeight](#oh_drawing_settextstylefontweight) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the font weight. | +| [OH_Drawing_SetTextStyleBaseLine](#oh_drawing_settextstylebaseline) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the text baseline. | +| [OH_Drawing_SetTextStyleDecoration](#oh_drawing_settextstyledecoration) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the text decoration. | +| [OH_Drawing_SetTextStyleDecorationColor](#oh_drawing_settextstyledecorationcolor) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, uint32_t) | Sets the color for the text decoration. | +| [OH_Drawing_SetTextStyleFontHeight](#oh_drawing_settextstylefontheight) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, double) | Sets the font height. | +| [OH_Drawing_SetTextStyleFontFamilies](#oh_drawing_settextstylefontfamilies) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int, const char \*fontFamilies[]) | Sets the font families. | +| [OH_Drawing_SetTextStyleFontStyle](#oh_drawing_settextstylefontstyle) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, int) | Sets the font style. | +| [OH_Drawing_SetTextStyleLocale](#oh_drawing_settextstylelocale) ([OH_Drawing_TextStyle](#oh_drawing_textstyle) \*, const char \*) | Sets the locale. | +| [OH_Drawing_CreateTypographyHandler](#oh_drawing_createtypographyhandler) ([OH_Drawing_TypographyStyle](#oh_drawing_typographystyle) \*, [OH_Drawing_FontCollection](#oh_drawing_fontcollection) \*) | Creates a pointer to an **OH_Drawing_TypographyCreate** object. | +| [OH_Drawing_DestroyTypographyHandler](#oh_drawing_destroytypographyhandler) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Releases the memory occupied by an **OH_Drawing_TypographyCreate** object. | +| [OH_Drawing_TypographyHandlerPushTextStyle](#oh_drawing_typographyhandlerpushtextstyle) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*, [OH_Drawing_TextStyle](#oh_drawing_textstyle) \*) | Sets the text style. | +| [OH_Drawing_TypographyHandlerAddText](#oh_drawing_typographyhandleraddtext) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*, const char \*) | Sets the text content. | +| [OH_Drawing_TypographyHandlerPopTextStyle](#oh_drawing_typographyhandlerpoptextstyle) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Removes the topmost style in the stack, leaving the remaining styles in effect. | +| [OH_Drawing_CreateTypography](#oh_drawing_createtypography) ([OH_Drawing_TypographyCreate](#oh_drawing_typographycreate) \*) | Creates an **OH_Drawing_Typography** object. | +| [OH_Drawing_DestroyTypography](#oh_drawing_destroytypography) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Releases the memory occupied by an **OH_Drawing_Typography** object. | +| [OH_Drawing_TypographyLayout](#oh_drawing_typographylayout) ([OH_Drawing_Typography](#oh_drawing_typography) \*, double) | Lays out the typography. | +| [OH_Drawing_TypographyPaint](#oh_drawing_typographypaint) ([OH_Drawing_Typography](#oh_drawing_typography) \*, [OH_Drawing_Canvas](#oh_drawing_canvas) \*, double, double) | Paints text on the canvas. | +| [OH_Drawing_TypographyGetMaxWidth](#oh_drawing_typographygetmaxwidth) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the maximum width. | +| [OH_Drawing_TypographyGetHeight](#oh_drawing_typographygetheight) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the height. | +| [OH_Drawing_TypographyGetLongestLine](#oh_drawing_typographygetlongestline) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the longest line. | +| [OH_Drawing_TypographyGetMinIntrinsicWidth](#oh_drawing_typographygetminintrinsicwidth) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the minimum intrinsic width. | +| [OH_Drawing_TypographyGetMaxIntrinsicWidth](#oh_drawing_typographygetmaxintrinsicwidth) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the maximum intrinsic width. | +| [OH_Drawing_TypographyGetAlphabeticBaseline](#oh_drawing_typographygetalphabeticbaseline) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the alphabetic baseline. | +| [OH_Drawing_TypographyGetIdeographicBaseline](#oh_drawing_typographygetideographicbaseline) ([OH_Drawing_Typography](#oh_drawing_typography) \*) | Obtains the ideographic baseline. | + + +## Type Description + + +### OH_Drawing_Bitmap + + +``` +typedef struct OH_Drawing_BitmapOH_Drawing_Bitmap +``` +**Description**
+Defines a bitmap, which is a memory that contains the pixel data of a shape. + + +### OH_Drawing_Brush + + +``` +typedef struct OH_Drawing_BrushOH_Drawing_Brush +``` +**Description**
+Defines as a brush, which is used to describe the style and color to fill in a shape. + + +### OH_Drawing_Canvas + + +``` +typedef struct OH_Drawing_CanvasOH_Drawing_Canvas +``` +**Description**
+Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. + + +### OH_Drawing_FontCollection + + +``` +typedef struct OH_Drawing_FontCollectionOH_Drawing_FontCollection +``` +**Description**
+Defines an **OH_Drawing_FontCollection**, which is used to load fonts. + + +### OH_Drawing_Path + + +``` +typedef struct OH_Drawing_PathOH_Drawing_Path +``` +**Description**
+Defines a path, which is used to customize various shapes. + + +### OH_Drawing_Pen + + +``` +typedef struct OH_Drawing_PenOH_Drawing_Pen +``` +**Description**
+Defines a pen, which is used to describe the style and color to outline a shape. + + +### OH_Drawing_TextStyle + + +``` +typedef struct OH_Drawing_TextStyleOH_Drawing_TextStyle +``` +**Description**
+Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. + + +### OH_Drawing_Typography + + +``` +typedef struct OH_Drawing_TypographyOH_Drawing_Typography +``` +**Description**
+Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. + + +### OH_Drawing_TypographyCreate + + +``` +typedef struct OH_Drawing_TypographyCreateOH_Drawing_TypographyCreate +``` +**Description**
+Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. + + +### OH_Drawing_TypographyStyle + + +``` +typedef struct OH_Drawing_TypographyStyleOH_Drawing_TypographyStyle +``` +**Description**
+Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. + + +## Enum Description + + +### OH_Drawing_AlphaFormat + + +``` +enum OH_Drawing_AlphaFormat +``` +**Description**
+Enumerates alpha formats of bitmap pixels. + +| Name | Description | +| -------- | -------- | +| ALPHA_FORMAT_UNKNOWN | Unknown format. | +| ALPHA_FORMAT_OPAQUE | The bitmap does not have the alpha component. | +| ALPHA_FORMAT_PREMUL | The color component of each pixel is premultiplied by the alpha component. | +| ALPHA_FORMAT_UNPREMUL | The color component of each pixel is not premultiplied by the alpha component. | + + +### OH_Drawing_ColorFormat + + +``` +enum OH_Drawing_ColorFormat +``` +**Description**
+Enumerates storage formats of bitmap pixels. + +| Name | Description | +| -------- | -------- | +| COLOR_FORMAT_UNKNOWN | Unknown format. | +| COLOR_FORMAT_ALPHA_8 | Each pixel is represented by 8 bits, which together indicate alpha. | +| COLOR_FORMAT_RGB_565 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue. | +| COLOR_FORMAT_ARGB_4444 | Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, every 4 bits indicate alpha, red, green, and blue, respectively. | +| COLOR_FORMAT_RGBA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate alpha, red, green, and blue, respectively. | +| COLOR_FORMAT_BGRA_8888 | Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate blue, green, red, and alpha, respectively. | + + +### OH_Drawing_FontStyle + + +``` +enum OH_Drawing_FontStyle +``` +**Description**
+Enumerates font styles. + +| Name | Description | +| -------- | -------- | +| FONT_STYLE_NORMAL | Normal style | +| FONT_STYLE_ITALIC | Italic style | + + +### OH_Drawing_FontWeight + + +``` +enum OH_Drawing_FontWeight +``` +**Description**
+Enumerates font weights. + +| Name | Description | +| -------- | -------- | +| FONT_WEIGHT_100 | Thin | +| FONT_WEIGHT_200 | Extra-light | +| FONT_WEIGHT_300 | Light | +| FONT_WEIGHT_400 | Normal/Regular | +| FONT_WEIGHT_500 | Medium | +| FONT_WEIGHT_600 | Semi-bold | +| FONT_WEIGHT_700 | Bold | +| FONT_WEIGHT_800 | Extra-bold | +| FONT_WEIGHT_900 | Black | + + +### OH_Drawing_PenLineCapStyle + + +``` +enum OH_Drawing_PenLineCapStyle +``` +**Description**
+Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. + +| Name | Description | +| -------- | -------- | +| LINE_FLAT_CAP | There is no cap style. Both ends of the line segment are cut off square. | +| LINE_SQUARE_CAP | Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width. | +| LINE_ROUND_CAP | Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment. | + + +### OH_Drawing_PenLineJoinStyle + + +``` +enum OH_Drawing_PenLineJoinStyle +``` +**Description**
+Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. + +| Name | Description | +| -------- | -------- | +| LINE_MITER_JOIN | Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. In this case, you need to use the miter limit to limit the miter length. | +| LINE_ROUND_JOIN | Round corner. | +| LINE_BEVEL_JOIN | Beveled corner. | + + +### OH_Drawing_TextAlign + + +``` +enum OH_Drawing_TextAlign +``` +**Description**
+Enumerates text alignment modes. + +| Name | Description | +| -------- | -------- | +| TEXT_ALIGN_LEFT | Left-aligned | +| TEXT_ALIGN_RIGHT | Right-aligned | +| TEXT_ALIGN_CENTER | Center-aligned | +| TEXT_ALIGN_JUSTIFY | Justified, which means that each line (except the last line) is stretched so that every line has equal width, and the left and right margins are straight. | +| TEXT_ALIGN_START | **TEXT_ALIGN_START** achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**. | +| TEXT_ALIGN_END | **TEXT_ALIGN_END** achieves the same effect as **TEXT_ALIGN_RIGHT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_LTR**; it achieves the same effect as **TEXT_ALIGN_LEFT** when **OH_Drawing_TextDirection** is **TEXT_DIRECTION_RTL**. | + + +### OH_Drawing_TextBaseline + + +``` +enum OH_Drawing_TextBaseline +``` +**Description**
+Enumerates text baselines. + +| Name | Description | +| -------- | -------- | +| TEXT_BASELINE_ALPHABETIC | Alphabetic, where the letters in alphabets like English sit on. | +| TEXT_BASELINE_IDEOGRAPHIC | Ideographic. The baseline is at the bottom of the text area. | + + +### OH_Drawing_TextDecoration + + +``` +enum OH_Drawing_TextDecoration +``` +**Description**
+Enumerates text decorations. + +| Name | Description | +| -------- | -------- | +| TEXT_DECORATION_NONE | No decoration. | +| TEXT_DECORATION_UNDERLINE | A underline is used for decoration. | +| TEXT_DECORATION_OVERLINE | An overline is used for decoration. | +| TEXT_DECORATION_LINE_THROUGH | A strikethrough is used for decoration. | + + +### OH_Drawing_TextDirection + + +``` +enum OH_Drawing_TextDirection +``` +**Description**
+Enumerates text directions. + +| Name | Description | +| -------- | -------- | +| TEXT_DIRECTION_RTL | Right to left (RTL) | +| TEXT_DIRECTION_LTR | Left to right (LTR) | + + +## Function Description + + +### OH_Drawing_BitmapBuild() + + +``` +void OH_Drawing_BitmapBuild (OH_Drawing_Bitmap * , const uint32_t width, const uint32_t height, const OH_Drawing_BitmapFormat * ) +``` +**Description**
+Initializes the width and height of an **OH_Drawing_Bitmap** object and sets the pixel format for the bitmap. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | +| width | Indicates the width of the bitmap to be initialized. | +| height | Indicates the height of the bitmap to be initialized. | +| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Indicates the pixel format of the bitmap to be initialized, including the pixel color type and alpha type. | + + +### OH_Drawing_BitmapCreate() + + +``` +OH_Drawing_Bitmap* OH_Drawing_BitmapCreate (void ) +``` +**Description**
+Creates an **OH_Drawing_Bitmap** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_Bitmap** object created. + + +### OH_Drawing_BitmapDestroy() + + +``` +void OH_Drawing_BitmapDestroy (OH_Drawing_Bitmap * ) +``` +**Description**
+Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | + + +### OH_Drawing_BitmapGetHeight() + + +``` +uint32_t OH_Drawing_BitmapGetHeight (OH_Drawing_Bitmap * ) +``` +**Description**
+Obtains the height of a bitmap. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | + +**Returns** + +Returns the height. + + +### OH_Drawing_BitmapGetPixels() + + +``` +void* OH_Drawing_BitmapGetPixels (OH_Drawing_Bitmap * ) +``` +**Description**
+Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | + +**Returns** + +Returns the pixel address. + + +### OH_Drawing_BitmapGetWidth() + + +``` +uint32_t OH_Drawing_BitmapGetWidth (OH_Drawing_Bitmap * ) +``` +**Description**
+Obtains the width of a bitmap. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | + +**Returns** + +Returns the width. + + +### OH_Drawing_BrushCreate() + + +``` +OH_Drawing_Brush* OH_Drawing_BrushCreate (void ) +``` +**Description**
+Creates an **OH_Drawing_Brush** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_Brush** object created. + + +### OH_Drawing_BrushDestroy() + + +``` +void OH_Drawing_BrushDestroy (OH_Drawing_Brush * ) +``` +**Description**
+Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | + + +### OH_Drawing_BrushGetColor() + + +``` +uint32_t OH_Drawing_BrushGetColor (const OH_Drawing_Brush * ) +``` +**Description**
+Obtains the color of a brush. The color is used by the brush to fill in a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | + +**Returns** + +Returns a 32-bit (ARGB) variable that describes the color. + + +### OH_Drawing_BrushIsAntiAlias() + + +``` +bool OH_Drawing_BrushIsAntiAlias (const OH_Drawing_Brush * ) +``` +**Description**
+Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | + +**Returns** + +Returns **true** if anti-aliasing is enabled; returns **false** otherwise. + + +### OH_Drawing_BrushSetAntiAlias() + + +``` +void OH_Drawing_BrushSetAntiAlias (OH_Drawing_Brush * , bool ) +``` +**Description**
+Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | +| bool | Specifies whether to enable anti-aliasing. The value **true** means to enable anti-aliasing, and **false** means the opposite. | + + +### OH_Drawing_BrushSetColor() + + +``` +void OH_Drawing_BrushSetColor (OH_Drawing_Brush * , uint32_t color ) +``` +**Description**
+Sets the color for a brush. The color will be used by the brush to fill in a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | +| color | Indicates the color to set, which is a 32-bit (ARGB) variable. | + + +### OH_Drawing_CanvasAttachBrush() + + +``` +void OH_Drawing_CanvasAttachBrush (OH_Drawing_Canvas * , const OH_Drawing_Brush * ) +``` +**Description**
+Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| OH_Drawing_Brush | Indicates the pointer to an **OH_Drawing_Brush** object. | + + +### OH_Drawing_CanvasAttachPen() + + +``` +void OH_Drawing_CanvasAttachPen (OH_Drawing_Canvas * , const OH_Drawing_Pen * ) +``` +**Description**
+Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + + +### OH_Drawing_CanvasBind() + + +``` +void OH_Drawing_CanvasBind (OH_Drawing_Canvas * , OH_Drawing_Bitmap * ) +``` +**Description**
+Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering). + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| OH_Drawing_Bitmap | Indicates the pointer to an **OH_Drawing_Bitmap** object. | + + +### OH_Drawing_CanvasClear() + + +``` +void OH_Drawing_CanvasClear (OH_Drawing_Canvas * , uint32_t color ) +``` +**Description**
+Clears a canvas by using a specified color. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| color | Indicates the color, which is a 32-bit (ARGB) variable. | + + +### OH_Drawing_CanvasCreate() + + +``` +OH_Drawing_Canvas* OH_Drawing_CanvasCreate (void ) +``` +**Description**
+Creates an **OH_Drawing_Canvas** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_Canvas** object created. + + +### OH_Drawing_CanvasDestroy() + + +``` +void OH_Drawing_CanvasDestroy (OH_Drawing_Canvas * ) +``` +**Description**
+Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | + + +### OH_Drawing_CanvasDetachBrush() + + +``` +void OH_Drawing_CanvasDetachBrush (OH_Drawing_Canvas * ) +``` +**Description**
+Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | + + +### OH_Drawing_CanvasDetachPen() + + +``` +void OH_Drawing_CanvasDetachPen (OH_Drawing_Canvas * ) +``` +**Description**
+Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | + + +### OH_Drawing_CanvasDrawLine() + + +``` +void OH_Drawing_CanvasDrawLine (OH_Drawing_Canvas * , float x1, float y1, float x2, float y2 ) +``` +**Description**
+Draws a line segment. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| x1 | Indicates the x coordinate of the start point of the line segment. | +| y1 | Indicates the y coordinate of the start point of the line segment. | +| x2 | Indicates the x coordinate of the end point of the line segment. | +| y2 | Indicates the y coordinate of the end point of the line segment. | + + +### OH_Drawing_CanvasDrawPath() + + +``` +void OH_Drawing_CanvasDrawPath (OH_Drawing_Canvas * , const OH_Drawing_Path * ) +``` +**Description**
+Draws a path. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | + + +### OH_Drawing_CanvasRestore() + + +``` +void OH_Drawing_CanvasRestore (OH_Drawing_Canvas * ) +``` +**Description**
+Restores the canvas status (canvas matrix) saved on the top of the stack. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | + + +### OH_Drawing_CanvasSave() + + +``` +void OH_Drawing_CanvasSave (OH_Drawing_Canvas * ) +``` +**Description**
+Saves the current canvas status (canvas matrix) to the top of the stack. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | + + +### OH_Drawing_ColorSetArgb() + + +``` +uint32_t OH_Drawing_ColorSetArgb (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue ) +``` +**Description**
+Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| alpha | Indicates a variable that describes alpha. The value ranges from 0x00 to 0xFF. | +| red | Indicates a variable that describes red. The value ranges from 0x00 to 0xFF. | +| green | Indicates a variable that describes green. The value ranges from 0x00 to 0xFF. | +| blue | Indicates a variable that describes blue. The value ranges from 0x00 to 0xFF. | + +**Returns** + +Returns a 32-bit (ARGB) variable that describes the color. + + +### OH_Drawing_CreateFontCollection() + + +``` +OH_Drawing_FontCollection* OH_Drawing_CreateFontCollection (void ) +``` +**Description**
+Creates an **OH_Drawing_FontCollection** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_FontCollection** object created. + + +### OH_Drawing_CreateTextStyle() + + +``` +OH_Drawing_TextStyle* OH_Drawing_CreateTextStyle (void ) +``` +**Description**
+Creates an **OH_Drawing_TextStyle** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_TextStyle** object created. + + +### OH_Drawing_CreateTypography() + + +``` +OH_Drawing_Typography* OH_Drawing_CreateTypography (OH_Drawing_TypographyCreate * ) +``` +**Description**
+Creates an **OH_Drawing_Typography** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyCreate | Indicates the pointer to an **OH_Drawing_TypographyCreate** object. | + +**Returns** + +Returns the pointer to the **OH_Drawing_Typography** object created. + + +### OH_Drawing_CreateTypographyHandler() + + +``` +OH_Drawing_TypographyCreate* OH_Drawing_CreateTypographyHandler (OH_Drawing_TypographyStyle * , OH_Drawing_FontCollection * ) +``` +**Description**
+Creates a pointer to an **OH_Drawing_TypographyCreate** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyStyle | Indicates the pointer to an **OH_Drawing_TypographyStyle** object. | +| OH_Drawing_FontCollection | Indicates the pointer to an **OH_Drawing_FontCollection** object. | + +**Returns** + +Returns the pointer to the **OH_Drawing_TypographyCreate** object created. + + +### OH_Drawing_CreateTypographyStyle() + + +``` +OH_Drawing_TypographyStyle* OH_Drawing_CreateTypographyStyle (void ) +``` +**Description**
+Creates an **OH_Drawing_TypographyStyle** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_TypographyStyle** object created. + + +### OH_Drawing_DestroyFontCollection() + + +``` +void OH_Drawing_DestroyFontCollection (OH_Drawing_FontCollection * ) +``` +**Description**
+Releases the memory occupied by an **OH_Drawing_FontCollection** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_FontCollection | Indicates the pointer to an **OH_Drawing_FontCollection** object. | + + +### OH_Drawing_DestroyTextStyle() + + +``` +void OH_Drawing_DestroyTextStyle (OH_Drawing_TextStyle * ) +``` +**Description**
+Releases the memory occupied by an **OH_Drawing_TextStyle** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | + + +### OH_Drawing_DestroyTypography() + + +``` +void OH_Drawing_DestroyTypography (OH_Drawing_Typography * ) +``` +**Description**
+Releases the memory occupied by an **OH_Drawing_Typography** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + + +### OH_Drawing_DestroyTypographyHandler() + + +``` +void OH_Drawing_DestroyTypographyHandler (OH_Drawing_TypographyCreate * ) +``` +**Description**
+Releases the memory occupied by an **OH_Drawing_TypographyCreate** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyCreate | Indicates the pointer to an **OH_Drawing_TypographyCreate** object. | + + +### OH_Drawing_DestroyTypographyStyle() + + +``` +void OH_Drawing_DestroyTypographyStyle (OH_Drawing_TypographyStyle * ) +``` +**Description**
+Releases the memory occupied by an **OH_Drawing_TypographyStyle** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyStyle | Indicates the pointer to an **OH_Drawing_TypographyStyle** object. | + + +### OH_Drawing_PathArcTo() + + +``` +void OH_Drawing_PathArcTo (OH_Drawing_Path * , float x1, float y1, float x2, float y2, float startDeg, float sweepDeg ) +``` +**Description**
+Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | +| x1 | Indicates the x coordinate of the upper left corner of the rectangle. | +| y1 | Indicates the y coordinate of the upper left corner of the rectangle. | +| x2 | Indicates the x coordinate of the lower right corner of the rectangle. | +| y2 | Indicates the y coordinate of the lower right corner of the rectangle. | +| startDeg | Indicates the start angle, in degrees. | +| sweepDeg | Indicates the angle to sweep, in degrees. | + + +### OH_Drawing_PathClose() + + +``` +void OH_Drawing_PathClose (OH_Drawing_Path * ) +``` +**Description**
+Closes a path. A line segment from the start point to the last point of the path is added. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | + + +### OH_Drawing_PathCreate() + + +``` +OH_Drawing_Path* OH_Drawing_PathCreate (void ) +``` +**Description**
+Creates an **OH_Drawing_Path** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_Path** object created. + + +### OH_Drawing_PathCubicTo() + + +``` +void OH_Drawing_PathCubicTo (OH_Drawing_Path * , float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY ) +``` +**Description**
+Draws a cubic Bezier curve from the last point of a path to the target point. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | +| ctrlX1 | Indicates the x coordinate of the first control point. | +| ctrlY1 | Indicates the y coordinate of the first control point. | +| ctrlX2 | Indicates the x coordinate of the second control point. | +| ctrlY2 | Indicates the y coordinate of the second control point. | +| endX | Indicates the x coordinate of the target point. | +| endY | Indicates the y coordinate of the target point. | + + +### OH_Drawing_PathDestroy() + + +``` +void OH_Drawing_PathDestroy (OH_Drawing_Path * ) +``` +**Description**
+Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | + + +### OH_Drawing_PathLineTo() + + +``` +void OH_Drawing_PathLineTo (OH_Drawing_Path * , float x, float y ) +``` +**Description**
+Draws a line segment from the last point of a path to the target point. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | +| x | Indicates the x coordinate of the target point. | +| y | Indicates the y coordinate of the target point. | + + +### OH_Drawing_PathMoveTo() + + +``` +void OH_Drawing_PathMoveTo (OH_Drawing_Path * , float x, float y ) +``` +**Description**
+Sets the start point of a path. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | +| x | Indicates the x coordinate of the start point. | +| y | Indicates the y coordinate of the start point. | + + +### OH_Drawing_PathQuadTo() + + +``` +void OH_Drawing_PathQuadTo (OH_Drawing_Path * , float ctrlX, float ctrlY, float endX, float endY ) +``` +**Description**
+Draws a quadratic Bezier curve from the last point of a path to the target point. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | +| ctrlX | Indicates the x coordinate of the control point. | +| ctrlY | Indicates the y coordinate of the control point. | +| endX | Indicates the x coordinate of the target point. | +| endY | Indicates the y coordinate of the target point. | + + +### OH_Drawing_PathReset() + + +``` +void OH_Drawing_PathReset (OH_Drawing_Path * ) +``` +**Description**
+Resets path data. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Path | Indicates the pointer to an **OH_Drawing_Path** object. | + + +### OH_Drawing_PenCreate() + + +``` +OH_Drawing_Pen* OH_Drawing_PenCreate (void ) +``` +**Description**
+Creates an **OH_Drawing_Pen** object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + +**Returns** + +Returns the pointer to the **OH_Drawing_Pen** object created. + + +### OH_Drawing_PenDestroy() + + +``` +void OH_Drawing_PenDestroy (OH_Drawing_Pen * ) +``` +**Description**
+Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + + +### OH_Drawing_PenGetCap() + + +``` +OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap (const OH_Drawing_Pen * ) +``` +**Description**
+Obtains the line cap style of a pen. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns the line cap style. + + +### OH_Drawing_PenGetColor() + + +``` +uint32_t OH_Drawing_PenGetColor (const OH_Drawing_Pen * ) +``` +**Description**
+Obtains the color of a pen. The color is used by the pen to outline a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns a 32-bit (ARGB) variable that describes the color. + + +### OH_Drawing_PenGetJoin() + + +``` +OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin (const OH_Drawing_Pen * ) +``` +**Description**
+Obtains the line join style of a pen. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns the line join style. + + +### OH_Drawing_PenGetMiterLimit() + + +``` +float OH_Drawing_PenGetMiterLimit (const OH_Drawing_Pen * ) +``` +**Description**
+Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns the miter limit. + + +### OH_Drawing_PenGetWidth() + + +``` +float OH_Drawing_PenGetWidth (const OH_Drawing_Pen * ) +``` +**Description**
+Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns the thickness. + + +### OH_Drawing_PenIsAntiAlias() + + +``` +bool OH_Drawing_PenIsAntiAlias (const OH_Drawing_Pen * ) +``` +**Description**
+Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | + +**Returns** + +Returns **true** if anti-aliasing is enabled; returns **false** otherwise. + + +### OH_Drawing_PenSetAntiAlias() + + +``` +void OH_Drawing_PenSetAntiAlias (OH_Drawing_Pen * , bool ) +``` +**Description**
+Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| bool | Specifies whether to enable anti-aliasing. The value **true** means to enable anti-aliasing, and **false** means the opposite. | + + +### OH_Drawing_PenSetCap() + + +``` +void OH_Drawing_PenSetCap (OH_Drawing_Pen * , OH_Drawing_PenLineCapStyle ) +``` +**Description**
+Sets the line cap style for a pen. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| OH_Drawing_PenLineCapStyle | Indicates a variable that describes the line cap style. | + + +### OH_Drawing_PenSetColor() + + +``` +void OH_Drawing_PenSetColor (OH_Drawing_Pen * , uint32_t color ) +``` +**Description**
+Sets the color for a pen. The color is used by the pen to outline a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| color | Indicates the color to set, which is a 32-bit (ARGB) variable. | + + +### OH_Drawing_PenSetJoin() + + +``` +void OH_Drawing_PenSetJoin (OH_Drawing_Pen * , OH_Drawing_PenLineJoinStyle ) +``` +**Description**
+Sets the line join style for a pen. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| OH_Drawing_PenLineJoinStyle | Indicates a variable that describes the line join style. | + + +### OH_Drawing_PenSetMiterLimit() + + +``` +void OH_Drawing_PenSetMiterLimit (OH_Drawing_Pen * , float miter ) +``` +**Description**
+Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| miter | Indicates a variable that describes the miter limit. | + + +### OH_Drawing_PenSetWidth() + + +``` +void OH_Drawing_PenSetWidth (OH_Drawing_Pen * , float width ) +``` +**Description**
+Sets the thickness for a pen. This thickness determines the width of the outline of a shape. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Pen | Indicates the pointer to an **OH_Drawing_Pen** object. | +| width | Indicates the thickness to set, which is a variable. | + + +### OH_Drawing_SetTextStyleBaseLine() + + +``` +void OH_Drawing_SetTextStyleBaseLine (OH_Drawing_TextStyle * , int ) +``` +**Description**
+Sets the text baseline. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| int | Indicates the text baseline to set. For details, see the enum **OH_Drawing_TextBaseline**. | + + +### OH_Drawing_SetTextStyleColor() + + +``` +void OH_Drawing_SetTextStyleColor (OH_Drawing_TextStyle * , uint32_t ) +``` +**Description**
+Sets the text color. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| uint32_t | Indicates the color to set. | + + +### OH_Drawing_SetTextStyleDecoration() + + +``` +void OH_Drawing_SetTextStyleDecoration (OH_Drawing_TextStyle * , int ) +``` +**Description**
+Sets the text decoration. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| int | Indicates the text decoration to set. For details, see the enum **OH_Drawing_TextDecoration**. | + + +### OH_Drawing_SetTextStyleDecorationColor() + + +``` +void OH_Drawing_SetTextStyleDecorationColor (OH_Drawing_TextStyle * , uint32_t ) +``` +**Description**
+Sets the color for the text decoration. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| uint32_t | Indicates the color to set. | + + +### OH_Drawing_SetTextStyleFontFamilies() + + +``` +void OH_Drawing_SetTextStyleFontFamilies (OH_Drawing_TextStyle * , int , const char * fontFamilies[] ) +``` +**Description**
+Sets the font families. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| int | Indicates the number of font families to set. | +| char | Indicates the pointer to the font families to set. | + + +### OH_Drawing_SetTextStyleFontHeight() + + +``` +void OH_Drawing_SetTextStyleFontHeight (OH_Drawing_TextStyle * , double ) +``` +**Description**
+Sets the font height. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| double | Indicates the font height to set. | + + +### OH_Drawing_SetTextStyleFontSize() + + +``` +void OH_Drawing_SetTextStyleFontSize (OH_Drawing_TextStyle * , double ) +``` +**Description**
+Sets the font size. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| double | Indicates the font size to set. | + + +### OH_Drawing_SetTextStyleFontStyle() + + +``` +void OH_Drawing_SetTextStyleFontStyle (OH_Drawing_TextStyle * , int ) +``` +**Description**
+Sets the font style. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| int | Indicates the font style to set. For details, see the enum **OH_Drawing_FontStyle**. | + + +### OH_Drawing_SetTextStyleFontWeight() + + +``` +void OH_Drawing_SetTextStyleFontWeight (OH_Drawing_TextStyle * , int ) +``` +**Description**
+Sets the font weight. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| int | Indicates the font weight to set. For details, see the enum **OH_Drawing_FontWeight**. | + + +### OH_Drawing_SetTextStyleLocale() + + +``` +void OH_Drawing_SetTextStyleLocale (OH_Drawing_TextStyle * , const char * ) +``` +**Description**
+Sets the locale. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | +| char | Indicates the pointer to the locale to set. | + + +### OH_Drawing_SetTypographyTextAlign() + + +``` +void OH_Drawing_SetTypographyTextAlign (OH_Drawing_TypographyStyle * , int ) +``` +**Description**
+Sets the text alignment mode. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyStyle | Indicates the pointer to an **OH_Drawing_TypographyStyle** object. | +| int | Indicates the text alignment mode to set. For details, see the enum **OH_Drawing_TextAlign**. | + + +### OH_Drawing_SetTypographyTextDirection() + + +``` +void OH_Drawing_SetTypographyTextDirection (OH_Drawing_TypographyStyle * , int ) +``` +**Description**
+Sets the text direction. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyStyle | Indicates the pointer to an **OH_Drawing_TypographyStyle** object. | +| int | Indicates the text direction to set. For details, see the enum **OH_Drawing_TextDirection**. | + + +### OH_Drawing_SetTypographyTextMaxLines() + + +``` +void OH_Drawing_SetTypographyTextMaxLines (OH_Drawing_TypographyStyle * , int ) +``` +**Description**
+Sets the maximum number of lines in a text file. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyStyle | Indicates the pointer to an **OH_Drawing_TypographyStyle** object. | +| int | Indicates the maximum number of lines to set. | + + +### OH_Drawing_TypographyGetAlphabeticBaseline() + + +``` +double OH_Drawing_TypographyGetAlphabeticBaseline (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the alphabetic baseline. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the alphabetic baseline. + + +### OH_Drawing_TypographyGetHeight() + + +``` +double OH_Drawing_TypographyGetHeight (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the height. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the height. + + +### OH_Drawing_TypographyGetIdeographicBaseline() + + +``` +double OH_Drawing_TypographyGetIdeographicBaseline (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the ideographic baseline. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the ideographic baseline. + + +### OH_Drawing_TypographyGetLongestLine() + + +``` +double OH_Drawing_TypographyGetLongestLine (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the longest line. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the longest line. + + +### OH_Drawing_TypographyGetMaxIntrinsicWidth() + + +``` +double OH_Drawing_TypographyGetMaxIntrinsicWidth (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the maximum intrinsic width. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the maximum intrinsic width. + + +### OH_Drawing_TypographyGetMaxWidth() + + +``` +double OH_Drawing_TypographyGetMaxWidth (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the maximum width. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the maximum width. + + +### OH_Drawing_TypographyGetMinIntrinsicWidth() + + +``` +double OH_Drawing_TypographyGetMinIntrinsicWidth (OH_Drawing_Typography * ) +``` +**Description**
+Obtains the minimum intrinsic width. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | + +**Returns** + +Returns the minimum intrinsic width. + + +### OH_Drawing_TypographyHandlerAddText() + + +``` +void OH_Drawing_TypographyHandlerAddText (OH_Drawing_TypographyCreate * , const char * ) +``` +**Description**
+Sets the text content. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyCreate | Indicates the pointer to an **OH_Drawing_TypographyCreate** object. | +| char | Indicates the pointer to the text content to set. | + + +### OH_Drawing_TypographyHandlerPopTextStyle() + + +``` +void OH_Drawing_TypographyHandlerPopTextStyle (OH_Drawing_TypographyCreate * ) +``` +**Description**
+Removes the topmost style in the stack, leaving the remaining styles in effect. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyCreate | Indicates the pointer to an **OH_Drawing_TypographyCreate** object. | + + +### OH_Drawing_TypographyHandlerPushTextStyle() + + +``` +void OH_Drawing_TypographyHandlerPushTextStyle (OH_Drawing_TypographyCreate * , OH_Drawing_TextStyle * ) +``` +**Description**
+Sets the text style. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_TypographyCreate | Indicates the pointer to an **OH_Drawing_TypographyCreate** object. | +| OH_Drawing_TextStyle | Indicates the pointer to an **OH_Drawing_TextStyle** object. | + + +### OH_Drawing_TypographyLayout() + + +``` +void OH_Drawing_TypographyLayout (OH_Drawing_Typography * , double ) +``` +**Description**
+Lays out the typography. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | +| double | Indicates the maximum text width to set. | + + +### OH_Drawing_TypographyPaint() + + +``` +void OH_Drawing_TypographyPaint (OH_Drawing_Typography * , OH_Drawing_Canvas * , double , double ) +``` +**Description**
+Paints text on the canvas. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + + **Parameters** + +| Name | Description | +| -------- | -------- | +| OH_Drawing_Typography | Indicates the pointer to an **OH_Drawing_Typography** object. | +| OH_Drawing_Canvas | Indicates the pointer to an **OH_Drawing_Canvas** object. | +| double | Indicates the x coordinate. | +| double | Indicates the y coordinate. | diff --git a/en/application-dev/reference/native-apis/_hi_log.md b/en/application-dev/reference/native-apis/_hi_log.md new file mode 100644 index 0000000000000000000000000000000000000000..95b3519df13c7120267c6c9057e90633fb322771 --- /dev/null +++ b/en/application-dev/reference/native-apis/_hi_log.md @@ -0,0 +1,297 @@ +# HiLog + + +## Overview + +Provides logging functions. + +For example, you can use logging functions to output logs of the specified log type, service domain, log tag, and log level. + +\@syscap SystemCapability.HiviewDFX.HiLog + +**Since:** +8 + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [log.h](log_8h.md) | Defines the logging functions of the HiLog module.
File to Include: | + + +### Macros + +| Name | Description | +| -------- | -------- | +| [LOG_DOMAIN](#log_domain) 0 | Defines the service domain for a log file. | +| [LOG_TAG](#log_tag) NULL | Defines a string constant used to identify the class, file, or service. | +| [OH_LOG_DEBUG](#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_DEBUG, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. | +| [OH_LOG_INFO](#oh_log_info)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_INFO, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. | +| [OH_LOG_WARN](#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_WARN, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. | +| [OH_LOG_ERROR](#oh_log_error)(type, ...) ((void)[OH_LOG_Print](#oh_log_print)((type), LOG_ERROR, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. | +| [OH_LOG_FATAL](#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), LOG_FATAL, [LOG_DOMAIN](#log_domain), [LOG_TAG](#log_tag), __VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [LogType](#logtype) { LOG_APP = 0 } | Enumerates log types. | +| [LogLevel](#loglevel) {
LOG_DEBUG = 3, LOG_INFO = 4, LOG_WARN = 5, LOG_ERROR = 6,
LOG_FATAL = 7
} | Enumerates log levels. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_LOG_Print](#oh_log_print) ([LogType](#logtype) type, [LogLevel](#loglevel) level, unsigned int domain, const char *tag, const char *fmt,...) \_\_attribute\_\_((\_\_format\_\_(os_log, 5,6))) |Outputs logs. | +| [OH_LOG_IsLoggable](#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. | + + +## Macro Description + + +### LOG_DOMAIN + + +``` +#define LOG_DOMAIN 0 +``` +**Description**
+Defines the service domain for a log file. + +The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated. + + +### LOG_TAG + + +``` +#define LOG_TAG NULL +``` +**Description**
+Defines a string constant used to identify the class, file, or service. + + +### OH_LOG_DEBUG + + +``` +#define OH_LOG_DEBUG( type, ... ) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +``` +**Description**
+Outputs DEBUG logs. This is a function-like macro. + +Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + + **See** + +[OH_LOG_Print](#oh_log_print) + + +### OH_LOG_ERROR + + +``` +#define OH_LOG_ERROR( type, ... ) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +``` +**Description**
+Outputs ERROR logs. This is a function-like macro. + +Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + + **See** + +[OH_LOG_Print](#oh_log_print) + + +### OH_LOG_FATAL + + +``` +#define OH_LOG_FATAL( type, ... ) ((void)HiLogPrint((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +``` +**Description**
+Outputs FATAL logs. This is a function-like macro. + +Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + + **See** + +[OH_LOG_Print](#oh_log_print) + + +### OH_LOG_INFO + + +``` +#define OH_LOG_INFO( type, ... ) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +``` +**Description**
+Outputs INFO logs. This is a function-like macro. + +Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + + **See** + +[OH_LOG_Print](#oh_log_print) + + +### OH_LOG_WARN + + +``` +#define OH_LOG_WARN( type, ... ) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) +``` +**Description**
+Outputs WARN logs. This is a function-like macro. + +Before calling this function, define the log service domain and log tag. Generally, you need to define them at the beginning of the source file. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + + **See** + +[OH_LOG_Print](#oh_log_print) + + +## Enum Description + + +### LogLevel + + +``` +enum LogLevel +``` +**Description**
+Enumerates log levels. + +You are advised to select log levels based on their respective use cases: + +DEBUG: provides more detailed process information than INFO logs to help developers analyze service processes and locate faults. DEBUG logs are not recorded in official versions by default. They are available in debug versions or in official versions with the debug function enabled. + +INFO: indicates the key service process nodes and exceptions (for example, no network signal or login failure) that occur during service running. 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: indicates a severe, unexpected fault that has little impact on users and can be rectified by the programs themselves or through simple operations. + +ERROR: indicates a program or functional error that affects the normal running or use of the functionality and can be fixed at a high cost, for example, by resetting data. + +FATAL: indicates that a program or functionality is about to crash and the fault cannot be rectified. + +| Name | Description | +| -------- | -------- | +| LOG_DEBUG | DEBUG level to be used by OH_LOG_DEBUG | +| LOG_INFO | INFO level to be used by OH_LOG_INFO | +| LOG_WARN | WARN level to be used by OH_LOG_WARN | +| LOG_ERROR | ERROR level to be used by OH_LOG_ERROR | +| LOG_FATAL | FATAL level to be used by OH_LOG_FATAL | + + +### LogType + + +``` +enum LogType +``` +**Description**
+Enumerates log types. + +Currently, only LOG_APP is available. + +| Name | Description | +| -------- | -------- | +| LOG_APP | Application log | + + +## Function Description + + +### OH_LOG_IsLoggable() + + +``` +int bool OH_LOG_IsLoggable (unsigned int domain, const char * tag, LogLevel level ) +``` +**Description**
+Checks whether logs of the specified service domain, log tag, and log level can be output. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| domain | Indicates the service domain of logs. | +| tag | Indicates the log tag. | +| level | Indicates the log level. | + +**Returns** + +Returns **true** if the specified logs can be output; returns **false** otherwise. + + +### OH_LOG_Print() + + +``` +int OH_LOG_Print (LogType type, LogLevel level, unsigned int domain, const char * tag, const char * fmt, ... ) +``` +**Description**
+Outputs logs. + +You can use this function to output logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| type | Indicates the log type. The type for third-party applications is defined by LOG_APP. | +| level | Indicates the log level, which can be **LOG_DEBUG**, **LOG_INFO**, **LOG_WARN**, **LOG_ERROR**, and **LOG_FATAL**. | +| domain | Indicates the service domain. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. | +| tag | Indicates the log tag, which is a string used to identify the class, file, or service. | +| fmt | Indicates the format string, which is an enhancement of a printf format string and supports the privacy identifier. Specifically, **{public}** or **{private}** is added between the % character and the format specifier in each parameter. | +| ... | Indicates the parameter list corresponding to the parameter type in the format string. The number and type of parameters must be mapped onto the identifier in the format string. | + +**Returns** + +Returns **0** or a larger value if the operation is successful; returns a value smaller than **0** otherwise. diff --git a/en/application-dev/reference/native-apis/_huks_key_api.md b/en/application-dev/reference/native-apis/_huks_key_api.md new file mode 100644 index 0000000000000000000000000000000000000000..a8fffd18de8c4e9aa8f687b7c221aad24d89d41b --- /dev/null +++ b/en/application-dev/reference/native-apis/_huks_key_api.md @@ -0,0 +1,364 @@ +# HuksKeyApi + + +## Overview + +Describes the OpenHarmony Universal KeyStore (HUKS) capabilities, including key management and cryptography operations, provided for applications. The keys managed by HUKS can be imported by applications or generated by calling the HUKS APIs. + +\@syscap SystemCapability.Security.Huks + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_huks_api.h](native__huks__api_8h.md) | Declares the APIs used to access the HUKS.
File to Include: | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Huks_GetSdkVersion](#oh_huks_getsdkversion) (struct [OH_Huks_Blob](_o_h___huks___blob.md) \*sdkVersion) | Obtains the current HUKS SDK version. | +| [OH_Huks_GenerateKeyItem](#oh_huks_generatekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Generates a key. | +| [OH_Huks_ImportKeyItem](#oh_huks_importkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Imports a key in plaintext. | +| [OH_Huks_ImportWrappedKeyItem](#oh_huks_importwrappedkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappingKeyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappedKeyData) | Imports a wrapped key. | +| [OH_Huks_ExportPublicKeyItem](#oh_huks_exportpublickeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Exports a public key. | +| [OH_Huks_DeleteKeyItem](#oh_huks_deletekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Deletes a key. | +| [OH_Huks_GetKeyItemParamSet](#oh_huks_getkeyitemparamset) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Obtains the attributes of a key. | +| [OH_Huks_IsKeyItemExist](#oh_huks_iskeyitemexist) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether a key exists. | +| [OH_Huks_AttestKeyItem](#oh_huks_attestkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_CertChain](_o_h___huks___cert_chain.md) \*certChain) | Obtain the key certificate chain. | +| [OH_Huks_InitSession](#oh_huks_initsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*challenge) | Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). | +| [OH_Huks_UpdateSession](#oh_huks_updatesession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. | +| [OH_Huks_FinishSession](#oh_huks_finishsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Ends the key session. | +| [OH_Huks_AbortSession](#oh_huks_abortsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Aborts a key session. | + + +## Function Description + + +### OH_Huks_AbortSession() + + +``` +struct OH_Huks_Result OH_Huks_AbortSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet ) +``` +**Description**
+Aborts a key session. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). | +| paramSet | Indicates the pointer to the parameters required for aborting the key session. By default, this parameter is a null pointer. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + **See** + +[OH_Huks_InitSession](#oh_huks_initsession) + +[OH_Huks_UpdateSession](#oh_huks_updatesession) + +[OH_Huks_FinishSession](#oh_huks_finishsession) + + +### OH_Huks_AttestKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_AttestKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_CertChain * certChain ) +``` +**Description**
+Obtain the key certificate chain. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the target key. | +| paramSet | Indicates the pointer to the parameters required for obtaining the key certificate. | +| certChain | Indicates the pointer to the key certificate chain obtained. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_DeleteKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_DeleteKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet ) +``` +**Description**
+Deletes a key. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the key to delete. The alias must be the same as the alias for the key generated. | +| paramSet | Indicates the pointer to the parameters required for deleting the key. By default, this parameter is a null pointer. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_ExportPublicKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_ExportPublicKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * key ) +``` +**Description**
+Exports a public key. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the public key to export. The alias must be the same as the alias for the key generated. | +| paramSet | Indicates the pointer to the parameters required for exporting the public key. | +| key | Indicates the pointer to the public key exported. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_FinishSession() + + +``` +struct OH_Huks_Result OH_Huks_FinishSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData ) +``` +**Description**
+Ends the key session. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). | +| paramSet | Indicates the pointer to the parameters required for the key operation. | +| inData | Indicates the pointer to the data to be processed. | +| outData | Indicates the pointer to the output data. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + **See** + +[OH_Huks_InitSession](#oh_huks_initsession) + +[OH_Huks_UpdateSession](#oh_huks_updatesession) + +[OH_Huks_AbortSession](#oh_huks_abortsession) + + +### OH_Huks_GenerateKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_GenerateKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut ) +``` +**Description**
+Generates a key. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the key to generate. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. | +| paramSetIn | Indicates the pointer to the parameter set for generating the key. | +| paramSetOut | Indicates the pointer to a temporary key generated. If the generated key is not of a temporary type, this parameter is a null pointer. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_GetKeyItemParamSet() + + +``` +struct OH_Huks_Result OH_Huks_GetKeyItemParamSet (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSetIn, struct OH_Huks_ParamSet * paramSetOut ) +``` +**Description**
+Obtains the attributes of a key. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the target key. | +| paramSetIn | Indicates the pointer to the attribute tag required for obtaining the attributes. By default, this parameter is a null pointer. | +| paramSetOut | Indicates the pointer to the attributes obtained. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_GetSdkVersion() + + +``` +struct OH_Huks_Result OH_Huks_GetSdkVersion (struct OH_Huks_Blob * sdkVersion) +``` +**Description**
+Obtains the current HUKS SDK version. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| sdkVersion | Indicates the pointer to the SDK version (in string format) obtained. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_ImportKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_ImportKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * key ) +``` +**Description**
+Imports a key in plaintext. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. | +| paramSet | Indicates the pointer to the parameters of the key to import. | +| key | Indicates the pointer to the key to import. The key must be in the format required by the HUKS. For details, see [HuksTypeApi](_huks_type_api.md). | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_ImportWrappedKeyItem() + + +``` +struct OH_Huks_Result OH_Huks_ImportWrappedKeyItem (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_Blob * wrappingKeyAlias, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * wrappedKeyData ) +``` +**Description**
+Imports a wrapped key. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the key to import. The alias must be unique in the process of the service. Otherwise, the key will be overwritten. | +| wrappingKeyAlias | Indicates the pointer to the alias of the wrapping key, which is obtained through key agreement and used to decrypt the key to import. | +| paramSet | Indicates the pointer to the parameters of the wrapped key to import. | +| wrappedKeyData | Indicates the pointer to the wrapped key to import. The key must be in the format required by the HUKS. For details, see [OH_Huks_AlgSuite](_huks_type_api.md#oh_huks_algsuite). | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_InitSession() + + +``` +struct OH_Huks_Result OH_Huks_InitSession (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet, struct OH_Huks_Blob * handle, struct OH_Huks_Blob * challenge ) +``` +**Description**
+Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the target key. | +| paramSet | Indicates the pointer to the parameters for the initialization operation. | +| handle | Indicates the pointer to the handle of the key session obtained. This handle is required for subsequent operations, including [OH_Huks_UpdateSession](#oh_huks_updatesession), [OH_Huks_FinishSession](#oh_huks_finishsession), and [OH_Huks_AbortSession](#oh_huks_abortsession). | +| challenge | Indicates the pointer to the challenge value obtained. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + **See** + +[OH_Huks_UpdateSession](#oh_huks_updatesession) + +[OH_Huks_FinishSession](#oh_huks_finishsession) + +[OH_Huks_AbortSession](#oh_huks_abortsession) + + +### OH_Huks_IsKeyItemExist() + + +``` +struct OH_Huks_Result OH_Huks_IsKeyItemExist (const struct OH_Huks_Blob * keyAlias, const struct OH_Huks_ParamSet * paramSet ) +``` +**Description**
+Checks whether a key exists. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| keyAlias | Indicates the pointer to the alias of the target key. | +| paramSet | Indicates the pointer to the attribute tag required for checking the key. By default, this parameter is a null pointer. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the key exists. + +Returns [OH_Huks_ErrCode#OH_HUKS_ERR_CODE_ITEM_NOT_EXIST](_huks_type_api.md) if the key does not exist. + +Returns any other error code for other cases. + + +### OH_Huks_UpdateSession() + + +``` +struct OH_Huks_Result OH_Huks_UpdateSession (const struct OH_Huks_Blob * handle, const struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Blob * inData, struct OH_Huks_Blob * outData ) +``` +**Description**
+Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| handle | Indicates the pointer to the key session handle, which is generated by [OH_Huks_InitSession](#oh_huks_initsession). | +| paramSet | Indicates the pointer to the parameters required for the key operation. | +| inData | Indicates the pointer to the data to be processed. This API can be called multiples time to process large data by segment. | +| outData | Indicates the pointer to the output data. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + **See** + +[OH_Huks_InitSession](#oh_huks_initsession) + +[OH_Huks_FinishSession](#oh_huks_finishsession) + +[OH_Huks_AbortSession](#oh_huks_abortsession) diff --git a/en/application-dev/reference/native-apis/_huks_param_set_api.md b/en/application-dev/reference/native-apis/_huks_param_set_api.md new file mode 100644 index 0000000000000000000000000000000000000000..f04d09f0c48991b4371394a09e97cfeb4a25eeda --- /dev/null +++ b/en/application-dev/reference/native-apis/_huks_param_set_api.md @@ -0,0 +1,245 @@ +# HuksParamSetApi + + +## Overview + +Defines the capabilities of OpenHarmony Universal KeyStore (HUKS) parameter sets. The HUKS APIs can be used to perform parameter set lifecycle management, including initializing a parameter set, adding parameters to a parameter set, constructing a parameter set, and destroying a parameter set. They can also be used to obtain parameters, copy parameter sets, and check parameter validity. + +\@syscap SystemCapability.Security.Huks + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_huks_param.h](native__huks__param_8h.md) | Provides APIs for constructing, using, and destroying parameter sets.
File to Include: | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Huks_InitParamSet](#oh_huks_initparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. | +| [OH_Huks_AddParams](#oh_huks_addparams) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md) \*params, uint32_t paramCnt) | Adds parameters to a parameter set. | +| [OH_Huks_BuildParamSet](#oh_huks_buildparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. | +| [OH_Huks_FreeParamSet](#oh_huks_freeparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. | +| [OH_Huks_CopyParamSet](#oh_huks_copyparamset) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Copies a parameter set (deep copy). | +| [OH_Huks_GetParam](#oh_huks_getparam) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md) \*\*param) | Obtains parameters from a parameter set. | +| [OH_Huks_FreshParamSet](#oh_huks_freshparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. | +| [OH_Huks_isParamSetTagValid](#oh_huks_isparamsettagvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether the parameters in a parameter set are valid. | +| [OH_Huks_isParamSetValid](#oh_huks_isparamsetvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. | +| [OH_Huks_CheckParamMatch](#oh_huks_checkparammatch) (const struct [OH_Huks_Param](_o_h___huks___param.md) \*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md) \*param) | Checks whether two parameters are the same. | + + +## Function Description + + +### OH_Huks_AddParams() + + +``` +int32_t OH_Huks_AddParams (struct OH_Huks_ParamSet * paramSet, const struct OH_Huks_Param * params, uint32_t paramCnt ) +``` +**Description**
+Adds parameters to a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the pointer to the parameter set to which parameters are to be added. | +| params | Indicates the pointer to the array of parameters to add. | +| paramCnt | Indicates the number of parameters to add. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_BuildParamSet() + + +``` +int32_t OH_Huks_BuildParamSet (struct OH_Huks_ParamSet ** paramSet) +``` +**Description**
+Constructs a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the double pointer to the parameter set to construct. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_CheckParamMatch() + + +``` +int32_t OH_Huks_CheckParamMatch (const struct OH_Huks_Param * baseParam, const struct OH_Huks_Param * param ) +``` +**Description**
+Checks whether two parameters are the same. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| baseParam | Indicates the pointer to the first parameter. | +| param | Indicates the pointer to the second parameter. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the two parameters are the same; returns an error code otherwise. + + +### OH_Huks_CopyParamSet() + + +``` +int32_t OH_Huks_CopyParamSet (const struct OH_Huks_ParamSet * fromParamSet, uint32_t fromParamSetSize, struct OH_Huks_ParamSet ** paramSet ) +``` +**Description**
+Copies a parameter set (deep copy). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| fromParamSet | Indicates the pointer to the parameter set to copy. | +| fromParamSetSize | Indicates the memory size occupied by the source parameter set. | +| paramSet | Indicates the double pointer to the new parameter set generated. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful; returns an error code otherwise. + + +### OH_Huks_FreeParamSet() + + +``` +void OH_Huks_FreeParamSet (struct OH_Huks_ParamSet ** paramSet) +``` +**Description**
+Destroys a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the double pointer to the parameter set to destroy. | + + +### OH_Huks_FreshParamSet() + + +``` +int32_t OH_Huks_FreshParamSet (struct OH_Huks_ParamSet * paramSet, bool isCopy ) +``` +**Description**
+Refreshes data of the **Blob** type in a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the pointer to the target parameter set. | +| isCopy | Specifies whether to copy the data of the **Blob** type to the parameter set. If yes, the data of the **Blob** type will be copied to the parameter set. Otherwise, only the address of the **Blob** data will be refreshed. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if operation is successful; returns an error code otherwise. + + +### OH_Huks_GetParam() + + +``` +int32_t OH_Huks_GetParam (const struct OH_Huks_ParamSet * paramSet, uint32_t tag, struct OH_Huks_Param ** param ) +``` +**Description**
+Obtains parameters from a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the pointer to the target parameter set. | +| tag | Indicates the value of the parameter to be obtained. | +| param | Indicates the double pointer to the parameter obtained. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the operation is successful, returns an error code otherwise. + + +### OH_Huks_InitParamSet() + + +``` +int32_t OH_Huks_InitParamSet (struct OH_Huks_ParamSet ** paramSet) +``` +**Description**
+Initializes a parameter set. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the double pointer to the parameter set to initialize. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the initialization is successful; returns an error code otherwise. + + +### OH_Huks_isParamSetTagValid() + + +``` +int32_t OH_Huks_isParamSetTagValid (const struct OH_Huks_ParamSet * paramSet) +``` +**Description**
+Checks whether the parameters in a parameter set are valid. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the pointer to the parameter set to check. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameters in the parameter set are valid; returns other values if the parameter set has invalid, duplicate, or incorrect parameters. + + +### OH_Huks_isParamSetValid() + + +``` +int32_t OH_Huks_isParamSetValid (const struct OH_Huks_ParamSet * paramSet, uint32_t size ) +``` +**Description**
+Checks whether a parameter set is of the valid size. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| paramSet | Indicates the pointer to the parameter set to check. | +| size | Indicates the memory size occupied by the parameter set. | + +**Returns** + +Returns [OH_Huks_ErrCode#OH_HUKS_SUCCESS](_huks_type_api.md) if the parameter set is of the valid size; returns an error code otherwise. diff --git a/en/application-dev/reference/native-apis/_huks_type_api.md b/en/application-dev/reference/native-apis/_huks_type_api.md new file mode 100644 index 0000000000000000000000000000000000000000..398b5df7b89d78913171fe0aa5d06a41e5ed81e2 --- /dev/null +++ b/en/application-dev/reference/native-apis/_huks_type_api.md @@ -0,0 +1,506 @@ +# HuksTypeApi + + +## Overview + +Defines the macros, enumerated values, data structures, and error codes used by OpenHarmony Universal KeyStore (HUKS) APIs. + +\@syscap SystemCapability.Security.Huks + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_huks_type.h](native__huks__type_8h.md) | Defines the enumerated variables, structures, and macros used in the HUKS APIs.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_Huks_Result](_o_h___huks___result.md) | Defines the return data, including the result code and message. | +| [OH_Huks_Blob](_o_h___huks___blob.md) | Defines the structure for storing data. | +| [OH_Huks_Param](_o_h___huks___param.md) | Defines the parameter structure in a parameter set. | +| [OH_Huks_ParamSet](_o_h___huks___param_set.md) | Defines the structure of the parameter set. | +| [OH_Huks_CertChain](_o_h___huks___cert_chain.md) | Defines the structure of the certificate chain. | +| [OH_Huks_KeyInfo](_o_h___huks___key_info.md) | Defines the key information structure. | +| [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md) | Defines the structure of a public key. | +| [OH_Huks_KeyMaterialRsa](_o_h___huks___key_material_rsa.md) | Defines the structure of an RSA key. | +| [OH_Huks_KeyMaterialEcc](_o_h___huks___key_material_ecc.md) | Defines the structure of an ECC key. | +| [OH_Huks_KeyMaterialDsa](_o_h___huks___key_material_dsa.md) | Defines the structure of a DSA key. | +| [OH_Huks_KeyMaterialDh](_o_h___huks___key_material_dh.md) | Defines the structure of a DH key. | +| [OH_Huks_KeyMaterial25519](_o_h___huks___key_material25519.md) | Defines the structure of a 25519 key. | + + +### Macros + +| Name | Value | +| -------- | -------- | +| **OH_HUKS_AE_TAG_LEN** | 16 | +| **OH_HUKS_BITS_PER_BYTE** | 8 | +| **OH_HUKS_MAX_KEY_SIZE** | 2048 | +| **OH_HUKS_AE_NONCE_LEN** | 12| +| **OH_HUKS_MAX_KEY_ALIAS_LEN** | 64 | +| **OH_HUKS_MAX_PROCESS_NAME_LEN** | 50 | +| **OH_HUKS_MAX_RANDOM_LEN** | 1024 | +| **OH_HUKS_SIGNATURE_MIN_SIZE** | 64 | +| **OH_HUKS_MAX_OUT_BLOB_SIZE** | (5 \* 1024 \* 1024) | +| **OH_HUKS_WRAPPED_FORMAT_MAX_SIZE** | (1024 \* 1024) | +| **OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS** | 10 | +| **TOKEN_CHALLENGE_LEN** | 32 | +| **SHA256_SIGN_LEN** | 32 | +| **TOKEN_SIZE** | 32| +| **MAX_AUTH_TIMEOUT_SECOND** | 60 | +| **SECURE_SIGN_VERSION** | 0x01000001 | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Huks_KeyPurpose](#oh_huks_keypurpose) {
OH_HUKS_KEY_PURPOSE_ENCRYPT = 1, OH_HUKS_KEY_PURPOSE_DECRYPT = 2, OH_HUKS_KEY_PURPOSE_SIGN = 4, OH_HUKS_KEY_PURPOSE_VERIFY = 8,
OH_HUKS_KEY_PURPOSE_DERIVE = 16, OH_HUKS_KEY_PURPOSE_WRAP = 32, OH_HUKS_KEY_PURPOSE_UNWRAP = 64, OH_HUKS_KEY_PURPOSE_MAC = 128,
OH_HUKS_KEY_PURPOSE_AGREE = 256
} | Enumerates the key purposes. | +| [OH_Huks_KeyDigest](#oh_huks_keydigest) {
OH_HUKS_DIGEST_NONE = 0, OH_HUKS_DIGEST_MD5 = 1, OH_HUKS_DIGEST_SM3 = 2, OH_HUKS_DIGEST_SHA1 = 10,
OH_HUKS_DIGEST_SHA224 = 11, OH_HUKS_DIGEST_SHA256 = 12, OH_HUKS_DIGEST_SHA384 = 13, OH_HUKS_DIGEST_SHA512 = 14
} | Enumerates the digest algorithms. | +| [OH_Huks_KeyPadding](#oh_huks_keypadding) {
OH_HUKS_PADDING_NONE = 0, OH_HUKS_PADDING_OAEP = 1, OH_HUKS_PADDING_PSS = 2, OH_HUKS_PADDING_PKCS1_V1_5 = 3,
OH_HUKS_PADDING_PKCS5 = 4, OH_HUKS_PADDING_PKCS7 = 5
} | Enumerates the padding algorithms. | +| [OH_Huks_CipherMode](#oh_huks_ciphermode) {
OH_HUKS_MODE_ECB = 1, OH_HUKS_MODE_CBC = 2, OH_HUKS_MODE_CTR = 3, OH_HUKS_MODE_OFB = 4,
OH_HUKS_MODE_CCM = 31, OH_HUKS_MODE_GCM = 32
} | Enumerates the cipher modes. | +| [OH_Huks_KeySize](#oh_huks_keysize) {
OH_HUKS_RSA_KEY_SIZE_512 = 512, OH_HUKS_RSA_KEY_SIZE_768 = 768, OH_HUKS_RSA_KEY_SIZE_1024 = 1024, OH_HUKS_RSA_KEY_SIZE_2048 = 2048,
OH_HUKS_RSA_KEY_SIZE_3072 = 3072, OH_HUKS_RSA_KEY_SIZE_4096 = 4096, OH_HUKS_ECC_KEY_SIZE_224 = 224, OH_HUKS_ECC_KEY_SIZE_256 = 256,
OH_HUKS_ECC_KEY_SIZE_384 = 384, OH_HUKS_ECC_KEY_SIZE_521 = 521, OH_HUKS_AES_KEY_SIZE_128 = 128, OH_HUKS_AES_KEY_SIZE_192 = 192,
OH_HUKS_AES_KEY_SIZE_256 = 256, OH_HUKS_AES_KEY_SIZE_512 = 512, OH_HUKS_CURVE25519_KEY_SIZE_256 = 256, OH_HUKS_DH_KEY_SIZE_2048 = 2048,
OH_HUKS_DH_KEY_SIZE_3072 = 3072, OH_HUKS_DH_KEY_SIZE_4096 = 4096, OH_HUKS_SM2_KEY_SIZE_256 = 256, OH_HUKS_SM4_KEY_SIZE_128 = 128
} | Enumerates the key sizes. | +| [OH_Huks_KeyAlg](#oh_huks_keyalg) {
OH_HUKS_ALG_RSA = 1, OH_HUKS_ALG_ECC = 2, OH_HUKS_ALG_DSA = 3, OH_HUKS_ALG_AES = 20,
OH_HUKS_ALG_HMAC = 50, OH_HUKS_ALG_HKDF = 51, OH_HUKS_ALG_PBKDF2 = 52, OH_HUKS_ALG_ECDH = 100,
OH_HUKS_ALG_X25519 = 101, OH_HUKS_ALG_ED25519 = 102, OH_HUKS_ALG_DH = 103, OH_HUKS_ALG_SM2 = 150,
OH_HUKS_ALG_SM3 = 151, OH_HUKS_ALG_SM4 = 152
} | Enumerates the key algorithms. | +| [OH_Huks_AlgSuite](#oh_huks_algsuite) { OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2 } | Enumerates the algorithm suites required for ciphertext imports. | +| [OH_Huks_KeyGenerateType](#oh_huks_keygeneratetype) { OH_HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, OH_HUKS_KEY_GENERATE_TYPE_DERIVE = 1, OH_HUKS_KEY_GENERATE_TYPE_AGREE = 2 } | Enumerates the key generation types. | +| [OH_Huks_KeyFlag](#oh_huks_keyflag) { OH_HUKS_KEY_FLAG_IMPORT_KEY = 1, OH_HUKS_KEY_FLAG_GENERATE_KEY = 2, OH_HUKS_KEY_FLAG_AGREE_KEY = 3, OH_HUKS_KEY_FLAG_DERIVE_KEY = 4 } | Enumerates the key generation modes. | +| [OH_Huks_KeyStorageType](#oh_huks_keystoragetype) { OH_HUKS_STORAGE_TEMP = 0, OH_HUKS_STORAGE_PERSISTENT = 1 } | Enumerates the key storage modes. | +| [OH_Huks_ImportKeyType](#oh_huks_importkeytype) { OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, OH_HUKS_KEY_TYPE_KEY_PAIR = 2 } | Enumerates the types of keys to import. By default, a public key is imported. This field is not required when a symmetric key is imported. | +| [OH_Huks_ErrCode](#oh_huks_errcode) {
OH_HUKS_SUCCESS = 0, OH_HUKS_ERR_CODE_PERMISSION_FAIL = 201, OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT = 401, OH_HUKS_ERR_CODE_NOT_SUPPORTED_API = 801,
OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED = 12000001, OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT = 12000002, OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT = 12000003, OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL = 12000004,
OH_HUKS_ERR_CODE_COMMUNICATION_FAIL = 12000005, OH_HUKS_ERR_CODE_CRYPTO_FAIL = 12000006, OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED = 12000007, OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED = 12000008,
OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT = 12000009, OH_HUKS_ERR_CODE_SESSION_LIMIT = 12000010, OH_HUKS_ERR_CODE_ITEM_NOT_EXIST = 12000011, OH_HUKS_ERR_CODE_INTERNAL_ERROR = 12000012,
OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST = 12000013
} | Enumerates the error codes. | +| [OH_Huks_TagType](#oh_huks_tagtype) {
OH_HUKS_TAG_TYPE_INVALID = 0 << 28, OH_HUKS_TAG_TYPE_INT = 1 << 28, OH_HUKS_TAG_TYPE_UINT = 2 << 28, OH_HUKS_TAG_TYPE_ULONG = 3 << 28,
OH_HUKS_TAG_TYPE_BOOL = 4 << 28, OH_HUKS_TAG_TYPE_BYTES = 5 << 28
} | Enumerates the tag types. | +| [OH_Huks_UserAuthType](#oh_huks_userauthtype) { OH_HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 << 0, OH_HUKS_USER_AUTH_TYPE_FACE = 1 << 1, OH_HUKS_USER_AUTH_TYPE_PIN = 1 << 2 } | Enumerates the user authentication types. | +| [OH_Huks_AuthAccessType](#oh_huks_authaccesstype) { OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 << 0, OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 << 1 } | Enumerates the access control types. | +| [OH_Huks_ChallengeType](#oh_huks_challengetype) { OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, OH_HUKS_CHALLENGE_TYPE_NONE = 2 } | Enumerates the types of the challenges generated when a key is used. | +| [OH_Huks_ChallengePosition](#oh_huks_challengeposition) { OH_HUKS_CHALLENGE_POS_0 = 0, OH_HUKS_CHALLENGE_POS_1, OH_HUKS_CHALLENGE_POS_2, OH_HUKS_CHALLENGE_POS_3 } | Enumerates the positions of the 8-byte valid value in a custom challenge generated. | +| [OH_Huks_SecureSignType](#oh_huks_securesigntype) { OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 } | Enumerates the signature types of the keys generated or imported. | +| [OH_Huks_Tag](#oh_huks_tag) {
OH_HUKS_TAG_ALGORITHM = OH_HUKS_TAG_TYPE_UINT \| 1, OH_HUKS_TAG_PURPOSE = OH_HUKS_TAG_TYPE_UINT \| 2, OH_HUKS_TAG_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT \| 3,
OH_HUKS_TAG_DIGEST = OH_HUKS_TAG_TYPE_UINT \| 4, OH_HUKS_TAG_PADDING = OH_HUKS_TAG_TYPE_UINT \| 5, OH_HUKS_TAG_BLOCK_MODE = OH_HUKS_TAG_TYPE_UINT \| 6, OH_HUKS_TAG_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT \| 7,
OH_HUKS_TAG_ASSOCIATED_DATA = OH_HUKS_TAG_TYPE_BYTES \| 8, OH_HUKS_TAG_NONCE = OH_HUKS_TAG_TYPE_BYTES \| 9, OH_HUKS_TAG_IV = OH_HUKS_TAG_TYPE_BYTES \| 10, OH_HUKS_TAG_INFO = OH_HUKS_TAG_TYPE_BYTES \| 11,
OH_HUKS_TAG_SALT = OH_HUKS_TAG_TYPE_BYTES \| 12, OH_HUKS_TAG_ITERATION = OH_HUKS_TAG_TYPE_UINT \| 14, OH_HUKS_TAG_KEY_GENERATE_TYPE = OH_HUKS_TAG_TYPE_UINT \| 15,
OH_HUKS_TAG_AGREE_ALG = OH_HUKS_TAG_TYPE_UINT \| 19,
OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL \| 20, OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 21, OH_HUKS_TAG_AGREE_PUBLIC_KEY = OH_HUKS_TAG_TYPE_BYTES \| 22, OH_HUKS_TAG_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 23,
OH_HUKS_TAG_DERIVE_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT \| 24, OH_HUKS_TAG_IMPORT_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT \| 25, OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE = OH_HUKS_TAG_TYPE_UINT \| 26, OH_HUKS_TAG_ALL_USERS = OH_HUKS_TAG_TYPE_BOOL \| 301,
OH_HUKS_TAG_USER_ID = OH_HUKS_TAG_TYPE_UINT \| 302, OH_HUKS_TAG_NO_AUTH_REQUIRED = OH_HUKS_TAG_TYPE_BOOL \| 303, OH_HUKS_TAG_USER_AUTH_TYPE = OH_HUKS_TAG_TYPE_UINT \| 304, OH_HUKS_TAG_AUTH_TIMEOUT = OH_HUKS_TAG_TYPE_UINT \| 305,
OH_HUKS_TAG_AUTH_TOKEN = OH_HUKS_TAG_TYPE_BYTES \| 306, OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE = OH_HUKS_TAG_TYPE_UINT \| 307, OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE = OH_HUKS_TAG_TYPE_UINT \| 308, OH_HUKS_TAG_CHALLENGE_TYPE = OH_HUKS_TAG_TYPE_UINT \| 309,
OH_HUKS_TAG_CHALLENGE_POS = OH_HUKS_TAG_TYPE_UINT \| 310, OH_HUKS_TAG_ATTESTATION_CHALLENGE = OH_HUKS_TAG_TYPE_BYTES \| 501, OH_HUKS_TAG_ATTESTATION_APPLICATION_ID = OH_HUKS_TAG_TYPE_BYTES \| 502,
OH_HUKS_TAG_ATTESTATION_ID_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 511,
OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = OH_HUKS_TAG_TYPE_BYTES \| 514, OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO = OH_HUKS_TAG_TYPE_BYTES \| 515,
OH_HUKS_TAG_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL \| 1001, OH_HUKS_TAG_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT \| 1002, OH_HUKS_TAG_IS_ALLOWED_WRAP = OH_HUKS_TAG_TYPE_BOOL \| 1003, OH_HUKS_TAG_KEY_WRAP_TYPE = OH_HUKS_TAG_TYPE_UINT \| 1004,
OH_HUKS_TAG_KEY_AUTH_ID = OH_HUKS_TAG_TYPE_BYTES \| 1005, OH_HUKS_TAG_KEY_ROLE = OH_HUKS_TAG_TYPE_UINT \| 1006, OH_HUKS_TAG_KEY_FLAG = OH_HUKS_TAG_TYPE_UINT \| 1007, OH_HUKS_TAG_IS_ASYNCHRONIZED = OH_HUKS_TAG_TYPE_UINT \| 1008,
OH_HUKS_TAG_KEY_DOMAIN = OH_HUKS_TAG_TYPE_UINT \| 1011, OH_HUKS_TAG_SYMMETRIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20001,
OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20002, OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20003
} | Enumerates the tag values used in parameter sets. | + + +## Enum Description + + +### OH_Huks_AlgSuite + + +``` +enum OH_Huks_AlgSuite +``` +**Description**
+Enumerates the algorithm suites required for ciphertext imports. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING | Key material format (Length-Value format), X25519 key agreement, and AES-256-GCM encryption and decryption. \| x25519_plain_pubkey_length (4 Byte) \| x25519_plain_pubkey \| agreekey_aad_length (4 Byte) \| agreekey_aad \| agreekey_nonce_length (4 Byte) \| agreekey_nonce \| agreekey_aead_tag_len(4 Byte) \| agreekey_aead_tag \| kek_enc_data_length (4 Byte) \| kek_enc_data \| kek_aad_length (4 Byte) \| kek_aad \| kek_nonce_length (4 Byte) \| kek_nonce \| kek_aead_tag_len (4 Byte) \| kek_aead_tag \| key_material_size_len (4 Byte) \| key_material_size \| key_mat_enc_length (4 Byte) \| key_mat_enc_data | +| OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING | Key material format (Length-Value format), ECDH-p256 key agreement, and AES-256-GCM encryption and decryption. \| ECC_plain_pubkey_length (4 Byte) \| ECC_plain_pubkey \| agreekey_aad_length (4 Byte) \| agreekey_aad \| agreekey_nonce_length (4 Byte) \| agreekey_nonce \| agreekey_aead_tag_len(4 Byte) \| agreekey_aead_tag \| kek_enc_data_length (4 Byte) \| kek_enc_data \| kek_aad_length (4 Byte) \| kek_aad \| kek_nonce_length (4 Byte) \| kek_nonce \| kek_aead_tag_len (4 Byte) \| kek_aead_tag \| key_material_size_len (4 Byte) \| key_material_size \| key_mat_enc_length (4 Byte) \| key_mat_enc_data | + + +### OH_Huks_AuthAccessType + + +``` +enum OH_Huks_AuthAccessType +``` +**Description**
+Enumerates the access control types. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD | The key is invalid after the password is cleared. | +| OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL | The key is invalid after a new biometric feature is enrolled. | + + +### OH_Huks_ChallengePosition + + +``` +enum OH_Huks_ChallengePosition +``` +**Description**
+Enumerates the positions of the 8-byte valid value in a custom challenge generated. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_CHALLENGE_POS_0 | Bytes 0 to 7. | +| OH_HUKS_CHALLENGE_POS_1 | Bytes 8 to 15. | +| OH_HUKS_CHALLENGE_POS_2 | Bytes 16 to 23. | +| OH_HUKS_CHALLENGE_POS_3 | Bytes 24 to 31. | + + +### OH_Huks_ChallengeType + + +``` +enum OH_Huks_ChallengeType +``` +**Description**
+Enumerates the types of the challenges generated when a key is used. + + **See** + +[OH_Huks_ChallengePosition](#oh_huks_challengeposition) + +| Name | Description | +| -------- | -------- | +| OH_HUKS_CHALLENGE_TYPE_NORMAL | Normal challenge, which is of 32 bytes by default. | +| OH_HUKS_CHALLENGE_TYPE_CUSTOM | Custom challenge, which supports only one authentication for multiple keys. The valid value of a custom challenge is of 8 bytes. | +| OH_HUKS_CHALLENGE_TYPE_NONE | Challenge is not required. | + + +### OH_Huks_CipherMode + + +``` +enum OH_Huks_CipherMode +``` +**Description**
+Enumerates the cipher modes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_MODE_ECB | Electronic Code Block (ECB) mode. | +| OH_HUKS_MODE_CBC | Cipher Block Chaining (CBC) mode. | +| OH_HUKS_MODE_CTR | Counter (CTR) mode. | +| OH_HUKS_MODE_OFB | Output Feedback (OFB) mode. | +| OH_HUKS_MODE_CCM | Counter with CBC-MAC (CCM) mode. | +| OH_HUKS_MODE_GCM | Galois/Counter (GCM) mode. | + + +### OH_Huks_ErrCode + + +``` +enum OH_Huks_ErrCode +``` +**Description**
+Enumerates the error codes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_SUCCESS | The operation is successful. | +| OH_HUKS_ERR_CODE_PERMISSION_FAIL | Permission verification failed. | +| OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT | Invalid parameters are detected. | +| OH_HUKS_ERR_CODE_NOT_SUPPORTED_API | The API is not supported. | +| OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED | The feature is not supported. | +| OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT | Key algorithm parameters are missing. | +| OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT | Invalid key algorithm parameters are detected. | +| OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL | Failed to operate the file. | +| OH_HUKS_ERR_CODE_COMMUNICATION_FAIL | The process communication failed. | +| OH_HUKS_ERR_CODE_CRYPTO_FAIL | Failed to operate the algorithm library. | +| OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED | Failed to access the key because the key has expired. | +| OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED | Failed to access the key because the authentication has failed. | +| OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT | Key access timed out. | +| OH_HUKS_ERR_CODE_SESSION_LIMIT | The number of key operation sessions has reached the limit. | +| OH_HUKS_ERR_CODE_ITEM_NOT_EXIST | The entity does not exist. | +| OH_HUKS_ERR_CODE_INTERNAL_ERROR | Internal error. | +| OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST | The authentication credential does not exist. | + + +### OH_Huks_ImportKeyType + + +``` +enum OH_Huks_ImportKeyType +``` +**Description**
+Enumerates the types of keys to import. By default, a public key is imported. This field is not required when a symmetric key is imported. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_KEY_TYPE_PUBLIC_KEY | Public key. | +| OH_HUKS_KEY_TYPE_PRIVATE_KEY | Private key. | +| OH_HUKS_KEY_TYPE_KEY_PAIR | Public and private key pair. | + + +### OH_Huks_KeyAlg + + +``` +enum OH_Huks_KeyAlg +``` +**Description**
+Enumerates the key algorithms. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_ALG_RSA | RSA. | +| OH_HUKS_ALG_ECC | ECC. | +| OH_HUKS_ALG_DSA | DSA. | +| OH_HUKS_ALG_AES | AES. | +| OH_HUKS_ALG_HMAC | HMAC. | +| OH_HUKS_ALG_HKDF | HKDF. | +| OH_HUKS_ALG_PBKDF2 | PBKDF2. | +| OH_HUKS_ALG_ECDH | ECDH. | +| OH_HUKS_ALG_X25519 | X25519. | +| OH_HUKS_ALG_ED25519 | Ed25519. | +| OH_HUKS_ALG_DH | DH. | +| OH_HUKS_ALG_SM2 | SM2. | +| OH_HUKS_ALG_SM3 | SM3. | +| OH_HUKS_ALG_SM4 | SM4. | + + +### OH_Huks_KeyDigest + + +``` +enum OH_Huks_KeyDigest +``` +**Description**
+Enumerates the digest algorithms. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_DIGEST_NONE | No digest algorithm. | +| OH_HUKS_DIGEST_MD5 | MD5. | +| OH_HUKS_DIGEST_SM3 | SM3. | +| OH_HUKS_DIGEST_SHA1 | SHA-1. | +| OH_HUKS_DIGEST_SHA224 | SHA-224. | +| OH_HUKS_DIGEST_SHA256 | SHA-256. | +| OH_HUKS_DIGEST_SHA384 | SHA-384. | +| OH_HUKS_DIGEST_SHA512 | SHA-512. | + + +### OH_Huks_KeyFlag + + +``` +enum OH_Huks_KeyFlag +``` +**Description**
+Enumerates the key generation modes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_KEY_FLAG_IMPORT_KEY | Import a public key using an API. | +| OH_HUKS_KEY_FLAG_GENERATE_KEY | Generate a key by using an API. | +| OH_HUKS_KEY_FLAG_AGREE_KEY | Generate a key by using a key agreement API. | +| OH_HUKS_KEY_FLAG_DERIVE_KEY | Derive a key by using an API. | + + +### OH_Huks_KeyGenerateType + + +``` +enum OH_Huks_KeyGenerateType +``` +**Description**
+Enumerates the key generation types. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_KEY_GENERATE_TYPE_DEFAULT | Key generated by default. | +| OH_HUKS_KEY_GENERATE_TYPE_DERIVE | Derived key. | +| OH_HUKS_KEY_GENERATE_TYPE_AGREE | Key obtained by key agreement. | + + +### OH_Huks_KeyPadding + + +``` +enum OH_Huks_KeyPadding +``` +**Description**
+Enumerates the padding algorithms. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_PADDING_NONE | No padding algorithm. | +| OH_HUKS_PADDING_OAEP | Optimal Asymmetric Encryption Padding (OAEP). | +| OH_HUKS_PADDING_PSS | Probabilistic Signature Scheme (PSS). | +| OH_HUKS_PADDING_PKCS1_V1_5 | Public Key Cryptography Standards (PKCS) \#1 v1.5. | +| OH_HUKS_PADDING_PKCS5 | PKCS \#5. | +| OH_HUKS_PADDING_PKCS7 | PKCS \#7. | + + +### OH_Huks_KeyPurpose + + +``` +enum OH_Huks_KeyPurpose +``` +**Description**
+Enumerates the key purposes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_KEY_PURPOSE_ENCRYPT | Used to encrypt the plaintext. | +| OH_HUKS_KEY_PURPOSE_DECRYPT | Used to decrypt the cipher text. | +| OH_HUKS_KEY_PURPOSE_SIGN | Used to sign data. | +| OH_HUKS_KEY_PURPOSE_VERIFY | Used to verify the signature. | +| OH_HUKS_KEY_PURPOSE_DERIVE | Used to derive a key. | +| OH_HUKS_KEY_PURPOSE_WRAP | Used for an encrypted export. | +| OH_HUKS_KEY_PURPOSE_UNWRAP | Used for an encrypted import. | +| OH_HUKS_KEY_PURPOSE_MAC | Used to generate a message authentication code (MAC). | +| OH_HUKS_KEY_PURPOSE_AGREE | Used for key agreement. | + + +### OH_Huks_KeySize + + +``` +enum OH_Huks_KeySize +``` +**Description**
+Enumerates the key sizes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_RSA_KEY_SIZE_512 | Rivest-Shamir-Adleman (RSA) key of 512 bits. | +| OH_HUKS_RSA_KEY_SIZE_768 | RSA key of 768 bits. | +| OH_HUKS_RSA_KEY_SIZE_1024 | RSA key of 1024 bits. | +| OH_HUKS_RSA_KEY_SIZE_2048 | RSA key of 2048 bits. | +| OH_HUKS_RSA_KEY_SIZE_3072 | RSA key of 3072 bits. | +| OH_HUKS_RSA_KEY_SIZE_4096 | RSA key of 4096 bits. | +| OH_HUKS_ECC_KEY_SIZE_224 | Elliptic Curve Cryptography (ECC) key of 224 bits. | +| OH_HUKS_ECC_KEY_SIZE_256 | ECC key of 256 bits. | +| OH_HUKS_ECC_KEY_SIZE_384 | ECC key of 384 bits. | +| OH_HUKS_ECC_KEY_SIZE_521 | ECC key of 521 bits. | +| OH_HUKS_AES_KEY_SIZE_128 | Advanced Encryption Standard (AES) key of 128 bits. | +| OH_HUKS_AES_KEY_SIZE_192 | AES key of 192 bits. | +| OH_HUKS_AES_KEY_SIZE_256 | AES key of 256 bits. | +| OH_HUKS_AES_KEY_SIZE_512 | AES key of 512 bits. | +| OH_HUKS_CURVE25519_KEY_SIZE_256 | Curve25519 key of 256 bits. | +| OH_HUKS_DH_KEY_SIZE_2048 | Diffie-Hellman (DH) key of 2048 bits. | +| OH_HUKS_DH_KEY_SIZE_3072 | DH key of 3072 bits. | +| OH_HUKS_DH_KEY_SIZE_4096 | DH key of 4096 bits. | +| OH_HUKS_SM2_KEY_SIZE_256 | ShangMi2 (SM2) key of 256 bits. | +| OH_HUKS_SM4_KEY_SIZE_128 | ShangMi4 (SM4) key of 128 bits. | + + +### OH_Huks_KeyStorageType + + +``` +enum OH_Huks_KeyStorageType +``` +**Description**
+Enumerates the key storage modes. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_STORAGE_TEMP | The key is managed locally. | +| OH_HUKS_STORAGE_PERSISTENT | The key is managed by the HUKS service. | + + +### OH_Huks_SecureSignType + + +``` +enum OH_Huks_SecureSignType +``` +**Description**
+Enumerates the signature types of the keys generated or imported. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_SECURE_SIGN_WITH_AUTHINFO | The signature carries authentication information. This field is specified when a key is generated or imported. When the key is used to sign data, the data will be added with the authentication information and then be signed. | + + +### OH_Huks_Tag + + +``` +enum OH_Huks_Tag +``` +**Description**
+Enumerates the tag values used in parameter sets. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_TAG_ALGORITHM | Tags for key parameters. The value range is 1 to 200. Algorithm. | +| OH_HUKS_TAG_PURPOSE | Key purpose. | +| OH_HUKS_TAG_KEY_SIZE | Key size. | +| OH_HUKS_TAG_DIGEST | Digest algorithm. | +| OH_HUKS_TAG_PADDING | Padding algorithm. | +| OH_HUKS_TAG_BLOCK_MODE | Cipher mode. | +| OH_HUKS_TAG_KEY_TYPE | Key type. | +| OH_HUKS_TAG_ASSOCIATED_DATA | Associated authentication data. | +| OH_HUKS_TAG_NONCE | Field for key encryption and decryption. | +| OH_HUKS_TAG_IV | Initialized vector (IV). | +| OH_HUKS_TAG_INFO | Information generated during key derivation. | +| OH_HUKS_TAG_SALT | Salt value used for key derivation. | +| OH_HUKS_TAG_ITERATION | Number of iterations for key derivation. | +| OH_HUKS_TAG_KEY_GENERATE_TYPE | Type of the generated key. For details, see [OH_Huks_KeyGenerateType](#oh_huks_keygeneratetype). | +| OH_HUKS_TAG_AGREE_ALG | Algorithm used in key agreement. | +| OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS | Alias of the public key used for key agreement. | +| OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS | Alias of the private key used for key agreement. | +| OH_HUKS_TAG_AGREE_PUBLIC_KEY | Public key used for key agreement. | +| OH_HUKS_TAG_KEY_ALIAS | Alias of the key. | +| OH_HUKS_TAG_DERIVE_KEY_SIZE | Size of the derived key. | +| OH_HUKS_TAG_IMPORT_KEY_TYPE | Type of the key to import. For details, see [OH_Huks_ImportKeyType](#oh_huks_importkeytype). | +| OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE | Algorithm suite required for encrypted imports. | +| OH_HUKS_TAG_ALL_USERS | Tags for access control and user authentication. The value range is 301 to 500. All users in the multi-user scenario. | +| OH_HUKS_TAG_USER_ID | Multi-user ID. | +| OH_HUKS_TAG_NO_AUTH_REQUIRED | Specifies whether key access control is required. | +| OH_HUKS_TAG_USER_AUTH_TYPE | User authentication type in key access control. | +| OH_HUKS_TAG_AUTH_TIMEOUT | Timeout duration for key access. | +| OH_HUKS_TAG_AUTH_TOKEN | Authentication token for the key. | +| OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE | Access control type. For details, see [OH_Huks_AuthAccessType](#oh_huks_authaccesstype). This parameter must be set together with the user authentication type. | +| OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE | Signature type for the key to be generated or imported. | +| OH_HUKS_TAG_CHALLENGE_TYPE | Challenge type. For details, see [OH_Huks_ChallengeType](#oh_huks_challengetype). | +| OH_HUKS_TAG_CHALLENGE_POS | Position of the 8-byte valid value in a custom challenge. For details, see [OH_Huks_ChallengePosition](#oh_huks_challengeposition). | +| OH_HUKS_TAG_ATTESTATION_CHALLENGE | Tags for key attestation. The value range is 501 to 600. Challenge value used in the attestation. | +| OH_HUKS_TAG_ATTESTATION_APPLICATION_ID | Application ID used in the attestation. | +| OH_HUKS_TAG_ATTESTATION_ID_ALIAS | Alias of the key. | +| OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO | Security level used in the attestation. | +| OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO | Version information used in the attestation. | +| OH_HUKS_TAG_IS_KEY_ALIAS | 601 to 1000 are reserved for other tags.
Extended tags. The value range is 1001 to 9999. Specifies whether it is a key alias. | +| OH_HUKS_TAG_KEY_STORAGE_FLAG | Key storage mode. For details, see [OH_Huks_KeyStorageType](#oh_huks_keystoragetype). | +| OH_HUKS_TAG_IS_ALLOWED_WRAP | Specifies whether to allow the key to be wrapped. | +| OH_HUKS_TAG_KEY_WRAP_TYPE | Key wrap type. | +| OH_HUKS_TAG_KEY_AUTH_ID | Authentication ID. | +| OH_HUKS_TAG_KEY_ROLE | Role of the key. | +| OH_HUKS_TAG_KEY_FLAG | Key flag. For details, see [OH_Huks_KeyFlag](#oh_huks_keyflag). | +| OH_HUKS_TAG_IS_ASYNCHRONIZED | Specifies whether this API is asynchronous. | +| OH_HUKS_TAG_KEY_DOMAIN | Key domain. | +| OH_HUKS_TAG_SYMMETRIC_KEY_DATA | 11000 to 12000 are reserved.
20001 to N are reserved for other tags. Symmetric key data. | +| OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA | Public key data of the asymmetric key pair. | +| OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA | Private key data of the asymmetric key pair. | + + +### OH_Huks_TagType + + +``` +enum OH_Huks_TagType +``` +**Description**
+Enumerates the tag types. + + **See** + +[OH_Huks_Param](_o_h___huks___param.md) + +| Name | Description | +| -------- | -------- | +| OH_HUKS_TAG_TYPE_INVALID | Invalid tag type. | +| OH_HUKS_TAG_TYPE_INT | int32_t. | +| OH_HUKS_TAG_TYPE_UINT | uin32_t. | +| OH_HUKS_TAG_TYPE_ULONG | uin64_t. | +| OH_HUKS_TAG_TYPE_BOOL | Boolean. | +| OH_HUKS_TAG_TYPE_BYTES | [OH_Huks_Blob](_o_h___huks___blob.md). | + + +### OH_Huks_UserAuthType + + +``` +enum OH_Huks_UserAuthType +``` +**Description**
+Enumerates the user authentication types. + +| Name | Description | +| -------- | -------- | +| OH_HUKS_USER_AUTH_TYPE_FINGERPRINT | Fingerprint authentication. | +| OH_HUKS_USER_AUTH_TYPE_FACE | Facial authentication. | +| OH_HUKS_USER_AUTH_TYPE_PIN | PIN authentication. | diff --git a/en/application-dev/reference/native-apis/_mind_spore.md b/en/application-dev/reference/native-apis/_mind_spore.md new file mode 100644 index 0000000000000000000000000000000000000000..7e546e8f958341e55b9f59cd4123b274c78cc0f1 --- /dev/null +++ b/en/application-dev/reference/native-apis/_mind_spore.md @@ -0,0 +1,1348 @@ +# MindSpore + + +## Overview + +Provides APIs related to MindSpore Lite model inference. + +Copyright 2021 Huawei Technologies Co., Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +\@Syscap SystemCapability.Ai.MindSpore + +**Since:** +9 + +## Summary + + +### Files + +| 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. | + + +### 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**. | + + + +### 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. | + + +### 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. | + + +### 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. | + + +## Macro Description + + +### OH_AI_MAX_SHAPE_NUM + + +``` +#define OH_AI_MAX_SHAPE_NUM 32 +``` +**Description**
+Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. + + +## Type Description + + +### OH_AI_CallBackParam + + +``` +typedef struct OH_AI_CallBackParamOH_AI_CallBackParam +``` +**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. + + +### OH_AI_DataType + + +``` +typedef enum OH_AI_DataTypeOH_AI_DataType +``` +**Description**
+Declares data types supported by MSTensor. + + +### OH_AI_DeviceInfoHandle + + +``` +typedef void* OH_AI_DeviceInfoHandle +``` +**Description**
+Defines the pointer to the MindSpore device information. + + +### OH_AI_DeviceType + + +``` +typedef enum OH_AI_DeviceTypeOH_AI_DeviceType +``` +**Description**
+Defines the supported device types. + + +### OH_AI_Format + + +``` +typedef enum OH_AI_FormatOH_AI_Format +``` +**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**
+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. + + +### OH_AI_ModelHandle + + +``` +typedef void* OH_AI_ModelHandle +``` +**Description**
+Defines the pointer to a model object. + + +### OH_AI_ModelType + + +``` +typedef enum OH_AI_ModelTypeOH_AI_ModelType +``` +**Description**
+Defines model file types. + + +### OH_AI_Status + + +``` +typedef enum OH_AI_StatusOH_AI_Status +``` +**Description**
+Defines MindSpore status codes. + + +### OH_AI_TensorHandle + + +``` +typedef void* OH_AI_TensorHandle +``` +**Description**
+Defines the handle of a tensor object. + + +### OH_AI_TensorHandleArray + + +``` +typedef struct OH_AI_TensorHandleArrayOH_AI_TensorHandleArray +``` +**Description**
+Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. + + +## Enum Description + + +### 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 | + + +### OH_AI_DataType + + +``` +enum OH_AI_DataType +``` +**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 | + + +### OH_AI_DeviceType + + +``` +enum OH_AI_DeviceType +``` +**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 | + + +### OH_AI_Format + + +``` +enum OH_AI_Format +``` +**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 | + + +### OH_AI_ModelType + + +``` +enum OH_AI_ModelType +``` +**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 | + + +### 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 | + + +## 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** + +| 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**
+Creates a context object. + +**Returns** + +[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context. + + +### OH_AI_ContextDestroy() + + +``` +OH_AI_API void OH_AI_ContextDestroy (OH_AI_ContextHandle * context) +``` +**Description**
+Destroys a context object. + + **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. | + + +### OH_AI_ContextGetEnableParallel() + + +``` +OH_AI_API bool OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context) +``` +**Description**
+Checks whether parallelism between operators is supported. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | + +**Returns** + +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_ContextGetThreadAffinityCoreList() + + +``` +OH_AI_API const int32_t* OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t * core_num ) +``` +**Description**
+Obtains the list of bound CPU cores. + + **Parameters** + +| 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. + + +### OH_AI_ContextGetThreadAffinityMode() + + +``` +OH_AI_API int OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context) +``` +**Description**
+Obtains the affinity mode for binding runtime threads to CPU cores. + + **Parameters** + +| 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 + + +### OH_AI_ContextGetThreadNum() + + +``` +OH_AI_API int32_t OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context) +``` +**Description**
+Obtains the number of threads. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | + +**Returns** + +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** + +| 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. | + + +### OH_AI_ContextSetThreadAffinityCoreList() + + +``` +OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t * core_list, size_t core_num ) +``` +**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** + +| 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** + +| 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 | + + +### OH_AI_ContextSetThreadNum() + + +``` +OH_AI_API void OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num ) +``` +**Description**
+Sets the number of runtime threads. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| thread_num | Number of runtime threads. | + + +### OH_AI_DeviceInfoCreate() + + +``` +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type) +``` +**Description**
+Creates a device information object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| device_type | Device type. For details, see [OH_AI_DeviceType](#oh_ai_devicetype). | + +**Returns** + +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to the 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** + +| Name | Description | +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | + + +### 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** + +| Name | Description | +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | + +**Returns** + +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** + +| Name | Description | +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | + +**Returns** + +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** + +| 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 + + +### OH_AI_DeviceInfoGetProvider() + + +``` +OH_AI_API const char* OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info) +``` +**Description**
+Obtains the provider name. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | + +**Returns** + +Provider name. + + +### OH_AI_DeviceInfoGetProviderDevice() + + +``` +OH_AI_API const char* OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info) +``` +**Description**
+Obtains the name of a provider device. + + **Parameters** + +| 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_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** + +| Name | Description | +| -------- | -------- | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| is_fp16 | Whether to enable float16 inference. | + + +### OH_AI_DeviceInfoSetFrequency() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency ) +``` +**Description**
+Sets the NPU frequency type. This function is available only for NPU devices. + + **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_DeviceInfoSetProvider() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char * provider ) +``` +**Description**
+Sets the name of a provider. + + **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**
+Sets the name of a provider device. + + **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_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**
+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** + +| 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). | + +**Returns** + +Status code enumerated by [OH_AI_Status](#oh_ai_status). 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**
+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** + +| 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). | + +**Returns** + +Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. + + +### OH_AI_ModelCreate() + + +``` +OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate () +``` +**Description**
+Creates a model object. + +**Returns** + +Pointer to the model object. + + +### OH_AI_ModelDestroy() + + +``` +OH_AI_API void OH_AI_ModelDestroy (OH_AI_ModelHandle * model) +``` +**Description**
+Destroys a model object. + + **Parameters** + +| 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**
+Obtains the input tensor of a model by tensor name. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the model object. | +| tensor_name | Tensor name. | + +**Returns** + +Pointer to the input tensor indicated by **tensor_name**. If the tensor does not exist in the input, **null** will be returned. + + +### OH_AI_ModelGetInputs() + + +``` +OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs (const OH_AI_ModelHandle model) +``` +**Description**
+Obtains the input tensor array structure of a model. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the model object. | + +**Returns** + +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**
+Obtains the output tensor of a model by tensor name. + + **Parameters** + +| 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. + + +### OH_AI_ModelGetOutputs() + + +``` +OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs (const OH_AI_ModelHandle model) +``` +**Description**
+Obtains the output tensor array structure of a model. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the model object. | + +**Returns** + +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**
+Performs model inference. + + **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. | + +**Returns** + +Status code enumerated by [OH_AI_Status](#oh_ai_status). 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**
+Adjusts the input tensor shapes of a built model. + + **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. | + +**Returns** + +Status code enumerated by [OH_AI_Status](#oh_ai_status). 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**
+Clones a tensor. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Pointer to the tensor to clone. | + +**Returns** + +Handle of the new 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**
+Creates a tensor object. + + **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. | + +**Returns** + +Handle of the tensor object. + + +### OH_AI_TensorDestroy() + + +``` +OH_AI_API void OH_AI_TensorDestroy (OH_AI_TensorHandle * tensor) +``` +**Description**
+Destroys a tensor object. + + **Parameters** + +| 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**
+Obtains the pointer to tensor data. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +Pointer to tensor data. + + +### OH_AI_TensorGetDataSize() + + +``` +OH_AI_API size_t OH_AI_TensorGetDataSize (const OH_AI_TensorHandle tensor) +``` +**Description**
+Obtains the number of bytes of the tensor data. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +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** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +Data type of the tensor. + + +### OH_AI_TensorGetElementNum() + + +``` +OH_AI_API int64_t OH_AI_TensorGetElementNum (const OH_AI_TensorHandle tensor) +``` +**Description**
+Obtains the number of tensor elements. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +Number of tensor elements. + + +### OH_AI_TensorGetFormat() + + +``` +OH_AI_API OH_AI_Format OH_AI_TensorGetFormat (const OH_AI_TensorHandle tensor) +``` +**Description**
+Obtains the tensor data format. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +Tensor data format. + + +### OH_AI_TensorGetMutableData() + + +``` +OH_AI_API void* OH_AI_TensorGetMutableData (const OH_AI_TensorHandle tensor) +``` +**Description**
+Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +Pointer to variable tensor data. + + +### OH_AI_TensorGetName() + + +``` +OH_AI_API const char* OH_AI_TensorGetName (const OH_AI_TensorHandle tensor) +``` +**Description**
+Obtains the name of a tensor. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | + +**Returns** + +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** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | +| shape_num | Length of the tensor shape array. | + +**Returns** + +Tensor shape array. + + +### OH_AI_TensorSetData() + + +``` +OH_AI_API void OH_AI_TensorSetData (OH_AI_TensorHandle tensor, void * data ) +``` +**Description**
+Sets the tensor data. + + **Parameters** + +| 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** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | +| type | Data type. For details, see [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**
+Sets the tensor data format. + + **Parameters** + +| 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 ) +``` +**Description**
+Sets the name of a tensor. + + **Parameters** + +| 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** + +| Name | Description | +| -------- | -------- | +| tensor | Handle of the tensor object. | +| shape | Tensor shape array. | +| shape_num | Length of the tensor shape array. | diff --git a/en/application-dev/reference/native-apis/_native_window.md b/en/application-dev/reference/native-apis/_native_window.md new file mode 100644 index 0000000000000000000000000000000000000000..7a6f7d6f1cf6f344106543e35a5b01e2f7185521 --- /dev/null +++ b/en/application-dev/reference/native-apis/_native_window.md @@ -0,0 +1,512 @@ +# NativeWindow + + +## Overview + +Provides the native window capability for connection to the EGL. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + +**Since:** +8 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [external_window.h](external__window_8h.md) | Defines the functions for obtaining and using a native window.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [Region](_region.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | +| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Defines the HDR metadata. | +| [OHExtDataHandle](_o_h_ext_data_handle.md) | Defines the extended data handle. | + + +### Types + +| Name | Description | +| -------- | -------- | +| OHNativeWindow | Provides the function of accessing the **NativeWindow**. | +| OHNativeWindowBuffer | Provides the function of accessing the **NativeWindowBuffer**. | +| Region | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [NativeWindowOperation](#nativewindowoperation) {
SET_BUFFER_GEOMETRY, GET_BUFFER_GEOMETRY, GET_FORMAT, SET_FORMAT,
GET_USAGE, SET_USAGE, SET_STRIDE, GET_STRIDE,
SET_SWAP_INTERVAL, GET_SWAP_INTERVAL, SET_TIMEOUT, GET_TIMEOUT,
SET_COLOR_GAMUT, GET_COLOR_GAMUT, SET_TRANSFORM, GET_TRANSFORM,
SET_UI_TIMESTAMP
} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. | +| [OHScalingMode](#ohscalingmode) { OH_SCALING_MODE_FREEZE = 0, OH_SCALING_MODE_SCALE_TO_WINDOW, OH_SCALING_MODE_SCALE_CROP, OH_SCALING_MODE_NO_SCALE_CROP } | Enumerates the scaling modes. | +| [OHHDRMetadataKey](#ohhdrmetadatakey) {
OH_METAKEY_RED_PRIMARY_X = 0, OH_METAKEY_RED_PRIMARY_Y = 1, OH_METAKEY_GREEN_PRIMARY_X = 2, OH_METAKEY_GREEN_PRIMARY_Y = 3,
OH_METAKEY_BLUE_PRIMARY_X = 4, OH_METAKEY_BLUE_PRIMARY_Y = 5, OH_METAKEY_WHITE_PRIMARY_X = 6, OH_METAKEY_WHITE_PRIMARY_Y = 7,
OH_METAKEY_MAX_LUMINANCE = 8, OH_METAKEY_MIN_LUMINANCE = 9, OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
OH_METAKEY_HDR10_PLUS = 12, OH_METAKEY_HDR_VIVID = 13
} | Enumerates the HDR metadata keys. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NativeWindow_CreateNativeWindow](#oh_nativewindow_createnativewindow) (void \*pSurface) | Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. | +| [OH_NativeWindow_DestroyNativeWindow](#oh_nativewindow_destroynativewindow) (OHNativeWindow \*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. | +| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. | +| [OH_NativeWindow_DestroyNativeWindowBuffer](#oh_nativewindow_destroynativewindowbuffer) (OHNativeWindowBuffer \*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. | +| [OH_NativeWindow_NativeWindowRequestBuffer](#oh_nativewindow_nativewindowrequestbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. | +| [OH_NativeWindow_NativeWindowFlushBuffer](#oh_nativewindow_nativewindowflushbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. | +| [OH_NativeWindow_NativeWindowAbortBuffer](#oh_nativewindow_nativewindowabortbuffer) (OHNativeWindow \*window, OHNativeWindowBuffer \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. | +| [OH_NativeWindow_NativeWindowHandleOpt](#oh_nativewindow_nativewindowhandleopt) (OHNativeWindow \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format. | +| [OH_NativeWindow_GetBufferHandleFromNative](#oh_nativewindow_getbufferhandlefromnative) (OHNativeWindowBuffer \*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. | +| [OH_NativeWindow_NativeObjectReference](#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object. | +| [OH_NativeWindow_NativeObjectUnreference](#oh_nativewindow_nativeobjectunreference) (void \*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. | +| [OH_NativeWindow_GetNativeObjectMagic](#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object. | +| [OH_NativeWindow_NativeWindowSetScalingMode](#oh_nativewindow_nativewindowsetscalingmode) (OHNativeWindow \*window, uint32_t sequence, [OHScalingMode](#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. | +| [OH_NativeWindow_NativeWindowSetMetaData](#oh_nativewindow_nativewindowsetmetadata) (OHNativeWindow \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | Sets the metadata for a native window. | +| [OH_NativeWindow_NativeWindowSetMetaDataSet](#oh_nativewindow_nativewindowsetmetadataset) (OHNativeWindow \*window, uint32_t sequence, [OHHDRMetadataKey](#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. | +| [OH_NativeWindow_NativeWindowSetTunnelHandle](#oh_nativewindow_nativewindowsettunnelhandle) (OHNativeWindow \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | Sets a tunnel handle for a native window. | + + +## Enum Description + + +### NativeWindowOperation + + +``` +enum NativeWindowOperation +``` +**Description**
+Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. + +| Name | Description | +| -------- | -------- | +| SET_BUFFER_GEOMETRY | Setting the geometry for the local window buffer. Variable arguments in the function: [Input] int32_t height and [Input] int32_t width. | +| GET_BUFFER_GEOMETRY | Obtaining the geometry of the local window buffer. Variable arguments in the function: [Output] int32_t \*height and [Output] int32_t \*width. | +| GET_FORMAT | Obtaining the format of the local window buffer. Variable argument in the function: [Output] int32_t \*format. | +| SET_FORMAT | Setting the format for the local window buffer. Variable argument in the function: [Input] int32_t format. | +| GET_USAGE | Obtaining the usage mode of the local window buffer. Variable argument in the function: [Output] int32_t \*usage. | +| SET_USAGE | Setting the usage mode for the local window buffer. Variable argument in the function: [Input] int32_t usage. | +| SET_STRIDE | Setting the stride for the local window buffer. Variable argument in the function: [Input] int32_t stride. | +| GET_STRIDE | Obtaining the stride of the local window buffer. Variable argument in the function: [Output] int32_t \*stride. | +| SET_SWAP_INTERVAL | Setting the swap interval for the local window buffer. Variable argument in the function: [Input] int32_t interval. | +| GET_SWAP_INTERVAL | Obtaining the swap interval of the local window buffer. Variable argument in the function: [Output] int32_t \*interval. | +| SET_TIMEOUT | Setting the timeout duration for requesting the local window buffer. Variable argument in the function: [Input] int32_t timeout. | +| GET_TIMEOUT | Obtaining the timeout duration for requesting the local window buffer. Variable argument in the function: [Output] int32_t \*timeout. | +| SET_COLOR_GAMUT | Setting the color gamut for the local window buffer. Variable argument in the function: [Input] int32_t colorGamut. | +| GET_COLOR_GAMUT | Obtaining the color gamut of the local window buffer. Variable argument in the function: [out int32_t \*colorGamut]. | +| SET_TRANSFORM | Setting the transform for the local window buffer. Variable argument in the function: [Input] int32_t transform. | +| GET_TRANSFORM | Obtaining the transform of the local window buffer. Variable argument in the function: [Output] int32_t \*transform. | +| SET_UI_TIMESTAMP | Setting the UI timestamp for the local window buffer. Variable argument in the function: [Input] uint64_t uiTimestamp. | + + +### OHHDRMetadataKey + + +``` +enum OHHDRMetadataKey +``` +**Description**
+Enumerates the HDR metadata keys. + +| Name | Description | +| -------- | -------- | +| OH_METAKEY_RED_PRIMARY_X | X coordinate of the red primary color. | +| OH_METAKEY_RED_PRIMARY_Y | Y coordinate of the red primary color. | +| OH_METAKEY_GREEN_PRIMARY_X | X coordinate of the green primary color. | +| OH_METAKEY_GREEN_PRIMARY_Y | Y coordinate of the green primary color. | +| OH_METAKEY_BLUE_PRIMARY_X | X coordinate of the blue primary color. | +| OH_METAKEY_BLUE_PRIMARY_Y | Y coordinate of the blue primary color. | +| OH_METAKEY_WHITE_PRIMARY_X | X coordinate of the white point. | +| OH_METAKEY_WHITE_PRIMARY_Y | Y coordinate of the white point. | +| OH_METAKEY_MAX_LUMINANCE | Maximum luminance. | +| OH_METAKEY_MIN_LUMINANCE | Minimum luminance. | +| OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL | Maximum content light level (MaxCLL). | +| OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL | Maximum frame average light level (MaxFALLL). | +| OH_METAKEY_HDR10_PLUS | HDR10+. | +| OH_METAKEY_HDR_VIVID | Vivid. | + + +### OHScalingMode + + +``` +enum OHScalingMode +``` +**Description**
+Enumerates the scaling modes. + +| Name | Description | +| -------- | -------- | +| OH_SCALING_MODE_FREEZE | The window content cannot be updated before the buffer of the window size is received. | +| OH_SCALING_MODE_SCALE_TO_WINDOW | The buffer is scaled in two dimensions to match the window size. | +| OH_SCALING_MODE_SCALE_CROP | The buffer is scaled uniformly so that its smaller size can match the window size. | +| OH_SCALING_MODE_NO_SCALE_CROP | The window is cropped to the size of the buffer's cropping rectangle. Pixels outside the cropping rectangle are considered completely transparent. | + + +## Function Description + + +### OH_NativeWindow_CreateNativeWindow() + + +``` +OHNativeWindow* OH_NativeWindow_CreateNativeWindow (void * pSurface) +``` +**Description**
+Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| pSurface | Indicates the pointer to a **ProduceSurface**. The type is **sptr<OHOS::Surface>**. | + +**Returns** + +Returns the pointer to the **NativeWindow** instance created. + + +### OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer() + + +``` +OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer (void * pSurfaceBuffer) +``` +**Description**
+Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| pSurfaceBuffer | Indicates the pointer to a produce buffer. The type is **sptr<OHOS::SurfaceBuffer>**. | + +**Returns** + +Returns the pointer to the **NativeWindowBuffer** instance created. + + +### OH_NativeWindow_DestroyNativeWindow() + + +``` +void OH_NativeWindow_DestroyNativeWindow (OHNativeWindow * window) +``` +**Description**
+Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | + + +### OH_NativeWindow_DestroyNativeWindowBuffer() + + +``` +void OH_NativeWindow_DestroyNativeWindowBuffer (OHNativeWindowBuffer * buffer) +``` +**Description**
+Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | + + +### OH_NativeWindow_GetBufferHandleFromNative() + + +``` +BufferHandle* OH_NativeWindow_GetBufferHandleFromNative (OHNativeWindowBuffer * buffer) +``` +**Description**
+Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | + +**Returns** + +Returns the pointer to the **BufferHandle** instance obtained. + + +### OH_NativeWindow_GetNativeObjectMagic() + + +``` +int32_t OH_NativeWindow_GetNativeObjectMagic (void * obj) +``` +**Description**
+Obtains the magic ID of a native object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | + +**Returns** + +Returns the magic ID, which is unique for each native object. + + +### OH_NativeWindow_NativeObjectReference() + + +``` +int32_t OH_NativeWindow_NativeObjectReference (void * obj) +``` +**Description**
+Adds the reference count of a native object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeObjectUnreference() + + +``` +int32_t OH_NativeWindow_NativeObjectUnreference (void * obj) +``` +**Description**
+Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| obj | Indicates the pointer to a **NativeWindow** or **NativeWindowBuffer** instance. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowAbortBuffer() + + +``` +int32_t OH_NativeWindow_NativeWindowAbortBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer ) +``` +**Description**
+Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowFlushBuffer() + + +``` +int32_t OH_NativeWindow_NativeWindowFlushBuffer (OHNativeWindow * window, OHNativeWindowBuffer * buffer, int fenceFd, Region region ) +``` +**Description**
+Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| buffer | Indicates the pointer to a **NativeWindowBuffer** instance. | +| fenceFd | Indicates a file descriptor handle, which is used for timing synchronization. | +| region | Indicates a dirty region where content is updated. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowHandleOpt() + + +``` +int32_t OH_NativeWindow_NativeWindowHandleOpt (OHNativeWindow * window, int code, ... ) +``` +**Description**
+Sets or obtains the attributes of a native window, including the width, height, and content format. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| code | Indicates the operation code. For details, see [NativeWindowOperation](#nativewindowoperation). | +| ... | Indicates the variable argument, which must correspond to the operation code. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowRequestBuffer() + + +``` +int32_t OH_NativeWindow_NativeWindowRequestBuffer (OHNativeWindow * window, OHNativeWindowBuffer ** buffer, int * fenceFd ) +``` +**Description**
+Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| buffer | Indicates the double pointer to a **NativeWindowBuffer** instance. | +| fenceFd | Indicates the pointer to a file descriptor handle. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowSetMetaData() + + +``` +int32_t OH_NativeWindow_NativeWindowSetMetaData (OHNativeWindow * window, uint32_t sequence, int32_t size, const OHHDRMetaData * metaData ) +``` +**Description**
+Sets the metadata for a native window. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| sequence | Indicates the sequence of the producer buffer. | +| size | Indicates the size of the **[OHHDRMetaData](_o_h_h_d_r_meta_data.md)** array. | +| metaData | Indicates the pointer to the **[OHHDRMetaData](_o_h_h_d_r_meta_data.md)** array. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowSetMetaDataSet() + + +``` +int32_t OH_NativeWindow_NativeWindowSetMetaDataSet (OHNativeWindow * window, uint32_t sequence, OHHDRMetadataKey key, int32_t size, const uint8_t * metaData ) +``` +**Description**
+Sets the metadata set for a native window. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| sequence | Indicates the sequence of the producer buffer. | +| key | Indicates a metadata key. For details, see **OHHDRMetadataKey**. | +| size | Indicates the size of the uint8_t vector. | +| metaData | Indicates the pointer to the uint8_t vector. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowSetScalingMode() + + +``` +int32_t OH_NativeWindow_NativeWindowSetScalingMode (OHNativeWindow * window, uint32_t sequence, OHScalingMode scalingMode ) +``` +**Description**
+Sets the scaling mode for a native window. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| sequence | Indicates the sequence of the producer buffer. | +| scalingMode | Indicates the scaling mode to set. For details, see **OHScalingMode**. | + +**Returns** + +Returns an error code defined in **GSError**. + + +### OH_NativeWindow_NativeWindowSetTunnelHandle() + + +``` +int32_t OH_NativeWindow_NativeWindowSetTunnelHandle (OHNativeWindow * window, const OHExtDataHandle * handle ) +``` +**Description**
+Sets a tunnel handle for a native window. + +\@syscap SystemCapability.Graphic.Graphic2D.NativeWindow + + **Parameters** + +| Name | Description | +| -------- | -------- | +| window | Indicates the pointer to a **NativeWindow** instance. | +| handle | Indicates the pointer to an **[OHExtDataHandle](_o_h_ext_data_handle.md)**. | + +**Returns** + +Returns an error code defined in **GSError**. diff --git a/en/application-dev/reference/native-apis/_neural_nework_runtime.md b/en/application-dev/reference/native-apis/_neural_nework_runtime.md new file mode 100644 index 0000000000000000000000000000000000000000..01aa5d9299323f61be63179703d6bb3d279c034d --- /dev/null +++ b/en/application-dev/reference/native-apis/_neural_nework_runtime.md @@ -0,0 +1,1266 @@ +# NeuralNeworkRuntime + + +## Overview + +Provides APIs of Neural Network Runtime for accelerating the model inference. + +Provides APIs for accelerating the Neural Network Runtime model inference. + +\@Syscap SystemCapability.Ai.NeuralNetworkRuntime + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [neural_network_runtime.h](neural__network__runtime_8h.md) | Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime to construct and compile models and perform inference and computing on acceleration hardware. Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling.
File to Include: | +| [neural_network_runtime_type.h](neural__network__runtime__type_8h.md) | Defines the structure and enumeration for Neural Network Runtime.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) | This structure is used to store a 32-bit unsigned integer array. | +| [OH_NN_QuantParam](_o_h___n_n___quant_param.md) | Quantization information. | +| [OH_NN_Tensor](_o_h___n_n___tensor.md) | Defines the tensor structure. | +| [OH_NN_Memory](_o_h___n_n___memory.md) | Defines the memory structure. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_NNModel](#oh_nnmodel) | Defines the handles of models for Neural Network Runtime. | +| [OH_NNCompilation](#oh_nncompilation) | Defines the compiler handle for Neural Network Runtime. | +| [OH_NNExecutor](#oh_nnexecutor) | Defines the executor handle for Neural Network Runtime. | +| [OH_NN_UInt32Array](#oh_nn_uint32array) | This structure is used to store a 32-bit unsigned integer array. | +| [OH_NN_QuantParam](#oh_nn_quantparam) | Quantization information. | +| [OH_NN_Tensor](#oh_nn_tensor) | Defines the tensor structure. | +| [OH_NN_Memory](#oh_nn_memory) | Defines the memory structure. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_NN_PerformanceMode](#oh_nn_performancemode) {
OH_NN_PERFORMANCE_NONE = 0, OH_NN_PERFORMANCE_LOW = 1, OH_NN_PERFORMANCE_MEDIUM = 2, OH_NN_PERFORMANCE_HIGH = 3,
OH_NN_PERFORMANCE_EXTREME = 4
} | Defines the hardware performance mode. | +| [OH_NN_Priority](#oh_nn_priority) { OH_NN_PRIORITY_NONE = 0, OH_NN_PRIORITY_LOW = 1, OH_NN_PRIORITY_MEDIUM = 2, OH_NN_PRIORITY_HIGH = 3 } | Defines the model inference task priority. | +| [OH_NN_ReturnCode](#oh_nn_returncode) {
OH_NN_SUCCESS = 0, OH_NN_FAILED = 1, OH_NN_INVALID_PARAMETER = 2, OH_NN_MEMORY_ERROR = 3,
OH_NN_OPERATION_FORBIDDEN = 4, OH_NN_NULL_PTR = 5, OH_NN_INVALID_FILE = 6, OH_NN_UNAVALIDABLE_DEVICE = 7,
OH_NN_INVALID_PATH = 8
} | Defines error codes for Neural Network Runtime. | +| [OH_NN_FuseType](#oh_nn_fusetype) : int8_t { OH_NN_FUSED_NONE = 0, OH_NN_FUSED_RELU = 1, OH_NN_FUSED_RELU6 = 2 } | Defines activation function types in the fusion operator for Neural Network Runtime. | +| [OH_NN_Format](#oh_nn_format) { OH_NN_FORMAT_NONE = 0, OH_NN_FORMAT_NCHW = 1, OH_NN_FORMAT_NHWC = 2 } | Defines the layout type of tensor data. | +| [OH_NN_DeviceType](#oh_nn_devicetype) { OH_NN_OTHERS = 0, OH_NN_CPU = 1, OH_NN_GPU = 2, OH_NN_ACCELERATOR = 3 } | Defines device types supported by Neural Network Runtime. | +| [OH_NN_DataType](#oh_nn_datatype) {
OH_NN_UNKNOWN = 0, OH_NN_BOOL = 1, OH_NN_INT8 = 2, OH_NN_INT16 = 3,
OH_NN_INT32 = 4, OH_NN_INT64 = 5, OH_NN_UINT8 = 6, OH_NN_UINT16 = 7,
OH_NN_UINT32 = 8, OH_NN_UINT64 = 9, OH_NN_FLOAT16 = 10, OH_NN_FLOAT32 = 11,
OH_NN_FLOAT64 = 12
} | Defines tensor data types supported by Neural Network Runtime. | +| [OH_NN_OperationType](#oh_nn_operationtype) {
OH_NN_OPS_ADD = 1, OH_NN_OPS_AVG_POOL = 2, OH_NN_OPS_BATCH_NORM = 3, OH_NN_OPS_BATCH_TO_SPACE_ND = 4,
OH_NN_OPS_BIAS_ADD = 5, OH_NN_OPS_CAST = 6, OH_NN_OPS_CONCAT = 7, OH_NN_OPS_CONV2D = 8,
OH_NN_OPS_CONV2D_TRANSPOSE = 9, OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, OH_NN_OPS_DIV = 11, OH_NN_OPS_ELTWISE = 12,
OH_NN_OPS_EXPAND_DIMS = 13, OH_NN_OPS_FILL = 14, OH_NN_OPS_FULL_CONNECTION = 15, OH_NN_OPS_GATHER = 16,
OH_NN_OPS_HSWISH = 17, OH_NN_OPS_LESS_EQUAL = 18, OH_NN_OPS_MATMUL = 19, OH_NN_OPS_MAXIMUM = 20,
OH_NN_OPS_MAX_POOL = 21, OH_NN_OPS_MUL = 22, OH_NN_OPS_ONE_HOT = 23, OH_NN_OPS_PAD = 24,
OH_NN_OPS_POW = 25, OH_NN_OPS_SCALE = 26, OH_NN_OPS_SHAPE = 27, OH_NN_OPS_SIGMOID = 28,
OH_NN_OPS_SLICE = 29, OH_NN_OPS_SOFTMAX = 30, OH_NN_OPS_SPACE_TO_BATCH_ND = 31, OH_NN_OPS_SPLIT = 32,
OH_NN_OPS_SQRT = 33, OH_NN_OPS_SQUARED_DIFFERENCE = 34, OH_NN_OPS_SQUEEZE = 35, OH_NN_OPS_STACK = 36,
OH_NN_OPS_STRIDED_SLICE = 37, OH_NN_OPS_SUB = 38, OH_NN_OPS_TANH = 39, OH_NN_OPS_TILE = 40,
OH_NN_OPS_TRANSPOSE = 41, OH_NN_OPS_REDUCE_MEAN = 42, OH_NN_OPS_RESIZE_BILINEAR = 43, OH_NN_OPS_RSQRT = 44,
OH_NN_OPS_RESHAPE = 45, OH_NN_OPS_PRELU = 46, OH_NN_OPS_RELU = 47, OH_NN_OPS_RELU6 = 48,
OH_NN_OPS_LAYER_NORM = 49, OH_NN_OPS_REDUCE_PROD = 50, OH_NN_OPS_REDUCE_ALL = 51, OH_NN_OPS_QUANT_DTYPE_CAST = 52,
OH_NN_OPS_TOP_K = 53, OH_NN_OPS_ARG_MAX = 54, OH_NN_OPS_UNSQUEEZE = 55, OH_NN_OPS_GELU = 56
} | Defines operator types supported by Neural Network Runtime. | +| [OH_NN_TensorType](#oh_nn_tensortype) {
OH_NN_TENSOR = 0, OH_NN_ADD_ACTIVATIONTYPE = 1, OH_NN_AVG_POOL_KERNEL_SIZE = 2, OH_NN_AVG_POOL_STRIDE = 3,
OH_NN_AVG_POOL_PAD_MODE = 4, OH_NN_AVG_POOL_PAD = 5, OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, OH_NN_BATCH_NORM_EPSILON = 7,
OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, OH_NN_CONCAT_AXIS = 10, OH_NN_CONV2D_STRIDES = 11,
OH_NN_CONV2D_PAD = 12, OH_NN_CONV2D_DILATION = 13, OH_NN_CONV2D_PAD_MODE = 14, OH_NN_CONV2D_ACTIVATION_TYPE = 15,
OH_NN_CONV2D_GROUP = 16, OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, OH_NN_CONV2D_TRANSPOSE_PAD = 18, OH_NN_CONV2D_TRANSPOSE_DILATION = 19,
OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, OH_NN_CONV2D_TRANSPOSE_GROUP = 23,
OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27,
OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, OH_NN_DIV_ACTIVATIONTYPE = 29, OH_NN_ELTWISE_MODE = 30, OH_NN_FULL_CONNECTION_AXIS = 31,
OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, OH_NN_MATMUL_TRANSPOSE_A = 33, OH_NN_MATMUL_TRANSPOSE_B = 34, OH_NN_MATMUL_ACTIVATION_TYPE = 35,
OH_NN_MAX_POOL_KERNEL_SIZE = 36, OH_NN_MAX_POOL_STRIDE = 37, OH_NN_MAX_POOL_PAD_MODE = 38, OH_NN_MAX_POOL_PAD = 39,
OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, OH_NN_MUL_ACTIVATION_TYPE = 41, OH_NN_ONE_HOT_AXIS = 42, OH_NN_PAD_CONSTANT_VALUE = 43,
OH_NN_SCALE_ACTIVATIONTYPE = 44, OH_NN_SCALE_AXIS = 45, OH_NN_SOFTMAX_AXIS = 46, OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47,
OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, OH_NN_SPLIT_AXIS = 49, OH_NN_SPLIT_OUTPUT_NUM = 50, OH_NN_SPLIT_SIZE_SPLITS = 51,
OH_NN_SQUEEZE_AXIS = 52, OH_NN_STACK_AXIS = 53, OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, OH_NN_STRIDED_SLICE_END_MASK = 55,
OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, OH_NN_SUB_ACTIVATIONTYPE = 59,
OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63,
OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, OH_NN_LAYER_NORM_EPSILON = 67,
OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, OH_NN_REDUCE_PROD_KEEP_DIMS = 70, OH_NN_REDUCE_ALL_KEEP_DIMS = 71,
OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, OH_NN_QUANT_DTYPE_CAST_DST_T = 73, OH_NN_TOP_K_SORTED = 74, OH_NN_ARG_MAX_AXIS = 75,
OH_NN_ARG_MAX_KEEPDIMS = 76, OH_NN_UNSQUEEZE_AXIS = 77
} | Enumerates the tensor data types. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NNModel_Construct](#oh_nnmodel_construct) (void) | Creates a model instance of the [OH_NNModel](#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance. | +| [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) ([OH_NNModel](#oh_nnmodel) \*model, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor) | Adds a tensor to a model instance. | +| [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata) ([OH_NNModel](#oh_nnmodel) \*model, uint32_t index, const void \*dataBuffer, size_t length) | Sets the tensor value. | +| [OH_NNModel_AddOperation](#oh_nnmodel_addoperation) ([OH_NNModel](#oh_nnmodel) \*model, [OH_NN_OperationType](#oh_nn_operationtype) op, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*paramIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*outputIndices) | Adds an operator to a model instance. | +| [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) ([OH_NNModel](#oh_nnmodel) \*model, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*outputIndices) | Specifies the inputs and outputs of a model. | +| [OH_NNModel_Finish](#oh_nnmodel_finish) ([OH_NNModel](#oh_nnmodel) \*model) | Completes model composition. | +| [OH_NNModel_Destroy](#oh_nnmodel_destroy) ([OH_NNModel](#oh_nnmodel) \*\*model) | Releases a model instance. | +| [OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations) ([OH_NNModel](#oh_nnmodel) \*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. | +| [OH_NNCompilation_Construct](#oh_nncompilation_construct) (const [OH_NNModel](#oh_nnmodel) \*model) | Creates a compilation instance of the [OH_NNCompilation](#oh_nncompilation) type. | +| [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice) ([OH_NNCompilation](#oh_nncompilation) \*compilation, size_t deviceID) | Specifies the device for model compilation and computing. | +| [OH_NNCompilation_SetCache](#oh_nncompilation_setcache) ([OH_NNCompilation](#oh_nncompilation) \*compilation, const char \*cachePath, uint32_t version) | Set the cache directory and version of the compiled model. | +| [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode) ([OH_NNCompilation](#oh_nncompilation) \*compilation, [OH_NN_PerformanceMode](#oh_nn_performancemode) performanceMode) | Sets the performance mode for model computing. | +| [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority) ([OH_NNCompilation](#oh_nncompilation) \*compilation, [OH_NN_Priority](#oh_nn_priority) priority) | Sets the model computing priority. | +| [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) ([OH_NNCompilation](#oh_nncompilation) \*compilation, bool enableFloat16) | Enables float16 for computing. | +| [OH_NNCompilation_Build](#oh_nncompilation_build) ([OH_NNCompilation](#oh_nncompilation) \*compilation) | Compiles a model. | +| [OH_NNCompilation_Destroy](#oh_nncompilation_destroy) ([OH_NNCompilation](#oh_nncompilation) \*\*compilation) | Releases the **Compilation** object. | +| [OH_NNExecutor_Construct](#oh_nnexecutor_construct) ([OH_NNCompilation](#oh_nncompilation) \*compilation) | [OH_NNExecutor](#oh_nnexecutor) \*
Creates an executor instance of the [OH_NNExecutor](#oh_nnexecutor) type. | +| [OH_NNExecutor_SetInput](#oh_nnexecutor_setinput) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor, const void \*dataBuffer, size_t length) | Sets the single input data for a model. | +| [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | Sets the buffer for a single output of a model. | +| [OH_NNExecutor_GetOutputShape](#oh_nnexecutor_getoutputshape) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | Obtains the dimension information about the output tensor. | +| [OH_NNExecutor_Run](#oh_nnexecutor_run) ([OH_NNExecutor](#oh_nnexecutor) \*executor) | Performs inference. | +| [OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t inputIndex, size_t length) | Allocates shared memory to a single input on a device. | +| [OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t outputIndex, size_t length) | Allocates shared memory to a single output on a device. | +| [OH_NNExecutor_DestroyInputMemory](#oh_nnexecutor_destroyinputmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t inputIndex, [OH_NN_Memory](_o_h___n_n___memory.md) \*\*memory) | Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. | +| [OH_NNExecutor_DestroyOutputMemory](#oh_nnexecutor_destroyoutputmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t outputIndex, [OH_NN_Memory](_o_h___n_n___memory.md) \*\*memory) | Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. | +| [OH_NNExecutor_SetInputWithMemory](#oh_nnexecutor_setinputwithmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor, const [OH_NN_Memory](_o_h___n_n___memory.md) \*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input. | +| [OH_NNExecutor_SetOutputWithMemory](#oh_nnexecutor_setoutputwithmemory) ([OH_NNExecutor](#oh_nnexecutor) \*executor, uint32_t outputIndex, const [OH_NN_Memory](_o_h___n_n___memory.md) \*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output. | +| [OH_NNExecutor_Destroy](#oh_nnexecutor_destroy) ([OH_NNExecutor](#oh_nnexecutor) \*\*executor) | Destroys an executor instance to release the memory occupied by the executor. | +| [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid) (const size_t \*\*allDevicesID, uint32_t \*deviceCount) | Obtains the ID of the device connected to Neural Network Runtime. | +| [OH_NNDevice_GetName](#oh_nndevice_getname) (size_t deviceID, const char \*\*name) | Obtains the name of the specified device. | +| [OH_NNDevice_GetType](#oh_nndevice_gettype) (size_t deviceID, [OH_NN_DeviceType](#oh_nn_devicetype) \*deviceType) | Obtains the type information of the specified device. | + + +## Type Description + + +### OH_NN_Memory + + +``` +typedef struct OH_NN_MemoryOH_NN_Memory +``` +**Description**
+Defines the memory structure. + + +### OH_NN_QuantParam + + +``` +typedef struct OH_NN_QuantParamOH_NN_QuantParam +``` +**Description**
+Quantization information. + +In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula: + +s and z are quantization parameters, which are stored by **scale** and **zeroPoint** in [OH_NN_QuantParam](_o_h___n_n___quant_param.md). r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and q_max is an upper bound of a quantization result. The calculation method is as follows: + +The clamp function is defined as follows: + + +### OH_NN_Tensor + + +``` +typedef struct OH_NN_TensorOH_NN_Tensor +``` +**Description**
+Defines the tensor structure. + +It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, you need to specify the data type, number of dimensions, dimension information, and quantization information. + + +### OH_NN_UInt32Array + + +``` +typedef struct OH_NN_UInt32ArrayOH_NN_UInt32Array +``` +**Description**
+This structure is used to store a 32-bit unsigned integer array. + + +### OH_NNCompilation + + +``` +typedef struct OH_NNCompilationOH_NNCompilation +``` +**Description**
+Defines the compiler handle for Neural Network Runtime. + + +### OH_NNExecutor + + +``` +typedef struct OH_NNExecutorOH_NNExecutor +``` +**Description**
+Defines the executor handle for Neural Network Runtime. + + +### OH_NNModel + + +``` +typedef struct OH_NNModelOH_NNModel +``` +**Description**
+Defines the handles of models for Neural Network Runtime. + + +## Enum Description + + +### OH_NN_DataType + + +``` +enum OH_NN_DataType +``` +**Description**
+Defines tensor data types supported by Neural Network Runtime. + +| Name | Description | +| -------- | -------- | +| OH_NN_UNKNOWN | Unknown type | +| OH_NN_BOOL | bool | +| OH_NN_INT8 | int8 | +| OH_NN_INT16 | int16 | +| OH_NN_INT32 | int32 | +| OH_NN_INT64 | int64 | +| OH_NN_UINT8 | uint8 | +| OH_NN_UINT16 | uint16 | +| OH_NN_UINT32 | uint32 | +| OH_NN_UINT64 | uint64 | +| OH_NN_FLOAT16 | float16 | +| OH_NN_FLOAT32 | float32 | +| OH_NN_FLOAT64 | float64 | + + +### OH_NN_DeviceType + + +``` +enum OH_NN_DeviceType +``` +**Description**
+Defines device types supported by Neural Network Runtime. + +| Name | Description | +| -------- | -------- | +| OH_NN_OTHERS | Devices that are not CPU, GPU, or dedicated accelerator | +| OH_NN_CPU | CPU device | +| OH_NN_GPU | GPU device | +| OH_NN_ACCELERATOR | Dedicated hardware accelerator | + + +### OH_NN_Format + + +``` +enum OH_NN_Format +``` +**Description**
+Defines the layout type of tensor data. + +| Name | Description | +| -------- | -------- | +| OH_NN_FORMAT_NONE | The tensor does not have a specific layout type (such as scalar or vector). | +| OH_NN_FORMAT_NCHW | The tensor arranges data in NCHW format. | +| OH_NN_FORMAT_NHWC | The tensor arranges data in NHWC format. | + + +### OH_NN_FuseType + + +``` +enum OH_NN_FuseType : int8_t +``` +**Description**
+Defines activation function types in the fusion operator for Neural Network Runtime. + +| Name | Description | +| -------- | -------- | +| OH_NN_FUSED_NONE | The fusion activation function is not specified. | +| OH_NN_FUSED_RELU | Fusion relu activation function | +| OH_NN_FUSED_RELU6 | Fusion relu6 activation function | + + +### OH_NN_OperationType + + +``` +enum OH_NN_OperationType +``` +**Description**
+Defines operator types supported by Neural Network Runtime. + +| Name | Description | +| -------- | -------- | +| OH_NN_OPS_ADD | Returns the tensor of the sum of the elements corresponding to two input tensors.
Inputs:
- **input1**: first input tensor, of the Boolean or number type.
- **input2**: second input tensor, whose data type must be the same as that of the first tensor.
Parameters:
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: sum of **input1** and **input2**. The data shape is the same as that of the input after broadcasting, and the data type is the same as that of the input with a higher precision. | +| OH_NN_OPS_AVG_POOL | Apply 2D average pooling to the input tensor, which now must be in NHWC format. The int8 quantization input is supported.
If the input contains the **padMode** parameter:
Inputs:
- **input**: tensor.
Parameters:
- **kernelSize** indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.
- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.
- **padMode**: padding mode, which is optional. The value is of the int type and can be **0** (same) or **1** (valid). The nearest neighbor value is used for padding. **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right. **1** (valid): The possible maximum height and width of the output will be returned in case of no padding. Excessive pixels will be discarded.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
If the input contains the **padList** parameter:
Inputs:
- **input**: tensor.
Parameters:
- **kernelSize** indicates the kernel size used to obtain the average value. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.
- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.
- **padList**: padding around **input**. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: average pooling result of the input. | +| OH_NN_OPS_BATCH_NORM | Batch normalization is performed on a tensor to scale and shift tensor elements, relieving potential covariate shift in a batch of data.
Inputs:
- **input**: n-dimensional tensor of shape [N, ..., C]. The nth dimension is the number of channels.
- **scale**: 1D tensor of the scaling factor used to scale the first normalized tensor.
- **offset**: 1D tensor used to move to the first normalized tensor.
- **mean**: 1D tensor of the overall mean value. It is used only for inference. In case of training, this parameter must be left empty.
- **variance**: 1D tensor used for the overall variance. It is used only for inference. In case of training, this parameter must be left empty.
Parameters:
- **epsilon**: fixed small additional value.
Outputs:
- **output**: n-dimensional output tensor whose shape and data type are the same as those of the input. | +| OH_NN_OPS_BATCH_TO_SPACE_ND | Divides the batch dimension of a 4D tensor into small blocks by **block_shape**, and interleaves these blocks back into the spatial dimension.
Parameters:
- **input**: input tensor. The dimension will be divided into small blocks, and these blocks will be interleaved into the spatial dimension.
Outputs:
- **blockSize**: size of each block to be interleaved into the spatial dimension. The value is an array [height_block, width_block].
- **crops**: elements truncated from the spatial dimension of the output. The value is a 2D array [[crop0_start, crop0_end], [crop1_start, crop1_end]] with the shape of (2, 2).
Outputs:
- **output**. Assume that the shape of **input** is (n,h,w,c) and the shape of **output** is (n',h',w',c'): n' = n / (block_shape[0] \* block_shape[1]) h' = h \* block_shape[0] - crops[0][0] - crops[0][1] w' = w \* block_shape[1] - crops[1][0] - crops[1][1] c'= c | +| OH_NN_OPS_BIAS_ADD | Offsets the data in each dimension of the input tensor.
Inputs:
- **input**: input tensor, which can have two to five dimensions.
- **bias**: offset of the number of input dimensions.
Outputs:
- **output**: sum of the input tensor and the bias in each dimension. | +| OH_NN_OPS_CAST | Converts the data type in the input tensor.
Inputs:
- **input**: input tensor.
- **type**: converted data type.
Outputs:
- **output**: converted tensor. | +| OH_NN_OPS_CONCAT | Connects tensors in a specified dimension.
Inputs:
- **input**: N input tensors.
Parameters:
- **axis**: dimension for connecting tensors.
Outputs:
- **output**: result of connecting N tensors along the axis. | +| OH_NN_OPS_CONV2D | 2D convolutional layer.
If the input contains the **padMode** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.
**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.
- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
If the input contains the **padList** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padList**: padding around **input**. It is an int array [top, bottom, left, right].
- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is **in_channel**, it is depthwiseConv2d. In this case, group==in_channel==out_channel. If **group** is greater than **1** and less than **in_channel**, it is a group convolution. In this case, out_channel==group.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: convolution computing result. | +| OH_NN_OPS_CONV2D_TRANSPOSE | 2D convolution transposition.
If the input contains the **padMode** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
Parameters:
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right. **1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.
- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.
- **outputPads**: padding along the height and width of the output tensor. The value is an int or a tuple. It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding along a dimension must be less than the stride along this dimension.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
If the input contains the **padList** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, inChannel/group] format. The value of **inChannel** must be exactly divided by the value of **group**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padList**: padding around **input**. It is an int array [top, bottom, left, right].
- **group**: number of groups in which the input is divided by **in_channel**. The value is of the int type. If **group** is **1**, it is a conventional convolution. If **group** is greater than **1** and less than or equal to **in_channel**, it is a group convolution.
- **outputPads**: padding along the height and width of the output tensor. The value is an int or a tuple. It can be a single integer to specify the same value for all spatial dimensions. The amount of output padding along a dimension must be less than the stride along this dimension.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
**output**: computing result after convolution and transposition. | +| OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE | 2D depthwise separable convolution.
If the input contains the **padMode** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. **outChannel** is equal to **channelMultiplier** multiplied by **inChannel**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padMode**: padding mode of **input**. The value is of the int type and can be **0** (same) or **1** (valid). **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.
**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
If the input contains the **padList** parameter:
Inputs:
- **input**: input tensor.
- **weight**: convolution weight in [outChannel, kernelHeight, kernelWidth, 1] format. **outChannel** is equal to **channelMultiplier** multiplied by **inChannel**.
- **bias**: bias of the convolution. It is an array with a length of **[outChannel]**. In quantization scenarios, the **bias** parameter does not require quantization parameters. The quantization version requires data input of the **OH_NN_INT32** type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **stride**: movement stride of the convolution kernel in height and width. It is an int array [strideHeight, strideWidth].
- **dilation**: dilation size of the convolution kernel in height and width. It is an int array [dilationHeight, dilationWidth]. The value must be greater than or equal to **1** and cannot exceed the height and width of **input**.
- **padList**: padding around **input**. It is an int array [top, bottom, left, right].
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: convolution computing result. | +| OH_NN_OPS_DIV | Divides two input scalars or tensors.
Inputs:
- **input1**: first input, which is a number, a bool, or a tensor whose data type is number or Boolean.
- **input2**: second input, which must meet the following requirements: If the first input is a tensor, the second input can be a real number, a Boolean value, or a tensor whose data type is real number or Boolean value. If the first input is a real number or Boolean value, the second input must be a tensor whose data type is real number or Boolean value.
Parameters:
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: result of dividing **input1** by **input2**. | +| OH_NN_OPS_ELTWISE | Sets parameters to perform product (dot product), sum (addition and subtraction), or max (larger value) on the input.
Inputs:
- **input1**: first input tensor.
- **input2**: second input tensor.
Parameters:
- **mode**: operation mode. The value is an enumerated value.
Outputs:
- **output**: computing result, which has the same data type and shape of **output** and **input1**. | +| OH_NN_OPS_EXPAND_DIMS | Adds an additional dimension to a tensor in the given dimension.
Inputs:
- **input**: input tensor.
- **axis**: index of the dimension to be added. The value is of the int32_t type and must be a constant in the range [-dim-1, dim].
Outputs:
- **output**: tensor after dimension expansion. | +| OH_NN_OPS_FILL | Creates a tensor of the specified dimensions and fills it with a scalar.
Inputs:
- **value**: scalar used to fill the tensor.
- **shape**: dimensions of the tensor to be created.
Outputs:
- **output**: generated tensor, which has the same data type as **value**. The tensor shape is specified by the **shape** parameter. | +| OH_NN_OPS_FULL_CONNECTION | Full connection. The entire input is used as the feature map for feature extraction.
Inputs:
- **input**: full-connection input tensor.
- **weight**: weight tensor for a full connection.
- **bias**: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: computed tensor.
If the input contains the **axis** parameter:
Inputs:
- **input**: full-connection input tensor.
- **weight**: weight tensor for a full connection.
- **bias**: full-connection bias. In quantization scenarios, no quantized parameter is required for this parameter. If quantization is required, the data must be of the OH_NN_INT32 type. The actual quantization parameters are determined by **input** and **weight**.
Parameters:
- **axis**: axis in which the full connection is applied. The specified axis and its following axes are converted into a 1D tensor for applying the full connection.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: computed tensor. | +| OH_NN_OPS_GATHER | Returns the slice of the input tensor based on the specified index and axis.
Inputs:
- **input**: tensor to be sliced.
- **inputIndices**: indices of the specified input on the axis. The value is an array of the int type and must be in the range [0,input.shape[axis]).
- **axis**: axis on which **input** is sliced. The value is an array with one element of the int32_t type.
Outputs:
- **output**: sliced tensor. | +| OH_NN_OPS_HSWISH | Calculate the **Hswish** activation value of the input.
Inputs:
- An n-dimensional input tensor.
Outputs:
- n-dimensional **Hswish** activation value. The data type is the same as that of **shape** and **input**. | +| OH_NN_OPS_LESS_EQUAL | For **input1** and **input2**, calculate the result of input1[i]<=input2[i] for each pair of elements, where i is the index of each element in the input tensor.
Inputs:
- **input1**, which can be a real number, Boolean value, or tensor whose data type is real number or NN_BOOL.
- **input2**, which can be a real number or a Boolean value if **input1** is a tensor and must be a tensor with the data type of real number or NN_BOOL if **input1** is not a tensor.
Outputs:
- A tensor of the data type NN_BOOL. When a quantization model is used, the quantization parameters of the output cannot be omitted. However, values of the quantization parameters do not affect the result. | +| OH_NN_OPS_MATMUL | Calculate the inner product of **input1** and **input2**.
Inputs:
- **input1**: n-dimensional input tensor.
- **input2**: n-dimensional input tensor.
Parameters:
- **TransposeX**: Boolean value indicating whether to transpose **input1**.
- **TransposeY**: Boolean value indicating whether to transpose **input2**.
Outputs:
- **output**: inner product obtained after calculation. In case of type!=NN_UNKNOWN, the output data type is determined by **type**. In case of type==NN_UNKNOWN, the output data type depends on the data type converted during computing of **inputX** and **inputY**. | +| OH_NN_OPS_MAXIMUM | Calculates the maximum of **input1** and **input2** element-wise. The inputs of **input1** and **input2** comply with the implicit type conversion rules to make the data types consistent. \* The inputs must be two tensors or one tensor and one scalar. When the inputs are two tensors, their data types cannot be both NN_BOOL. Their shapes can be broadcast to the same size. When the inputs are one tensor and one scalar, the scalar must be a constant.
Inputs:
- **input1**: n-dimensional input tensor of the real number or NN_BOOL type.
- **input2**: n-dimensional input tensor of the real number or NN_BOOL type.
Outputs:
- **output**: n-dimensional output tensor. The **shape** and data type of **output** are the same as those of the two inputs with a higher precision. | +| OH_NN_OPS_MAX_POOL | Applies 2D maximum pooling to the input tensor.
If the input contains the **padMode** parameter:
Inputs:
- **input**: tensor.
Parameters:
- **kernelSize**: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.
- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.
- **padMode**: padding mode, which is optional. The value is of the int type and can be **0** (same) or **1** (valid). The nearest neighbor value is used for padding. **0** (same): The height and width of the output are the same as those of the input. The total padding quantity is calculated horizontally and vertically and evenly distributed to the top, bottom, left, and right if possible. Otherwise, the last additional padding will be completed from the bottom and right.
**1** (valid): The possible maximum height and width of the output will be returned in case of no padding. The excessive pixels will be discarded.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
If the input contains the **padList** parameter:
Inputs:
- **input**: tensor.
Parameters:
- **kernelSize**: kernel size used to obtain the maximum. It is an int array [kernel_height, kernel_width]. The first number indicates the kernel height, and the second number indicates the kernel width.
- **strides** indicates the distance of kernel moving. The value is an int array [stride_height, stride_width]. The first number indicates the moving step in height, and the second number indicates the moving step in width.
- **padList**: padding around **input**. It is an int array [top, bottom, left, right], and the nearest neighbor values are used for padding.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: tensor obtained after maximum pooling is applied to the input. | +| OH_NN_OPS_MUL | Multiplies elements in the same positions of **inputX** and **inputY** to obtain the output. If **inputX** and **inputY** have different shapes, expand them to the same shape through broadcast and then perform multiplication.
Inputs:
- **input1**: n-dimensional tensor.
- **input2**: n-dimensional tensor.
Parameters:
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- Product of each element of **input1** and **input2**. | +| OH_NN_OPS_ONE_HOT | Generates a one-hot tensor based on the positions specified by **indices**. The positions specified by **indices** are determined by **on_value**, and other positions are determined by **off_value**.
Inputs:
- **indices**: n-dimensional tensor. Each element in **indices** determines the position of **on_value** in each one-hot vector.
- **depth**: integer scalar that determines the depth of the one-hot vector. The value of **depth** must be greater than **0**.
- **on_value**: scalar that specifies a valid value in the one-hot vector.
- **off_value**: scalar that specifies the values of other posistions in the one-hot vector except the valid value.
Parameters:
- **axis**: integer scalar that specifies the dimension for inserting the one-hot. Assume that the shape of **indices** is [N, C], and the value of **depth** is D. When **axis** is **0**, the shape of the output is [D, N, C]. When **axis** is **-1**, the shape of the output is [N, C, D]. When **axis** is **1**, the shape of the output is [N, D, C].
Outputs:
- **output**: (n+1)-dimensional tensor if **indices** is an n-dimensional tensor. The output shape is determined by **indices** and **axis**. | +| OH_NN_OPS_PAD | Pads **inputX** in the specified dimensions.
Inputs:
- **inputX**: n-dimensional tensor in [BatchSize, ...] format.
- **paddings**: 2D tensor that specifies the length to pad in each dimension. The shape is [n, 2]. For example, **paddings[i][0]** indicates the number of paddings to be added preceding **inputX** in the ith dimension. **paddings[i][1]** indicates the number of paddings to be added following **inputX** in the ith dimension.
Parameters:
- **padValues**: value to be added to the pad operation. The value is a constant with the same data type as **inputX**.
Outputs:
- **output**: n-dimensional tensor after padding, with the same dimensions and data type as **inputX**. The shape is determined by **inputX** and **paddings**. output.shape[i] = input.shape[i] + paddings[i][0]+paddings[i][1] | +| OH_NN_OPS_POW | Calculates the **y** power of each element in **input**. The inputs must be two tensors or one tensor and one scalar. When the inputs are two tensors, their data types cannot be both NN_BOOL, and their shapes must be the same. When the inputs are one tensor and one scalar, the scalar must be a constant.
Inputs:
- **input**: real number, Boolean value, or tensor whose data type is real number or NN_BOOL.
- **y**: real number, Boolean value, or tensor whose data type is real number or NN_BOOL.
Outputs:
- **output**: tensor, whose shape is determined by the shape of **input** and **y** after broadcasting. | +| OH_NN_OPS_SCALE | Scales a tensor.
Inputs:
- **input**: n-dimensional tensor.
- **scale**: scaling tensor.
- **bias**: bias tensor.
Parameters:
- **axis**: dimensions to be scaled.
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: scaled n-dimensional tensor, whose data type is the same as that of **input** and shape is determined by **axis**. | +| OH_NN_OPS_SHAPE | Calculates the shape of the input tensor.
Inputs:
- **input**: n-dimensional tensor.
Outputs:
- **output**: integer array representing the dimensions of the input tensor. | +| OH_NN_OPS_SIGMOID | Applies the **sigmoid** operation to the input tensor.
Inputs:
- **input**: n-dimensional tensor.
Outputs:
- **output**: result of the **sigmoid** operation. It is an n-dimensional tensor with the same data type and shape as **input**. | +| OH_NN_OPS_SLICE | Slices a tensor of the specified size from the input in each dimension.
Inputs:
- **input**: n-dimensional input tensor.
- **begin**: start of the slice, which is an array of integers greater than or equal to 0.
- **size**: slice length, which is an array of integers greater than or equal to 0. Assume that a dimension is **i** and 1<=size[i]<=input.shape[i]-begin[i].
Outputs:
- **output**: n-dimensional tensor obtained by slicing. The **TensorType**, shape, and size of the output are the same as those of the input. | +| OH_NN_OPS_SOFTMAX | Applies the **softmax** operation to the input tensor.
Inputs:
- **input**: n-dimensional input tensor.
Parameters:
- **axis**: dimension in which the **softmax** operation is performed. The value is of the int64 type. It is an integer in the range [-n, n).
Outputs:
- **output**: result of the **softmax** operation. It is an n-dimensional tensor with the same data type and shape as **input**. | +| OH_NN_OPS_SPACE_TO_BATCH_ND | Divides a 4D tensor into small blocks and combines these blocks in the original batch. The number of blocks is **blockShape[0]** multiplied by **blockShape[1]**.
Inputs:
- **input**: 4D tensor.
Parameters:
- **blockShape**: a pair of integers. Each of them is greater than or equal to **1**.
- **paddings**: a pair of arrays. Each of them consists of two integers. The four integers that form **paddings** must be greater than or equal to **0**. **paddings[0][0]** and **paddings[0][1]** specify the number of paddings in the third dimension, and **paddings[1][0]** and **paddings[1][1]** specify the number of paddings in the fourth dimension.
Outputs:
- **output**: 4D tensor with the same data type as **input**. The shape is determined by **input**, **blockShape**, and **paddings**. Assume that the input shape is [n,c,h,w], then: output.shape[0] = n \* blockShape[0] \* blockShape[1] output.shape[1] = c output.shape[2] = (h + paddings[0][0] + paddings[0][1]) / blockShape[0] output.shape[3] = (w + paddings[1][0] + paddings[1][1]) / blockShape[1] (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]) is exactly divisible by (h + paddings[0][0] + paddings[0][1]) and (w + paddings[1][0] + paddings[1][1]). | +| OH_NN_OPS_SPLIT | Splits the input into multiple tensors along the axis dimension. The number of tensors is specified by **outputNum**.
Inputs:
- **input**: n-dimensional tensor.
Parameters:
- **outputNum**: number of output tensors. The data type is long.
- **size_splits**: size of each tensor split from the input. The value is a 1D tensor of the int type. If **size_splits** is empty, the input will be evenly split into tensors of the same size. In this case, **input.shape[axis]** can be exactly divisible by **outputNum**. If **size_splits** is not empty, the sum of all its elements must be equal to **input.shape[axis]**.
- **axis**: splitting dimension of the int type.
Outputs:
- **outputs**: array of n-dimensional tensors, with the same data type and dimensions. The data type of each tensor is the same as that of **input**. | +| OH_NN_OPS_SQRT | Calculates the square root of a tensor.
Inputs:
- **input**: n-dimensional tensor.
Outputs:
- **output**: square root of the input. It is an n-dimensional tensor with the same data type and shape as **input**. | +| OH_NN_OPS_SQUARED_DIFFERENCE | Calculates the square of the difference between two tensors. The **SquaredDifference** operator supports tensor and tensor subtraction. If two tensors have different **TensorTypes**, the Sub operator converts the low-precision tensor to a high-precision one. If two tensors have different shapes, the two tensors can be extended to tensors with the same shape through broadcast.
Inputs:
- **input1**: minuend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type.
- **input2**: subtrahend, which is a tensor of the NN_FLOAT16, NN_FLOAT32, NN_INT32, or NN_BOOL type.
Outputs:
- **output**: square of the difference between two inputs. The output shape is determined by**input1** and **input2**. If they have the same shape, the output tensor has the same shape as them. If they have different shapes, perform the broadcast operation on **input1** and **input2** and perform subtraction. **TensorType** of the output is the same as that of the input tensor with higher precision. | +| OH_NN_OPS_SQUEEZE | Removes the dimension with a length of 1 from the specified axis. The int8 quantization input is supported. Assume that the input shape is [2, 1, 1, 2, 2] and axis is [0,1], the output shape is [2, 1, 2, 2], which means the dimension whose length is 0 between dimensions 0 and dimension 1 is removed.
Inputs:
- **input**: n-dimensional tensor.
Parameters:
- **axis**: dimension to be removed. The value is of int64_t type and can be an integer in the range [-n, n) or an array.
Outputs:
- **output**: output tensor. | +| OH_NN_OPS_STACK | Stacks multiple tensors along the specified axis. If each tensor has n dimensions before stacking, the output tensor will have n+1 dimensions.
Inputs:
- **input**: input for stacking, which can contain multiple n-dimensional tensors. Each of them must have the same shape and type.
Parameters:
- **axis**: dimension for tensor stacking, which is an integer. The value range is [-(n+1),(n+1)), which means a negative number is allowed.
Outputs:
- **output**: stacking result of the input along the axis dimension. The value is an n+1-dimensional tensor and has the same **TensorType** as the input. | +| OH_NN_OPS_STRIDED_SLICE | Slices a tensor with the specified stride.
Inputs:
- **input**: n-dimensional input tensor.
- **begin**: start of slicing, which is a 1D tensor. The length of **begin** is n. **begin[i]** specifies the start of slicing in the ith dimension.
- **end**: end of slicing, which is a 1D tensor. The length of **end** is n. **end[i]** specifies the end of slicing in the ith dimension.
- **strides**: slicing stride, which is a 1D tensor. The length of **strides** is n. strides[i] specifies the stride at which the tensor is sliced in the ith dimension.
Parameters:
- **beginMask**: an integer used to mask **begin**. **beginMask** is represented in binary code. In case of binary(beginMask)[i]==1, for the ith dimension, elements are sliced from the first element at **strides[i]** until the end[i]-1 element.
- **endMask**: an integer used to mask **end**. **endMask** is represented in binary code. In case of binary(endMask)[i]==1, elements are sliced from the element at the **begin[i]** position in the ith dimension until the tensor boundary at **strides[i]**.
- **ellipsisMask**: integer used to mask **begin** and **end**. **ellipsisMask** is represented in binary code. In case of binary(ellipsisMask)[i]==1, elements are sliced from the first element at **strides[i]** in the ith dimension until the tensor boundary. Only one bit of **binary(ellipsisMask)** can be a non-zero value.
- **newAxisMask**: new dimension, which is an integer. **newAxisMask** is represented in binary code. In case of binary(newAxisMask)[i]==1, a new dimension whose length is 1 is inserted into the ith dimension.
- **shrinkAxisMask**: shrinking dimension, which is an integer. \* **shrinkAxisMask** is represented in binary code. In the case of binary(shrinkAxisMask)[i]==1, all elements in the ith dimension will be discarded, and the length of the ith dimension is shrunk to **1**.
Outputs:
- A tensor, with the same data type as **input**. The number of dimensions of the output tensor is rank(input[0])+1. | +| OH_NN_OPS_SUB | Calculates the difference between two tensors.
Inputs:
- **input1**: minuend, which is a tensor.
- **input2**: subtrahend, which is a tensor.
Parameters:
- **activationType** is an integer constant which is contained in **FuseType**. The specified activation function is called before output.
Outputs:
- **output**: difference between the two tensors. The output shape is determined by**input1** and **input2**. If they have the same shape, the output tensor has the same shape as them. If they have different shapes, perform the broadcast operation on **input1** and **input2** and perform subtraction. **TensorType** of the output is the same as that of the input tensor with higher precision. | +| OH_NN_OPS_TANH | Computes hyperbolic tangent of the input tensor.
Inputs:
- **input**: n-dimensional tensor.
Outputs:
- **output**: hyperbolic tangent of the input. The **TensorType** and tensor shape are the same as those of the input. | +| OH_NN_OPS_TILE | Copies a tensor the specified times.
Inputs:
- **input**: n-dimensional tensor.
- **multiples**: number of times that the input tensor is copied in each dimension. The value is a 1D tensor. The length m is not less than the number of dimensions, that is, n.
Outputs:
- An m-dimensional tensor whose **TensorType** is the same as that of the input. If **input** and **multiples** have the same length, **input** and **output** have the same number of dimensions. If the length of **multiples** is greater than n, 1 is used to fill the input dimension, and then the input is copied in each dimension the specified times to obtain the m-dimensional tensor. | +| OH_NN_OPS_TRANSPOSE | Transposes data of **input 0** based on **permutation**.
Inputs:
- **input**: n-dimensional tensor to be transposed.
- **permutation**: The value is a 1D tensor whose length is the same as the number of dimensions of **input 0**.
Outputs:
- **output**: n-dimensional tensor. **TensorType** of **output 0** is the same as that of **input 0**, and the output shape is determined by the shape and **permutation** of **input 0**. | +| OH_NN_OPS_REDUCE_MEAN | Calculates the average value in the specified dimension. If **keepDims** is set to **false**, the number of dimensions is reduced for the input; if **keepDims** is set to **true**, the number of dimensions is retained.
Inputs:
- **input**: n-dimensional input tensor, where n is less than 8.
- **axis**: dimension used to calculate the average value. The value is a 1D tensor. The value range of each element in **axis** is [–n, n).
Parameters:
- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value.
Outputs:
- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. | +| OH_NN_OPS_RESIZE_BILINEAR | The Bilinear method is used to deform the input based on the given parameters.
Inputs:
- **input**: 4D input tensor. Each element in the input cannot be less than 0. The input layout must be [batchSize, height, width, channels].
Parameters:
- **newHeight**: resized height of the 4D tensor.
- **newWidth**: resized width of the 4D tensor.
- **preserveAspectRatio**: indicates whether to maintain the height/width ratio of **input** after resizing.
- **coordinateTransformMode**: coordinate transformation method used by the resize operation. The value is an int32 integer. Currently, the following methods are supported:
- **excludeOutside**: an int64 floating point number. When its value is **1**, the sampling weight of the part that exceeds the boundary of **input** is set to **0**, and other weights are normalized.
Outputs:
- **output**: n-dimensional tensor, with the same shape and data type as **input**. | +| OH_NN_OPS_RSQRT | Calculates the reciprocal of the square root of a tensor.
Inputs:
- **input**: n-dimensional tensor, where n is less than 8. Each element of the tensor cannot be less than 0.
Outputs:
- **output**: n-dimensional tensor, with the same shape and data type as **input**. | +| OH_NN_OPS_RESHAPE | Reshapes a tensor.
Inputs:
- **input**: n-dimensional input tensor.
- **InputShape**: shape of the output tensor. The value is a 1D constant tensor.
Outputs:
- **output**: tensor whose data type is the same as that of **input** and shape is determined by **InputShape**. | +| OH_NN_OPS_PRELU | Calculates the PReLU activation value of **input** and **weight**.
Inputs:
- **input**: n-dimensional tensor. If n is greater than or equal to 2, **inputX** must be [BatchSize, ..., Channels]. The second dimension is the number of channels.
- **weight**: 1D tensor. The length of **weight** must be 1 or equal to the number of channels. If the length of **weight** is 1, all channels share the same weight. If the length of **weight** is equal to the number of channels, each channel exclusively has a weight. If n is less than 2 for **inputX**, the **weight** length must be 1.
Outputs:
**output**: PReLU activation value of **x**, with the same shape and data type as **inputX**. | +| OH_NN_OPS_RELU | Calculates the Relu activation value of **input**.
Inputs:
- **input**: n-dimensional input tensor.
Outputs:
- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. | +| OH_NN_OPS_RELU6 | Calculates the Relu6 activation value of the input, that is, calculate min(max(x, 0), 6) for each element x in the input.
Inputs:
- **input**: n-dimensional input tensor.
Outputs:
- **output**: n-dimensional Relu6 tensor, with the same data type and shape as the input tensor. | +| OH_NN_OPS_LAYER_NORM | Applies layer normalization for a tensor from the specified axis.
Inputs:
- **input**: n-dimensional input tensor.
- **gamma**: m-dimensional tensor. The dimensions of **gamma** must be the same as the shape of the part of the input tensor to normalize.
- **beta**: m-dimensional tensor with the same shape as **gamma**.
Parameters:
- **beginAxis** is an NN_INT32 scalar that specifies the axis from which normalization starts. The value range is [1, rank(input)).
- **epsilon** is a scalar of NN_FLOAT32. It is a tiny amount in the normalization formula. The common value is 1e-7.
Outputs:
- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. | +| OH_NN_OPS_REDUCE_PROD | Calculates the accumulated value for a tensor along the specified dimension.
Inputs:
- **input**: n-dimensional input tensor, where n is less than 8.
- **axis**: dimension used to calculate the product. The value is a 1D tensor. The value range of each element in **axis** is [–n, n).
Parameters:
- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value. When its value is **true**, the number of output dimensions is the same as that of the input. When its value is **false**, the number of output dimensions is reduced.
Outputs:
- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. | +| OH_NN_OPS_REDUCE_ALL | Operates the logical OR in the specified dimension. If **keepDims** is set to **false**, the number of dimensions is reduced for the input; if **keepDims** is set to **true**, the number of dimensions is retained.
Inputs:
- A n-dimensional input tensor, where n is less than 8.
- A 1D tensor specifying the dimension used to operate the logical OR. The value range of each element in **axis** is [–n, n).
Parameters:
- **keepDims**: indicates whether to retain the dimension. The value is a Boolean value.
Outputs:
- **output**: m-dimensional output tensor whose data type is the same as that of the input. If **keepDims** is **false**, m==n. If **keepDims** is **true**, m<n. | +| OH_NN_OPS_QUANT_DTYPE_CAST | Converts the data type.
Inputs:
- **input**: n-dimensional tensor.
Parameters:
- **src_t**: data type of the input.
- **dst_t**: data type of the output.
Outputs:
- **output**: n-dimensional tensor. The data type is determined by **input2**. The output shape is the same as the input shape. | +| OH_NN_OPS_TOP_K | Obtains the values and indices of the largest k entries in the last dimension.
Inputs:
- **input**: n-dimensional tensor.
- **input** k: first k records of data and their indices.
Parameters:
- **sorted**: order of sorting. The value **true** means descending and **false** means ascending.
Outputs:
- **output0**: largest k elements in each slice of the last dimension.
- **output1**: index of the value in the last dimension of the input. | +| OH_NN_OPS_ARG_MAX | Returns the index of the maximum tensor value across axes.
Inputs:
- **input**: n-dimensional tensor (N, ∗), where ∗ means any number of additional dimensions.
Parameters:
- **axis**: dimension for calculating the index of the maximum.
- **keep_dims**: indicates whether to maintain the input tensor dimension. The value is a Boolean value.
Outputs:
- **output**: index of the maximum input tensor on the axis. The value is a tensor. | +| OH_NN_OPS_UNSQUEEZE | Adds a dimension based on the value of **axis**.
Inputs:
- **input**: n-dimensional tensor.
Parameters:
- **axis**: dimension to be added. The value of **axis** can be an integer or an array of integers. The value range of the integer is [-n, n).
Outputs:
- **output**: output tensor. | +| OH_NN_OPS_GELU | Gaussian error linear unit activation function. The int quantization input is not supported. output=0.5∗input∗(1+tanh(input/2))
Inputs:
- An n-dimensional input tensor.
Outputs:
- **output**: n-dimensional tensor, with the same data type and shape as the input tensor. | + + +### OH_NN_PerformanceMode + + +``` +enum OH_NN_PerformanceMode +``` +**Description**
+Defines the hardware performance mode. + +| Name | Description | +| -------- | -------- | +| OH_NN_PERFORMANCE_NONE | No performance mode preference | +| OH_NN_PERFORMANCE_LOW | Low power consumption mode | +| OH_NN_PERFORMANCE_MEDIUM | Medium performance mode | +| OH_NN_PERFORMANCE_HIGH | High performance mode | +| OH_NN_PERFORMANCE_EXTREME | Ultimate performance mode | + + +### OH_NN_Priority + + +``` +enum OH_NN_Priority +``` +**Description**
+Defines the model inference task priority. + +| Name | Description | +| -------- | -------- | +| OH_NN_PRIORITY_NONE | No priority preference | +| OH_NN_PRIORITY_LOW | Low priority | +| OH_NN_PRIORITY_MEDIUM | Medium priority | +| OH_NN_PRIORITY_HIGH | High priority | + + +### OH_NN_ReturnCode + + +``` +enum OH_NN_ReturnCode +``` +**Description**
+Defines error codes for Neural Network Runtime. + +| Name | Description | +| -------- | -------- | +| OH_NN_SUCCESS | The operation is successful. | +| OH_NN_FAILED | The operation failed. | +| OH_NN_INVALID_PARAMETER | Invalid parameter. | +| OH_NN_MEMORY_ERROR | Memory-related error, for example, insufficient memory, memory data copy failure, or memory application failure. | +| OH_NN_OPERATION_FORBIDDEN | Invalid operation. | +| OH_NN_NULL_PTR | Null pointer exception | +| OH_NN_INVALID_FILE | Invalid file. | +| OH_NN_UNAVALIDABLE_DEVICE | A hardware error occurs, for example, HDL service crash. | +| OH_NN_INVALID_PATH | Invalid path. | + + +### OH_NN_TensorType + + +``` +enum OH_NN_TensorType +``` +**Description**
+Enumerates the tensor data types. + +Tensors are usually used to set the input, output, and operator parameters of a model. When a tensor is used as the input or output of a model (or operator), set the tensor type to OH_NN_TENSOR. When the tensor is used as an operator parameter, select an enumerated value other than OH_NN_TENSOR as the tensor type. Assume that the **pad** parameter of the OH_NN_OPS_CONV2D operator is being set. You need to set the **type** attribute of the [OH_NN_Tensor](_o_h___n_n___tensor.md) instance to OH_NN_CONV2D_PAD. The settings of other operator parameters are similar. The enumerated values are named in the format OH_NN_{Operator name}_{Attribute name}. + +| Name | Description | +| -------- | -------- | +| OH_NN_TENSOR | This enumerated value is used when the tensor is used as the input or output of a model (or operator). | +| OH_NN_ADD_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Add operator. | +| OH_NN_AVG_POOL_KERNEL_SIZE | This enumerated value is used when the tensor is used as the **kernel_size** parameter of the AvgPool operator. | +| OH_NN_AVG_POOL_STRIDE | This enumerated value is used when the tensor is used as the **stride** parameter of the AvgPool operator. | +| OH_NN_AVG_POOL_PAD_MODE | This enumerated value is used when the tensor is used as the **pad_mode** parameter of the AvgPool operator. | +| OH_NN_AVG_POOL_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the AvgPool operator. | +| OH_NN_AVG_POOL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activation_type** parameter of the AvgPool operator. | +| OH_NN_BATCH_NORM_EPSILON | This enumerated value is used when the tensor is used as the **eosilon** parameter of the BatchNorm operator. | +| OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE | This enumerated value is used when the tensor is used as the **blockSize** parameter of the BatchToSpaceND operator. | +| OH_NN_BATCH_TO_SPACE_ND_CROPS | This enumerated value is used when the tensor is used as the **crops** parameter of the BatchToSpaceND operator. | +| OH_NN_CONCAT_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Concat operator. | +| OH_NN_CONV2D_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the Conv2D operator. | +| OH_NN_CONV2D_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the Conv2D operator. | +| OH_NN_CONV2D_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the Conv2D operator. | +| OH_NN_CONV2D_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the Conv2D operator. | +| OH_NN_CONV2D_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Conv2D operator. | +| OH_NN_CONV2D_GROUP | This enumerated value is used when the tensor is used as the **group** parameter of the Conv2D operator. | +| OH_NN_CONV2D_TRANSPOSE_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS | This enumerated value is used when the tensor is used as the **outputPaddings** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Conv2DTranspose operator. | +| OH_NN_CONV2D_TRANSPOSE_GROUP | This enumerated value is used when the tensor is used as the **group** parameter of the Conv2DTranspose operator. | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES | This enumerated value is used when the tensor is used as the **strides** parameter of the DepthwiseConv2dNative operator. | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the DepthwiseConv2dNative operator. | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION | This enumerated value is used when the tensor is used as the **dilation** parameter of the DepthwiseConv2dNative operator. | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE | This enumerated value is used when the tensor is used as the **padMode** parameter of the DepthwiseConv2dNative operator. | +| OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the DepthwiseConv2dNative operator. | +| OH_NN_DIV_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Div operator. | +| OH_NN_ELTWISE_MODE | This enumerated value is used when the tensor is used as the **mode** parameter of the Eltwise operator. | +| OH_NN_FULL_CONNECTION_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the FullConnection operator. | +| OH_NN_FULL_CONNECTION_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the FullConnection operator. | +| OH_NN_MATMUL_TRANSPOSE_A | This enumerated value is used when the tensor is used as the **transposeA** parameter of the Matmul operator. | +| OH_NN_MATMUL_TRANSPOSE_B | This enumerated value is used when the tensor is used as the **transposeB** parameter of the Matmul operator. | +| OH_NN_MATMUL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Matmul operator. | +| OH_NN_MAX_POOL_KERNEL_SIZE | This enumerated value is used when the tensor is used as the **kernel_size** parameter of the MaxPool operator. | +| OH_NN_MAX_POOL_STRIDE | This enumerated value is used when the tensor is used as the **stride** parameter of the MaxPool operator. | +| OH_NN_MAX_POOL_PAD_MODE | This enumerated value is used when the tensor is used as the **pad_mode** parameter of the MaxPool operator. | +| OH_NN_MAX_POOL_PAD | This enumerated value is used when the tensor is used as the **pad** parameter of the MaxPool operator. | +| OH_NN_MAX_POOL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activation_type** parameter of the MaxPool operator. | +| OH_NN_MUL_ACTIVATION_TYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Mul operator. | +| OH_NN_ONE_HOT_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the OneHot operator. | +| OH_NN_PAD_CONSTANT_VALUE | This enumerated value is used when the tensor is used as the **constant_value** parameter of the Pad operator. | +| OH_NN_SCALE_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **activationType** parameter of the Scale operator. | +| OH_NN_SCALE_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Scale operator. | +| OH_NN_SOFTMAX_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the Softmax operator. | +| OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE | This enumerated value is used when the tensor is used as the **BlockShape** parameter of the SpaceToBatchND operator. | +| OH_NN_SPACE_TO_BATCH_ND_PADDINGS | This enumerated value is used when the tensor is used as the **Paddings** parameter of the SpaceToBatchND operator. | +| OH_NN_SPLIT_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Split operator. | +| OH_NN_SPLIT_OUTPUT_NUM | This enumerated value is used when the tensor is used as the **OutputNum** parameter of the Split operator. | +| OH_NN_SPLIT_SIZE_SPLITS | This enumerated value is used when the tensor is used as the **SizeSplits** parameter of the Split operator. | +| OH_NN_SQUEEZE_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Squeeze operator. | +| OH_NN_STACK_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Stack operator. | +| OH_NN_STRIDED_SLICE_BEGIN_MASK | This enumerated value is used when the tensor is used as the **BeginMask** parameter of the StridedSlice operator. | +| OH_NN_STRIDED_SLICE_END_MASK | This enumerated value is used when the tensor is used as the **EndMask** parameter of the StridedSlice operator. | +| OH_NN_STRIDED_SLICE_ELLIPSIS_MASK | This enumerated value is used when the tensor is used as the **EllipsisMask** parameter of the StridedSlice operator. | +| OH_NN_STRIDED_SLICE_NEW_AXIS_MASK | This enumerated value is used when the tensor is used as the **NewAxisMask** parameter of the StridedSlice operator. | +| OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK | This enumerated value is used when the tensor is used as the **ShrinkAxisMask** parameter of the StridedSlice operator. | +| OH_NN_SUB_ACTIVATIONTYPE | This enumerated value is used when the tensor is used as the **ActivationType** parameter of the Sub operator. | +| OH_NN_REDUCE_MEAN_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceMean operator. | +| OH_NN_RESIZE_BILINEAR_NEW_HEIGHT | This enumerated value is used when the tensor is used as the **new_height** parameter of the ResizeBilinear operator. | +| OH_NN_RESIZE_BILINEAR_NEW_WIDTH | This enumerated value is used when the tensor is used as the **new_width** parameter of the ResizeBilinear operator. | +| OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO | This enumerated value is used when the tensor is used as the **preserve_aspect_ratio** parameter of the ResizeBilinear operator. | +| OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE | This enumerated value is used when the tensor is used as the **coordinate_transform_mode** parameter of the ResizeBilinear operator. | +| OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE | This enumerated value is used when the tensor is used as the **exclude_outside** parameter of the ResizeBilinear operator. | +| OH_NN_LAYER_NORM_BEGIN_NORM_AXIS | This enumerated value is used when the tensor is used as the **beginNormAxis** parameter of the LayerNorm operator. | +| OH_NN_LAYER_NORM_EPSILON | This enumerated value is used when the tensor is used as the **epsilon** parameter of the LayerNorm operator. | +| OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS | This enumerated value is used when the tensor is used as the **beginParamsAxis** parameter of the LayerNorm operator. | +| OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE | This enumerated value is used when the tensor is used as the **elementwiseAffine** parameter of the LayerNorm operator. | +| OH_NN_REDUCE_PROD_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceProd operator. | +| OH_NN_REDUCE_ALL_KEEP_DIMS | This enumerated value is used when the tensor is used as the **keep_dims** parameter of the ReduceAll operator. | +| OH_NN_QUANT_DTYPE_CAST_SRC_T | This enumerated value is used when the tensor is used as the **src_t** parameter of the QuantDTypeCast operator. | +| OH_NN_QUANT_DTYPE_CAST_DST_T | This enumerated value is used when the tensor is used as the **dst_t** parameter of the QuantDTypeCast operator. | +| OH_NN_TOP_K_SORTED | This enumerated value is used when the tensor is used as the **Sorted** parameter of the Topk operator. | +| OH_NN_ARG_MAX_AXIS | This enumerated value is used when the tensor is used as the **axis** parameter of the ArgMax operator. | +| OH_NN_ARG_MAX_KEEPDIMS | This enumerated value is used when the tensor is used as the **keepDims** parameter of the ArgMax operator. | +| OH_NN_UNSQUEEZE_AXIS | This enumerated value is used when the tensor is used as the **Axis** parameter of the Unsqueeze operator. | + + +## Function Description + + +### OH_NNCompilation_Build() + + +``` +OH_NN_ReturnCode OH_NNCompilation_Build (OH_NNCompilation * compilation) +``` +**Description**
+Compiles a model. + +After the compilation configuration is complete, call this method to return the compilation result. The compilation instance pushes the model and compilation options to the device for compilation. After this method is called, additional compilation operations cannot be performed. If the [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice), [OH_NNCompilation_SetCache](#oh_nncompilation_setcache), [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode), [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority), and [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) methods are called, OH_NN_OPERATION_FORBIDDEN is returned. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + + +### OH_NNCompilation_Construct() + + +``` +OH_NNCompilation* OH_NNCompilation_Construct (const OH_NNModel * model) +``` +**Description**
+Creates a compilation instance of the [OH_NNCompilation](#oh_nncompilation) type. + +After the OH_NNModel module completes model construction, APIs provided by the OH_NNCompilation module pass the model to underlying device for compilation. This method creates a [OH_NNCompilation](#oh_nncompilation) instance based on the passed [OH_NNModel](#oh_nnmodel) instance. The [OH_NNCompilation_SetDevice](#oh_nncompilation_setdevice) method is called + +to set the device to compile on, and [OH_NNCompilation_Build](#oh_nncompilation_build) is then called to complete compilation. + +In addition to computing device selection, the OH_NNCompilation module supports features such as model caching, performance preference, priority setting, and float16 computing, which can be implemented by the following methods: + +- [OH_NNCompilation_SetCache](#oh_nncompilation_setcache) + +- [OH_NNCompilation_SetPerformanceMode](#oh_nncompilation_setperformancemode) + +- [OH_NNCompilation_SetPriority](#oh_nncompilation_setpriority) + +- [OH_NNCompilation_EnableFloat16](#oh_nncompilation_enablefloat16) + +After [OH_NNCompilation](#oh_nncompilation) is created by calling this method, the [OH_NNModel](#oh_nnmodel) instance can be released. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | + +**Returns** + +Returns the pointer to a [OH_NNCompilation](#oh_nncompilation) instance. + + +### OH_NNCompilation_Destroy() + + +``` +void OH_NNCompilation_Destroy (OH_NNCompilation ** compilation) +``` +**Description**
+Releases the **Compilation** object. + +This method needs to be called to release the compilation instance created by calling [OH_NNCompilation_Construct](#oh_nncompilation_construct). Otherwise, memory leak will occur. + +If **compilation** or **\*compilation** is a null pointer, this method only prints warning logs and does not execute the release logic. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Level-2 pointer to the [OH_NNCompilation](#oh_nncompilation) instance. After a compilation instance is destroyed, this method sets **\*compilation** to a null pointer. | + + +### OH_NNCompilation_EnableFloat16() + + +``` +OH_NN_ReturnCode OH_NNCompilation_EnableFloat16 (OH_NNCompilation * compilation, bool enableFloat16 ) +``` +**Description**
+Enables float16 for computing. + +Currently, Neural Network Runtime supports only float32 and int8. If this method is called on a device that supports float16, float16 will be used for computing the float32 model to reduce memory usage and execution time. + +If this method is called on the device that does not support float16, the OH_NN_UNAVALIDABLE_DEVICE error code is returned. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | +| enableFloat16 | Indicates whether to enable float16. If this parameter is set to **true**, float16 inference is performed. If this parameter is set to **false**, float32 inference is performed. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNCompilation_SetCache() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetCache (OH_NNCompilation * compilation, const char * cachePath, uint32_t version ) +``` +**Description**
+Set the cache directory and version of the compiled model. + +On the device that supports caching, a model can be saved as a cache file after being compiled at the device driver layer. The model can be directly read from the cache file in the next compilation, saving recompilation time. This method performs different operations based on the passed cache directory and version: + +- No file exists in the cache directory: Caches the compiled model to the directory and sets the cache version to **version**. + +- A complete cache file exists in the cache directory, and its version is **version**: Reads the cache file in the path and passes the data to the underlying device for conversion into executable model instances. + +- A complete cache file exists in the cache directory, and its version is earlier than **version**: When model compilation is complete on the underlying device, overwrites the cache file and changes the version number to **version**. + +- A complete cache file exists in the cache directory, and its version is later than **version**: Returns the OH_NN_INVALID_PARAMETER error code without reading the cache file. + +- The cache file in the cache directory is incomplete or you do not have the permission to access the cache file. Returns the OH_NN_INVALID_FILE error code. + +- The cache directory does not exist or you do not have the access permission. Returns the OH_NN_INVALID_PATH error code. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | +| cachePath | Directory for storing model cache files. This method creates directories for different devices in the **cachePath** directory. You are advised to use a separate cache directory for each model. | +| version | Cache version. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNCompilation_SetDevice() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetDevice (OH_NNCompilation * compilation, size_t deviceID ) +``` +**Description**
+Specifies the device for model compilation and computing. + +In the compilation phase, you need to specify the device for model compilation and computing. Call [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid) to obtain available device IDs. Call [OH_NNDevice_GetType](#oh_nndevice_gettype) and [OH_NNDevice_GetName](#oh_nndevice_getname) to obtain device information and pass target device IDs to this method for setting. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | +| deviceID | Device ID. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNCompilation_SetPerformanceMode() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetPerformanceMode (OH_NNCompilation * compilation, OH_NN_PerformanceMode performanceMode ) +``` +**Description**
+Sets the performance mode for model computing. + +Neural Network Runtime allows you to set the performance mode for model computing to meet the requirements of low power consumption and ultimate performance. If this method is not called to set the performance mode in the compilation phase, the compilation instance assigns the OH_NN_PERFORMANCE_NONE mode for the model by default. In this case, the device performs computing in the default performance mode. + +If this method is called on the device that does not support the setting of the performance mode, the OH_NN_UNAVALIDABLE_DEVICE error code is returned. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | +| performanceMode | Performance mode. For details about the available performance modes, see [OH_NN_PerformanceMode](#oh_nn_performancemode). | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNCompilation_SetPriority() + + +``` +OH_NN_ReturnCode OH_NNCompilation_SetPriority (OH_NNCompilation * compilation, OH_NN_Priority priority ) +``` +**Description**
+Sets the model computing priority. + +Neural Network Runtime allows you to set computing priorities for models. + +The priorities apply only to models created by the process with the same UID. The settings will not affect models created by processes with different UIDs on different devices. + +If this method is called on the device that does not support the priority setting, the OH_NN_UNAVALIDABLE_DEVICE error code is returned. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | +| priority | Priority. For details about the optional priorities, see [OH_NN_Priority](#oh_nn_priority). | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNDevice_GetAllDevicesID() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetAllDevicesID (const size_t ** allDevicesID, uint32_t * deviceCount ) +``` +**Description**
+Obtains the ID of the device connected to Neural Network Runtime. + +Each device has a unique and fixed ID in Neural Network Runtime. This method returns device IDs on the current device through the uint32_t array. + +Device IDs are returned through the size_t array. Each element of the array is the ID of a single device. The array memory is managed by Neural Network Runtime. The data pointer is valid before this method is called next time. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| allDevicesID | Pointer to the size_t array. The input **\*allDevicesID** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. | +| deviceCount | Pointer of the uint32_t type, which is used to return the length of **(\*allDevicesID)**. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNDevice_GetName() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetName (size_t deviceID, const char ** name ) +``` +**Description**
+Obtains the name of the specified device. + +**deviceID** specifies the device whose name will be obtained. The device ID needs to be obtained by calling [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| deviceID | Device ID. | +| name | Pointer to the char array. The passed **(\*char)** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. The value of **(\*name)** is a C-style string ended with **'\0'**. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNDevice_GetType() + + +``` +OH_NN_ReturnCode OH_NNDevice_GetType (size_t deviceID, OH_NN_DeviceType * deviceType ) +``` +**Description**
+Obtains the type information of the specified device. + +**deviceID** specifies the device whose type will be obtained. Currently, Neural Network Runtime supports the following device types: + +- **OH_NN_CPU**: CPU device. + +- **OH_NN_GPU**: GPU device. + +- **OH_NN_ACCELERATOR**: machine learning dedicated accelerator. + +- **OH_NN_OTHERS**: other hardware types. + +**Parameters** + +| Name | Description | +| -------- | -------- | +| deviceID | Device ID. | +| deviceType | Pointer to the [OH_NN_DeviceType](#oh_nn_devicetype) instance. The device type information is returned. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_AllocateInputMemory() + + +``` +OH_NN_Memory* OH_NNExecutor_AllocateInputMemory (OH_NNExecutor * executor, uint32_t inputIndex, size_t length ) +``` +**Description**
+Allocates shared memory to a single input on a device. + +Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and input index value, this method allocates shared memory whose size is specified by **length** on the device associated with a single input and returns the operation result through the [OH_NN_Memory](_o_h___n_n___memory.md) instance. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In the memory input application, the index value for the three inputs is **{0, 1, 2}**. | +| length | Memory size to be applied for, in bytes. | + +**Returns** + +Pointer to a [OH_NN_Memory](_o_h___n_n___memory.md) instance. + + +### OH_NNExecutor_AllocateOutputMemory() + + +``` +OH_NN_Memory* OH_NNExecutor_AllocateOutputMemory (OH_NNExecutor * executor, uint32_t outputIndex, size_t length ) +``` +**Description**
+Allocates shared memory to a single output on a device. + +Neural Network Runtime provides a method for proactively allocating shared memory on a device. By specifying the executor and output index value, this method allocates shared memory whose size is specified by **length** on the device associated with a single output and returns the operation result through the [OH_NN_Memory](_o_h___n_n___memory.md) instance. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output memory application, the index value for the three outputs is **{0, 1, 2}**. | +| length | Memory size to be applied for, in bytes. | + +**Returns** + +Pointer to a [OH_NN_Memory](_o_h___n_n___memory.md) instance. + + +### OH_NNExecutor_Construct() + + +``` +OH_NNExecutor* OH_NNExecutor_Construct (OH_NNCompilation * compilation) +``` +**Description**
+Creates an executor instance of the [OH_NNExecutor](#oh_nnexecutor) type. + +This method constructs a model inference executor associated with the device based on the passed compiler. Use [OH_NNExecutor_SetInput](#oh_nnexecutor_setinput) to set the model input data. After the input data is set, call [OH_NNExecutor_Run](#oh_nnexecutor_run) to perform inference and then call [OH_NNExecutor_SetOutput](#oh_nnexecutor_setoutput) to obtain the computing result. + +After calling this method to create the [OH_NNExecutor](#oh_nnexecutor) instance, you can release the [OH_NNCompilation](#oh_nncompilation) instance if you do not need to create any other executors. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| compilation | Pointer to the [OH_NNCompilation](#oh_nncompilation) instance. | + +**Returns** + +Pointer to a [OH_NNExecutor](#oh_nnexecutor) instance. + + +### OH_NNExecutor_Destroy() + + +``` +void OH_NNExecutor_Destroy (OH_NNExecutor ** executor) +``` +**Description**
+Destroys an executor instance to release the memory occupied by the executor. + +This method needs to be called to release the executor instance created by calling [OH_NNExecutor_Construct](#oh_nnexecutor_construct). Otherwise, memory leak will occur. + +If **executor** or **\*executor** is a null pointer, this method only prints warning logs and does not execute the release logic. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Level-2 pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | + + +### OH_NNExecutor_DestroyInputMemory() + + +``` +void OH_NNExecutor_DestroyInputMemory (OH_NNExecutor * executor, uint32_t inputIndex, OH_NN_Memory ** memory ) +``` +**Description**
+Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. + +This method needs to be called to release the memory instance created by calling [OH_NNExecutor_AllocateInputMemory](#oh_nnexecutor_allocateinputmemory). Otherwise, memory leak will occur. The mapping between **inputIndex** and **memory** must be the same as that in memory instance creation. + +If **memory** or **\*memory** is a null pointer, this method only prints warning logs and does not execute the release logic. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In memory input release, the index value for the three inputs is **{0, 1, 2}**. | +| memory | Level-2 pointer to the [OH_NN_Memory](_o_h___n_n___memory.md) instance. After shared memory is destroyed, this method sets **\*memory** to a null pointer. | + + +### OH_NNExecutor_DestroyOutputMemory() + + +``` +void OH_NNExecutor_DestroyOutputMemory (OH_NNExecutor * executor, uint32_t outputIndex, OH_NN_Memory ** memory ) +``` +**Description**
+Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. + +This method needs to be called to release the memory instance created by calling [OH_NNExecutor_AllocateOutputMemory](#oh_nnexecutor_allocateoutputmemory). Otherwise, memory leak will occur. The mapping between **outputIndex** and **memory** must be the same as that in memory instance creation. + +If **memory** or **\*memory** is a null pointer, this method only prints warning logs and does not execute the release logic. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output memory release, the index value for the three outputs is **{0, 1, 2}**. | +| memory | Level-2 pointer to the [OH_NN_Memory](_o_h___n_n___memory.md) instance. After shared memory is destroyed, this method sets **\*memory** to a null pointer. | + + +### OH_NNExecutor_GetOutputShape() + + +``` +OH_NN_ReturnCode OH_NNExecutor_GetOutputShape (OH_NNExecutor * executor, uint32_t outputIndex, int32_t ** shape, uint32_t * shapeLength ) +``` +**Description**
+Obtains the dimension information about the output tensor. + +After [OH_NNExecutor_Run](#oh_nnexecutor_run) is called to complete a single inference, call this method to obtain the specified output dimension information and number of dimensions. It is commonly used in dynamic shape input and output scenarios. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When [OH_NNExecutor_GetOutputShape](#oh_nnexecutor_getoutputshape) is called to obtain dimension information about the output tensor, **outputIndices** is **{0, 1, 2}**. | +| shape | Pointer to the int32_t array. The value of each element in the array is the length of the output tensor in each dimension. | +| shapeLength | Pointer to the uint32_t type. The number of output dimensions is returned. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_Run() + + +``` +OH_NN_ReturnCode OH_NNExecutor_Run (OH_NNExecutor * executor) +``` +**Description**
+Performs inference. + +Performs end-to-end inference and computing of the model on the device associated with the executor. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_SetInput() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetInput (OH_NNExecutor * executor, uint32_t inputIndex, const OH_NN_Tensor * tensor, const void * dataBuffer, size_t length ) +``` +**Description**
+Sets the single input data for a model. + +This method copies the data whose length is specified by **length** (in bytes) in **dataBuffer** to the shared memory of the underlying device. **inputIndex** specifies the input to be set and **tensor** sets information such as the input shape, type, and quantization parameters. + +Neural Network Runtime supports models with dynamical shape input. For fixed shape input and dynamic shape input scenarios, this method uses different processing policies. + +- Fixed shape input: The attributes of **tensor** must be the same as those of the tensor added by calling [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) in the composition phase. + +- Dynamic shape input: In the composition phase, because the shape is not fixed, each value in **tensor.dimensions** must be greater than **0** in the method calls to determine the shape input in the calculation phase. When setting the shape, you can modify only the dimension whose value is **-1**. Assume that **[-1, 224, 224, 3]** is input as the the dimension of A in the composition phase. When this method is called, only the size of the first dimension can be modified, for example, to **[3, 224, 224, 3]**. If other dimensions are adjusted, OH_NN_INVALID_PARAMETER is returned. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In input settings, the index value for the three inputs is **{0, 1, 2}**. | +| tensor | Sets the tensor corresponding to the input data. | +| dataBuffer | Pointer to the input data. | +| length | Length of the data buffer, in bytes. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_SetInputWithMemory() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetInputWithMemory (OH_NNExecutor * executor, uint32_t inputIndex, const OH_NN_Tensor * tensor, const OH_NN_Memory * memory ) +``` +**Description**
+Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input. + +In scenarios where memory needs to be managed by yourself, this method binds the execution input to the [OH_NN_Memory](_o_h___n_n___memory.md) memory instance. During computing, the underlying device reads the input data from the shared memory pointed to by the memory instance. By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| inputIndex | Input index value, which is in the same sequence of the data input when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **inputIndices** is **{1, 5, 9}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When the input shared memory is specified, the index value for the three inputs is **{0, 1, 2}**. | +| tensor | Pointer to [OH_NN_Tensor](_o_h___n_n___tensor.md), used to set the tensor corresponding to a single input. | +| memory | Pointer to [OH_NN_Memory](_o_h___n_n___memory.md). | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_SetOutput() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetOutput (OH_NNExecutor * executor, uint32_t outputIndex, void * dataBuffer, size_t length ) +``` +**Description**
+Sets the buffer for a single output of a model. + +This method binds the buffer to which **dataBuffer** points to the output specified by **outputIndex**. The length of the buffer is specified by **length**. + +After [OH_NNExecutor_Run](#oh_nnexecutor_run) is called to complete a single model inference, Neural Network Runtime compares the length of the buffer to which **dataBuffer** points with the length of the output data and returns different results based on the actual situation. + +- If the buffer length is greater than or equal to the data length, the inference result is copied to the buffer and OH_NN_SUCCESS is returned. You can read the inference result from **dataBuffer**. + +- If the buffer length is smaller than the data length, [OH_NNExecutor_Run](#oh_nnexecutor_run) returns OH_NN_INVALID_PARAMETER and generates a log indicating that the buffer is too small. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Pointer to the [OH_NNExecutor](#oh_nnexecutor) instance. | +| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. In output buffer settings, the index value for the three outputs is **{0, 1, 2}**. | +| dataBuffer | Pointer to the output data. | +| length | Length of the data buffer, in bytes. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNExecutor_SetOutputWithMemory() + + +``` +OH_NN_ReturnCode OH_NNExecutor_SetOutputWithMemory (OH_NNExecutor * executor, uint32_t outputIndex, const OH_NN_Memory * memory ) +``` +**Description**
+Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output. + +In scenarios where memory needs to be managed by yourself, this method binds the execution output to the [OH_NN_Memory](_o_h___n_n___memory.md) memory instance. When computing is performed, the underlying hardware directly writes the computing result to the shared memory to which the memory instance points. By using this method, concurrent execution of input setting, computing, and read can be implemented to improve inference efficiency of a data flow. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| executor | Executor. | +| outputIndex | Output Index value, which is in the same sequence of the data output when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. Assume that the value of **outputIndices** is **{4, 6, 8}** when [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) is called. When output shared memory is specified, the index value for the three outputs is **{0, 1, 2}**. | +| memory | Pointer to [OH_NN_Memory](_o_h___n_n___memory.md). | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_AddOperation() + + +``` +OH_NN_ReturnCode OH_NNModel_AddOperation (OH_NNModel * model, OH_NN_OperationType op, const OH_NN_UInt32Array * paramIndices, const OH_NN_UInt32Array * inputIndices, const OH_NN_UInt32Array * outputIndices ) +``` +**Description**
+Adds an operator to a model instance. + +This method is used to add an operator to a model instance. The operator type is specified by **op**, and the operator parameters, inputs, and outputs are specified by **paramIndices**, **inputIndices**, and **outputIndices** respectively. This method verifies the attributes of operator parameters and the number of input and output parameters. These attributes must be correctly set when [OH_NNModel_AddTensor](#oh_nnmodel_addtensor) is called to add tensors. For details about the expected parameters, input attributes, and output attributes of each operator, see [OH_NN_OperationType](#oh_nn_operationtype). + +**paramIndices**, **inputIndices**, and **outputIndices** store index values of tensors. Index values are determined by the sequence in which tensors are added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor). + +If unnecessary parameters are added for adding an operator, this method returns OH_NN_INVALID_PARAMETER. If no operator parameter is set, the operator uses the default parameter value. For details about the default values, see [OH_NN_OperationType](#oh_nn_operationtype). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | +| op | Specifies the type of an operator to be added. For details, see the enumerated values of [OH_NN_OperationType](#oh_nn_operationtype). | +| paramIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set operator parameters. | +| inputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator input. | +| outputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator output. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_AddTensor() + + +``` +OH_NN_ReturnCode OH_NNModel_AddTensor (OH_NNModel * model, const OH_NN_Tensor * tensor ) +``` +**Description**
+Adds a tensor to a model instance. + +The data node and operator parameters in the Neural Network Runtime model are composed of tensors of the model. This method is used to add tensors to a model instance based on the **tensor** parameter. The sequence of adding tensors is specified by the index value recorded in the model. The [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), and [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) methods specifies tensors based on the index value. + +Neural Network Runtime supports inputs and outputs of the dynamic shape. When adding a data node with a dynamic shape, you need to set the dimensions that support dynamic changes in **tensor.dimensions** to **-1**. For example, if **tensor.dimensions** of a four-dimensional tensor is set to **[1, -1, 2, 2]**, the second dimension supports dynamic changes. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | +| tensor | Pointer to the [OH_NN_Tensor](_o_h___n_n___tensor.md) tensor. The tensor specifies the attributes of the tensor added to the model instance. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_Construct() + + +``` +OH_NNModel* OH_NNModel_Construct (void ) +``` +**Description**
+Creates a model instance of the [OH_NNModel](#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance. + +Before composition, call [OH_NNModel_Construct](#oh_nnmodel_construct) to create a model instance. Based on the model topology, call the [OH_NNModel_AddTensor](#oh_nnmodel_addtensor), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), and [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata) methods to fill in the data and operator nodes of the model, and then call [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) to specify the inputs and outputs of the model. After the model topology is constructed, call [OH_NNModel_Finish](#oh_nnmodel_finish) to build the model. + +After a model instance is used, you need to destroy it by calling [OH_NNModel_Destroy](#oh_nnmodel_destroy) to avoid memory leak. + +**Returns** + +Returns the pointer to a [OH_NNModel](#oh_nnmodel) instance. + + +### OH_NNModel_Destroy() + + +``` +void OH_NNModel_Destroy (OH_NNModel ** model) +``` +**Description**
+Releases a model instance. + +This method needs to be called to release the model instance created by calling [OH_NNModel_Construct](#oh_nnmodel_construct). Otherwise, memory leak will occur. + +If **model** or **\*model** is a null pointer, this method only prints warning logs and does not execute the release logic. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Level-2 pointer to the [OH_NNModel](#oh_nnmodel) instance. After a model instance is destroyed, this method sets **\*model** to a null pointer. | + + +### OH_NNModel_Finish() + + +``` +OH_NN_ReturnCode OH_NNModel_Finish (OH_NNModel * model) +``` +**Description**
+Completes model composition. + +After the model topology is set up, call this method to indicate that the composition is complete. After this method is called, additional composition operations cannot be performed. If [OH_NNModel_AddTensor](#oh_nnmodel_addtensor), [OH_NNModel_AddOperation](#oh_nnmodel_addoperation), [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata), and [OH_NNModel_SpecifyInputsAndOutputs](#oh_nnmodel_specifyinputsandoutputs) are called, OH_NN_OPERATION_FORBIDDEN is returned. + +Before calling [OH_NNModel_GetAvailableOperations](#oh_nnmodel_getavailableoperations) and [OH_NNCompilation_Construct](#oh_nncompilation_construct), you must call this method to complete composition. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_GetAvailableOperations() + + +``` +OH_NN_ReturnCode OH_NNModel_GetAvailableOperations (OH_NNModel * model, size_t deviceID, const bool ** isSupported, uint32_t * opCount ) +``` +**Description**
+Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. + +Queries whether underlying device supports operators in a model instance. The device is specified by **deviceID**, and the result is represented by the array pointed by **isSupported**. If the ith operator is supported, the value of **(\*isSupported)**[i] is **true**. Otherwise, the value is **false**. + +After this method is successfully executed, **(\*isSupported)** points to the bool array that records the operator support status. The operator quantity for the array length is the same as that for the model instance. The memory corresponding to this array is managed by Neural Network Runtime and is automatically destroyed after the model instance is destroyed or this method is called again. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | +| deviceID | Device ID to be queried, which can be obtained by using [OH_NNDevice_GetAllDevicesID](#oh_nndevice_getalldevicesid). | +| isSupported | Pointer to the bool array. When this method is called, **(\*isSupported)** must be a null pointer. Otherwise, OH_NN_INVALID_PARAMETER is returned. | +| opCount | Number of operators in a model instance, corresponding to the length of the **(\*isSupported)** array. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_SetTensorData() + + +``` +OH_NN_ReturnCode OH_NNModel_SetTensorData (OH_NNModel * model, uint32_t index, const void * dataBuffer, size_t length ) +``` +**Description**
+Sets the tensor value. + +For tensors with constant values (such as model weights), you need to use this method in the composition phase. The index value of a tensor is determined by the sequence in which the tensor is added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | +| index | Index value of a tensor. | +| dataBuffer | Pointer to real data. | +| length | Length of the data buffer. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). + + +### OH_NNModel_SpecifyInputsAndOutputs() + + +``` +OH_NN_ReturnCode OH_NNModel_SpecifyInputsAndOutputs (OH_NNModel * model, const OH_NN_UInt32Array * inputIndices, const OH_NN_UInt32Array * outputIndices ) +``` +**Description**
+Specifies the inputs and outputs of a model. + +A tensor must be specified as the end-to-end inputs and outputs of a model instance. This type of tensor cannot be set using [OH_NNModel_SetTensorData](#oh_nnmodel_settensordata). The **OH_NNExecutor** method needs to be called in the execution phase to set the input and output data. + +The index value of a tensor is determined by the sequence in which the tensor is added to the model. For details about how to add a tensor, see [OH_NNModel_AddTensor](#oh_nnmodel_addtensor). + +Currently, the model inputs and outputs cannot be set asynchronously. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| model | Pointer to the [OH_NNModel](#oh_nnmodel) instance. | +| inputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator input. | +| outputIndices | Pointer to the **[OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md)** instance, which is used to set the operator output. | + +**Returns** + +Execution result of the function. If the operation is successful, **OH_NN_SUCCESS** is returned. If the operation fails, an error code is returned. For details about the error codes, see [OH_NN_ReturnCode](#oh_nn_returncode). \ No newline at end of file diff --git a/en/application-dev/reference/native-apis/_o_h___a_i___call_back_param.md b/en/application-dev/reference/native-apis/_o_h___a_i___call_back_param.md new file mode 100644 index 0000000000000000000000000000000000000000..3d129f96d0c17a196c9f94dfbf33302cf3db2fc3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_i___call_back_param.md @@ -0,0 +1,47 @@ +# OH_AI_CallBackParam + + +## Overview + +Defines the operator information passed in a callback. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [node_name](#node_name) |Operator name | +| [node_type](#node_type) |Operator type | + + +## Member Variable Description + + +### node_name + + +``` +char* OH_AI_CallBackParam::node_name +``` +**Description**
+Operator name + + +### node_type + + +``` +char* OH_AI_CallBackParam::node_type +``` +**Description**
+Operator type diff --git a/en/application-dev/reference/native-apis/_o_h___a_i___shape_info.md b/en/application-dev/reference/native-apis/_o_h___a_i___shape_info.md new file mode 100644 index 0000000000000000000000000000000000000000..f5b66a817867c749472da61909a1a3307aa351ee --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_i___shape_info.md @@ -0,0 +1,44 @@ +# OH_AI_ShapeInfo + + +## Overview + +Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [shape_num](#shape_num) | size_t
Dimension array length | +| [shape](#shape) [[OH_AI_MAX_SHAPE_NUM](_mind_spore.md#oh_ai_max_shape_num)] | Dimension array | + + +## Member Variable Description + + +### shape + + +``` +int64_t OH_AI_ShapeInfo::shape[OH_AI_MAX_SHAPE_NUM] +``` +**Description**
+Dimension array + + +### shape_num + + +``` +size_t OH_AI_ShapeInfo::shape_num +``` +**Description**
+Dimension array length diff --git a/en/application-dev/reference/native-apis/_o_h___a_i___tensor_handle_array.md b/en/application-dev/reference/native-apis/_o_h___a_i___tensor_handle_array.md new file mode 100644 index 0000000000000000000000000000000000000000..4d0271c0f16f845ddc0058c7e23df1ea46492e1e --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_i___tensor_handle_array.md @@ -0,0 +1,47 @@ +# OH_AI_TensorHandleArray + + +## Overview + +Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [handle_num](#handle_num) | Tensor array length | +| [handle_list](#handle_list) | Tensor array pointer | + + +## Member Variable Description + + +### handle_list + + +``` +OH_AI_TensorHandle* OH_AI_TensorHandleArray::handle_list +``` +**Description**
+Tensor array pointer + + +### handle_num + + +``` +size_t OH_AI_TensorHandleArray::handle_num +``` +**Description**
+Tensor array length diff --git a/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md b/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md new file mode 100644 index 0000000000000000000000000000000000000000..adb8cb60db7a3d9a894fec49b7bbe87c1a370315 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_v_codec_async_callback.md @@ -0,0 +1,28 @@ +# OH_AVCodecAsyncCallback + + +## Overview + +Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since:** +9 + +**Related Modules:** + +[CodecBase](_codec_base.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| **onError** | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror) | +| **onStreamChanged** | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged) | +| **onNeedInputData** | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) | +| **onNeedOutputData** | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata) | diff --git a/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md b/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md new file mode 100644 index 0000000000000000000000000000000000000000..dc711939d91580c22bee2583d8e3c93b69247976 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___a_v_codec_buffer_attr.md @@ -0,0 +1,28 @@ +# OH_AVCodecBufferAttr + + +## Overview + +Defines the buffer attributes of an **OH_AVCodec** instance. + +\@syscap SystemCapability.Multimedia.Media.CodecBase + +**Since:** +9 + +**Related Modules:** + +[CodecBase](_codec_base.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [pts](_codec_base.md#pts) | Presentation timestamp of the buffer, in microseconds.| +| [size](_codec_base.md#size) | Size of the data contained in the buffer, in bytes. | +| [offset](_codec_base.md#offset) | Start offset of valid data in the buffer. | +| [flags](_codec_base.md#flags) | Buffer flag, which is a combination of multiple **OH_AVCodecBufferFlags**. | diff --git a/en/application-dev/reference/native-apis/_o_h___drawing___bitmap_format.md b/en/application-dev/reference/native-apis/_o_h___drawing___bitmap_format.md new file mode 100644 index 0000000000000000000000000000000000000000..ca8f27de37d540f6080ce2ece7b8178685ef2975 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___drawing___bitmap_format.md @@ -0,0 +1,47 @@ +# OH_Drawing_BitmapFormat + + +## Overview + +Defines the pixel format of a bitmap, including the color type and alpha type. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [colorFormat](#colorformat) | Storage format of bitmap pixels | +| [alphaFormat](#alphaformat) | Alpha format of bitmap pixels | + + +## Member Variable Description + + +### alphaFormat + + +``` +OH_Drawing_AlphaFormat OH_Drawing_BitmapFormat::alphaFormat +``` +**Description**
+Alpha format of bitmap pixels + + +### colorFormat + + +``` +OH_Drawing_ColorFormat OH_Drawing_BitmapFormat::colorFormat +``` +**Description**
+Storage format of bitmap pixels diff --git a/en/application-dev/reference/native-apis/_o_h___huks___blob.md b/en/application-dev/reference/native-apis/_o_h___huks___blob.md new file mode 100644 index 0000000000000000000000000000000000000000..a4aa174fe62869d837d1113d285a07b6563c48b7 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___blob.md @@ -0,0 +1,47 @@ +# OH_Huks_Blob + + +## Overview + +Defines the structure for storing data. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [size](#size) | Data size. | +| [data](#data) | Pointer to the memory in which the data is stored. | + + +## Member Variable Description + + +### data + + +``` +uint8_t* OH_Huks_Blob::data +``` +**Description**
+Pointer to the memory in which the data is stored. + + +### size + + +``` +uint32_t OH_Huks_Blob::size +``` +**Description**
+Data size. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___cert_chain.md b/en/application-dev/reference/native-apis/_o_h___huks___cert_chain.md new file mode 100644 index 0000000000000000000000000000000000000000..838dd3761f3ce9880895248a181c7fe09e241fc6 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___cert_chain.md @@ -0,0 +1,47 @@ +# OH_Huks_CertChain + + +## Overview + +Defines the structure of the certificate chain. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [certs](#certs) | Pointer to the certificate data. | +| [certsCount](#certscount) | Number of certificates. | + + +## Member Variable Description + + +### certs + + +``` +struct OH_Huks_Blob* OH_Huks_CertChain::certs +``` +**Description**
+Pointer to the certificate data. + + +### certsCount + + +``` +uint32_t OH_Huks_CertChain::certsCount +``` +**Description**
+Number of certificates. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_info.md b/en/application-dev/reference/native-apis/_o_h___huks___key_info.md new file mode 100644 index 0000000000000000000000000000000000000000..22919520392f44d1d748a87fa22aa4f58391be06 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_info.md @@ -0,0 +1,47 @@ +# OH_Huks_KeyInfo + + +## Overview + +Defines the key information structure. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [alias](#alias) | Alias of the key. | +| [paramSet](#paramset) | Pointer to the key parameter set. | + + +## Member Variable Description + + +### alias + + +``` +struct OH_Huks_Blob OH_Huks_KeyInfo::alias +``` +**Description**
+Alias of the key. + + +### paramSet + + +``` +struct OH_Huks_ParamSet* OH_Huks_KeyInfo::paramSet +``` +**Description**
+Pointer to the key parameter set. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_material25519.md b/en/application-dev/reference/native-apis/_o_h___huks___key_material25519.md new file mode 100644 index 0000000000000000000000000000000000000000..ae81e65e70f1b8d25e04c3f8867d207806f43f2b --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_material25519.md @@ -0,0 +1,80 @@ +# OH_Huks_KeyMaterial25519 + + +## Overview + +Defines the structure of a 25519 key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) | Algorithm of the key. | +| [keySize](#keysize) | Length of the 25519 key. | +| [pubKeySize](#pubkeysize) | Length of the public key. | +| [priKeySize](#prikeysize) | Length of the private key. | +| [reserved](#reserved) | Reserved. | + + +## Member Variable Description + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_KeyMaterial25519::keyAlg +``` +**Description**
+Algorithm of the key. + + +### keySize + + +``` +uint32_t OH_Huks_KeyMaterial25519::keySize +``` +**Description**
+Length of the 25519 key. + + +### priKeySize + + +``` +uint32_t OH_Huks_KeyMaterial25519::priKeySize +``` +**Description**
+Length of the private key. + + +### pubKeySize + + +``` +uint32_t OH_Huks_KeyMaterial25519::pubKeySize +``` +**Description**
+Length of the public key. + + +### reserved + + +``` +uint32_t OH_Huks_KeyMaterial25519::reserved +``` +**Description**
+Reserved. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_material_dh.md b/en/application-dev/reference/native-apis/_o_h___huks___key_material_dh.md new file mode 100644 index 0000000000000000000000000000000000000000..1c7dcce47e7ace87738c3772bedfb2fc19be0be9 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_material_dh.md @@ -0,0 +1,80 @@ +# OH_Huks_KeyMaterialDh + + +## Overview + +Defines the structure of a DH key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) |Algorithm of the key. | +| [keySize](#keysize) | Length of the DH key. | +| [pubKeySize](#pubkeysize) | Length of the public key. | +| [priKeySize](#prikeysize) | Length of the private key. | +| [reserved](#reserved) | Reserved. | + + +## Member Variable Description + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_KeyMaterialDh::keyAlg +``` +**Description**
+Algorithm of the key. + + +### keySize + + +``` +uint32_t OH_Huks_KeyMaterialDh::keySize +``` +**Description**
+Length of the DH key. + + +### priKeySize + + +``` +uint32_t OH_Huks_KeyMaterialDh::priKeySize +``` +**Description**
+Length of the private key. + + +### pubKeySize + + +``` +uint32_t OH_Huks_KeyMaterialDh::pubKeySize +``` +**Description**
+Length of the public key. + + +### reserved + + +``` +uint32_t OH_Huks_KeyMaterialDh::reserved +``` +**Description**
+Reserved. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_material_dsa.md b/en/application-dev/reference/native-apis/_o_h___huks___key_material_dsa.md new file mode 100644 index 0000000000000000000000000000000000000000..b1932e43ec2941f2adf28d12bd6d9357fcdec8e9 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_material_dsa.md @@ -0,0 +1,102 @@ +# OH_Huks_KeyMaterialDsa + + +## Overview + +Defines the structure of a DSA key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) |Algorithm of the key. | +| [keySize](#keysize) | Length of the key. | +| [xSize](#xsize) | Length of the x value. | +| [ySize](#ysize) | Length of the y value. | +| [pSize](#psize) | Length of the p value. | +| [qSize](#qsize) | Length of the q value. | +| [gSize](#gsize) | Length of the g value. | + + +## Member Variable Description + + +### gSize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::gSize +``` +**Description**
+Length of the g value. + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_KeyMaterialDsa::keyAlg +``` +**Description**
+Algorithm of the key. + + +### keySize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::keySize +``` +**Description**
+Length of the key. + + +### pSize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::pSize +``` +**Description**
+Length of the p value. + + +### qSize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::qSize +``` +**Description**
+Length of the q value. + + +### xSize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::xSize +``` +**Description**
+Length of the x value. + + +### ySize + + +``` +uint32_t OH_Huks_KeyMaterialDsa::ySize +``` +**Description**
+Length of the y value. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_material_ecc.md b/en/application-dev/reference/native-apis/_o_h___huks___key_material_ecc.md new file mode 100644 index 0000000000000000000000000000000000000000..471e8ce5495489235b2096a5fcfb7e64082c82f3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_material_ecc.md @@ -0,0 +1,80 @@ +# OH_Huks_KeyMaterialEcc + + +## Overview + +Defines the structure of an ECC key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) |Algorithm of the key. | +| [keySize](#keysize) | Length of the key. | +| [xSize](#xsize) | Length of the x value. | +| [ySize](#ysize) | Length of the y value. | +| [zSize](#zsize) | Length of the z value. | + + +## Member Variable Description + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_KeyMaterialEcc::keyAlg +``` +**Description**
+Algorithm of the key. + + +### keySize + + +``` +uint32_t OH_Huks_KeyMaterialEcc::keySize +``` +**Description**
+Length of the key. + + +### xSize + + +``` +uint32_t OH_Huks_KeyMaterialEcc::xSize +``` +**Description**
+Length of the x value. + + +### ySize + + +``` +uint32_t OH_Huks_KeyMaterialEcc::ySize +``` +**Description**
+Length of the y value. + + +### zSize + + +``` +uint32_t OH_Huks_KeyMaterialEcc::zSize +``` +**Description**
+Length of the z value. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___key_material_rsa.md b/en/application-dev/reference/native-apis/_o_h___huks___key_material_rsa.md new file mode 100644 index 0000000000000000000000000000000000000000..579e97778e504e772aca232cda81ba0a838b2320 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___key_material_rsa.md @@ -0,0 +1,80 @@ +# OH_Huks_KeyMaterialRsa + + +## Overview + +Defines the structure of an RSA key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) |Algorithm of the key. | +| [keySize](#keysize) | Length of the key. | +| [nSize](#nsize) | Length of the n value. | +| [eSize](#esize) | Length of the e value. | +| [dSize](#dsize) | Length of the d value. | + + +## Member Variable Description + + +### dSize + + +``` +uint32_t OH_Huks_KeyMaterialRsa::dSize +``` +**Description**
+Length of the d value. + + +### eSize + + +``` +uint32_t OH_Huks_KeyMaterialRsa::eSize +``` +**Description**
+Length of the e value. + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_KeyMaterialRsa::keyAlg +``` +**Description**
+Algorithm of the key. + + +### keySize + + +``` +uint32_t OH_Huks_KeyMaterialRsa::keySize +``` +**Description**
+Length of the key. + + +### nSize + + +``` +uint32_t OH_Huks_KeyMaterialRsa::nSize +``` +**Description**
+Length of the n value. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___param.md b/en/application-dev/reference/native-apis/_o_h___huks___param.md new file mode 100644 index 0000000000000000000000000000000000000000..3402901d156b11f779325f3095f86291a5e1d0d0 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___param.md @@ -0,0 +1,87 @@ +# OH_Huks_Param + + +## Overview + +Defines the parameter structure in a parameter set. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [tag](#tag) | Tag value. | +| union {
bool [boolParam](#boolparam)
int32_t [int32Param](#int32param)
uint32_t [uint32Param](#uint32param)
uint64_t [uint64Param](#uint64param)
struct [OH_Huks_Blob](_o_h___huks___blob.md)[blob](#blob)
}; | boolParam:Parameter of the Boolean type.
int32Param:Parameter of the int32_t type.
uint32Param:Parameter of the uint32_t type.
Parameter of the uint64_t type.
blob:Parameter of the struct [OH_Huks_Blob](_o_h___huks___blob.md) type.| + + +## Member Variable Description + + +### blob + + +``` +struct OH_Huks_Blob OH_Huks_Param::blob +``` +**Description**
+Parameter of the struct [OH_Huks_Blob](_o_h___huks___blob.md) type. + + +### boolParam + + +``` +bool OH_Huks_Param::boolParam +``` +**Description**
+Parameter of the Boolean type. + + +### int32Param + + +``` +int32_t OH_Huks_Param::int32Param +``` +**Description**
+Parameter of the int32_t type. + + +### tag + + +``` +uint32_t OH_Huks_Param::tag +``` +**Description**
+Tag value. + + +### uint32Param + + +``` +uint32_t OH_Huks_Param::uint32Param +``` +**Description**
+Parameter of the uint32_t type. + + +### uint64Param + + +``` +uint64_t OH_Huks_Param::uint64Param +``` +**Description**
+Parameter of the uint64_t type. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___param_set.md b/en/application-dev/reference/native-apis/_o_h___huks___param_set.md new file mode 100644 index 0000000000000000000000000000000000000000..7ad7e4811f23990445987b77b66bda2997e5335a --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___param_set.md @@ -0,0 +1,58 @@ +# OH_Huks_ParamSet + + +## Overview + +Defines the structure of the parameter set. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [paramSetSize](#paramsetsize) | Memory size of the parameter set. | +| [paramsCnt](#paramscnt) | Number of parameters in the parameter set. | +| [params](#params) [] | Parameter array. | + + +## Member Variable Description + + +### params + + +``` +struct OH_Huks_Param OH_Huks_ParamSet::params[] +``` +**Description**
+Parameter array. + + +### paramsCnt + + +``` +uint32_t OH_Huks_ParamSet::paramsCnt +``` +**Description**
+Number of parameters in the parameter set. + + +### paramSetSize + + +``` +uint32_t OH_Huks_ParamSet::paramSetSize +``` +**Description**
+Memory size of the parameter set. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___pub_key_info.md b/en/application-dev/reference/native-apis/_o_h___huks___pub_key_info.md new file mode 100644 index 0000000000000000000000000000000000000000..fd13a26e4894d414eeb5a386223965e4775d6d3f --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___pub_key_info.md @@ -0,0 +1,80 @@ +# OH_Huks_PubKeyInfo + + +## Overview + +Defines the structure of a public key. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [keyAlg](#keyalg) |Algorithm of the public key. | +| [keySize](#keysize) | Length of the public key. | +| [nOrXSize](#norxsize) | Length of the n or X value. | +| [eOrYSize](#eorysize) | Length of the e or Y value. | +| [placeHolder](#placeholder) | Placeholder size. | + + +## Member Variable Description + + +### eOrYSize + + +``` +uint32_t OH_Huks_PubKeyInfo::eOrYSize +``` +**Description**
+Length of the e or Y value. + + +### keyAlg + + +``` +enum OH_Huks_KeyAlg OH_Huks_PubKeyInfo::keyAlg +``` +**Description**
+Algorithm of the public key. + + +### keySize + + +``` +uint32_t OH_Huks_PubKeyInfo::keySize +``` +**Description**
+Length of the public key. + + +### nOrXSize + + +``` +uint32_t OH_Huks_PubKeyInfo::nOrXSize +``` +**Description**
+Length of the n or X value. + + +### placeHolder + + +``` +uint32_t OH_Huks_PubKeyInfo::placeHolder +``` +**Description**
+Placeholder size. diff --git a/en/application-dev/reference/native-apis/_o_h___huks___result.md b/en/application-dev/reference/native-apis/_o_h___huks___result.md new file mode 100644 index 0000000000000000000000000000000000000000..dbe5e980641aac91b26838bac9b0d72a368245c3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___huks___result.md @@ -0,0 +1,58 @@ +# OH_Huks_Result + + +## Overview + +Defines the return data, including the result code and message. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [errorCode](#errorcode) | Result code. | +| [errorMsg](#errormsg) | Description of the result code. | +| [data](#data) | Other data returned. | + + +## Member Variable Description + + +### data + + +``` +uint8_t* OH_Huks_Result::data +``` +**Description**
+Other data returned. + + +### errorCode + + +``` +int32_t OH_Huks_Result::errorCode +``` +**Description**
+Result code. + + +### errorMsg + + +``` +const char* OH_Huks_Result::errorMsg +``` +**Description**
+Description of the result code. diff --git a/en/application-dev/reference/native-apis/_o_h___n_n___memory.md b/en/application-dev/reference/native-apis/_o_h___n_n___memory.md new file mode 100644 index 0000000000000000000000000000000000000000..961ce156d806dd4aa010c61bda0d10ac99ffb773 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___n_n___memory.md @@ -0,0 +1,47 @@ +# OH_NN_Memory + + +## Overview + +Defines the memory structure. + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [data](#data) |Pointer to the shared memory. The shared memory is usually allocated by the underlying hardware driver. | +| [length](#length) |Records the length of the shared memory, in bytes. | + + +## Member Variable Description + + +### data + + +``` +void* const OH_NN_Memory::data +``` +**Description**
+Pointer to the shared memory. The shared memory is usually allocated by the underlying hardware driver. + + +### length + + +``` +const size_t OH_NN_Memory::length +``` +**Description**
+Records the length of the shared memory, in bytes. diff --git a/en/application-dev/reference/native-apis/_o_h___n_n___quant_param.md b/en/application-dev/reference/native-apis/_o_h___n_n___quant_param.md new file mode 100644 index 0000000000000000000000000000000000000000..1a4d6adc08101d15a68055df9e96775adc22a964 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___n_n___quant_param.md @@ -0,0 +1,75 @@ +# OH_NN_QuantParam + + +## Overview + +Quantization information. + +In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula: + +s and z are quantization parameters, which are stored by **scale** and **zeroPoint** in OH_NN_QuantParam. r is a floating point number, q is the quantization result, q_min is the lower bound of the quantization result, and q_max is an upper bound of a quantization result. The calculation method is as follows: + +The clamp function is defined as follows: + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [quantCount](#quantcount) | Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, **quantCount** is usually set to **1**. That is, all channels of a tensor share a set of quantization parameters. In the per-channel quantization scenario, **quantCount** is usually the same as the number of tensor channels, and each channel uses its own quantization parameters. | +| [numBits](#numbits) | Number of quantization bits | +| [scale](#scale) | Pointer to the scale data in the quantization formula | +| [zeroPoint](#zeropoint) | Pointer to the zero point data in the quantization formula | + + +## Member Variable Description + + +### numBits + + +``` +const uint32_t* OH_NN_QuantParam::numBits +``` +**Description**
+Number of quantization bits + + +### quantCount + + +``` +uint32_t OH_NN_QuantParam::quantCount +``` +**Description**
+Specifies the length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, **quantCount** is usually set to **1**. That is, all channels of a tensor share a set of quantization parameters. In the per-channel quantization scenario, **quantCount** is usually the same as the number of tensor channels, and each channel uses its own quantization parameters. + + +### scale + + +``` +const double* OH_NN_QuantParam::scale +``` +**Description**
+Pointer to the scale data in the quantization formula + + +### zeroPoint + + +``` +const int32_t* OH_NN_QuantParam::zeroPoint +``` +**Description**
+Pointer to the zero point data in the quantization formula diff --git a/en/application-dev/reference/native-apis/_o_h___n_n___tensor.md b/en/application-dev/reference/native-apis/_o_h___n_n___tensor.md new file mode 100644 index 0000000000000000000000000000000000000000..28e8b43e1d3e87463ba4cceab3061323d1d89712 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___n_n___tensor.md @@ -0,0 +1,82 @@ +# OH_NN_Tensor + + +## Overview + +Defines the tensor structure. + +It is usually used to construct data nodes and operator parameters in a model graph. When constructing a tensor, you need to specify the data type, number of dimensions, dimension information, and quantization information. + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [dataType](#datatype) | Data type of the specified tensor. The value must be an enumerated value of [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype). | +| [dimensionCount](#dimensioncount) | Number of dimensions of the specified tensor | +| [dimensions](#dimensions) | Dimension information (shape) of the specified tensor | +| [quantParam](#quantparam) | Quantization information of the specified tensor. The data type must be [OH_NN_QuantParam](_o_h___n_n___quant_param.md). | +| [type](#type) | Specifies the tensor type. The value of **type** is related to the tensor usage. When the tensor is used as the input or output of the model, set **type** to [OH_NN_TENSOR](_neural_nework_runtime.md). When a tensor is used as an operator parameter, select any enumerated value except [OH_NN_TENSOR](_neural_nework_runtime.md) from [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype). | + + +## Member Variable Description + + +### dataType + + +``` +OH_NN_DataType OH_NN_Tensor::dataType +``` +**Description**
+Data type of the specified tensor. The value must be an enumerated value of [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype). + + +### dimensionCount + + +``` +uint32_t OH_NN_Tensor::dimensionCount +``` +**Description**
+Number of dimensions of the specified tensor + + +### dimensions + + +``` +const int32_t* OH_NN_Tensor::dimensions +``` +**Description**
+Dimension information (shape) of the specified tensor + + +### quantParam + + +``` +const OH_NN_QuantParam* OH_NN_Tensor::quantParam +``` +**Description**
+Quantization information of the specified tensor. The data type must be [OH_NN_QuantParam](_o_h___n_n___quant_param.md). + + +### type + + +``` +OH_NN_TensorType OH_NN_Tensor::type +``` +**Description**
+Specifies the tensor type. The value of **type** is related to the tensor usage. When the tensor is used as the input or output of the model, set **type** to [OH_NN_TENSOR](_neural_nework_runtime.md). When a tensor is used as an operator parameter, select any enumerated value except [OH_NN_TENSOR](_neural_nework_runtime.md) from [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype). diff --git a/en/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md b/en/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md new file mode 100644 index 0000000000000000000000000000000000000000..6041af7daa397d904754fec66797c37730b224a3 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___n_n___u_int32_array.md @@ -0,0 +1,47 @@ +# OH_NN_UInt32Array + + +## Overview + +This structure is used to store a 32-bit unsigned integer array. + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [data](#data) | Pointer to the unsigned integer array | +| [size](#size) | Array length | + + +## Member Variable Description + + +### data + + +``` +uint32_t* OH_NN_UInt32Array::data +``` +**Description**
+Pointer to the unsigned integer array + + +### size + + +``` +uint32_t OH_NN_UInt32Array::size +``` +**Description**
+Array length diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component.md b/en/application-dev/reference/native-apis/_o_h___native_x_component.md new file mode 100644 index 0000000000000000000000000000000000000000..37dd107c618fdd0f6ce9ce2f2e786387c407373d --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component.md @@ -0,0 +1,1184 @@ +# Native XComponent + + +## Overview + +Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES and media data input and displayed on the ArkUI XComponent. + + +**Since:** +8 + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_interface_xcomponent.h](native__interface__xcomponent_8h.md) | Declare the APIs used to access the native XComponent.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) | Describes the touch point of the touch event. | +| [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) | Describes the touch event. | +| [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) | Describes the mouse event. | +| [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) | Registers a callback for the surface lifecycle and touch event. | +| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) | Registers a callback for the mouse event. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent](#oh_nativexcomponent) | Provides an encapsulated OH_NativeXComponent instance. | +| [OH_NativeXComponent_Callback](#oh_nativexcomponent_callback) | Registers a callback for the surface lifecycle and touch event. | +| [OH_NativeXComponent_MouseEvent_Callback](#oh_nativexcomponent_mouseevent_callback) | Registers a callback for the mouse event. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| {OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0,
OH_NATIVEXCOMPONENT_RESULT_FAILED = -1,
OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 } | [Enumerates](#anonymous-enum) the API access states. | +| [OH_NativeXComponent_TouchEventType](#oh_nativexcomponent_toucheventtype) {
OH_NATIVEXCOMPONENT_DOWN = 0,
OH_NATIVEXCOMPONENT_UP,
OH_NATIVEXCOMPONENT_MOVE,
OH_NATIVEXCOMPONENT_CANCEL,
OH_NATIVEXCOMPONENT_UNKNOWN } | Enumerates the touch event types. | +| [OH_NativeXComponent_TouchPointToolType](#oh_nativexcomponent_touchpointtooltype) {
OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0,
OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER,
OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN,
OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER,
OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH,
OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL,
OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH,
OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE,
OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS } | Enumerates the contact point tool types. | +| [OH_NativeXComponent_EventSourceType](#oh_nativexcomponent_eventsourcetype) {
OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0,
OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN,
OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD,
OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK} | Enumerates the source types of the touch event. | +| [OH_NativeXComponent_MouseEventAction](#oh_nativexcomponent_mouseeventaction) {
OH_NATIVEXCOMPONENT_MOUSE_NONE = 0,
OH_NATIVEXCOMPONENT_MOUSE_PRESS,
OH_NATIVEXCOMPONENT_MOUSE_RELEASE,
OH_NATIVEXCOMPONENT_MOUSE_MOVE } | Enumerates the mouse event actions. | +| [OH_NativeXComponent_MouseEventButton](#oh_nativexcomponent_mouseeventbutton) {
OH_NATIVEXCOMPONENT_NONE_BUTTON = 0,
OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01,
OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02,
OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04,
OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08,
OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10 } | Enumerates the mouse event buttons. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent_GetXComponentId](#oh_nativexcomponent_getxcomponentid) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, char \*id, uint64_t \*size) | Obtains the ID of the ArkUI XComponent. | +| [OH_NativeXComponent_GetXComponentSize](#oh_nativexcomponent_getxcomponentsize) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, uint64_t \*width, uint64_t \*height) | Obtains the size of the surface held by the ArkUI XComponent. | +| [OH_NativeXComponent_GetXComponentOffset](#oh_nativexcomponent_getxcomponentoffset) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, double \*x, double \*y) | Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. | +| [OH_NativeXComponent_GetTouchEvent](#oh_nativexcomponent_gettouchevent) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) \*touchEvent) | Obtains the touch event scheduled by the ArkUI XComponent. | +| [OH_NativeXComponent_GetTouchPointToolType](#oh_nativexcomponent_gettouchpointtooltype) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, [OH_NativeXComponent_TouchPointToolType](#oh_nativexcomponent_touchpointtooltype) \*toolType) | Obtains the ArkUI XComponent touch point tool type. | +| [OH_NativeXComponent_GetTouchPointTiltX](#oh_nativexcomponent_gettouchpointtiltx) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, float \*tiltX) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the x-axis. | +| [OH_NativeXComponent_GetTouchPointTiltY](#oh_nativexcomponent_gettouchpointtilty) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, uint32_t pointIndex, float \*tiltY) | Obtains the angle between the tilt of the ArkUI XComponent touch point and the y-axis. | +| [OH_NativeXComponent_GetMouseEvent](#oh_nativexcomponent_getmouseevent) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) \*mouseEvent) | Obtains the mouse event scheduled by ArkUI XComponent. | +| [OH_NativeXComponent_RegisterCallback](#oh_nativexcomponent_registercallback) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) \*callback) | Registers a callback for this **OH_NativeXComponent** instance. | +| [OH_NativeXComponent_RegisterMouseEventCallback](#oh_nativexcomponent_registermouseeventcallback) ([OH_NativeXComponent](#oh_nativexcomponent) \*component, [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) \*callback) | Registers a mouse event callback for this **OH_NativeXComponent** instance. | + + +### Variables + +| Name | Description | +| -------- | -------- | +| [OH_XCOMPONENT_ID_LEN_MAX](#oh_xcomponent_id_len_max) = 128 | Maximum length of an ArkUI XComponent ID. | +| [OH_MAX_TOUCH_POINTS_NUMBER](#oh_max_touch_points_number) = 10 | Maximum number of identifiable touch points in a touch event. | +| [OH_NativeXComponent_TouchPoint::id](#id-12) = 0 | Unique identifier of the finger. | +| [OH_NativeXComponent_TouchPoint::screenX](#screenx-13) = 0.0 | X coordinate of the touch point relative to the left edge of the screen. | +| [OH_NativeXComponent_TouchPoint::screenY](#screeny-13) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen. | +| [OH_NativeXComponent_TouchPoint::x](#x-13) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. | +| [OH_NativeXComponent_TouchPoint::y](#y-13) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. | +| [OH_NativeXComponent_TouchPoint::type](#type-12) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. | +| [OH_NativeXComponent_TouchPoint::size](#size-12) = 0.0 | Contact area between the finger pad and the screen. | +| [OH_NativeXComponent_TouchPoint::force](#force-12) = 0.0 | Pressure of the current touch event. | +| [OH_NativeXComponent_TouchPoint::timeStamp](#timestamp-12) = 0 | Timestamp of the current touch event. | +| [OH_NativeXComponent_TouchPoint::isPressed](#ispressed) = false | Whether the current point is pressed. | +| [OH_NativeXComponent_TouchEvent::id](#id-22) = 0 | Unique identifier of the finger. | +| [OH_NativeXComponent_TouchEvent::screenX](#screenx-23) = 0.0 | X coordinate of the touch point relative to the left edge of the screen. | +| [OH_NativeXComponent_TouchEvent::screenY](#screeny-23) = 0.0 | Y coordinate of the touch point relative to the left edge of the screen. | +| [OH_NativeXComponent_TouchEvent::x](#x-23) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. | +| [OH_NativeXComponent_TouchEvent::y](#y-23) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. | +| [OH_NativeXComponent_TouchEvent::type](#type-22) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. | +| [OH_NativeXComponent_TouchEvent::size](#size-22) = 0.0 | Contact area between the finger pad and the screen. | +| [OH_NativeXComponent_TouchEvent::force](#force-22) = 0.0 | Pressure of the current touch event. | +| [OH_NativeXComponent_TouchEvent::deviceId](#deviceid) = 0 | ID of the device where the current touch event is triggered. | +| [OH_NativeXComponent_TouchEvent::timeStamp](#timestamp-22) = 0 | Timestamp of the current touch event. | +| [OH_NativeXComponent_TouchEvent::touchPoints](#touchpoints) [OH_MAX_TOUCH_POINTS_NUMBER] | Array of the current touch points. | +| [OH_NativeXComponent_TouchEvent::numPoints](#numpoints) = 0 | Number of current touch points. | +| [OH_NativeXComponent_MouseEvent::x](#x-33) = 0.0 | X coordinate of the clicked point relative to the upper left corner of the component. | +| [OH_NativeXComponent_MouseEvent::y](#y-33) = 0.0 | Y coordinate of the clicked point relative to the upper left corner of the component. | +| [OH_NativeXComponent_MouseEvent::screenX](#screenx-33) = 0.0 | X coordinate of the clicked point relative to the upper left corner of the screen. | +| [OH_NativeXComponent_MouseEvent::screenY](#screeny-33) = 0.0 | Y coordinate of the clicked point relative to the upper left corner of the screen. | +| [OH_NativeXComponent_MouseEvent::timestamp](#timestamp) = 0 | Timestamp of the current mouse event. | +| [OH_NativeXComponent_MouseEvent::action](#action) = [OH_NativeXComponent_MouseEventAction::OH_NATIVEXCOMPONENT_MOUSE_NONE](#oh_nativexcomponent_mouseeventaction) | Current mouse event action. | +| [OH_NativeXComponent_MouseEvent::button](#button) = [OH_NativeXComponent_MouseEventButton::OH_NATIVEXCOMPONENT_NONE_BUTTON](#oh_nativexcomponent_mouseeventbutton) | Mouse event button | +| [OH_NativeXComponent_Callback::OnSurfaceCreated](#onsurfacecreated) | Invoked when a surface is created. | +| [OH_NativeXComponent_Callback::OnSurfaceChanged](#onsurfacechanged) | Invoked when the surface changes. | +| [OH_NativeXComponent_Callback::OnSurfaceDestroyed](#onsurfacedestroyed) | Invoked when the surface is destroyed. | +| [OH_NativeXComponent_Callback::DispatchTouchEvent](#dispatchtouchevent) | Invoked when a touch event is triggered. | +| [OH_NativeXComponent_MouseEvent_Callback::DispatchMouseEvent](#dispatchmouseevent) | Invoked when a mouse event is triggered. | +| [OH_NativeXComponent_MouseEvent_Callback::DispatchHoverEvent](#dispatchhoverevent) | Invoked when a hover event is triggered. | + + +## Type Description + +### OH_NativeXComponent + + +``` +typedef struct OH_NativeXComponent OH_NativeXComponent +``` + +**Description** + +Provides an encapsulated OH_NativeXComponent instance. + +**Since:** + +8 + + +### OH_NativeXComponent_Callback + + +``` +typedef struct OH_NativeXComponent_Callback OH_NativeXComponent_Callback +``` + +**Description** + +Registers a callback for the surface lifecycle and touch event. + +**Since:** + +8 + + +### OH_NativeXComponent_MouseEvent_Callback + + +``` +typedef struct OH_NativeXComponent_MouseEvent_Callback OH_NativeXComponent_MouseEvent_Callback +``` + +**Description** + +Registers a callback for the mouse event. + +**Since:** + +9 + + +## Enum Description + +### anonymous enum + + +``` +anonymous enum +``` + +**Description** + +Enumerates the API access states. + +| Name | Description | +| ---------------------------------------- | ---------- | +| OH_NATIVEXCOMPONENT_RESULT_SUCCESS | Success result. | +| OH_NATIVEXCOMPONENT_RESULT_FAILED | Failure. | +| OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER | Invalid parameter. | + +**Since:** + +8 + +### OH_NativeXComponent_EventSourceType + +OH_NativeXComponent_EventSourceType + + +``` +enum OH_NativeXComponent_EventSourceType +``` + +**Description** + +Enumerates the source types of the touch event. + +| Name | Description | +| -------- | -------- | +| OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN | Unknown source type. | +| OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE | Source that generates a mouse multi-touch event. | +| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN | Source that generates a touchscreen multi-touch event. | +| OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD | Source that generates a touchpad multi-touch event. | +| OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK | Source that generates a joystick multi-touch event. | + +**Since:** + +9 + +### OH_NativeXComponent_MouseEventAction + + +``` +enum OH_NativeXComponent_MouseEventAction +``` + +**Description** + +Enumerates the mouse event actions. + +| Name | Description | +| --------------------------------- | -------------------------------- | +| OH_NATIVEXCOMPONENT_MOUSE_NONE | Invalid mouse event. | +| OH_NATIVEXCOMPONENT_MOUSE_PRESS | The mouse event is triggered when a mouse button is pressed. | +| OH_NATIVEXCOMPONENT_MOUSE_RELEASE | The mouse event is triggered when a mouse button is released. | +| OH_NATIVEXCOMPONENT_MOUSE_MOVE | The mouse event is triggered when the mouse moves on the screen. | + +**Since:** + +9 + + +### OH_NativeXComponent_MouseEventButton + + +``` +enum OH_NativeXComponent_MouseEventButton +``` + +**Description** + +Enumerates the mouse event buttons. + +| Name | Description | +| ---------------------------------- | ---------------------------------- | +| OH_NATIVEXCOMPONENT_NONE_BUTTON | The mouse event is triggered when no mouse button is pressed. | +| OH_NATIVEXCOMPONENT_LEFT_BUTTON | The mouse event is triggered when the left mouse button is pressed. | +| OH_NATIVEXCOMPONENT_RIGHT_BUTTON | The mouse event is triggered when the right mouse button is pressed. | +| OH_NATIVEXCOMPONENT_MIDDLE_BUTTON | The mouse event is triggered when the middle mouse button is pressed. | +| OH_NATIVEXCOMPONENT_BACK_BUTTON | The mouse event is triggered when the back button on the left of the mouse is pressed. | +| OH_NATIVEXCOMPONENT_FORWARD_BUTTON | The mouse event is triggered when the forward button on the left of the mouse is pressed. | + +**Since:** + +9 + + +### OH_NativeXComponent_TouchEventType + + +``` +enum OH_NativeXComponent_TouchEventType +``` + +**Description** + +Enumerates the touch event types. + +| Name | Description | +| --------------------------- | ------------------------------------------ | +| OH_NATIVEXCOMPONENT_DOWN | The touch event is triggered when a finger is pressed. | +| OH_NATIVEXCOMPONENT_UP | The touch event is triggered when a finger is lifted. | +| OH_NATIVEXCOMPONENT_MOVE | The touch event is triggered when a finger is pressed and moves on the screen. | +| OH_NATIVEXCOMPONENT_CANCEL | The event is triggered when a touch event is canceled. | +| OH_NATIVEXCOMPONENT_UNKNOWN | Invalid touch type. | + +**Since:** + +8 + +### OH_NativeXComponent_TouchPointToolType + + +``` +enum OH_NativeXComponent_TouchPointToolType +``` + +**Description** + +Enumerates the contact point tool types. + +| Name | Description | +| -------- | -------- | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN | Unknown tool type. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER | Finger. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN | Stylus. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER | Eraser. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH | Brush. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL | Pencil. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH | Air brush. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE | Mouse. | +| OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS | Lens. | + +**Since:** + +9 + + +## Function Description + + +### OH_NativeXComponent_GetMouseEvent() + + +``` +int32_t OH_NativeXComponent_GetMouseEvent (OH_NativeXComponent * component, const void * window, OH_NativeXComponent_MouseEvent * mouseEvent ) +``` + +**Description** + +Obtains the mouse event scheduled by ArkUI XComponent. + +**Parameters** + +| Name | Description | +| ---------- | --------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| window | Indicates the pointer to a **NativeWindow** handle. | +| mouseEvent | Indicates the pointer to the current mouse event. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +9 + + +### OH_NativeXComponent_GetTouchEvent() + + +``` +int32_t OH_NativeXComponent_GetTouchEvent (OH_NativeXComponent * component, const void * window, OH_NativeXComponent_TouchEvent * touchEvent ) +``` + +**Description** + +Obtains the touch event scheduled by the ArkUI XComponent. + +**Parameters** + +| Name | Description | +| ---------- | --------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| window | Indicates the pointer to a **NativeWindow** handle. | +| touchEvent | Indicates the pointer to the current touch event. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +8 + +### OH_NativeXComponent_GetTouchPointTiltX() + + +``` +int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent * component, uint32_t pointIndex, float * tiltX ) +``` + +**Description** + +Obtains the angle between the tilt of the ArkUI XComponent touch point and the x-axis. + +**Parameters** + +| Name | Description | +| -------- | -------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| pointIndex | Indicates the index of the pointer to a touch point. | +| tiltX | Indicates the pointer to the tilt along the x-axis. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +9 + + +### OH_NativeXComponent_GetTouchPointTiltY() + + +``` +int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent * component, uint32_t pointIndex, float * tiltY ) +``` + +**Description** + +Obtains the angle between the tilt of the ArkUI XComponent touch point and the y-axis. + +**Parameters** + +| Name | Description | +| -------- | -------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| pointIndex | Indicates the index of the pointer to a touch point. | +| tiltY | Indicates the pointer to the tilt along the y-axis. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +9 + + +### OH_NativeXComponent_GetTouchPointToolType() + + +``` +int32_t OH_NativeXComponent_GetTouchPointToolType (OH_NativeXComponent * component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType * toolType ) +``` + +**Description** + +Obtains the ArkUI XComponent touch point tool type. + +**Parameters** + +| Name | Description | +| -------- | -------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| pointIndex | Indicates the index of the pointer to a touch point. | +| toolType | Indicates the pointer to the tool type. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +9 + + +### OH_NativeXComponent_GetXComponentId() + + +``` +int32_t OH_NativeXComponent_GetXComponentId (OH_NativeXComponent * component, char * id, uint64_t * size ) +``` + +**Description** + +Obtains the ID of the ArkUI XComponent. + +**Parameters** + +| Name | Description | +| --------- | ------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| id | Indicates the pointer to the character buffer used to hold the ID of the OH_NativeXComponent instance.
Note that the null terminator is attached to the character buffer, so the size of the character buffer should be at least one unit greater than the length of the real ID.
The recommended size of the character buffer is [OH_XCOMPONENT_ID_LEN_MAX + 1]. | +| size | Indicates the pointer to the length of the ID. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +8 + + +### OH_NativeXComponent_GetXComponentOffset() + + +``` +int32_t OH_NativeXComponent_GetXComponentOffset (OH_NativeXComponent * component, const void * window, double * x, double * y ) +``` + +**Description** + +Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. + +**Parameters** + +| Name | Description | +| --------- | --------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| window | Indicates the pointer to a **NativeWindow** handle. | +| x | Indicates the pointer to the x coordinate of the current surface. | +| y | Indicates the pointer to the y coordinate of the current surface. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +8 + + +### OH_NativeXComponent_GetXComponentSize() + + +``` +int32_t OH_NativeXComponent_GetXComponentSize (OH_NativeXComponent * component, const void * window, uint64_t * width, uint64_t * height ) +``` + +**Description** + +Obtains the size of the surface held by the ArkUI XComponent. + +**Parameters** + +| Name | Description | +| --------- | --------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| window | Indicates the pointer to a **NativeWindow** handle. | +| width | Indicates the pointer to the width of the current surface. | +| height | Indicates the pointer to the height of the current surface. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +8 + + +### OH_NativeXComponent_RegisterCallback() + + +``` +int32_t OH_NativeXComponent_RegisterCallback (OH_NativeXComponent * component, OH_NativeXComponent_Callback * callback ) +``` + +**Description** + +Registers a callback for this **OH_NativeXComponent** instance. + +**Parameters** + +| Name | Description | +| --------- | --------------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| callback | Indicates the pointer to the surface lifecycle and touch event callback.| + +**Returns** + +Returns the status code of the operation. + +**Since:** + +8 + + +### OH_NativeXComponent_RegisterMouseEventCallback() + + +``` +int32_t OH_NativeXComponent_RegisterMouseEventCallback (OH_NativeXComponent * component, OH_NativeXComponent_MouseEvent_Callback * callback ) +``` + +**Description** + +Registers a mouse event callback for this **OH_NativeXComponent** instance. + +**Parameters** + +| Name | Description | +| --------- | --------------------------------------- | +| component | Indicates the pointer to an **OH_NativeXComponent** instance. | +| callback | Indicates the pointer to the mouse event callback. | + +**Returns** + +Returns the status code of the operation. + +**Since:** + +9 + + +## Variable Description + + +### OH_XCOMPONENT_ID_LEN_MAX + + +``` +const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128 +``` + +**Description** + +Maximum length of an ArkUI XComponent ID. + +**Since:** + +8 + + +### OH_MAX_TOUCH_POINTS_NUMBER + + +``` +const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10 +``` + +**Description** + +Maximum number of identifiable touch points in a touch event. + +**Since:** + +8 + + +### action + + +``` +OH_NativeXComponent_MouseEventAction OH_NativeXComponent_MouseEvent::action +``` + +**Description** + +Current mouse event action. + +**Since:** + +8 + + +### button + + +``` +OH_NativeXComponent_MouseEventButton OH_NativeXComponent_MouseEvent::button +``` + +**Description** + +Mouse event button + +**Since:** + +8 + + +### deviceId + + +``` +int64_t OH_NativeXComponent_TouchEvent::deviceId = 0 +``` + +**Description** + +ID of the device where the current touch event is triggered. + +**Since:** + +8 + + +### DispatchHoverEvent + + +``` +void(* OH_NativeXComponent_MouseEvent_Callback::DispatchHoverEvent) (OH_NativeXComponent *component, bool isHover) +``` + +**Description** + +Invoked when a hover event is triggered. + +**Since:** + +8 + + +### DispatchMouseEvent + + +``` +void(* OH_NativeXComponent_MouseEvent_Callback::DispatchMouseEvent) (OH_NativeXComponent *component, void *window) +``` + +**Description** + +Invoked when a mouse event is triggered. + +**Since:** + +8 + + +### DispatchTouchEvent + + +``` +void(* OH_NativeXComponent_Callback::DispatchTouchEvent) (OH_NativeXComponent *component, void *window) +``` + +**Description** + +Invoked when a touch event is triggered. + +**Since:** + +8 + + +### force [1/2] + + +``` +float OH_NativeXComponent_TouchPoint::force = 0.0 +``` + +**Description** + +Pressure of the current touch event. + +**Since:** + +8 + + +### force [2/2] + + +``` +float OH_NativeXComponent_TouchEvent::force = 0.0 +``` + +**Description** + +Pressure of the current touch event. + +**Since:** + +8 + + +### id [1/2] + + +``` +int32_t OH_NativeXComponent_TouchPoint::id = 0 +``` + +**Description** + +Unique identifier of the finger. + +**Since:** + +8 + + +### id [2/2] + + +``` +int32_t OH_NativeXComponent_TouchEvent::id = 0 +``` + +**Description** + +Unique identifier of the finger. + +**Since:** + +8 + + +### isPressed + + +``` +bool OH_NativeXComponent_TouchPoint::isPressed = false +``` + +**Description** + +Whether the current point is pressed. + +**Since:** + +8 + + +### numPoints + + +``` +uint32_t OH_NativeXComponent_TouchEvent::numPoints = 0 +``` + +**Description** + +Number of current touch points. + +**Since:** + +8 + + +### OnSurfaceChanged + + +``` +void(* OH_NativeXComponent_Callback::OnSurfaceChanged) (OH_NativeXComponent *component, void *window) +``` + +**Description** + +Invoked when the surface changes. + +**Since:** + +8 + + +### OnSurfaceCreated + + +``` +void(* OH_NativeXComponent_Callback::OnSurfaceCreated) (OH_NativeXComponent *component, void *window) +``` + +**Description** + +Invoked when a surface is created. + +**Since:** + +8 + + +### OnSurfaceDestroyed + + +``` +void(* OH_NativeXComponent_Callback::OnSurfaceDestroyed) (OH_NativeXComponent *component, void *window) +``` + +**Description** + +Invoked when the surface is destroyed. + +**Since:** + +8 + + +### screenX [1/3] + + +``` +float OH_NativeXComponent_TouchPoint::screenX = 0.0 +``` + +**Description** + +X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. + +**Since:** + +8 + + +### screenX [2/3] + + +``` +float OH_NativeXComponent_TouchEvent::screenX = 0.0 +``` + +**Description** + +X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. + +**Since:** + +8 + + +### screenX [3/3] + + +``` +float OH_NativeXComponent_MouseEvent::screenX +``` + +**Description** + +X coordinate of the clicked point relative to the upper left corner of the screen. + +**Since:** + +8 + + +### screenY [1/3] + + +``` +float OH_NativeXComponent_TouchPoint::screenY = 0.0 +``` + +**Description** + +Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. + +**Since:** + +8 + + +### screenY [2/3] + + +``` +float OH_NativeXComponent_TouchEvent::screenY = 0.0 +``` + +**Description** + +Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. + +**Since:** + +8 + + +### screenY [3/3] + + +``` +float OH_NativeXComponent_MouseEvent::screenY +``` + +**Description** + +Y coordinate of the clicked point relative to the upper left corner of the screen. + +**Since:** + +8 + + +### size [1/2] + + +``` +double OH_NativeXComponent_TouchPoint::size = 0.0 +``` + +**Description** + +Contact area between the finger pad and the screen. + +**Since:** + +8 + + +### size [2/2] + + +``` +double OH_NativeXComponent_TouchEvent::size = 0.0 +``` + +**Description** + +Contact area between the finger pad and the screen. + +**Since:** + +8 + + +### timeStamp [1/2] + + +``` +long long OH_NativeXComponent_TouchPoint::timeStamp = 0 +``` + +**Description** + +Timestamp of the current touch event. + +**Since:** + +8 + + +### timeStamp [2/2] + + +``` +long long OH_NativeXComponent_TouchEvent::timeStamp = 0 +``` + +**Description** + +Timestamp of the current touch event. + +**Since:** + +8 + + +### timestamp + + +``` +int64_t OH_NativeXComponent_MouseEvent::timestamp +``` + +**Description** + +Timestamp of the current mouse event. + +**Since:** + +8 + + +### touchPoints + + +``` +OH_NativeXComponent_TouchPoint OH_NativeXComponent_TouchEvent::touchPoints[OH_MAX_TOUCH_POINTS_NUMBER] +``` + +**Description** + +Array of the current touch points. + +**Since:** + +8 + + +### type [1/2] + + +``` +OH_NativeXComponent_TouchEventType OH_NativeXComponent_TouchPoint::type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN +``` + +**Description** + +Touch type of the touch event. + +**Since:** + +8 + + +### type [2/2] + + +``` +OH_NativeXComponent_TouchEventType OH_NativeXComponent_TouchEvent::type = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN +``` + +**Description** + +Touch type of the touch event. + +**Since:** + +8 + + +### x [1/3] + + +``` +float OH_NativeXComponent_TouchPoint::x = 0.0 +``` + +**Description** + +X coordinate of the touch point relative to the left edge of the XComponent. + +**Since:** + +8 + + +### x [2/3] + + +``` +float OH_NativeXComponent_TouchEvent::x = 0.0 +``` + +**Description** + +X coordinate of the touch point relative to the left edge of the XComponent. + +**Since:** + +8 + + +### x [3/3] + + +``` +float OH_NativeXComponent_MouseEvent::x +``` + +**Description** + +X coordinate of the clicked point relative to the upper left corner of the component. + +**Since:** + +8 + + +### y [1/3] + + +``` +float OH_NativeXComponent_TouchPoint::y = 0.0 +``` + +**Description** + +Y coordinate of the touch point relative to the upper edge of the XComponent. + +**Since:** + +8 + + +### y [2/3] + + +``` +float OH_NativeXComponent_TouchEvent::y = 0.0 +``` + +**Description** + +Y coordinate of the touch point relative to the upper edge of the XComponent. + +**Since:** + +8 + + +### y [3/3] + + +``` +float OH_NativeXComponent_MouseEvent::y +``` + +**Description** + +Y coordinate of the clicked point relative to the upper left corner of the component. + +**Since:** + +8 \ No newline at end of file diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component___callback.md b/en/application-dev/reference/native-apis/_o_h___native_x_component___callback.md new file mode 100644 index 0000000000000000000000000000000000000000..fd2a0ebced876c110742f8fbe75c080f218d5d6a --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component___callback.md @@ -0,0 +1,26 @@ +# OH_NativeXComponent_Callback + + +## Overview + +Registers a callback for the surface lifecycle and touch event. + +**Since:** +8 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [OnSurfaceCreated](_o_h___native_x_component.md#onsurfacecreated)| Invoked when a surface is created. | +| [OnSurfaceChanged](_o_h___native_x_component.md#onsurfacechanged)| Invoked when the surface changes. | +| [OnSurfaceDestroyed](_o_h___native_x_component.md#onsurfacedestroyed)| Invoked when the surface is destroyed. | +| [DispatchTouchEvent](_o_h___native_x_component.md#dispatchtouchevent)| Invoked when a touch event is triggered. | diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event.md b/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event.md new file mode 100644 index 0000000000000000000000000000000000000000..a8a283b19ad3dc19a7d95239ae20cb8794c45f01 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event.md @@ -0,0 +1,30 @@ +# OH_NativeXComponent_MouseEvent + + +## Overview + +Describes the mouse event. + +**Since:** + +9 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [x = 0.0](_o_h___native_x_component.md#x-33) | X coordinate of the clicked point relative to the upper left corner of the component. | +| [y = 0.0](_o_h___native_x_component.md#y-33) | Y coordinate of the clicked point relative to the upper left corner of the component. | +| [screenX = 0.0](_o_h___native_x_component.md#screenx-33) | X coordinate of the clicked point relative to the upper left corner of the screen. | +| [screenY = 0.0](_o_h___native_x_component.md#screeny-33) | Y coordinate of the clicked point relative to the upper left corner of the screen. | +| [timestamp = 0](_o_h___native_x_component.md#timestamp) | Timestamp of the current mouse event. | +| [action = OH_NativeXComponent_MouseEventAction::OH_NATIVEXCOMPONENT_MOUSE_NONE](_o_h___native_x_component.md#action) | Current mouse event action. | +| [button = OH_NativeXComponent_MouseEventButton::OH_NATIVEXCOMPONENT_NONE_BUTTON](_o_h___native_x_component.md#button) | Mouse event button | diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event___callback.md b/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event___callback.md new file mode 100644 index 0000000000000000000000000000000000000000..531b6b7151febabc65b37dcfe97daa434f676825 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component___mouse_event___callback.md @@ -0,0 +1,24 @@ +# OH_NativeXComponent_MouseEvent_Callback + + +## Overview + +Registers a callback for the mouse event. + +**Since:** +9 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [DispatchMouseEvent](_o_h___native_x_component.md#dispatchmouseevent) | Invoked when a mouse event is triggered. | +| [DispatchHoverEvent](_o_h___native_x_component.md#dispatchhoverevent) | Invoked when a hover event is triggered. | diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_event.md b/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_event.md new file mode 100644 index 0000000000000000000000000000000000000000..a87a0bc0f6a0d957a720c384a4999028e0fc640c --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_event.md @@ -0,0 +1,34 @@ +# OH_NativeXComponent_TouchEvent + + +## Overview + +Describes the touch event. + +**Since:** +8 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [id](_o_h___native_x_component.md#id-22) = 0 | Unique identifier of the finger. | +| [screenX](_o_h___native_x_component.md#screenx-23) = 0.0 | X coordinate of the touch point relative to the left edge of the screen. | +| [screenY](_o_h___native_x_component.md#screeny-23) = 0.0 | Y coordinate of the touch point relative to the upper edge of the screen. | +| [x](_o_h___native_x_component.md#x-23) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. | +| [y](_o_h___native_x_component.md#y-23) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. | +| [type](_o_h___native_x_component.md#type-22) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. | +| [size](_o_h___native_x_component.md#size-22) = 0.0 | Contact area between the finger pad and the screen. | +| [force](_o_h___native_x_component.md#force-22) = 0.0 | Pressure of the current touch event. | +| [deviceId](_o_h___native_x_component.md#deviceid) = 0 | ID of the device where the current touch event is triggered. | +| [timeStamp](_o_h___native_x_component.md#timestamp-22) = 0 | Timestamp of the current touch event. | +| [touchPoints](_o_h___native_x_component.md#touchpoints) [OH_MAX_TOUCH_POINTS_NUMBER] | Array of the current touch points. | +| [numPoints](_o_h___native_x_component.md#numpoints) = 0 | Number of current touch points. | diff --git a/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_point.md b/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_point.md new file mode 100644 index 0000000000000000000000000000000000000000..10c7925fd0fe6403569af40d1b74fab0147b2c02 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h___native_x_component___touch_point.md @@ -0,0 +1,32 @@ +# OH_NativeXComponent_TouchPoint + + +## Overview + +Describes the touch point of the touch event. + +**Since:** +8 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [id](_o_h___native_x_component.md#id-12) = 0 | Unique identifier of the finger. | +| [screenX](_o_h___native_x_component.md#screenx-13) = 0.0 | X coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. | +| [screenY](_o_h___native_x_component.md#screeny-13) = 0.0 | Y coordinate of the touch point relative to the upper left corner of the application window where the XComponent is located. | +| [x](_o_h___native_x_component.md#x-13) = 0.0 | X coordinate of the touch point relative to the left edge of the XComponent. | +| [y](_o_h___native_x_component.md#y-13) = 0.0 | Y coordinate of the touch point relative to the upper edge of the XComponent. | +| [type](_o_h___native_x_component.md#type-12) = OH_NativeXComponent_TouchEventType::OH_NATIVEXCOMPONENT_UNKNOWN | Touch type of the touch event. | +| [size](_o_h___native_x_component.md#size-12) = 0.0 | Contact area between the finger pad and the screen. | +| [force](_o_h___native_x_component.md#force-12) = 0.0 | Pressure of the current touch event. | +| [timeStamp](_o_h___native_x_component.md#timestamp-12) = 0 | Timestamp of the current touch event. | +| [isPressed](_o_h___native_x_component.md#ispressed) = false | Whether the current point is pressed. | diff --git a/en/application-dev/reference/native-apis/_o_h_ext_data_handle.md b/en/application-dev/reference/native-apis/_o_h_ext_data_handle.md new file mode 100644 index 0000000000000000000000000000000000000000..d482454e9ea6f34c794a72b85330211071782111 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h_ext_data_handle.md @@ -0,0 +1,55 @@ +# OHExtDataHandle + + +## Overview + +Defines the extended data handle. + +**Related Modules:** + +[NativeWindow](_native_window.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [fd](#fd) | File descriptor handle. The value **-1** indicates that the handle is not supported. | +| [reserveInts](#reserveints) | Number of reserved arrays. | +| [reserve](#reserve) [0] | Reserve array. | + + +## Member Variable Description + + +### fd + + +``` +int32_t OHExtDataHandle::fd +``` +**Description**
+File descriptor handle. The value **-1** indicates that the handle is not supported. + + +### reserve + + +``` +int32_t OHExtDataHandle::reserve[0] +``` +**Description**
+Reserve array. + + +### reserveInts + + +``` +uint32_t OHExtDataHandle::reserveInts +``` +**Description**
+Number of reserved arrays. diff --git a/en/application-dev/reference/native-apis/_o_h_h_d_r_meta_data.md b/en/application-dev/reference/native-apis/_o_h_h_d_r_meta_data.md new file mode 100644 index 0000000000000000000000000000000000000000..d0255c7e7584c60b9512195374db0f34d312cd88 --- /dev/null +++ b/en/application-dev/reference/native-apis/_o_h_h_d_r_meta_data.md @@ -0,0 +1,44 @@ +# OHHDRMetaData + + +## Overview + +Defines the HDR metadata. + +**Related Modules:** + +[NativeWindow](_native_window.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [key](#key) | Key of the HDR metadata. | +| [value](#value) | Value corresponding to the metadata key. | + + +## Member Variable Description + + +### key + + +``` +OHHDRMetadataKey OHHDRMetaData::key +``` +**Description**
+Key of the HDR metadata. + + +### value + + +``` +float OHHDRMetaData::value +``` +**Description**
+Value corresponding to the metadata key. diff --git a/en/application-dev/reference/native-apis/_ohos_pixel_map_create_ops.md b/en/application-dev/reference/native-apis/_ohos_pixel_map_create_ops.md new file mode 100644 index 0000000000000000000000000000000000000000..330a50ddd7bbe1b790834ce2ce62ef94e0ab8b08 --- /dev/null +++ b/en/application-dev/reference/native-apis/_ohos_pixel_map_create_ops.md @@ -0,0 +1,91 @@ +# OhosPixelMapCreateOps + + +## Overview + +Defines the options used for creating a pixel map. + +**Since:** +9 + +**Related Modules:** + +[Image](image.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [width](#width) | Image width, in pixels. | +| [height](#height) | Image height, in pixels. | +| [pixelFormat](#pixelformat) | Image format. | +| [editable](#editable) | Editing type of the image. | +| [alphaType](#alphatype) | Alpha type of the image. | +| [scaleMode](#scalemode) | Scale mode of the image. | + + +## Member Variable Description + + +### alphaType + + +``` +uint32_t OhosPixelMapCreateOps::alphaType +``` +**Description**
+Alpha type of the image. + + +### editable + + +``` +uint32_t OhosPixelMapCreateOps::editable +``` +**Description**
+Editing type of the image. + + +### height + + +``` +uint32_t OhosPixelMapCreateOps::height +``` +**Description**
+Image height, in pixels. + + +### pixelFormat + + +``` +int32_t OhosPixelMapCreateOps::pixelFormat +``` +**Description**
+Image format. + + +### scaleMode + + +``` +uint32_t OhosPixelMapCreateOps::scaleMode +``` +**Description**
+Scale mode of the image. + + +### width + + +``` +uint32_t OhosPixelMapCreateOps::width +``` +**Description**
+Image width, in pixels. diff --git a/en/application-dev/reference/native-apis/_ohos_pixel_map_info.md b/en/application-dev/reference/native-apis/_ohos_pixel_map_info.md new file mode 100644 index 0000000000000000000000000000000000000000..fef93fbc492a0df88bc598ce7d4ff814a36f2773 --- /dev/null +++ b/en/application-dev/reference/native-apis/_ohos_pixel_map_info.md @@ -0,0 +1,69 @@ +# OhosPixelMapInfo + + +## Overview + +Defines the pixel map information. + +**Since:** +8 + +**Related Modules:** + +[Image](image.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [width](#width) | Image width, in pixels. | +| [height](#height) | Image height, in pixels. | +| [rowSize](#rowsize) | Number of bytes in each line. | +| [pixelFormat](#pixelformat) | Pixel format. | + + +## Member Variable Description + + +### height + + +``` +uint32_t OhosPixelMapInfo::height +``` +**Description**
+Image height, in pixels. + + +### pixelFormat + + +``` +int32_t OhosPixelMapInfo::pixelFormat +``` +**Description**
+Pixel format. + + +### rowSize + + +``` +uint32_t OhosPixelMapInfo::rowSize +``` +**Description**
+Number of bytes in each line. + + +### width + + +``` +uint32_t OhosPixelMapInfo::width +``` +**Description**
+Image width, in pixels. diff --git a/en/application-dev/reference/native-apis/_raw_file_descriptor.md b/en/application-dev/reference/native-apis/_raw_file_descriptor.md new file mode 100644 index 0000000000000000000000000000000000000000..5bc1389177db0e4d24bf1df07eab8a13a85e0fe0 --- /dev/null +++ b/en/application-dev/reference/native-apis/_raw_file_descriptor.md @@ -0,0 +1,60 @@ +# RawFileDescriptor + + +## Overview + +Provides rawfile descriptor information. + +**RawFileDescriptor** is an output parameter of [OH_ResourceManager_GetRawFileDescriptor](rawfile.md#oh_resourcemanager_getrawfiledescriptor). It provides information including the rawfile descriptor and the start position and length of the rawfile in the HAP package. + +**Since:** +8 + +**Related Modules:** + +[Rawfile](rawfile.md) + + +## Summary + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [fd](#fd) |rawfile descriptor | +| [start](#start) | Start position of rawfile in the HAP package | +| [length](#length) | Length of rawfile in the HAP package | + + +## Member Variable Description + + +### fd + + +``` +int RawFileDescriptor::fd +``` +**Description**
+rawfile descriptor + + +### length + + +``` +long RawFileDescriptor::length +``` +**Description**
+Length of rawfile in the HAP package + + +### start + + +``` +long RawFileDescriptor::start +``` +**Description**
+Start position of rawfile in the HAP package diff --git a/en/application-dev/reference/native-apis/_rect.md b/en/application-dev/reference/native-apis/_rect.md new file mode 100644 index 0000000000000000000000000000000000000000..9707978e7b7c36dc338eba145f304c67f9c8a753 --- /dev/null +++ b/en/application-dev/reference/native-apis/_rect.md @@ -0,0 +1,65 @@ +# Rect + + +## Overview + +If **rects** is a null pointer, the buffer size is the same as the size of the dirty region by default. + + +**Related Modules:** + +[NativeWindow](_native_window.md) + + +## Summary + + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| x | Start X coordinate of the rectangle. | +| y | Start Y coordinate of the rectangle. | +| w | Width of the rectangle. | +| h | Height of the rectangle. | + + +## Member Variable Description + +### x + +``` +int32_t Rect::x +``` +**Description**
+Start X coordinate of the rectangle. + + +### y + + +``` +int32_t Rect::y +``` +**Description**
+Start Y coordinate of the rectangle. + +### w + + +``` +int32_t Rect::w +``` +**Description**
+Width of the rectangle. + + +### h + + +``` +int32_t Rect::h +``` +**Description**
+Height of the rectangle. diff --git a/en/application-dev/reference/native-apis/_region.md b/en/application-dev/reference/native-apis/_region.md new file mode 100644 index 0000000000000000000000000000000000000000..e745660c6e0c0ca837326fd78137f0b5bf74910f --- /dev/null +++ b/en/application-dev/reference/native-apis/_region.md @@ -0,0 +1,47 @@ +# Region + + +## Overview + +Defines the rectangle (dirty region) where the content is to be updated in the local native window. + +**Related Modules:** + +[NativeWindow](_native_window.md) + + +## Summary + + + +### Member Variables + +| Name | Description | +| -------- | -------- | +| [rects](#rects) | If **rects** is a null pointer, the buffer size is the same as the size of the dirty region by default. | +| [rectNumber](#rectnumber) | If **rectNumber** is **0**, the buffer size is the same as the size of the dirty region by default. | + + +## Member Variable Description + + +### rectNumber + + +``` +int32_t Region::rectNumber +``` +**Description**
+If **rectNumber** is **0**, the buffer size is the same as the size of the dirty region by default. + + +### *rects + +``` +struct Rect Region::*rects +``` + +**Description**
+If **rects** is a null pointer, the buffer size is the same as the size of the dirty region by default. + + \ No newline at end of file diff --git a/en/application-dev/reference/native-apis/_video_decoder.md b/en/application-dev/reference/native-apis/_video_decoder.md new file mode 100644 index 0000000000000000000000000000000000000000..23fcefb0c633bbe7682b6b5ceb4a835e2b5b6f32 --- /dev/null +++ b/en/application-dev/reference/native-apis/_video_decoder.md @@ -0,0 +1,433 @@ +# VideoDecoder + + +## Overview + +Provides the functions for video decoding. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_avcodec_videodecoder.h](native__avcodec__videodecoder_8h.md) | Declares the native APIs used for video decoding.
File to Include: | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_VideoDecoder_CreateByMime](#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoDecoder_CreateByName](#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | +| [OH_VideoDecoder_Destroy](#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | +| [OH_VideoDecoder_SetCallback](#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_SetSurface](#oh_videodecoder_setsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Configure](#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Prepare](#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | +| [OH_VideoDecoder_Start](#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoDecoder_Stop](#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_VideoDecoder_Flush](#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoDecoder_Reset](#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_VideoDecoder_GetOutputDescription](#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoDecoder_SetParameter](#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_VideoDecoder_PushInputData](#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | +| [OH_VideoDecoder_RenderOutputData](#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | +| [OH_VideoDecoder_FreeOutputData](#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | + + +## Function Description + + +### OH_VideoDecoder_Configure() + + +``` +OH_AVErrCode OH_VideoDecoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be decoded. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_CreateByMime() + + +``` +OH_AVCodec* OH_VideoDecoder_CreateByMime (const char * mime) +``` +**Description**
+Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc). | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_VideoDecoder_CreateByName() + + +``` +OH_AVCodec* OH_VideoDecoder_CreateByName (const char * name) +``` +**Description**
+Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| name | Indicates the pointer to a video decoder name. | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_VideoDecoder_Destroy() + + +``` +OH_AVErrCode OH_VideoDecoder_Destroy (OH_AVCodec * codec) +``` +**Description**
+Clears the internal resources of a video decoder and destroys the video decoder instance. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_Flush() + + +``` +OH_AVErrCode OH_VideoDecoder_Flush (OH_AVCodec * codec) +``` +**Description**
+Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_FreeOutputData() + + +``` +OH_AVErrCode OH_VideoDecoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +``` +**Description**
+Frees an output buffer of a video decoder. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_GetOutputDescription() + + +``` +OH_AVFormat* OH_VideoDecoder_GetOutputDescription (OH_AVCodec * codec) +``` +**Description**
+Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns the pointer to an **OH_AVFormat** instance. + + +### OH_VideoDecoder_Prepare() + + +``` +OH_AVErrCode OH_VideoDecoder_Prepare (OH_AVCodec * codec) +``` +**Description**
+Prepares internal resources for a video decoder. This API must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_PushInputData() + + +``` +OH_AVErrCode OH_VideoDecoder_PushInputData (OH_AVCodec * codec, uint32_t index, OH_AVCodecBufferAttr attr ) +``` +**Description**
+Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an input buffer. | +| attr | Indicates the attributes of the data contained in the buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_RenderOutputData() + + +``` +OH_AVErrCode OH_VideoDecoder_RenderOutputData (OH_AVCodec * codec, uint32_t index ) +``` +**Description**
+Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_Reset() + + +``` +OH_AVErrCode OH_VideoDecoder_Reset (OH_AVCodec * codec) +``` +**Description**
+Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_SetCallback() + + +``` +OH_AVErrCode OH_VideoDecoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +``` +**Description**
+Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | +| userData | Indicates the pointer to user-specific data. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_SetParameter() + + +``` +OH_AVErrCode OH_VideoDecoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_SetSurface() + + +``` +OH_AVErrCode OH_VideoDecoder_SetSurface (OH_AVCodec * codec, OHNativeWindow * window ) +``` +**Description**
+Sets an output surface for a video decoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| window | Indicates the pointer to an **OHNativeWindow** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_Start() + + +``` +OH_AVErrCode OH_VideoDecoder_Start (OH_AVCodec * codec) +``` +**Description**
+Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoDecoder_Stop() + + +``` +OH_AVErrCode OH_VideoDecoder_Stop (OH_AVCodec * codec) +``` +**Description**
+Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. + +\@syscap SystemCapability.Multimedia.Media.VideoDecoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. diff --git a/en/application-dev/reference/native-apis/_video_encoder.md b/en/application-dev/reference/native-apis/_video_encoder.md new file mode 100644 index 0000000000000000000000000000000000000000..c28d758c417106607997feec3f8d5f75a0ea6099 --- /dev/null +++ b/en/application-dev/reference/native-apis/_video_encoder.md @@ -0,0 +1,455 @@ +# VideoEncoder + + +## Overview + +Provides the functions and enums for video encoding. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +**Since:** +9 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the native APIs used for video encoding.
File to Include: | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | +| [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | +| [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Configure](#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | +| [OH_VideoEncoder_Start](#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoEncoder_Stop](#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_VideoEncoder_Flush](#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoEncoder_Reset](#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | +| [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | + + +## Type Description + + +### OH_VideoEncodeBitrateMode + + +``` +typedef enum OH_VideoEncodeBitrateModeOH_VideoEncodeBitrateMode +``` +**Description**
+Enumerates the bit rate modes of video encoding. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + +## Enum Description + + +### OH_VideoEncodeBitrateMode + + +``` +enum OH_VideoEncodeBitrateMode +``` +**Description**
+Enumerates the bit rate modes of video encoding. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + +| Name | Description | +| -------- | -------- | +| CBR | Constant bit rate. | +| VBR | Variable bit rate. | +| CQ | Constant quality. | + + +## Function Description + + +### OH_VideoEncoder_Configure() + + +``` +OH_AVErrCode OH_VideoEncoder_Configure (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance, which provides the attributes of the video track to be encoded. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_CreateByMime() + + +``` +OH_AVCodec* OH_VideoEncoder_CreateByMime (const char * mime) +``` +**Description**
+Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mime | Indicates the pointer to a MIME type. For details, see [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc). | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_VideoEncoder_CreateByName() + + +``` +OH_AVCodec* OH_VideoEncoder_CreateByName (const char * name) +``` +**Description**
+Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| name | Indicates the pointer to a video encoder name. | + +**Returns** + +Returns the pointer to an **OH_AVCodec** instance. + + +### OH_VideoEncoder_Destroy() + + +``` +OH_AVErrCode OH_VideoEncoder_Destroy (OH_AVCodec * codec) +``` +**Description**
+Clears the internal resources of a video encoder and destroys the video encoder instance. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_Flush() + + +``` +OH_AVErrCode OH_VideoEncoder_Flush (OH_AVCodec * codec) +``` +**Description**
+Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_FreeOutputData() + + +``` +OH_AVErrCode OH_VideoEncoder_FreeOutputData (OH_AVCodec * codec, uint32_t index ) +``` +**Description**
+Frees an output buffer of a video encoder. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| index | Indicates the index of an output buffer. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_GetOutputDescription() + + +``` +OH_AVFormat* OH_VideoEncoder_GetOutputDescription (OH_AVCodec * codec) +``` +**Description**
+Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns the pointer to an **OH_AVFormat** instance. + + +### OH_VideoEncoder_GetSurface() + + +``` +OH_AVErrCode OH_VideoEncoder_GetSurface (OH_AVCodec * codec, OHNativeWindow ** window ) +``` +**Description**
+Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| window | Indicates the double pointer to an **OHNativeWindow** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_NotifyEndOfStream() + + +``` +OH_AVErrCode OH_VideoEncoder_NotifyEndOfStream (OH_AVCodec * codec) +``` +**Description**
+Notifies a video encoder that input streams end. This API is recommended in surface mode. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_Prepare() + + +``` +OH_AVErrCode OH_VideoEncoder_Prepare (OH_AVCodec * codec) +``` +**Description**
+Prepares internal resources for a video encoder. This API must be called after **Configure**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_Reset() + + +``` +OH_AVErrCode OH_VideoEncoder_Reset (OH_AVCodec * codec) +``` +**Description**
+Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_SetCallback() + + +``` +OH_AVErrCode OH_VideoEncoder_SetCallback (OH_AVCodec * codec, OH_AVCodecAsyncCallback callback, void * userData ) +``` +**Description**
+Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| callback | Indicates a collection of all callback functions. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | +| userData | Indicates the pointer to user-specific data. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_SetParameter() + + +``` +OH_AVErrCode OH_VideoEncoder_SetParameter (OH_AVCodec * codec, OH_AVFormat * format ) +``` +**Description**
+Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | +| format | Indicates the handle to an **OH_AVFormat** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_Start() + + +``` +OH_AVErrCode OH_VideoEncoder_Start (OH_AVCodec * codec) +``` +**Description**
+Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. + + +### OH_VideoEncoder_Stop() + + +``` +OH_AVErrCode OH_VideoEncoder_Stop (OH_AVCodec * codec) +``` +**Description**
+Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. + +\@syscap SystemCapability.Multimedia.Media.VideoEncoder + + **Parameters** + +| Name | Description | +| -------- | -------- | +| codec | Indicates the pointer to an **OH_AVCodec** instance. | + +**Returns** + +Returns **AV_ERR_OK** if the operation is successful. + +Returns an error code defined in [OH_AVErrCode](_core.md#oh_averrcode) if the operation fails. diff --git a/en/application-dev/reference/native-apis/context_8h.md b/en/application-dev/reference/native-apis/context_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..f73e70d24871b35a026b39befa08fbebeee5380a --- /dev/null +++ b/en/application-dev/reference/native-apis/context_8h.md @@ -0,0 +1,52 @@ +# context.h + + +## Overview + +Provides **Context** APIs for configuring runtime information. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| 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. | + + +### Functions + +| 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. | diff --git a/en/application-dev/reference/native-apis/data__type_8h.md b/en/application-dev/reference/native-apis/data__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..28d8228cdbdc9aa84d3a17852036e00819fd226f --- /dev/null +++ b/en/application-dev/reference/native-apis/data__type_8h.md @@ -0,0 +1,29 @@ +# data_type.h + + +## Overview + +Declares tensor data types. + +**Since:** +9 +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_DataType](_mind_spore.md#oh_ai_datatype) | Declares data types supported by MSTensor. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AI_DataType](_mind_spore.md#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. | diff --git a/en/application-dev/reference/native-apis/drawing__bitmap_8h.md b/en/application-dev/reference/native-apis/drawing__bitmap_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d667a584d80e588137c568d7ce5ad674209f8708 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__bitmap_8h.md @@ -0,0 +1,35 @@ +# drawing_bitmap.h + + +## Overview + +Declares functions related to the **bitmap** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) | Defines the pixel format of a bitmap, including the color type and alpha type. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_BitmapCreate](_drawing.md#oh_drawing_bitmapcreate) (void) | Creates an **OH_Drawing_Bitmap** object. | +| [OH_Drawing_BitmapDestroy](_drawing.md#oh_drawing_bitmapdestroy) ([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*) | Destroys an **OH_Drawing_Bitmap** object and reclaims the memory occupied by the object. | +| [OH_Drawing_BitmapBuild](_drawing.md#oh_drawing_bitmapbuild) ([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*, const uint32_t width, const uint32_t height, const [OH_Drawing_BitmapFormat](_o_h___drawing___bitmap_format.md) \*) | Initializes the width and height of an **OH_Drawing_Bitmap** object and sets the pixel format for the bitmap. | +| [OH_Drawing_BitmapGetWidth](_drawing.md#oh_drawing_bitmapgetwidth) ([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*) | Obtains the width of a bitmap. | +| [OH_Drawing_BitmapGetHeight](_drawing.md#oh_drawing_bitmapgetheight) ([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*) | Obtains the height of a bitmap. | +| [OH_Drawing_BitmapGetPixels](_drawing.md#oh_drawing_bitmapgetpixels) ([OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*) | Obtains the pixel address of a bitmap. You can use this address to obtain the pixel data of the bitmap. | diff --git a/en/application-dev/reference/native-apis/drawing__brush_8h.md b/en/application-dev/reference/native-apis/drawing__brush_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d6f3962c034bc217e6e2be9cc9d30dfe1a60d161 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__brush_8h.md @@ -0,0 +1,28 @@ +# drawing_brush.h + + +## Overview + +Declares functions related to the **brush** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_BrushCreate](_drawing.md#oh_drawing_brushcreate) (void) | Creates an **OH_Drawing_Brush** object. | +| [OH_Drawing_BrushDestroy](_drawing.md#oh_drawing_brushdestroy) ([OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Destroys an **OH_Drawing_Brush** object and reclaims the memory occupied by the object. | +| [OH_Drawing_BrushIsAntiAlias](_drawing.md#oh_drawing_brushisantialias) (const [OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_BrushSetAntiAlias](_drawing.md#oh_drawing_brushsetantialias) ([OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*, bool) | Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_BrushGetColor](_drawing.md#oh_drawing_brushgetcolor) (const [OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Obtains the color of a brush. The color is used by the brush to fill in a shape. | +| [OH_Drawing_BrushSetColor](_drawing.md#oh_drawing_brushsetcolor) ([OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*, uint32_t color) | Sets the color for a brush. The color will be used by the brush to fill in a shape. | diff --git a/en/application-dev/reference/native-apis/drawing__canvas_8h.md b/en/application-dev/reference/native-apis/drawing__canvas_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..b1e9ed8e272cec59ac7294110b75b896c1f7672d --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__canvas_8h.md @@ -0,0 +1,34 @@ +# drawing_canvas.h + + +## Overview + +Declares functions related to the **canvas** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_CanvasCreate](_drawing.md#oh_drawing_canvascreate) (void) | Creates an **OH_Drawing_Canvas** object. | +| [OH_Drawing_CanvasDestroy](_drawing.md#oh_drawing_canvasdestroy) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*) | Destroys an **OH_Drawing_Canvas** object and reclaims the memory occupied by the object. | +| [OH_Drawing_CanvasBind](_drawing.md#oh_drawing_canvasbind) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, [OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) \*) | Binds a bitmap to a canvas so that the content drawn on the canvas is output to the bitmap (this process is called CPU rendering). | +| [OH_Drawing_CanvasAttachPen](_drawing.md#oh_drawing_canvasattachpen) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape. | +| [OH_Drawing_CanvasDetachPen](_drawing.md#oh_drawing_canvasdetachpen) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*) | Detaches the pen from a canvas so that the canvas will not use the style and color of the pen to outline a shape. | +| [OH_Drawing_CanvasAttachBrush](_drawing.md#oh_drawing_canvasattachbrush) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, const [OH_Drawing_Brush](_drawing.md#oh_drawing_brush) \*) | Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape. | +| [OH_Drawing_CanvasDetachBrush](_drawing.md#oh_drawing_canvasdetachbrush) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*) | Detaches the brush from a canvas so that the canvas will not use the style and color of the brush to fill in a shape. | +| [OH_Drawing_CanvasSave](_drawing.md#oh_drawing_canvassave) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*) | Saves the current canvas status (canvas matrix) to the top of the stack. | +| [OH_Drawing_CanvasRestore](_drawing.md#oh_drawing_canvasrestore) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*) | Restores the canvas status (canvas matrix) saved on the top of the stack. | +| [OH_Drawing_CanvasDrawLine](_drawing.md#oh_drawing_canvasdrawline) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, float x1, float y1, float x2, float y2) | Draws a line segment. | +| [OH_Drawing_CanvasDrawPath](_drawing.md#oh_drawing_canvasdrawpath) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, const [OH_Drawing_Path](_drawing.md#oh_drawing_path) \*) | Draws a path. | +| [OH_Drawing_CanvasClear](_drawing.md#oh_drawing_canvasclear) ([OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, uint32_t color) | Clears a canvas by using a specified color. | diff --git a/en/application-dev/reference/native-apis/drawing__color_8h.md b/en/application-dev/reference/native-apis/drawing__color_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..1fbc194e23770db73a176a50f94bcb8ecad7ec17 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__color_8h.md @@ -0,0 +1,23 @@ +# drawing_color.h + + +## Overview + +Declares functions related to the **color** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_ColorSetArgb](_drawing.md#oh_drawing_colorsetargb) (uint32_t alpha, uint32_t red, uint32_t green, uint32_t blue) | Converts four variables (alpha, red, green, and blue) into a 32-bit (ARGB) variable that describes a color. | diff --git a/en/application-dev/reference/native-apis/drawing__font__collection_8h.md b/en/application-dev/reference/native-apis/drawing__font__collection_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..5d80541dd0d0a316369eddf34f3aa4432412d692 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__font__collection_8h.md @@ -0,0 +1,24 @@ +# drawing_font_collection.h + + +## Overview + +Declares functions related to **FontCollection** in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_CreateFontCollection](_drawing.md#oh_drawing_createfontcollection) (void) | Creates an **OH_Drawing_FontCollection** object. | +| [OH_Drawing_DestroyFontCollection](_drawing.md#oh_drawing_destroyfontcollection) ([OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection) \*) | Releases the memory occupied by an **OH_Drawing_FontCollection** object. | diff --git a/en/application-dev/reference/native-apis/drawing__path_8h.md b/en/application-dev/reference/native-apis/drawing__path_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..63a17ef36b111490f6ad4ebf3d8e18e00ec90c31 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__path_8h.md @@ -0,0 +1,31 @@ +# drawing_path.h + + +## Overview + +Declares functions related to the **path** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_PathCreate](_drawing.md#oh_drawing_pathcreate) (void) | Creates an **OH_Drawing_Path** object. | +| [OH_Drawing_PathDestroy](_drawing.md#oh_drawing_pathdestroy) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*) | Destroys an **OH_Drawing_Path** object and reclaims the memory occupied by the object. | +| [OH_Drawing_PathMoveTo](_drawing.md#oh_drawing_pathmoveto) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*, float x, float y) | Sets the start point of a path. | +| [OH_Drawing_PathLineTo](_drawing.md#oh_drawing_pathlineto) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*, float x, float y) | Draws a line segment from the last point of a path to the target point. | +| [OH_Drawing_PathArcTo](_drawing.md#oh_drawing_patharcto) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg) | Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, and then a start angle and a sweep angle are specified. The arc is a portion of the ellipse defined by the start angle and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. | +| [OH_Drawing_PathQuadTo](_drawing.md#oh_drawing_pathquadto) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*, float ctrlX, float ctrlY, float endX, float endY) | Draws a quadratic Bezier curve from the last point of a path to the target point. | +| [OH_Drawing_PathCubicTo](_drawing.md#oh_drawing_pathcubicto) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY) | Draws a cubic Bezier curve from the last point of a path to the target point. | +| [OH_Drawing_PathClose](_drawing.md#oh_drawing_pathclose) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*) | Closes a path. A line segment from the start point to the last point of the path is added. | +| [OH_Drawing_PathReset](_drawing.md#oh_drawing_pathreset) ([OH_Drawing_Path](_drawing.md#oh_drawing_path) \*) | Resets path data. | diff --git a/en/application-dev/reference/native-apis/drawing__pen_8h.md b/en/application-dev/reference/native-apis/drawing__pen_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..65a6eb9bbdd986ab1fbf4b0d70ca7da981fabc1c --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__pen_8h.md @@ -0,0 +1,44 @@ +# drawing_pen.h + + +## Overview + +Declares functions related to the **pen** object in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_PenLineCapStyle](_drawing.md#oh_drawing_penlinecapstyle) { [LINE_FLAT_CAP](_drawing.md), [LINE_SQUARE_CAP](_drawing.md), [LINE_ROUND_CAP](_drawing.md) } | Enumerates line cap styles of a pen. The line cap style defines the style of both ends of a line segment drawn by the pen. | +| [OH_Drawing_PenLineJoinStyle](_drawing.md#oh_drawing_penlinejoinstyle) { [LINE_MITER_JOIN](_drawing.md), [LINE_ROUND_JOIN](_drawing.md), [LINE_BEVEL_JOIN](_drawing.md) } | Enumerates pen line join styles. The line join style defines the shape of the joints of a polyline segment drawn by the pen. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_PenCreate](_drawing.md#oh_drawing_pencreate) (void) | Creates an **OH_Drawing_Pen** object. | +| [OH_Drawing_PenDestroy](_drawing.md#oh_drawing_pendestroy) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Destroys an **OH_Drawing_Pen** object and reclaims the memory occupied by the object. | +| [OH_Drawing_PenIsAntiAlias](_drawing.md#oh_drawing_penisantialias) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_PenSetAntiAlias](_drawing.md#oh_drawing_pensetantialias) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, bool) | Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled, edges will be drawn with partial transparency. | +| [OH_Drawing_PenGetColor](_drawing.md#oh_drawing_pengetcolor) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the color of a pen. The color is used by the pen to outline a shape. | +| [OH_Drawing_PenSetColor](_drawing.md#oh_drawing_pensetcolor) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, uint32_t color) | Sets the color for a pen. The color is used by the pen to outline a shape. | +| [OH_Drawing_PenGetWidth](_drawing.md#oh_drawing_pengetwidth) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. | +| [OH_Drawing_PenSetWidth](_drawing.md#oh_drawing_pensetwidth) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, float width) | Sets the thickness for a pen. This thickness determines the width of the outline of a shape. | +| [OH_Drawing_PenGetMiterLimit](_drawing.md#oh_drawing_pengetmiterlimit) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the stroke miter limit of a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. | +| [OH_Drawing_PenSetMiterLimit](_drawing.md#oh_drawing_pensetmiterlimit) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, float miter) | Sets the stroke miter limit for a polyline drawn by a pen. When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded, and a mitered corner is displayed if the miter limit is not exceeded. | +| [OH_Drawing_PenGetCap](_drawing.md#oh_drawing_pengetcap) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the line cap style of a pen. | +| [OH_Drawing_PenSetCap](_drawing.md#oh_drawing_pensetcap) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, [OH_Drawing_PenLineCapStyle](_drawing.md#oh_drawing_penlinecapstyle)) | Sets the line cap style for a pen. | +| [OH_Drawing_PenGetJoin](_drawing.md#oh_drawing_pengetjoin) (const [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*) | Obtains the line join style of a pen. | +| [OH_Drawing_PenSetJoin](_drawing.md#oh_drawing_pensetjoin) ([OH_Drawing_Pen](_drawing.md#oh_drawing_pen) \*, [OH_Drawing_PenLineJoinStyle](_drawing.md#oh_drawing_penlinejoinstyle)) | Sets the line join style for a pen. | diff --git a/en/application-dev/reference/native-apis/drawing__text__declaration_8h.md b/en/application-dev/reference/native-apis/drawing__text__declaration_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..3b188162f666775b643bb396d69e0a635e8ee064 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__text__declaration_8h.md @@ -0,0 +1,27 @@ +# drawing_text_declaration.h + + +## Overview + +Declares the data structure related to text in 2D drawing. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection) | Defines an **OH_Drawing_FontCollection**, which is used to load fonts. | +| [OH_Drawing_Typography](_drawing.md#oh_drawing_typography) | Defines an **OH_Drawing_Typography**, which is used to manage the typography layout and display. | +| [OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) | Defines an **OH_Drawing_TextStyle**, which is used to manage text colors and decorations. | +| [OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) | Defines an **OH_Drawing_TypographyStyle**, which is used to manage the typography style, such as the text direction. | +| [OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) | Defines an **OH_Drawing_TypographyCreate**, which is used to create an **OH_Drawing_Typography** object. | diff --git a/en/application-dev/reference/native-apis/drawing__text__typography_8h.md b/en/application-dev/reference/native-apis/drawing__text__typography_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..b70d32f778794e2da7f328929a8954e5146cc929 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__text__typography_8h.md @@ -0,0 +1,67 @@ +# drawing_text_typography.h + + +## Overview + +Declares functions related to **typography** in the drawing module. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_TextDirection](_drawing.md#oh_drawing_textdirection) { [TEXT_DIRECTION_RTL](_drawing.md), [TEXT_DIRECTION_LTR](_drawing.md) } | Enumerates text directions. | +| [OH_Drawing_TextAlign](_drawing.md#oh_drawing_textalign) {
[TEXT_ALIGN_LEFT](_drawing.md), [TEXT_ALIGN_RIGHT](_drawing.md), [TEXT_ALIGN_CENTER](_drawing.md), [TEXT_ALIGN_JUSTIFY](_drawing.md),
[TEXT_ALIGN_START](_drawing.md), [TEXT_ALIGN_END](_drawing.md)
} | Enumerates text alignment modes. | +| [OH_Drawing_FontWeight](_drawing.md#oh_drawing_fontweight) {
[FONT_WEIGHT_100](_drawing.md), [FONT_WEIGHT_200](_drawing.md), [FONT_WEIGHT_300](_drawing.md), [FONT_WEIGHT_400](_drawing.md),
[FONT_WEIGHT_500](_drawing.md), [FONT_WEIGHT_600](_drawing.md), [FONT_WEIGHT_700](_drawing.md), [FONT_WEIGHT_800](_drawing.md),
[FONT_WEIGHT_900](_drawing.md)
} | Enumerates font weights. | +| [OH_Drawing_TextBaseline](_drawing.md#oh_drawing_textbaseline) { [TEXT_BASELINE_ALPHABETIC](_drawing.md), [TEXT_BASELINE_IDEOGRAPHIC](_drawing.md) } | Enumerates text baselines. | +| [OH_Drawing_TextDecoration](_drawing.md#oh_drawing_textdecoration) { [TEXT_DECORATION_NONE](_drawing.md) = 0x0, [TEXT_DECORATION_UNDERLINE](_drawing.md) = 0x1, [TEXT_DECORATION_OVERLINE](_drawing.md) = 0x2, [TEXT_DECORATION_LINE_THROUGH](_drawing.md) = 0x4 } | Enumerates text decorations. | +| [OH_Drawing_FontStyle](_drawing.md#oh_drawing_fontstyle) { [FONT_STYLE_NORMAL](_drawing.md), [FONT_STYLE_ITALIC](_drawing.md) } | Enumerates font styles. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_CreateTypographyStyle](_drawing.md#oh_drawing_createtypographystyle) (void) | Creates an **OH_Drawing_TypographyStyle** object. | +| [OH_Drawing_DestroyTypographyStyle](_drawing.md#oh_drawing_destroytypographystyle) ([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) \*) | Releases the memory occupied by an **OH_Drawing_TypographyStyle** object. | +| [OH_Drawing_SetTypographyTextDirection](_drawing.md#oh_drawing_settypographytextdirection) ([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) \*, int) | Sets the text direction. | +| [OH_Drawing_SetTypographyTextAlign](_drawing.md#oh_drawing_settypographytextalign) ([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) \*, int) | Sets the text alignment mode. | +| [OH_Drawing_SetTypographyTextMaxLines](_drawing.md#oh_drawing_settypographytextmaxlines) ([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) \*, int) | Sets the maximum number of lines in a text file. | +| [OH_Drawing_CreateTextStyle](_drawing.md#oh_drawing_createtextstyle) (void) | Creates an **OH_Drawing_TextStyle** object. | +| [OH_Drawing_DestroyTextStyle](_drawing.md#oh_drawing_destroytextstyle) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*) | Releases the memory occupied by an **OH_Drawing_TextStyle** object. | +| [OH_Drawing_SetTextStyleColor](_drawing.md#oh_drawing_settextstylecolor) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, uint32_t) | Sets the text color. | +| [OH_Drawing_SetTextStyleFontSize](_drawing.md#oh_drawing_settextstylefontsize) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, double) | Sets the font size. | +| [OH_Drawing_SetTextStyleFontWeight](_drawing.md#oh_drawing_settextstylefontweight) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, int) | Sets the font weight. | +| [OH_Drawing_SetTextStyleBaseLine](_drawing.md#oh_drawing_settextstylebaseline) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, int) | Sets the text baseline. | +| [OH_Drawing_SetTextStyleDecoration](_drawing.md#oh_drawing_settextstyledecoration) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, int) | Sets the text decoration. | +| [OH_Drawing_SetTextStyleDecorationColor](_drawing.md#oh_drawing_settextstyledecorationcolor) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, uint32_t) | Sets the color for the text decoration. | +| [OH_Drawing_SetTextStyleFontHeight](_drawing.md#oh_drawing_settextstylefontheight) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, double) | Sets the font height. | +| [OH_Drawing_SetTextStyleFontFamilies](_drawing.md#oh_drawing_settextstylefontfamilies) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, int, const char \*fontFamilies[]) | Sets the font families. | +| [OH_Drawing_SetTextStyleFontStyle](_drawing.md#oh_drawing_settextstylefontstyle) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, int) | Sets the font style. | +| [OH_Drawing_SetTextStyleLocale](_drawing.md#oh_drawing_settextstylelocale) ([OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*, const char \*) | Sets the locale. | +| [OH_Drawing_CreateTypographyHandler](_drawing.md#oh_drawing_createtypographyhandler) ([OH_Drawing_TypographyStyle](_drawing.md#oh_drawing_typographystyle) \*, [OH_Drawing_FontCollection](_drawing.md#oh_drawing_fontcollection) \*) | Creates a pointer to an **OH_Drawing_TypographyCreate** object. | +| [OH_Drawing_DestroyTypographyHandler](_drawing.md#oh_drawing_destroytypographyhandler) ([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) \*) | Releases the memory occupied by an **OH_Drawing_TypographyCreate** object. | +| [OH_Drawing_TypographyHandlerPushTextStyle](_drawing.md#oh_drawing_typographyhandlerpushtextstyle) ([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) \*, [OH_Drawing_TextStyle](_drawing.md#oh_drawing_textstyle) \*) | Sets the text style. | +| [OH_Drawing_TypographyHandlerAddText](_drawing.md#oh_drawing_typographyhandleraddtext) ([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) \*, const char \*) | Sets the text content. | +| [OH_Drawing_TypographyHandlerPopTextStyle](_drawing.md#oh_drawing_typographyhandlerpoptextstyle) ([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) \*) | Removes the topmost style in the stack, leaving the remaining styles in effect. | +| [OH_Drawing_CreateTypography](_drawing.md#oh_drawing_createtypography) ([OH_Drawing_TypographyCreate](_drawing.md#oh_drawing_typographycreate) \*) | Creates an **OH_Drawing_Typography** object. | +| [OH_Drawing_DestroyTypography](_drawing.md#oh_drawing_destroytypography) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Releases the memory occupied by an **OH_Drawing_Typography** object. | +| [OH_Drawing_TypographyLayout](_drawing.md#oh_drawing_typographylayout) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*, double) | Lays out the typography. | +| [OH_Drawing_TypographyPaint](_drawing.md#oh_drawing_typographypaint) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*, [OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) \*, double, double) | Paints text on the canvas. | +| [OH_Drawing_TypographyGetMaxWidth](_drawing.md#oh_drawing_typographygetmaxwidth) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the maximum width. | +| [OH_Drawing_TypographyGetHeight](_drawing.md#oh_drawing_typographygetheight) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the height. | +| [OH_Drawing_TypographyGetLongestLine](_drawing.md#oh_drawing_typographygetlongestline) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the longest line. | +| [OH_Drawing_TypographyGetMinIntrinsicWidth](_drawing.md#oh_drawing_typographygetminintrinsicwidth) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the minimum intrinsic width. | +| [OH_Drawing_TypographyGetMaxIntrinsicWidth](_drawing.md#oh_drawing_typographygetmaxintrinsicwidth) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the maximum intrinsic width. | +| [OH_Drawing_TypographyGetAlphabeticBaseline](_drawing.md#oh_drawing_typographygetalphabeticbaseline) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the alphabetic baseline. | +| [OH_Drawing_TypographyGetIdeographicBaseline](_drawing.md#oh_drawing_typographygetideographicbaseline) ([OH_Drawing_Typography](_drawing.md#oh_drawing_typography) \*) | Obtains the ideographic baseline. | diff --git a/en/application-dev/reference/native-apis/drawing__types_8h.md b/en/application-dev/reference/native-apis/drawing__types_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..644a9c3802599577d8fb5943d33c7f2bc1cf2c22 --- /dev/null +++ b/en/application-dev/reference/native-apis/drawing__types_8h.md @@ -0,0 +1,35 @@ +# drawing_types.h + + +## Overview + +Declares the data types for drawing 2D graphics, including the canvas, brush, pen, bitmap, and path. + +**Since:** +8 + +**Related Modules:** + +[Drawing](_drawing.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_Canvas](_drawing.md#oh_drawing_canvas) | Defines a rectangular canvas on which various shapes, images, and texts can be drawn by using the brush and pen. | +| [OH_Drawing_Pen](_drawing.md#oh_drawing_pen) | Defines a pen, which is used to describe the style and color to outline a shape. | +| [OH_Drawing_Brush](_drawing.md#oh_drawing_brush) | Defines as a brush, which is used to describe the style and color to fill in a shape. | +| [OH_Drawing_Path](_drawing.md#oh_drawing_path) | Defines a path, which is used to customize various shapes. | +| [OH_Drawing_Bitmap](_drawing.md#oh_drawing_bitmap) | Defines a bitmap, which is a memory that contains the pixel data of a shape. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Drawing_ColorFormat](_drawing.md#oh_drawing_colorformat) {
COLOR_FORMAT_UNKNOWN, COLOR_FORMAT_ALPHA_8, COLOR_FORMAT_RGB_565, COLOR_FORMAT_ARGB_4444,
COLOR_FORMAT_RGBA_8888, COLOR_FORMAT_BGRA_8888
} | Enumerates storage formats of bitmap pixels. | +| [OH_Drawing_AlphaFormat](_drawing.md#oh_drawing_alphaformat) { ALPHA_FORMAT_UNKNOWN, ALPHA_FORMAT_OPAQUE, ALPHA_FORMAT_PREMUL, ALPHA_FORMAT_UNPREMUL } | Enumerates alpha formats of bitmap pixels. | diff --git a/en/application-dev/reference/native-apis/external__window_8h.md b/en/application-dev/reference/native-apis/external__window_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..6245c6f40cc0090a80d6fa0616ce28c5c47c22fb --- /dev/null +++ b/en/application-dev/reference/native-apis/external__window_8h.md @@ -0,0 +1,66 @@ +# external_window.h + + +## Overview + +Defines the functions for obtaining and using a native window. + +**Since:** +8 + +**Related Modules:** + +[NativeWindow](_native_window.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [Region](_region.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | +| [Region::Rect](_rect.md) | Rectangular area. | +| [OHHDRMetaData](_o_h_h_d_r_meta_data.md) | Defines the HDR metadata. | +| [OHExtDataHandle](_o_h_ext_data_handle.md) | Defines the extended data handle. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OHNativeWindow](_native_window.md) | Provides the function of accessing the **NativeWindow**. | +| [OHNativeWindowBuffer](_native_window.md) | Provides the function of accessing the **NativeWindowBuffer**. | +| [Region](_native_window.md) | Defines the rectangle (dirty region) where the content is to be updated in the local native window. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [NativeWindowOperation](_native_window.md#nativewindowoperation) {
[SET_BUFFER_GEOMETRY](_native_window.md), [GET_BUFFER_GEOMETRY](_native_window.md), [GET_FORMAT](_native_window.md), [SET_FORMAT](_native_window.md),
[GET_USAGE](_native_window.md), [SET_USAGE](_native_window.md), [SET_STRIDE](_native_window.md), [GET_STRIDE](_native_window.md),
[SET_SWAP_INTERVAL](_native_window.md), [GET_SWAP_INTERVAL](_native_window.md), [SET_TIMEOUT](_native_window.md), [GET_TIMEOUT](_native_window.md),
[SET_COLOR_GAMUT](_native_window.md), [GET_COLOR_GAMUT](_native_window.md), [SET_TRANSFORM](_native_window.md), [GET_TRANSFORM](_native_window.md),
[SET_UI_TIMESTAMP](_native_window.md)
} | Enumerates the operation codes in the **OH_NativeWindow_NativeWindowHandleOpt** function. | +| [OHScalingMode](_native_window.md#ohscalingmode) { [OH_SCALING_MODE_FREEZE](_native_window.md) = 0, [OH_SCALING_MODE_SCALE_TO_WINDOW](_native_window.md), [OH_SCALING_MODE_SCALE_CROP](_native_window.md), [OH_SCALING_MODE_NO_SCALE_CROP](_native_window.md) } | Enumerates the scaling modes. | +| [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) {
[OH_METAKEY_RED_PRIMARY_X](_native_window.md) = 0, [OH_METAKEY_RED_PRIMARY_Y](_native_window.md) = 1, [OH_METAKEY_GREEN_PRIMARY_X](_native_window.md) = 2, [OH_METAKEY_GREEN_PRIMARY_Y](_native_window.md) = 3,
[OH_METAKEY_BLUE_PRIMARY_X](_native_window.md) = 4, [OH_METAKEY_BLUE_PRIMARY_Y](_native_window.md) = 5, [OH_METAKEY_WHITE_PRIMARY_X](_native_window.md) = 6, [OH_METAKEY_WHITE_PRIMARY_Y](_native_window.md) = 7,
[OH_METAKEY_MAX_LUMINANCE](_native_window.md) = 8, [OH_METAKEY_MIN_LUMINANCE](_native_window.md) = 9, [OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL](_native_window.md) = 10, [OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL](_native_window.md) = 11,
[OH_METAKEY_HDR10_PLUS](_native_window.md) = 12, [OH_METAKEY_HDR_VIVID](_native_window.md) = 13
} | Enumerates the HDR metadata keys. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NativeWindow_CreateNativeWindow](_native_window.md#oh_nativewindow_createnativewindow) (void \*pSurface) | [OHNativeWindow](_native_window.md) \*
Creates a **NativeWindow** instance. A new **NativeWindow** instance is created each time this function is called. | +| [OH_NativeWindow_DestroyNativeWindow](_native_window.md#oh_nativewindow_destroynativewindow) ([OHNativeWindow](_native_window.md) \*window) | Decreases the reference count of a **NativeWindow** instance by 1 and when the reference count reaches 0, destroys the instance. | +| [OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer](_native_window.md#oh_nativewindow_createnativewindowbufferfromsurfacebuffer) (void \*pSurfaceBuffer) | [OHNativeWindowBuffer](_native_window.md) \*
Creates a **NativeWindowBuffer** instance. A new **NativeWindowBuffer** instance is created each time this function is called. | +| [OH_NativeWindow_DestroyNativeWindowBuffer](_native_window.md#oh_nativewindow_destroynativewindowbuffer) ([OHNativeWindowBuffer](_native_window.md) \*buffer) | Decreases the reference count of a **NativeWindowBuffer** instance by 1 and when the reference count reaches 0, destroys the instance. | +| [OH_NativeWindow_NativeWindowRequestBuffer](_native_window.md#oh_nativewindow_nativewindowrequestbuffer) ([OHNativeWindow](_native_window.md) \*window, [OHNativeWindowBuffer](_native_window.md) \*\*buffer, int \*fenceFd) | Requests a **NativeWindowBuffer** through a **NativeWindow** instance for content production. | +| [OH_NativeWindow_NativeWindowFlushBuffer](_native_window.md#oh_nativewindow_nativewindowflushbuffer) ([OHNativeWindow](_native_window.md) \*window, [OHNativeWindowBuffer](_native_window.md) \*buffer, int fenceFd, [Region](_region.md) region) | Flushes the **NativeWindowBuffer** filled with the content to the buffer queue through a **NativeWindow** instance for content consumption. | +| [OH_NativeWindow_NativeWindowAbortBuffer](_native_window.md#oh_nativewindow_nativewindowabortbuffer) ([OHNativeWindow](_native_window.md) \*window, [OHNativeWindowBuffer](_native_window.md) \*buffer) | Returns the **NativeWindowBuffer** to the buffer queue through a **NativeWindow** instance, without filling in any content. The **NativeWindowBuffer** can be used for another request. | +| [OH_NativeWindow_NativeWindowHandleOpt](_native_window.md#oh_nativewindow_nativewindowhandleopt) ([OHNativeWindow](_native_window.md) \*window, int code,...) | Sets or obtains the attributes of a native window, including the width, height, and content format. | +| [OH_NativeWindow_GetBufferHandleFromNative](_native_window.md#oh_nativewindow_getbufferhandlefromnative) ([OHNativeWindowBuffer](_native_window.md) \*buffer) | Obtains the pointer to a **BufferHandle** of a **NativeWindowBuffer** instance. | +| [OH_NativeWindow_NativeObjectReference](_native_window.md#oh_nativewindow_nativeobjectreference) (void \*obj) | Adds the reference count of a native object. | +| [OH_NativeWindow_NativeObjectUnreference](_native_window.md#oh_nativewindow_nativeobjectunreference) (void \*obj) | Decreases the reference count of a native object and when the reference count reaches 0, destroys this object. | +| [OH_NativeWindow_GetNativeObjectMagic](_native_window.md#oh_nativewindow_getnativeobjectmagic) (void \*obj) | Obtains the magic ID of a native object. | +| [OH_NativeWindow_NativeWindowSetScalingMode](_native_window.md#oh_nativewindow_nativewindowsetscalingmode) ([OHNativeWindow](_native_window.md) \*window, uint32_t sequence, [OHScalingMode](_native_window.md#ohscalingmode) scalingMode) | Sets the scaling mode for a native window. | +| [OH_NativeWindow_NativeWindowSetMetaData](_native_window.md#oh_nativewindow_nativewindowsetmetadata) ([OHNativeWindow](_native_window.md) \*window, uint32_t sequence, int32_t size, const [OHHDRMetaData](_o_h_h_d_r_meta_data.md) \*metaData) | Sets the metadata for a native window. | +| [OH_NativeWindow_NativeWindowSetMetaDataSet](_native_window.md#oh_nativewindow_nativewindowsetmetadataset) ([OHNativeWindow](_native_window.md) \*window, uint32_t sequence, [OHHDRMetadataKey](_native_window.md#ohhdrmetadatakey) key, int32_t size, const uint8_t \*metaData) | Sets the metadata set for a native window. | +| [OH_NativeWindow_NativeWindowSetTunnelHandle](_native_window.md#oh_nativewindow_nativewindowsettunnelhandle) ([OHNativeWindow](_native_window.md) \*window, const [OHExtDataHandle](_o_h_ext_data_handle.md) \*handle) | Sets a tunnel handle for a native window. | diff --git a/en/application-dev/reference/native-apis/format_8h.md b/en/application-dev/reference/native-apis/format_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d3ecd85ad3a793c55b24d388ab7e859b97a53432 --- /dev/null +++ b/en/application-dev/reference/native-apis/format_8h.md @@ -0,0 +1,30 @@ +# format.h + + +## Overview + +Declares tensor data formats. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_Format](_mind_spore.md#oh_ai_format) | Declares data formats supported by MSTensor. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AI_Format](_mind_spore.md#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. | diff --git a/en/application-dev/reference/native-apis/image.md b/en/application-dev/reference/native-apis/image.md new file mode 100644 index 0000000000000000000000000000000000000000..218c78042c84bc5a43edf57b4849d08c0f6808a4 --- /dev/null +++ b/en/application-dev/reference/native-apis/image.md @@ -0,0 +1,727 @@ +# Image + + +## Overview + +Provides APIs for obtaining pixel map data and information. + +\@Syscap SystemCapability.Multimedia.Image + +**Since:** +8 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [image_pixel_map_napi.h](image__pixel__map__napi_8h.md) | Declares the APIs that can lock, access, and unlock pixel map data.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information. | +| [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) | Defines the options used for creating a pixel map. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [NativePixelMap](#nativepixelmap) | Defines the data type name of the native pixel map. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by a function. | +| { OHOS_PIXEL_MAP_FORMAT_NONE = 0, OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 } | Enumerates the pixel formats. | +| { OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0, OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1, OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2, OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3 } | Enumerates the pixel map alpha types. | +| { OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0, OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1 } | Enumerates the pixel map scale modes. | +| { OHOS_PIXEL_MAP_READ_ONLY = 0, OHOS_PIXEL_MAP_EDITABLE = 1 } | Enumerates the pixel map editing types. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_GetImageInfo](#oh_getimageinfo) (napi_env env, napi_value value, [OhosPixelMapInfo](_ohos_pixel_map_info.md) \*info) | Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure. | +| [OH_AccessPixels](#oh_accesspixels) (napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of the **PixelMap** object data and locks the memory. | +| [OH_UnAccessPixels](#oh_unaccesspixels) (napi_env env, napi_value value) | Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. | +| [OH_PixelMap_CreatePixelMap](#oh_pixelmap_createpixelmap) (napi_env env, [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) info, void \*buf, size_t len, napi_value \*res) | Creates a **PixelMap** object. | +| [OH_PixelMap_CreateAlphaPixelMap](#oh_pixelmap_createalphapixelmap) (napi_env env, napi_value source, napi_value \*alpha) | Creates a **PixelMap** object that contains only alpha channel information. | +| [OH_PixelMap_InitNativePixelMap](#oh_pixelmap_initnativepixelmap) (napi_env env, napi_value source) | Initializes a **PixelMap** object. | +| [OH_PixelMap_GetBytesNumberPerRow](#oh_pixelmap_getbytesnumberperrow) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*num) | Obtains the number of bytes per row of a **PixelMap** object. | +| [OH_PixelMap_GetIsEditable](#oh_pixelmap_getiseditable) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*[editable](image__pixel__map__napi_8h.md#editable)) | Checks whether a **PixelMap** object is editable. | +| [OH_PixelMap_IsSupportAlpha](#oh_pixelmap_issupportalpha) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*alpha) | Checks whether a **PixelMap** object supports alpha channels. | +| [OH_PixelMap_SetAlphaAble](#oh_pixelmap_setalphaable) (const [NativePixelMap](#nativepixelmap) \*native, int32_t alpha) | Sets an alpha channel for a **PixelMap** object. | +| [OH_PixelMap_GetDensity](#oh_pixelmap_getdensity) (const [NativePixelMap](#nativepixelmap) \*native, int32_t \*density) | Obtains the pixel density of a **PixelMap** object. | +| [OH_PixelMap_SetDensity](#oh_pixelmap_setdensity) (const [NativePixelMap](#nativepixelmap) \*native, int32_t density) | Sets the pixel density for a **PixelMap** object. | +| [OH_PixelMap_SetOpacity](#oh_pixelmap_setopacity) (const [NativePixelMap](#nativepixelmap) \*native, float opacity) | Sets the opacity for a **PixelMap** object. | +| [OH_PixelMap_Scale](#oh_pixelmap_scale) (const [NativePixelMap](#nativepixelmap) \*native, float x, float y) | Scales a **PixelMap** object. | +| [OH_PixelMap_Translate](#oh_pixelmap_translate) (const [NativePixelMap](#nativepixelmap) \*native, float x, float y) | Translates a **PixelMap** object. | +| [OH_PixelMap_Rotate](#oh_pixelmap_rotate) (const [NativePixelMap](#nativepixelmap) \*native, float angle) | Rotates a **PixelMap** object. | +| [OH_PixelMap_Flip](#oh_pixelmap_flip) (const [NativePixelMap](#nativepixelmap) \*native, int32_t x, int32_t y) | Flips a **PixelMap** object. | +| [OH_PixelMap_Crop](#oh_pixelmap_crop) (const [NativePixelMap](#nativepixelmap) \*native, int32_t x, int32_t y, int32_t [width](image__pixel__map__napi_8h.md#width), int32_t [height](image__pixel__map__napi_8h.md#height)) | Crops a **PixelMap** object. | + +## Type Description + + +### NativePixelMap + + +``` +typedef struct NativePixelMapNativePixelMap +``` +**Description:**
+Defines the data type name of the native pixel map. + +## Enum Description + + +### anonymous enum + + +``` +anonymous enum +``` +**Description**
+Enumerates the error codes returned by a function. + +| Name | Description | +| -------- | -------- | +| OHOS_IMAGE_RESULT_SUCCESS | Operation success. | +| OHOS_IMAGE_RESULT_BAD_PARAMETER | Invalid value. | + + +### anonymous enum + + +``` +anonymous enum +``` +**Description**
+Enumerates the pixel formats. + +| Name | Description | +| -------- | -------- | +| OHOS_PIXEL_MAP_FORMAT_NONE | Unknown format. | +| OHOS_PIXEL_MAP_FORMAT_RGBA_8888 | 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). The data is stored from the most significant bit to the least significant bit. | +| OHOS_PIXEL_MAP_FORMAT_RGB_565 | 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. The storage sequence is from the most significant bit to the least significant bit. | + +### anonymous enum + + +``` +anonymous enum +``` +**Description:**
+Enumerates the pixel map alpha types. + +| Name | Description | +| -------- | -------- | +| OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN | Unknown format. | +| OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE | Opaque format. | +| OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL | Premultiplied format. | +| OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL | Unpremultiplied format. | + + +### anonymous enum + + +``` +anonymous enum +``` +**Description:**
+Enumerates the pixel map scale modes. + +| Name | Description | +| -------- | -------- | +| OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE | Adaptation to the target image size. | +| OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP | Cropping the center portion of an image to the target size. | + + +### anonymous enum + + +``` +anonymous enum +``` +**Description:**
+Enumerates the pixel map editing types. + +| Name | Description | +| -------- | -------- | +| OHOS_PIXEL_MAP_READ_ONLY | Read-only. | +| OHOS_PIXEL_MAP_EDITABLE | Editable. | + + +## Function Description + + +### OH_AccessPixels() + + +``` +int32_t OH_AccessPixels (napi_env env, napi_value value, void ** addrPtr ) +``` +**Description**
+Obtains the memory address of the **PixelMap** object data and locks the memory. + +After the function is executed successfully, **\*addrPtr** is the address of the memory to be accessed. After the access operation is complete, you must use [OH_UnAccessPixels](#oh_unaccesspixels) to unlock the memory. Otherwise, the resources in the memory cannot be released. After being unlocked, the memory address cannot be accessed or operated. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| value | Indicates the **PixelMap** object at the application layer. | +| addrPtr | Indicates the double pointer to the memory address. | + + **See** + +UnAccessPixels + +**Returns** + +Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. + + +### OH_GetImageInfo() + + +``` +int32_t OH_GetImageInfo (napi_env env, napi_value value, OhosPixelMapInfo * info ) +``` +**Description**
+Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| value | Indicates the **PixelMap** object at the application layer. | +| info | Indicates the pointer to the object that stores the information obtained. For details, see [OhosPixelMapInfo](_ohos_pixel_map_info.md). | + +**Returns** + +Returns **0** if the information is obtained and stored successfully; returns an error code otherwise. + + **See** + +[OhosPixelMapInfo](_ohos_pixel_map_info.md) + + +### OH_UnAccessPixels() + + +``` +int32_t OH_UnAccessPixels (napi_env env, napi_value value ) +``` +**Description**
+Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| value | Indicates the **PixelMap** object at the application layer. | + +**Returns** + +Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. + + **See** + +AccessPixels + +### OH_PixelMap_CreateAlphaPixelMap() + + +``` +int32_t OH_PixelMap_CreateAlphaPixelMap (napi_env env, napi_value source, napi_value * alpha ) +``` +**Description:**
+Creates a **PixelMap** object that contains only alpha channel information. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| source | Indicates the options for setting the **PixelMap** object. | +| alpha | Indicates the pointer to the alpha channel. | + +**Returns** + +Returns a **PixelMap** object if the operation is successful; returns an error code otherwise. + + **See** + +CreateAlphaPixelMap + + +### OH_PixelMap_CreatePixelMap() + + +``` +int32_t OH_PixelMap_CreatePixelMap (napi_env env, OhosPixelMapCreateOps info, void * buf, size_t len, napi_value * res ) +``` +**Description:**
+Creates a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| info | Indicates the options for setting the **PixelMap** object. | +| buf | Indicates the pointer to the buffer of the image. | +| len | Indicates the image size. | +| res | Indicates the pointer to the **PixelMap** object at the application layer. | + +**Returns** + +Returns a **PixelMap** object if the operation is successful; returns an error code otherwise. + + **See** + +CreatePixelMap + + +### OH_PixelMap_Crop() + + +``` +int32_t OH_PixelMap_Crop (const NativePixelMap * native, int32_t x, int32_t y, int32_t width, int32_t height ) +``` +**Description:**
+Crops a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| x | Indicates the x-coordinate of the upper left corner of the target image. | +| y | Indicates the y-coordinate of the upper left corner of the target image. | +| width | Indicates the width of the cropped region. | +| height | Indicates the height of the cropped region. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +Crop + + +### OH_PixelMap_Flip() + + +``` +int32_t OH_PixelMap_Flip (const NativePixelMap * native, int32_t x, int32_t y ) +``` +**Description:**
+Flips a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| x | Specifies whether to flip around the x axis. | +| y | Specifies whether to flip around the y axis. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +Flip + + +### OH_PixelMap_GetBytesNumberPerRow() + + +``` +int32_t OH_PixelMap_GetBytesNumberPerRow (const NativePixelMap * native, int32_t * num ) +``` +**Description:**
+Obtains the number of bytes per row of a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| num | Indicates the pointer to the number of bytes per row of the **PixelMap** object. | + +**Returns** + +Returns the number of bytes per row of the **PixelMap** object if the operation is successful; returns an error code otherwise. + + **See** + +GetBytesNumberPerRow + + +### OH_PixelMap_GetDensity() + + +``` +int32_t OH_PixelMap_GetDensity (const NativePixelMap * native, int32_t * density ) +``` +**Description:**
+Obtains the pixel density of a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| density | Indicates the pointer to the pixel density. | + +**Returns** + +Returns the pixel density if the operation is successful; returns an error code otherwise. + + **See** + +GetDensity + + +### OH_PixelMap_GetImageInfo() + + +``` +int32_t OH_PixelMap_GetImageInfo (const NativePixelMap * native, OhosPixelMapInfo * info ) +``` +**Description:**
+Obtains the image information of a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| info | Indicates the pointer to the image information. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +[OhosPixelMapInfo](_ohos_pixel_map_info.md) + + +### OH_PixelMap_GetIsEditable() + + +``` +int32_t OH_PixelMap_GetIsEditable (const NativePixelMap * native, int32_t * editable ) +``` +**Description:**
+Checks whether a **PixelMap** object is editable. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| editable | Indicates the pointer to the editing type of the **PixelMap** object. | + +**Returns** + +Returns an enumerated value that indicates the editing type of the **PixelMap** object if the operation is successful; returns an error code otherwise. + + **See** + +GetIsEditable + + +### OH_PixelMap_InitNativePixelMap() + + +``` +NativePixelMap* OH_PixelMap_InitNativePixelMap (napi_env env, napi_value source ) +``` +**Description:**
+Initializes a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| source | Indicates the options for setting the **PixelMap** object. | + +**Returns** + +Returns a pointer to the **NativePixelMap** object if the operation is successful; returns an error code otherwise. + + **See** + +InitNativePixelMap + + +### OH_PixelMap_IsSupportAlpha() + + +``` +int32_t OH_PixelMap_IsSupportAlpha (const NativePixelMap * native, int32_t * alpha ) +``` +**Description:**
+Checks whether a **PixelMap** object supports alpha channels. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| alpha | Indicates the pointer to the support for alpha channels. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +IsSupportAlpha + + +### OH_PixelMap_Rotate() + + +``` +int32_t OH_PixelMap_Rotate (const NativePixelMap * native, float angle ) +``` +**Description:**
+Rotates a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| angle | Indicates the angle to rotate. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +Rotate + + +### OH_PixelMap_Scale() + + +``` +int32_t OH_PixelMap_Scale (const NativePixelMap * native, float x, float y ) +``` +**Description:**
+Scales a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| x | Indicates the scaling ratio of the width. | +| y | Indicates the scaling ratio of the height. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +Scale + + +### OH_PixelMap_SetAlphaAble() + + +``` +int32_t OH_PixelMap_SetAlphaAble (const NativePixelMap * native, int32_t alpha ) +``` +**Description:**
+Sets an alpha channel for a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| alpha | Indicates the alpha channel to set. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +SetAlphaAble + + +### OH_PixelMap_SetDensity() + + +``` +int32_t OH_PixelMap_SetDensity (const NativePixelMap * native, int32_t density ) +``` +**Description:**
+Sets the pixel density for a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| density | Indicates the pixel density to set. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +GetDensity + + +### OH_PixelMap_SetOpacity() + + +``` +int32_t OH_PixelMap_SetOpacity (const NativePixelMap * native, float opacity ) +``` +**Description:**
+Sets the opacity for a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| opacity | Indicates the opacity to set. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +SetOpacity + + +### OH_PixelMap_Translate() + + +``` +int32_t OH_PixelMap_Translate (const NativePixelMap * native, float x, float y ) +``` +**Description:**
+Translates a **PixelMap** object. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| x | Indicates the horizontal distance to translate. | +| y | Indicates the vertical distance to translate. | + +**Returns** + +Returns **0** if the operation is successful; returns an error code otherwise. + + **See** + +Translate + + +### OH_PixelMap_UnAccessPixels() + + +``` +int32_t OH_PixelMap_UnAccessPixels (const NativePixelMap * native) +``` +**Description:**
+Unlocks the memory of the **NativePixelMap** object data. This function is used with [OH_PixelMap_AccessPixels](#oh_pixelmap_accesspixels) in pairs. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | + +**Returns** + +Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. + + **See** + +AccessPixels + + +### OH_PixelMap_AccessPixels() + + +``` +int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr) +``` +**Description:**
+Obtains the memory address of a **NativePixelMap** object and locks the memory. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| native | Indicates the pointer to a **NativePixelMap** object. | +| addr | Indicates the double pointer to the memory address. | + +**Returns** + +Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. + + **See** + +UnAccessPixels + + +### OH_UnAccessPixels() + + +``` +int32_t OH_UnAccessPixels (napi_env env, napi_value value ) +``` +**Description:**
+Unlocks the memory of a **PixelMap** object. This function is used with [OH_AccessPixels](#oh_accesspixels) in pairs. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the NAPI environment pointer. | +| value | Indicates the **PixelMap** object at the application layer. | + +**Returns** + +Returns OHOS_IMAGE_RESULT_SUCCESS if the operation is successful; returns an error code otherwise. + + **See** + +AccessPixels diff --git a/en/application-dev/reference/native-apis/image__pixel__map__napi_8h.md b/en/application-dev/reference/native-apis/image__pixel__map__napi_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..aea56bd66bd0cd29f3200787c73264acb07c6bad --- /dev/null +++ b/en/application-dev/reference/native-apis/image__pixel__map__napi_8h.md @@ -0,0 +1,124 @@ +# image_pixel_map_napi.h + + +## Overview + +Declares the APIs that can lock, access, and unlock pixel map data. + +**Since:** +8 + +**Related Modules:** + +[Image](image.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OhosPixelMapInfo](_ohos_pixel_map_info.md) | Defines the pixel map information. | +| [OhosPixelMapCreateOps](_ohos_pixel_map_create_ops.md) |Defines the options used for creating a pixel map. | + +### Types + +| Name | Description | +| -------- | -------- | +| [NativePixelMap](image.md#nativepixelmap) | Defines the data type name of the native pixel map. | + +### Enums + +| Name | Description | +| -------- | -------- | +| { OHOS_IMAGE_RESULT_SUCCESS = 0, OHOS_IMAGE_RESULT_BAD_PARAMETER = -1 } | Enumerates the error codes returned by a function. | +| { OHOS_PIXEL_MAP_FORMAT_NONE = 0, OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2 } | Enumerates the pixel formats. | +| { OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0, OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1, OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2, OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3 } | Enumerates the pixel map alpha types. | +| { OHOS_PIXEL_MAP_SCALE_MODE_FIT_TARGET_SIZE = 0, OHOS_PIXEL_MAP_SCALE_MODE_CENTER_CROP = 1 } | Enumerates the pixel map scale modes. | +| { OHOS_PIXEL_MAP_READ_ONLY = 0, OHOS_PIXEL_MAP_EDITABLE = 1 } | Enumerates the pixel map editing types. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_GetImageInfo](image.md#oh_getimageinfo) (napi_env env, napi_value value, [OhosPixelMapInfo](_ohos_pixel_map_info.md) \*info) | Obtains the **PixelMap** information and stores the information to the [OhosPixelMapInfo](_ohos_pixel_map_info.md) structure. | +| [OH_AccessPixels](image.md#oh_accesspixels) (napi_env env, napi_value value, void \*\*addrPtr) | Obtains the memory address of the **PixelMap** object data and locks the memory. | +| [OH_UnAccessPixels](image.md#oh_unaccesspixels) (napi_env env, napi_value value) | Unlocks the memory of the **PixelMap** object data. This function is used with [OH_AccessPixels](image.md#oh_accesspixels) in pairs. | + + +### Variables + +| Name | Description | +| -------- | -------- | +| [width](#width) | Image width, in pixels. | +| [height](#height) | Image height, in pixels. | +| [pixelFormat](#pixelformat) | Image format. | +| [editable](#editable) | Editing type of the image. | +| [alphaType](#alphatype) | Alpha type of the image. | +| [scaleMode](#scalemode) | Scale mode of the image. | + + +## Variable Description + + +### alphaType + + +``` +uint32_t alphaType +``` +**Description:** +Alpha type of the image. + + +### editable + + +``` +uint32_t editable +``` +**Description:** +Editing type of the image. + + +### height + + +``` +uint32_t height +``` +**Description:** +Image height, in pixels. + + +### pixelFormat + + +``` +int32_t pixelFormat +``` +**Description:** +Image format. + + +### scaleMode + + +``` +uint32_t scaleMode +``` +**Description:** +Scale mode of the image. + + +### width + + +``` +uint32_t width +``` +**Description:** +Image width, in pixels. diff --git a/en/application-dev/reference/native-apis/log_8h.md b/en/application-dev/reference/native-apis/log_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..ed2777d472663cc2090147091f05e1a1d3df28ad --- /dev/null +++ b/en/application-dev/reference/native-apis/log_8h.md @@ -0,0 +1,73 @@ +# log.h + + +## Overview + +Defines the logging functions of the HiLog module. + +Before outputting logs, you must define the service domain, and log tag, use the function with the specified log type and level, and specify the privacy identifier. + +Service domain: service domain of logs. You can define the value as required. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + +Log tag: a string used to identify the class, file, or service behavior. + +Log level: DEBUG, INFO, WARN, ERROR, or FATAL + +Parameter format: printf format string, which starts with a % character, including a parameter type identifier and a variable parameter. + +Privacy identifier: **{public}** or **{private}** added between the % character and the parameter type identifier in each parameter. If no privacy identifier is added, the parameter is considered to be **private**. + +Sample code: + +Defining the service domain and log tag: + +\#define LOG_DOMAIN 0x0201 + +\#define LOG_TAG "MY_TAG" + +Outputting logs: + +HILOG_WARN([LOG_APP](_hi_log.md), "Failed to visit %{private}s, reason:%{public}d.", url, errno); + +Output: + +05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit <private>, reason:503. + +**Since:** +8 + +**Related Modules:** + +[HiLog](_hi_log.md) + + +## Summary + + +### Macros + +| Name | Description | +| -------- | -------- | +| [LOG_DOMAIN](_hi_log.md#log_domain) 0 | Defines the service domain for a log file. | +| [LOG_TAG](_hi_log.md#log_tag) NULL | Defines a string constant used to identify the class, file, or service. | +| [OH_LOG_DEBUG](_hi_log.md#oh_log_debug)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_DEBUG](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs DEBUG logs. This is a function-like macro. | +| [OH_LOG_INFO](_hi_log.md#oh_log_info)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_INFO](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs INFO logs. This is a function-like macro. | +| [OH_LOG_WARN](_hi_log.md#oh_log_warn)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_WARN](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs WARN logs. This is a function-like macro. | +| [OH_LOG_ERROR](_hi_log.md#oh_log_error)(type, ...) ((void)[OH_LOG_Print](_hi_log.md#oh_log_print)((type), [LOG_ERROR](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs ERROR logs. This is a function-like macro. | +| [OH_LOG_FATAL](_hi_log.md#oh_log_fatal)(type, ...) ((void)HiLogPrint((type), [LOG_FATAL](_hi_log.md), [LOG_DOMAIN](_hi_log.md#log_domain), [LOG_TAG](_hi_log.md#log_tag), \_\_VA_ARGS__)) | Outputs FATAL logs. This is a function-like macro. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [LogType](_hi_log.md#logtype) { LOG_APP = 0 } | Enumerates log types. | +| [LogLevel](_hi_log.md#loglevel) {
LOG_DEBUG = 3, LOG_INFO = 4, LOG_WARN = 5, LOG_ERROR = 6,
LOG_FATAL = 7
} | Enumerates log levels. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_LOG_Print](_hi_log.md#oh_log_print) ([LogType](_hi_log.md#logtype) type, [LogLevel](_hi_log.md#loglevel) level, unsigned int domain, const char \*tag, const char \*fmt,...) \_\_attribute__((\_\_format__(os_log, 5, 6))) |Outputs logs. | +| [OH_LOG_IsLoggable](_hi_log.md#oh_log_isloggable) (unsigned int domain, const char \*tag, [LogLevel](_hi_log.md#loglevel) level) | Checks whether logs of the specified service domain, log tag, and log level can be output. | diff --git a/en/application-dev/reference/native-apis/model_8h.md b/en/application-dev/reference/native-apis/model_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d2e9e997edd021560a2c0b5f3f601501825d31cf --- /dev/null +++ b/en/application-dev/reference/native-apis/model_8h.md @@ -0,0 +1,59 @@ +# model.h + + +## Overview + +Provides model-related APIs for model creation and inference. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### 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. | + + +### Macros + +| Name | Description | +| -------- | -------- | +| [OH_AI_MAX_SHAPE_NUM](_mind_spore.md#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) | Defines the pointer to a model object. | +| [OH_AI_TensorHandleArray](_mind_spore.md#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](_mind_spore.md#oh_ai_callbackparam) | Defines the operator information passed in a callback. | +| [OH_AI_KernelCallBack](_mind_spore.md#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. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AI_ModelCreate](_mind_spore.md#oh_ai_modelcreate) () | Creates a model object. | +| [OH_AI_ModelDestroy](_mind_spore.md#oh_ai_modeldestroy) ([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) \*model) | Destroys a model object. | +| [OH_AI_ModelBuild](_mind_spore.md#oh_ai_modelbuild) ([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | +| [OH_AI_ModelBuildFromFile](_mind_spore.md#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | +| [OH_AI_ModelResize](_mind_spore.md#oh_ai_modelresize) ([OH_AI_ModelHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_modelpredict) ([OH_AI_ModelHandle](_mind_spore.md#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](_mind_spore.md#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](_mind_spore.md#oh_ai_kernelcallback) after) | Performs model inference. | +| [OH_AI_ModelGetInputs](_mind_spore.md#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | +| [OH_AI_ModelGetOutputs](_mind_spore.md#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | +| [OH_AI_ModelGetInputByTensorName](_mind_spore.md#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | +| [OH_AI_ModelGetOutputByTensorName](_mind_spore.md#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](_mind_spore.md#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | diff --git a/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..7de3cf3ee68cfdcd946048e3f37646f0981dc51e --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcodec__audiodecoder_8h.md @@ -0,0 +1,36 @@ +# native_avcodec_audiodecoder.h + + +## Overview + +Declares the native APIs used for audio decoding. + +**Since:** +9 + +**Related Modules:** + +[AudioDecoder](_audio_decoder.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AudioDecoder_CreateByMime](_audio_decoder.md#oh_audiodecoder_createbymime) (const char \*mime) | Creates an audio decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioDecoder_CreateByName](_audio_decoder.md#oh_audiodecoder_createbyname) (const char \*name) | Creates an audio decoder instance based on an audio decoder name. To use this API, you must know the exact name of the audio decoder. | +| [OH_AudioDecoder_Destroy](_audio_decoder.md#oh_audiodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio decoder and destroys the audio decoder instance. | +| [OH_AudioDecoder_SetCallback](_audio_decoder.md#oh_audiodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio decoder. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Configure](_audio_decoder.md#oh_audiodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the audio track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_AudioDecoder_Prepare](_audio_decoder.md#oh_audiodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio decoder. This API must be called after **Configure**. | +| [OH_AudioDecoder_Start](_audio_decoder.md#oh_audiodecoder_start) (OH_AVCodec \*codec) | Starts an audio decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioDecoder_Stop](_audio_decoder.md#oh_audiodecoder_stop) (OH_AVCodec \*codec) | Stops an audio decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_AudioDecoder_Flush](_audio_decoder.md#oh_audiodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioDecoder_Reset](_audio_decoder.md#oh_audiodecoder_reset) (OH_AVCodec \*codec) | Resets an audio decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_AudioDecoder_GetOutputDescription](_audio_decoder.md#oh_audiodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio decoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioDecoder_SetParameter](_audio_decoder.md#oh_audiodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_AudioDecoder_PushInputData](_audio_decoder.md#oh_audiodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data to initialize the decoding process. | +| [OH_AudioDecoder_FreeOutputData](_audio_decoder.md#oh_audiodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio decoder. | diff --git a/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..719009d67a638e083242cd77c1660a3fd3e44686 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcodec__audioencoder_8h.md @@ -0,0 +1,36 @@ +# native_avcodec_audioencoder.h + + +## Overview + +Declares the native APIs used for audio encoding. + +**Since:** +9 + +**Related Modules:** + +[AudioEncoder](_audio_encoder.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AudioEncoder_CreateByMime](_audio_encoder.md#oh_audioencoder_createbymime) (const char \*mime) | Creates an audio encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_AudioEncoder_CreateByName](_audio_encoder.md#oh_audioencoder_createbyname) (const char \*name) | Creates an audio encoder instance based on an audio encoder name. To use this API, you must know the exact name of the audio encoder. | +| [OH_AudioEncoder_Destroy](_audio_encoder.md#oh_audioencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of an audio encoder and destroys the audio encoder instance. | +| [OH_AudioEncoder_SetCallback](_audio_encoder.md#oh_audioencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by an audio encoder. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Configure](_audio_encoder.md#oh_audioencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures an audio encoder. Typically, you need to configure the attributes of the audio track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_AudioEncoder_Prepare](_audio_encoder.md#oh_audioencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for an audio encoder. This API must be called after **Configure**. | +| [OH_AudioEncoder_Start](_audio_encoder.md#oh_audioencoder_start) (OH_AVCodec \*codec) | Starts an audio encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_AudioEncoder_Stop](_audio_encoder.md#oh_audioencoder_stop) (OH_AVCodec \*codec) | Stops an audio encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_AudioEncoder_Flush](_audio_encoder.md#oh_audioencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of an audio encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_AudioEncoder_Reset](_audio_encoder.md#oh_audioencoder_reset) (OH_AVCodec \*codec) | Resets an audio encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_AudioEncoder_GetOutputDescription](_audio_encoder.md#oh_audioencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of an audio encoder. The caller must manually release the **OH_AVFormat** instance in the return value. | +| [OH_AudioEncoder_SetParameter](_audio_encoder.md#oh_audioencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for an audio encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_AudioEncoder_PushInputData](_audio_encoder.md#oh_audioencoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to an audio encoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. | +| [OH_AudioEncoder_FreeOutputData](_audio_encoder.md#oh_audioencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of an audio encoder. | diff --git a/en/application-dev/reference/native-apis/native__avcodec__base_8h.md b/en/application-dev/reference/native-apis/native__avcodec__base_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..51b5a5e373007bb61bfd2e2b7ff151fb9c7ed64b --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcodec__base_8h.md @@ -0,0 +1,76 @@ +# native_avcodec_base.h + + +## Overview + +Declares the common structs, character constants, and enums for running **OH_AVCodec** instances. + +**Since:** +9 + +**Related Modules:** + +[CodecBase](_codec_base.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_AVCodecBufferAttr](_codec_base.md#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance. | +| [OH_AVCodecOnError](_codec_base.md#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance. | +| [OH_AVCodecOnStreamChanged](_codec_base.md#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance. | +| [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called. | +| [OH_AVCodecAsyncCallback](_codec_base.md#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance. | +| [OH_MediaType](_codec_base.md#oh_mediatype) | Enumerates the media types. | +| [OH_AVCProfile](_codec_base.md#oh_avcprofile) | Enumerates the AVC profiles. | +| [OH_AACProfile](_codec_base.md#oh_aacprofile) | Enumerates the AAC profiles. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AVCodecBufferFlags](_codec_base.md#oh_avcodecbufferflags) {
AVCODEC_BUFFER_FLAGS_NONE = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3
} | Enumerates the buffer flags of an **OH_AVCodec** instance. | +| [OH_MediaType](_codec_base.md#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types. | +| [OH_AVCProfile](_codec_base.md#oh_avcprofile) { AVC_PROFILE_BASELINE = 0, AVC_PROFILE_HIGH = 4, AVC_PROFILE_MAIN = 8 } | Enumerates the AVC profiles. | +| [OH_AACProfile](_codec_base.md#oh_aacprofile) { AAC_PROFILE_LC = 0 } | Enumerates the AAC profiles. | + + +### Variables + +| Name | Description | +| -------- | -------- | +| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](_codec_base.md#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC). | +| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](_codec_base.md#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC). | +| [OH_ED_KEY_TIME_STAMP](_codec_base.md#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer. | +| [OH_ED_KEY_EOS](_codec_base.md#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.| +| [OH_MD_KEY_TRACK_TYPE](_codec_base.md#oh_md_key_track_type) | Provides unified character descriptors for the media playback framework. | +| [OH_MD_KEY_CODEC_MIME](_codec_base.md#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string.| +| [OH_MD_KEY_DURATION](_codec_base.md#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t.| +| [OH_MD_KEY_BITRATE](_codec_base.md#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t. | +| [OH_MD_KEY_MAX_INPUT_SIZE](_codec_base.md#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t. | +| [OH_MD_KEY_WIDTH](_codec_base.md#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t. | +| [OH_MD_KEY_HEIGHT](_codec_base.md#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t. | +| [OH_MD_KEY_PIXEL_FORMAT](_codec_base.md#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. | +| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](_codec_base.md#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t. | +| [OH_MD_KEY_FRAME_RATE](_codec_base.md#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double. | +| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](_codec_base.md#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. | +| [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. | +| [OH_MD_KEY_AUD_CHANNEL_COUNT](_codec_base.md#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t. | +| [OH_MD_KEY_AUD_SAMPLE_RATE](_codec_base.md#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t. | +| [OH_MD_KEY_I_FRAME_INTERVAL](_codec_base.md#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms. | +| [OH_MD_KEY_ROTATION](_codec_base.md#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0. | diff --git a/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..ef449f410240ffab32922d9e092b3a290dcc087a --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcodec__videodecoder_8h.md @@ -0,0 +1,38 @@ +# native_avcodec_videodecoder.h + + +## Overview + +Declares the native APIs used for video decoding. + +**Since:** +9 + +**Related Modules:** + +[VideoDecoder](_video_decoder.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_VideoDecoder_CreateByMime](_video_decoder.md#oh_videodecoder_createbymime) (const char \*mime) | Creates a video decoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoDecoder_CreateByName](_video_decoder.md#oh_videodecoder_createbyname) (const char \*name) | Creates a video decoder instance based on a video decoder name. To use this API, you must know the exact name of the video decoder. | +| [OH_VideoDecoder_Destroy](_video_decoder.md#oh_videodecoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video decoder and destroys the video decoder instance. | +| [OH_VideoDecoder_SetCallback](_video_decoder.md#oh_videodecoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_SetSurface](_video_decoder.md#oh_videodecoder_setsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*window) | Sets an output surface for a video decoder. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Configure](_video_decoder.md#oh_videodecoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video decoder. Typically, you need to configure the attributes, which can be extracted from the container, of the video track that can be decoded. This API must be called prior to **Prepare**. | +| [OH_VideoDecoder_Prepare](_video_decoder.md#oh_videodecoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video decoder. This API must be called after **Configure**. | +| [OH_VideoDecoder_Start](_video_decoder.md#oh_videodecoder_start) (OH_AVCodec \*codec) | Starts a video decoder. This API can be called only after the decoder is prepared successfully. After being started, the decoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoDecoder_Stop](_video_decoder.md#oh_videodecoder_stop) (OH_AVCodec \*codec) | Stops a video decoder. After the decoder is stopped, you can call **Start** to start it again. If you have passed codec-specific data in the previous **Start** for the decoder, you must pass it again. | +| [OH_VideoDecoder_Flush](_video_decoder.md#oh_videodecoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video decoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoDecoder_Reset](_video_decoder.md#oh_videodecoder_reset) (OH_AVCodec \*codec) | Resets a video decoder. To continue decoding, you must call **Configure** and **Start** to configure and start the decoder again. | +| [OH_VideoDecoder_GetOutputDescription](_video_decoder.md#oh_videodecoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video decoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoDecoder_SetParameter](_video_decoder.md#oh_videodecoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video decoder. This API can be called only after the decoder is started. Incorrect parameter settings may cause decoding failure. | +| [OH_VideoDecoder_PushInputData](_video_decoder.md#oh_videodecoder_pushinputdata) (OH_AVCodec \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video decoder. The [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback reports available input buffers and their indexes. After being pushed to the decoder, a buffer is not accessible until the buffer with the same index is reported again through the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) callback. In addition, some decoders require the input of codec-specific data, such as PPS/SPS data in H.264 format, to initialize the decoding process. | +| [OH_VideoDecoder_RenderOutputData](_video_decoder.md#oh_videodecoder_renderoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder and instructs the decoder to render the decoded data in the buffer on the output surface. If no output surface is configured, calling this API only frees the output buffer. | +| [OH_VideoDecoder_FreeOutputData](_video_decoder.md#oh_videodecoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video decoder. | diff --git a/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md b/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..4870d9ce8d1ce472c983b4b825073b7cb573f8f2 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avcodec__videoencoder_8h.md @@ -0,0 +1,51 @@ +# native_avcodec_videoencoder.h + + +## Overview + +Declares the native APIs used for video encoding. + +**Since:** +9 + +**Related Modules:** + +[VideoEncoder](_video_encoder.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) | Enumerates the bit rate modes of video encoding. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of video encoding. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_VideoEncoder_CreateByMime](_video_encoder.md#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This API is recommended in most cases. | +| [OH_VideoEncoder_CreateByName](_video_encoder.md#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on a video encoder name. To use this API, you must know the exact name of the video encoder. | +| [OH_VideoEncoder_Destroy](_video_encoder.md#oh_videoencoder_destroy) (OH_AVCodec \*codec) | Clears the internal resources of a video encoder and destroys the video encoder instance. | +| [OH_VideoEncoder_SetCallback](_video_encoder.md#oh_videoencoder_setcallback) (OH_AVCodec \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an asynchronous callback so that your application can respond to events generated by a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Configure](_video_encoder.md#oh_videoencoder_configure) (OH_AVCodec \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the attributes of the video track that can be encoded. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_Prepare](_video_encoder.md#oh_videoencoder_prepare) (OH_AVCodec \*codec) | Prepares internal resources for a video encoder. This API must be called after **Configure**. | +| [OH_VideoEncoder_Start](_video_encoder.md#oh_videoencoder_start) (OH_AVCodec \*codec) | Starts a video encoder. This API can be called only after the encoder is prepared successfully. After being started, the encoder starts to report the [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata) event. | +| [OH_VideoEncoder_Stop](_video_encoder.md#oh_videoencoder_stop) (OH_AVCodec \*codec) | Stops a video encoder. After the encoder is stopped, you can call **Start** to start it again. | +| [OH_VideoEncoder_Flush](_video_encoder.md#oh_videoencoder_flush) (OH_AVCodec \*codec) | Clears the input and output data in the internal buffer of a video encoder. This API invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this API, ensure that the buffers corresponding to the indexes are no longer required. | +| [OH_VideoEncoder_Reset](_video_encoder.md#oh_videoencoder_reset) (OH_AVCodec \*codec) | Resets a video encoder. To continue encoding, you must call **Configure** and **Start** to configure and start the encoder again. | +| [OH_VideoEncoder_GetOutputDescription](_video_encoder.md#oh_videoencoder_getoutputdescription) (OH_AVCodec \*codec) | Obtains the attributes of the output data of a video encoder. The **OH_AVFormat** instance in the return value will become invalid when this API is called again or when the **OH_AVCodec** instance is destroyed. | +| [OH_VideoEncoder_SetParameter](_video_encoder.md#oh_videoencoder_setparameter) (OH_AVCodec \*codec, OH_AVFormat \*format) | Sets dynamic parameters for a video encoder. This API can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure. | +| [OH_VideoEncoder_GetSurface](_video_encoder.md#oh_videoencoder_getsurface) (OH_AVCodec \*codec, [OHNativeWindow](_native_window.md) \*\*window) | Obtains an input surface from a video encoder. This API must be called prior to **Prepare**. | +| [OH_VideoEncoder_FreeOutputData](_video_encoder.md#oh_videoencoder_freeoutputdata) (OH_AVCodec \*codec, uint32_t index) | Frees an output buffer of a video encoder. | +| [OH_VideoEncoder_NotifyEndOfStream](_video_encoder.md#oh_videoencoder_notifyendofstream) (OH_AVCodec \*codec) | Notifies a video encoder that input streams end. This API is recommended in surface mode. | diff --git a/en/application-dev/reference/native-apis/native__averrors_8h.md b/en/application-dev/reference/native-apis/native__averrors_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..0ee77c10bbc02c3303ee27044e71e1947911fb95 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__averrors_8h.md @@ -0,0 +1,30 @@ +# native_averrors.h + + +## Overview + +Declares the error codes used by the media playback framework. + +**Since:** +9 + +**Related Modules:** + +[Core](_core.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AVErrCode](_core.md#oh_averrcode) | Enumerates the audio and video error codes. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AVErrCode](_core.md#oh_averrcode) {
AV_ERR_OK = 0, AV_ERR_NO_MEMORY = 1, AV_ERR_OPERATE_NOT_PERMIT = 2, AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4, AV_ERR_TIMEOUT = 5, AV_ERR_UNKNOWN = 6, AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8, AV_ERR_UNSUPPORT = 9, AV_ERR_EXTEND_START = 100
} | Enumerates the audio and video error codes. | diff --git a/en/application-dev/reference/native-apis/native__avformat_8h.md b/en/application-dev/reference/native-apis/native__avformat_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..36f3abe69cb6f28441c953c20dcb4fc99fee3dd5 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avformat_8h.md @@ -0,0 +1,52 @@ +# native_avformat.h + + +## Overview + +Declares the format-related functions and enums. + +**Since:** +9 + +**Related Modules:** + +[Core](_core.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AVPixelFormat](_core.md#oh_avpixelformat) | Enumerates the audio and video pixel formats. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AVPixelFormat](_core.md#oh_avpixelformat) {
AV_PIXEL_FORMAT_YUVI420 = 1, AV_PIXEL_FORMAT_NV12 = 2, AV_PIXEL_FORMAT_NV21 = 3, AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
} | Enumerates the audio and video pixel formats. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AVFormat_Create](_core.md#oh_avformat_create) (void) | Creates an **OH_AVFormat** instance for reading and writing data. | +| [OH_AVFormat_Destroy](_core.md#oh_avformat_destroy) (struct OH_AVFormat \*format) | Destroys an **OH_AVFormat** instance. | +| [OH_AVFormat_Copy](_core.md#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | Copies the resources from an **OH_AVFormat** instance to another. | +| [OH_AVFormat_SetIntValue](_core.md#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | Writes data of the int type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetLongValue](_core.md#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | Writes data of the long type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetFloatValue](_core.md#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | Writes data of the float type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetDoubleValue](_core.md#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | Writes data of the double type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetStringValue](_core.md#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | Writes data of the string type to an **OH_AVFormat** instance. | +| [OH_AVFormat_SetBuffer](_core.md#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | Writes data with a specified size to an **OH_AVFormat** instance. | +| [OH_AVFormat_GetIntValue](_core.md#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | Reads data of the int type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetLongValue](_core.md#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | Reads data of the long type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetFloatValue](_core.md#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | Reads data of the float type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetDoubleValue](_core.md#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | Reads data of the double type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetStringValue](_core.md#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | Reads data of the double type from an **OH_AVFormat** instance. | +| [OH_AVFormat_GetBuffer](_core.md#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | Reads data with a specified size from an **OH_AVFormat** instance. | +| [OH_AVFormat_DumpInfo](_core.md#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | Dumps the information contained in an **OH_AVFormat** instance as a string. | diff --git a/en/application-dev/reference/native-apis/native__avmemory_8h.md b/en/application-dev/reference/native-apis/native__avmemory_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..b1842e12136bc083c9e0753f418bea33e4044733 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__avmemory_8h.md @@ -0,0 +1,25 @@ +# native_avmemory.h + + +## Overview + +Declares the memory-related functions. + +**Since:** +9 + +**Related Modules:** + +[Core](_core.md) + + +## Summary + + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AVMemory_GetAddr](_core.md#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | Obtains the virtual memory address of an **OH_AVMemory** instance. | +| [OH_AVMemory_GetSize](_core.md#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | Obtains the memory size of an **OH_AVMemory** instance. | diff --git a/en/application-dev/reference/native-apis/native__huks__api_8h.md b/en/application-dev/reference/native-apis/native__huks__api_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..6525a0c165662deb59c9c39f1f26b700a6f807c5 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__huks__api_8h.md @@ -0,0 +1,35 @@ +# native_huks_api.h + + +## Overview + +Declares the APIs used to access the HUKS. + +**Since:** +9 + +**Related Modules:** + +[HuksKeyApi](_huks_key_api.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Huks_GetSdkVersion](_huks_key_api.md#oh_huks_getsdkversion) (struct [OH_Huks_Blob](_o_h___huks___blob.md) \*sdkVersion) | Obtains the current HUKS SDK version. | +| [OH_Huks_GenerateKeyItem](_huks_key_api.md#oh_huks_generatekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Generates a key. | +| [OH_Huks_ImportKeyItem](_huks_key_api.md#oh_huks_importkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Imports a key in plaintext. | +| [OH_Huks_ImportWrappedKeyItem](_huks_key_api.md#oh_huks_importwrappedkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappingKeyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*wrappedKeyData) | Imports a wrapped key. | +| [OH_Huks_ExportPublicKeyItem](_huks_key_api.md#oh_huks_exportpublickeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*key) | Exports a public key. | +| [OH_Huks_DeleteKeyItem](_huks_key_api.md#oh_huks_deletekeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Deletes a key. | +| [OH_Huks_GetKeyItemParamSet](_huks_key_api.md#oh_huks_getkeyitemparamset) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetIn, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSetOut) | Obtains the attributes of a key. | +| [OH_Huks_IsKeyItemExist](_huks_key_api.md#oh_huks_iskeyitemexist) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether a key exists. | +| [OH_Huks_AttestKeyItem](_huks_key_api.md#oh_huks_attestkeyitem) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_CertChain](_o_h___huks___cert_chain.md) \*certChain) | Obtain the key certificate chain. | +| [OH_Huks_InitSession](_huks_key_api.md#oh_huks_initsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*keyAlias, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*challenge) | Initializes the key session interface and obtains a handle (mandatory) and challenge value (optional). | +| [OH_Huks_UpdateSession](_huks_key_api.md#oh_huks_updatesession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Adds data by segment for the key operation, performs the related key operation, and outputs the processed data. | +| [OH_Huks_FinishSession](_huks_key_api.md#oh_huks_finishsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*inData, struct [OH_Huks_Blob](_o_h___huks___blob.md) \*outData) | Ends the key session. | +| [OH_Huks_AbortSession](_huks_key_api.md#oh_huks_abortsession) (const struct [OH_Huks_Blob](_o_h___huks___blob.md) \*handle, const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Aborts a key session. | diff --git a/en/application-dev/reference/native-apis/native__huks__param_8h.md b/en/application-dev/reference/native-apis/native__huks__param_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..6977c2746638807d313503c2953f4c37d043d1e0 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__huks__param_8h.md @@ -0,0 +1,32 @@ +# native_huks_param.h + + +## Overview + +Provides APIs for constructing, using, and destroying parameter sets. + +**Since:** +9 + +**Related Modules:** + +[HuksParamSetApi](_huks_param_set_api.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_Huks_InitParamSet](_huks_param_set_api.md#oh_huks_initparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Initializes a parameter set. | +| [OH_Huks_AddParams](_huks_param_set_api.md#oh_huks_addparams) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, const struct [OH_Huks_Param](_o_h___huks___param.md) \*params, uint32_t paramCnt) | Adds parameters to a parameter set. | +| [OH_Huks_BuildParamSet](_huks_param_set_api.md#oh_huks_buildparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Constructs a parameter set. | +| [OH_Huks_FreeParamSet](_huks_param_set_api.md#oh_huks_freeparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Destroys a parameter set. | +| [OH_Huks_CopyParamSet](_huks_param_set_api.md#oh_huks_copyparamset) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*fromParamSet, uint32_t fromParamSetSize, struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*\*paramSet) | Copies a parameter set (deep copy). | +| [OH_Huks_GetParam](_huks_param_set_api.md#oh_huks_getparam) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t tag, struct [OH_Huks_Param](_o_h___huks___param.md) \*\*param) | Obtains parameters from a parameter set. | +| [OH_Huks_FreshParamSet](_huks_param_set_api.md#oh_huks_freshparamset) (struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, bool isCopy) | Refreshes data of the **Blob** type in a parameter set. | +| [OH_Huks_isParamSetTagValid](_huks_param_set_api.md#oh_huks_isparamsettagvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet) | Checks whether the parameters in a parameter set are valid. | +| [OH_Huks_isParamSetValid](_huks_param_set_api.md#oh_huks_isparamsetvalid) (const struct [OH_Huks_ParamSet](_o_h___huks___param_set.md) \*paramSet, uint32_t size) | Checks whether a parameter set is of the valid size. | +| [OH_Huks_CheckParamMatch](_huks_param_set_api.md#oh_huks_checkparammatch) (const struct [OH_Huks_Param](_o_h___huks___param.md) \*baseParam, const struct [OH_Huks_Param](_o_h___huks___param.md) \*param) | Checks whether two parameters are the same. | diff --git a/en/application-dev/reference/native-apis/native__huks__type_8h.md b/en/application-dev/reference/native-apis/native__huks__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..caa129bf8f4d97fdf18e2e333998e536b84bbbba --- /dev/null +++ b/en/application-dev/reference/native-apis/native__huks__type_8h.md @@ -0,0 +1,81 @@ +# native_huks_type.h + + +## Overview + +Defines the enumerated variables, structures, and macros used in the HUKS APIs. + +**Since:** +9 + +**Related Modules:** + +[HuksTypeApi](_huks_type_api.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_Huks_Result](_o_h___huks___result.md) | Defines the return data, including the result code and message. | +| [OH_Huks_Blob](_o_h___huks___blob.md) | Defines the structure for storing data. | +| [OH_Huks_Param](_o_h___huks___param.md) | Defines the parameter structure in a parameter set. | +| [OH_Huks_ParamSet](_o_h___huks___param_set.md) | Defines the structure of the parameter set. | +| [OH_Huks_CertChain](_o_h___huks___cert_chain.md) | Defines the structure of the certificate chain. | +| [OH_Huks_KeyInfo](_o_h___huks___key_info.md) | Defines the key information structure. | +| [OH_Huks_PubKeyInfo](_o_h___huks___pub_key_info.md) | Defines the structure of a public key. | +| [OH_Huks_KeyMaterialRsa](_o_h___huks___key_material_rsa.md) | Defines the structure of an RSA key. | +| [OH_Huks_KeyMaterialEcc](_o_h___huks___key_material_ecc.md) | Defines the structure of an ECC key. | +| [OH_Huks_KeyMaterialDsa](_o_h___huks___key_material_dsa.md) | Defines the structure of a DSA key. | +| [OH_Huks_KeyMaterialDh](_o_h___huks___key_material_dh.md) | Defines the structure of a DH key. | +| [OH_Huks_KeyMaterial25519](_o_h___huks___key_material25519.md) | Defines the structure of a 25519 key. | + + +### Macros + +| Name | Value | +| -------- | -------- | +| **OH_HUKS_AE_TAG_LEN** | 16 | +| **OH_HUKS_BITS_PER_BYTE** | 8| +| **OH_HUKS_MAX_KEY_SIZE** | 2048 | +| **OH_HUKS_AE_NONCE_LEN** | 12 | +| **OH_HUKS_MAX_KEY_ALIAS_LEN** | 64 | +| **OH_HUKS_MAX_PROCESS_NAME_LEN** | 50| +| **OH_HUKS_MAX_RANDOM_LEN** | 1024 | +| **OH_HUKS_SIGNATURE_MIN_SIZE** | 64 | +| **OH_HUKS_MAX_OUT_BLOB_SIZE** | (5 \* 1024 \* 1024) | +| **OH_HUKS_WRAPPED_FORMAT_MAX_SIZE** | (1024 \* 1024) | +| **OH_HUKS_IMPORT_WRAPPED_KEY_TOTAL_BLOBS** | 10 | +| **TOKEN_CHALLENGE_LEN** | 32 | +| **SHA256_SIGN_LEN** | 32 | +| **TOKEN_SIZE** | 32 | +| **MAX_AUTH_TIMEOUT_SECOND** | 60 | +| **SECURE_SIGN_VERSION** | 0x01000001 | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_Huks_KeyPurpose](_huks_type_api.md#oh_huks_keypurpose) {
OH_HUKS_KEY_PURPOSE_ENCRYPT = 1, OH_HUKS_KEY_PURPOSE_DECRYPT = 2, OH_HUKS_KEY_PURPOSE_SIGN = 4, OH_HUKS_KEY_PURPOSE_VERIFY = 8,
OH_HUKS_KEY_PURPOSE_DERIVE = 16, OH_HUKS_KEY_PURPOSE_WRAP = 32, OH_HUKS_KEY_PURPOSE_UNWRAP = 64, OH_HUKS_KEY_PURPOSE_MAC = 128,
OH_HUKS_KEY_PURPOSE_AGREE = 256
} | Enumerates the key purposes. | +| [OH_Huks_KeyDigest](_huks_type_api.md#oh_huks_keydigest) {
OH_HUKS_DIGEST_NONE = 0, OH_HUKS_DIGEST_MD5 = 1, OH_HUKS_DIGEST_SM3 = 2, OH_HUKS_DIGEST_SHA1 = 10,
OH_HUKS_DIGEST_SHA224 = 11, OH_HUKS_DIGEST_SHA256 = 12, OH_HUKS_DIGEST_SHA384 = 13, OH_HUKS_DIGEST_SHA512 = 14
} | Enumerates the digest algorithms. | +| [OH_Huks_KeyPadding](_huks_type_api.md#oh_huks_keypadding) {
OH_HUKS_PADDING_NONE = 0, OH_HUKS_PADDING_OAEP = 1, OH_HUKS_PADDING_PSS = 2, OH_HUKS_PADDING_PKCS1_V1_5 = 3,
OH_HUKS_PADDING_PKCS5 = 4, OH_HUKS_PADDING_PKCS7 = 5
} | Enumerates the padding algorithms. | +| [OH_Huks_CipherMode](_huks_type_api.md#oh_huks_ciphermode) {
OH_HUKS_MODE_ECB = 1, OH_HUKS_MODE_CBC = 2, OH_HUKS_MODE_CTR = 3, OH_HUKS_MODE_OFB = 4,
OH_HUKS_MODE_CCM = 31, OH_HUKS_MODE_GCM = 32
} | Enumerates the cipher modes. | +| [OH_Huks_KeySize](_huks_type_api.md#oh_huks_keysize) {
OH_HUKS_RSA_KEY_SIZE_512 = 512, OH_HUKS_RSA_KEY_SIZE_768 = 768, OH_HUKS_RSA_KEY_SIZE_1024 = 1024, OH_HUKS_RSA_KEY_SIZE_2048 = 2048,
OH_HUKS_RSA_KEY_SIZE_3072 = 3072, OH_HUKS_RSA_KEY_SIZE_4096 = 4096, OH_HUKS_ECC_KEY_SIZE_224 = 224, OH_HUKS_ECC_KEY_SIZE_256 = 256,
OH_HUKS_ECC_KEY_SIZE_384 = 384, OH_HUKS_ECC_KEY_SIZE_521 = 521, OH_HUKS_AES_KEY_SIZE_128 = 128, OH_HUKS_AES_KEY_SIZE_192 = 192,
OH_HUKS_AES_KEY_SIZE_256 = 256, OH_HUKS_AES_KEY_SIZE_512 = 512, OH_HUKS_CURVE25519_KEY_SIZE_256 = 256, OH_HUKS_DH_KEY_SIZE_2048 = 2048,
OH_HUKS_DH_KEY_SIZE_3072 = 3072, OH_HUKS_DH_KEY_SIZE_4096 = 4096, OH_HUKS_SM2_KEY_SIZE_256 = 256, OH_HUKS_SM4_KEY_SIZE_128 = 128
} | Enumerates the key sizes. | +| [OH_Huks_KeyAlg](_huks_type_api.md#oh_huks_keyalg) {
OH_HUKS_ALG_RSA = 1, OH_HUKS_ALG_ECC = 2, OH_HUKS_ALG_DSA = 3, OH_HUKS_ALG_AES = 20,
OH_HUKS_ALG_HMAC = 50, OH_HUKS_ALG_HKDF = 51, OH_HUKS_ALG_PBKDF2 = 52, OH_HUKS_ALG_ECDH = 100,
OH_HUKS_ALG_X25519 = 101, OH_HUKS_ALG_ED25519 = 102, OH_HUKS_ALG_DH = 103, OH_HUKS_ALG_SM2 = 150,
OH_HUKS_ALG_SM3 = 151, OH_HUKS_ALG_SM4 = 152
} | Enumerates the key algorithms. | +| [OH_Huks_AlgSuite](_huks_type_api.md#oh_huks_algsuite) { OH_HUKS_UNWRAP_SUITE_X25519_AES_256_GCM_NOPADDING = 1, OH_HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING = 2 } | Enumerates the algorithm suites required for ciphertext imports. | +| [OH_Huks_KeyGenerateType](_huks_type_api.md#oh_huks_keygeneratetype) { OH_HUKS_KEY_GENERATE_TYPE_DEFAULT = 0, OH_HUKS_KEY_GENERATE_TYPE_DERIVE = 1, OH_HUKS_KEY_GENERATE_TYPE_AGREE = 2 } | Enumerates the key generation types. | +| [OH_Huks_KeyFlag](_huks_type_api.md#oh_huks_keyflag) { OH_HUKS_KEY_FLAG_IMPORT_KEY = 1, OH_HUKS_KEY_FLAG_GENERATE_KEY = 2, OH_HUKS_KEY_FLAG_AGREE_KEY = 3, OH_HUKS_KEY_FLAG_DERIVE_KEY = 4 } | Enumerates the key generation modes. | +| [OH_Huks_KeyStorageType](_huks_type_api.md#oh_huks_keystoragetype) { OH_HUKS_STORAGE_TEMP = 0, OH_HUKS_STORAGE_PERSISTENT = 1 } | Enumerates the key storage modes. | +| [OH_Huks_ImportKeyType](_huks_type_api.md#oh_huks_importkeytype) { OH_HUKS_KEY_TYPE_PUBLIC_KEY = 0, OH_HUKS_KEY_TYPE_PRIVATE_KEY = 1, OH_HUKS_KEY_TYPE_KEY_PAIR = 2 } | Enumerates the types of keys to import. By default, a public key is imported. This field is not required when a symmetric key is imported. | +| [OH_Huks_ErrCode](_huks_type_api.md#oh_huks_errcode) {
OH_HUKS_SUCCESS = 0, OH_HUKS_ERR_CODE_PERMISSION_FAIL = 201, OH_HUKS_ERR_CODE_ILLEGAL_ARGUMENT = 401, OH_HUKS_ERR_CODE_NOT_SUPPORTED_API = 801,
OH_HUKS_ERR_CODE_FEATURE_NOT_SUPPORTED = 12000001, OH_HUKS_ERR_CODE_MISSING_CRYPTO_ALG_ARGUMENT = 12000002, OH_HUKS_ERR_CODE_INVALID_CRYPTO_ALG_ARGUMENT = 12000003, OH_HUKS_ERR_CODE_FILE_OPERATION_FAIL = 12000004,
OH_HUKS_ERR_CODE_COMMUNICATION_FAIL = 12000005, OH_HUKS_ERR_CODE_CRYPTO_FAIL = 12000006, OH_HUKS_ERR_CODE_KEY_AUTH_PERMANENTLY_INVALIDATED = 12000007, OH_HUKS_ERR_CODE_KEY_AUTH_VERIFY_FAILED = 12000008,
OH_HUKS_ERR_CODE_KEY_AUTH_TIME_OUT = 12000009, OH_HUKS_ERR_CODE_SESSION_LIMIT = 12000010, OH_HUKS_ERR_CODE_ITEM_NOT_EXIST = 12000011, OH_HUKS_ERR_CODE_INTERNAL_ERROR = 12000012,
OH_HUKS_ERR_CODE_CREDENTIAL_NOT_EXIST = 12000013
} | Enumerates the error codes. | +| [OH_Huks_TagType](_huks_type_api.md#oh_huks_tagtype) {
OH_HUKS_TAG_TYPE_INVALID = 0 << 28, OH_HUKS_TAG_TYPE_INT = 1 << 28, OH_HUKS_TAG_TYPE_UINT = 2 << 28, OH_HUKS_TAG_TYPE_ULONG = 3 << 28,
OH_HUKS_TAG_TYPE_BOOL = 4 << 28, OH_HUKS_TAG_TYPE_BYTES = 5 << 28
} | Enumerates the tag types. | +| [OH_Huks_UserAuthType](_huks_type_api.md#oh_huks_userauthtype) { OH_HUKS_USER_AUTH_TYPE_FINGERPRINT = 1 << 0, OH_HUKS_USER_AUTH_TYPE_FACE = 1 << 1, OH_HUKS_USER_AUTH_TYPE_PIN = 1 << 2 } | Enumerates the user authentication types. | +| [OH_Huks_AuthAccessType](_huks_type_api.md#oh_huks_authaccesstype) { OH_HUKS_AUTH_ACCESS_INVALID_CLEAR_PASSWORD = 1 << 0, OH_HUKS_AUTH_ACCESS_INVALID_NEW_BIO_ENROLL = 1 << 1 } | Enumerates the access control types. | +| [OH_Huks_ChallengeType](_huks_type_api.md#oh_huks_challengetype) { OH_HUKS_CHALLENGE_TYPE_NORMAL = 0, OH_HUKS_CHALLENGE_TYPE_CUSTOM = 1, OH_HUKS_CHALLENGE_TYPE_NONE = 2 } | Enumerates the types of the challenges generated when a key is used. | +| [OH_Huks_ChallengePosition](_huks_type_api.md#oh_huks_challengeposition) { OH_HUKS_CHALLENGE_POS_0 = 0, OH_HUKS_CHALLENGE_POS_1, OH_HUKS_CHALLENGE_POS_2, OH_HUKS_CHALLENGE_POS_3 } | Enumerates the positions of the 8-byte valid value in a custom challenge generated. | +| [OH_Huks_SecureSignType](_huks_type_api.md#oh_huks_securesigntype) { OH_HUKS_SECURE_SIGN_WITH_AUTHINFO = 1 } | Enumerates the signature types of the keys generated or imported. | +| [OH_Huks_Tag](_huks_type_api.md#oh_huks_tag) {
OH_HUKS_TAG_ALGORITHM = OH_HUKS_TAG_TYPE_UINT \| 1, OH_HUKS_TAG_PURPOSE = OH_HUKS_TAG_TYPE_UINT \| 2, OH_HUKS_TAG_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT \| 3,
OH_HUKS_TAG_DIGEST = OH_HUKS_TAG_TYPE_UINT \| 4, OH_HUKS_TAG_PADDING = OH_HUKS_TAG_TYPE_UINT \| 5, OH_HUKS_TAG_BLOCK_MODE = OH_HUKS_TAG_TYPE_UINT \| 6, OH_HUKS_TAG_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT \| 7,
OH_HUKS_TAG_ASSOCIATED_DATA = OH_HUKS_TAG_TYPE_BYTES \| 8, OH_HUKS_TAG_NONCE = OH_HUKS_TAG_TYPE_BYTES \| 9, OH_HUKS_TAG_IV = OH_HUKS_TAG_TYPE_BYTES \| 10, OH_HUKS_TAG_INFO = OH_HUKS_TAG_TYPE_BYTES \| 11,
OH_HUKS_TAG_SALT = OH_HUKS_TAG_TYPE_BYTES \| 12, OH_HUKS_TAG_ITERATION = OH_HUKS_TAG_TYPE_UINT \| 14, OH_HUKS_TAG_KEY_GENERATE_TYPE = OH_HUKS_TAG_TYPE_UINT \| 15,
OH_HUKS_TAG_AGREE_ALG = OH_HUKS_TAG_TYPE_UINT \| 19,
OH_HUKS_TAG_AGREE_PUBLIC_KEY_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL \| 20, OH_HUKS_TAG_AGREE_PRIVATE_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 21, OH_HUKS_TAG_AGREE_PUBLIC_KEY = OH_HUKS_TAG_TYPE_BYTES \| 22, OH_HUKS_TAG_KEY_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 23,
OH_HUKS_TAG_DERIVE_KEY_SIZE = OH_HUKS_TAG_TYPE_UINT \| 24, OH_HUKS_TAG_IMPORT_KEY_TYPE = OH_HUKS_TAG_TYPE_UINT \| 25, OH_HUKS_TAG_UNWRAP_ALGORITHM_SUITE = OH_HUKS_TAG_TYPE_UINT \| 26, OH_HUKS_TAG_ALL_USERS = OH_HUKS_TAG_TYPE_BOOL \| 301,
OH_HUKS_TAG_USER_ID = OH_HUKS_TAG_TYPE_UINT \| 302, OH_HUKS_TAG_NO_AUTH_REQUIRED = OH_HUKS_TAG_TYPE_BOOL \| 303, OH_HUKS_TAG_USER_AUTH_TYPE = OH_HUKS_TAG_TYPE_UINT \| 304, OH_HUKS_TAG_AUTH_TIMEOUT = OH_HUKS_TAG_TYPE_UINT \| 305,
OH_HUKS_TAG_AUTH_TOKEN = OH_HUKS_TAG_TYPE_BYTES \| 306, OH_HUKS_TAG_KEY_AUTH_ACCESS_TYPE = OH_HUKS_TAG_TYPE_UINT \| 307, OH_HUKS_TAG_KEY_SECURE_SIGN_TYPE = OH_HUKS_TAG_TYPE_UINT \| 308, OH_HUKS_TAG_CHALLENGE_TYPE = OH_HUKS_TAG_TYPE_UINT \| 309,
OH_HUKS_TAG_CHALLENGE_POS = OH_HUKS_TAG_TYPE_UINT \| 310, OH_HUKS_TAG_ATTESTATION_CHALLENGE = OH_HUKS_TAG_TYPE_BYTES \| 501, OH_HUKS_TAG_ATTESTATION_APPLICATION_ID = OH_HUKS_TAG_TYPE_BYTES \| 502,
OH_HUKS_TAG_ATTESTATION_ID_ALIAS = OH_HUKS_TAG_TYPE_BYTES \| 511,
OH_HUKS_TAG_ATTESTATION_ID_SEC_LEVEL_INFO = OH_HUKS_TAG_TYPE_BYTES \| 514, OH_HUKS_TAG_ATTESTATION_ID_VERSION_INFO = OH_HUKS_TAG_TYPE_BYTES \| 515,
OH_HUKS_TAG_IS_KEY_ALIAS = OH_HUKS_TAG_TYPE_BOOL \| 1001, OH_HUKS_TAG_KEY_STORAGE_FLAG = OH_HUKS_TAG_TYPE_UINT \| 1002, OH_HUKS_TAG_IS_ALLOWED_WRAP = OH_HUKS_TAG_TYPE_BOOL \| 1003, OH_HUKS_TAG_KEY_WRAP_TYPE = OH_HUKS_TAG_TYPE_UINT \| 1004,
OH_HUKS_TAG_KEY_AUTH_ID = OH_HUKS_TAG_TYPE_BYTES \| 1005, OH_HUKS_TAG_KEY_ROLE = OH_HUKS_TAG_TYPE_UINT \| 1006, OH_HUKS_TAG_KEY_FLAG = OH_HUKS_TAG_TYPE_UINT \| 1007, OH_HUKS_TAG_IS_ASYNCHRONIZED = OH_HUKS_TAG_TYPE_UINT \| 1008,
OH_HUKS_TAG_KEY_DOMAIN = OH_HUKS_TAG_TYPE_UINT \| 1011, OH_HUKS_TAG_SYMMETRIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20001,
OH_HUKS_TAG_ASYMMETRIC_PUBLIC_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20002, OH_HUKS_TAG_ASYMMETRIC_PRIVATE_KEY_DATA = OH_HUKS_TAG_TYPE_BYTES \| 20003
} | Enumerates the tag values used in parameter sets. | diff --git a/en/application-dev/reference/native-apis/native__interface__xcomponent_8h.md b/en/application-dev/reference/native-apis/native__interface__xcomponent_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..184f2aa0a1d11409f243f86f9d40e279488a8812 --- /dev/null +++ b/en/application-dev/reference/native-apis/native__interface__xcomponent_8h.md @@ -0,0 +1,68 @@ +# native_interface_xcomponent.h + + +## Overview + +Declares the APIs used to access the native XComponent. + +**Since:** + +8 + +**Related Modules:** + +[Native XComponent](_o_h___native_x_component.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent_TouchPoint](_o_h___native_x_component___touch_point.md) | Describes the touch point of the touch event. | +| [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) | Describes the touch event. | +| [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) | Describes the mouse event.| +| [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) | Registers a callback for the surface lifecycle and touch event. | +| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) | Registers a callback for the mouse event. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) | Provides an encapsulated OH_NativeXComponent instance. | +| [OH_NativeXComponent_Callback](_o_h___native_x_component.md#oh_nativexcomponent_callback) | Registers a callback for the surface lifecycle and touch event. | +| [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component.md#oh_nativexcomponent_mouseevent_callback) | Registers a callback for the mouse event. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| { OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0,
OH_NATIVEXCOMPONENT_RESULT_FAILED = -1,
OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2} | [Enumerates](_o_h___native_x_component.md#anonymous-enum)the API access states. | +| [OH_NativeXComponent_TouchEventType](_o_h___native_x_component.md#oh_nativexcomponent_toucheventtype) {
OH_NATIVEXCOMPONENT_DOWN = 0,
OH_NATIVEXCOMPONENT_UP,
OH_NATIVEXCOMPONENT_MOVE,
OH_NATIVEXCOMPONENT_CANCEL,
OH_NATIVEXCOMPONENT_UNKNOWN } | Enumerates the touch event types. | +| [OH_NativeXComponent_MouseEventAction](_o_h___native_x_component.md#oh_nativexcomponent_mouseeventaction) {
OH_NATIVEXCOMPONENT_MOUSE_NONE = 0,
OH_NATIVEXCOMPONENT_MOUSE_PRESS,
OH_NATIVEXCOMPONENT_MOUSE_RELEASE,
OH_NATIVEXCOMPONENT_MOUSE_MOVE } | Enumerates the mouse event actions. | +| [OH_NativeXComponent_MouseEventButton](_o_h___native_x_component.md#oh_nativexcomponent_mouseeventbutton) {
OH_NATIVEXCOMPONENT_NONE_BUTTON = 0,
OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01,
OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02,
OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04,
OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08,
OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10 } | Enumerates the mouse event buttons. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NativeXComponent_GetXComponentId](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentid) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, char \*id, uint64_t \*size) | Obtains the ID of the ArkUI XComponent. | +| [OH_NativeXComponent_GetXComponentSize](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentsize) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, const void \*window, uint64_t \*width, uint64_t \*height) | Obtains the size of the surface held by the ArkUI XComponent. | +| [OH_NativeXComponent_GetXComponentOffset](_o_h___native_x_component.md#oh_nativexcomponent_getxcomponentoffset) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, const void \*window, double \*x, double \*y) | Obtains the offset of the ArkUI XComponent relative to the upper left vertex of the screen. | +| [OH_NativeXComponent_GetTouchEvent](_o_h___native_x_component.md#oh_nativexcomponent_gettouchevent) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_TouchEvent](_o_h___native_x_component___touch_event.md) \*touchEvent) | Obtains the touch event scheduled by the ArkUI XComponent. | +| [OH_NativeXComponent_GetMouseEvent](_o_h___native_x_component.md#oh_nativexcomponent_getmouseevent) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, const void \*window, [OH_NativeXComponent_MouseEvent](_o_h___native_x_component___mouse_event.md) \*mouseEvent) | Obtains the mouse event scheduled by ArkUI XComponent. | +| [OH_NativeXComponent_RegisterCallback](_o_h___native_x_component.md#oh_nativexcomponent_registercallback) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, [OH_NativeXComponent_Callback](_o_h___native_x_component___callback.md) \*callback) | Registers a callback for this **OH_NativeXComponent** instance. | +| [OH_NativeXComponent_RegisterMouseEventCallback](_o_h___native_x_component.md#oh_nativexcomponent_registermouseeventcallback) ([OH_NativeXComponent](_o_h___native_x_component.md#oh_nativexcomponent) \*component, [OH_NativeXComponent_MouseEvent_Callback](_o_h___native_x_component___mouse_event___callback.md) \*callback) | Registers a mouse event callback for this **OH_NativeXComponent** instance. | + + +### Variables + +| Name | Description | +| -------- | -------- | +| **OH_XCOMPONENT_ID_LEN_MAX** = 128 | Maximum length of an ArkUI XComponent ID. | +| **OH_MAX_TOUCH_POINTS_NUMBER** = 10 | Maximum number of identifiable touch points in a touch event. | diff --git a/en/application-dev/reference/native-apis/neural__network__runtime_8h.md b/en/application-dev/reference/native-apis/neural__network__runtime_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..ee48d17742d221359fbd03c71f4a9689f91376af --- /dev/null +++ b/en/application-dev/reference/native-apis/neural__network__runtime_8h.md @@ -0,0 +1,53 @@ +# neural_network_runtime.h + + +## Overview + +Defines the Neural Network Runtime APIs. The AI inference framework uses the Native APIs provided by Neural Network Runtime to construct and compile models and perform inference and computing on acceleration hardware. Note: Currently, the APIs of Neural Network Runtime do not support multi-thread calling. + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_NNModel_Construct](_neural_nework_runtime.md#oh_nnmodel_construct) (void) | Creates a model instance of the [OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) type and uses other APIs provided by OH_NNModel to construct the model instance. | +| [OH_NNModel_AddTensor](_neural_nework_runtime.md#oh_nnmodel_addtensor) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor) | Adds a tensor to a model instance. | +| [OH_NNModel_SetTensorData](_neural_nework_runtime.md#oh_nnmodel_settensordata) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model, uint32_t index, const void \*dataBuffer, size_t length) | Sets the tensor value. | +| [OH_NNModel_AddOperation](_neural_nework_runtime.md#oh_nnmodel_addoperation) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model, [OH_NN_OperationType](_neural_nework_runtime.md#oh_nn_operationtype) op, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*paramIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*outputIndices) | Adds an operator to a model instance. | +| [OH_NNModel_SpecifyInputsAndOutputs](_neural_nework_runtime.md#oh_nnmodel_specifyinputsandoutputs) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*inputIndices, const [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) \*outputIndices) | Specifies the inputs and outputs of a model. | +| [OH_NNModel_Finish](_neural_nework_runtime.md#oh_nnmodel_finish) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model) | Completes model composition. | +| [OH_NNModel_Destroy](_neural_nework_runtime.md#oh_nnmodel_destroy) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*\*model) | Releases a model instance. | +| [OH_NNModel_GetAvailableOperations](_neural_nework_runtime.md#oh_nnmodel_getavailableoperations) ([OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model, size_t deviceID, const bool \*\*isSupported, uint32_t \*opCount) | Queries whether the device supports operators in the model. The support status is indicated by the Boolean value. | +| [OH_NNCompilation_Construct](_neural_nework_runtime.md#oh_nncompilation_construct) (const [OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) \*model) | Creates a compilation instance of the [OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) type. | +| [OH_NNCompilation_SetDevice](_neural_nework_runtime.md#oh_nncompilation_setdevice) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation, size_t deviceID) | Specifies the device for model compilation and computing. | +| [OH_NNCompilation_SetCache](_neural_nework_runtime.md#oh_nncompilation_setcache) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation, const char \*cachePath, uint32_t version) | Set the cache directory and version of the compiled model. | +| [OH_NNCompilation_SetPerformanceMode](_neural_nework_runtime.md#oh_nncompilation_setperformancemode) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation, [OH_NN_PerformanceMode](_neural_nework_runtime.md#oh_nn_performancemode) performanceMode) | Sets the performance mode for model computing. | +| [OH_NNCompilation_SetPriority](_neural_nework_runtime.md#oh_nncompilation_setpriority) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation, [OH_NN_Priority](_neural_nework_runtime.md#oh_nn_priority) priority) | Sets the model computing priority. | +| [OH_NNCompilation_EnableFloat16](_neural_nework_runtime.md#oh_nncompilation_enablefloat16) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation, bool enableFloat16) | Enables float16 for computing. | +| [OH_NNCompilation_Build](_neural_nework_runtime.md#oh_nncompilation_build) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation) | Compiles a model. | +| [OH_NNCompilation_Destroy](_neural_nework_runtime.md#oh_nncompilation_destroy) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*\*compilation) | Releases the **Compilation** object. | +| [OH_NNExecutor_Construct](_neural_nework_runtime.md#oh_nnexecutor_construct) ([OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) \*compilation) | [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*
Creates an executor instance of the [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) type. | +| [OH_NNExecutor_SetInput](_neural_nework_runtime.md#oh_nnexecutor_setinput) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor, const void \*dataBuffer, size_t length) | Sets the single input data for a model. | +| [OH_NNExecutor_SetOutput](_neural_nework_runtime.md#oh_nnexecutor_setoutput) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t outputIndex, void \*dataBuffer, size_t length) | Sets the buffer for a single output of a model. | +| [OH_NNExecutor_GetOutputShape](_neural_nework_runtime.md#oh_nnexecutor_getoutputshape) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t outputIndex, int32_t \*\*shape, uint32_t \*shapeLength) | Obtains the dimension information about the output tensor. | +| [OH_NNExecutor_Run](_neural_nework_runtime.md#oh_nnexecutor_run) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor) | Performs inference. | +| [OH_NNExecutor_AllocateInputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateinputmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t inputIndex, size_t length) | Allocates shared memory to a single input on a device. | +| [OH_NNExecutor_AllocateOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_allocateoutputmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t outputIndex, size_t length) | Allocates shared memory to a single output on a device. | +| [OH_NNExecutor_DestroyInputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyinputmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t inputIndex, [OH_NN_Memory](_o_h___n_n___memory.md) \*\*memory) | Releases the input memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. | +| [OH_NNExecutor_DestroyOutputMemory](_neural_nework_runtime.md#oh_nnexecutor_destroyoutputmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t outputIndex, [OH_NN_Memory](_o_h___n_n___memory.md) \*\*memory) | Releases the output memory to which the [OH_NN_Memory](_o_h___n_n___memory.md) instance points. | +| [OH_NNExecutor_SetInputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setinputwithmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t inputIndex, const [OH_NN_Tensor](_o_h___n_n___tensor.md) \*tensor, const [OH_NN_Memory](_o_h___n_n___memory.md) \*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single input. | +| [OH_NNExecutor_SetOutputWithMemory](_neural_nework_runtime.md#oh_nnexecutor_setoutputwithmemory) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*executor, uint32_t outputIndex, const [OH_NN_Memory](_o_h___n_n___memory.md) \*memory) | Specifies the hardware shared memory pointed to by the [OH_NN_Memory](_o_h___n_n___memory.md) instance as the shared memory used by a single output. | +| [OH_NNExecutor_Destroy](_neural_nework_runtime.md#oh_nnexecutor_destroy) ([OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) \*\*executor) | Destroys an executor instance to release the memory occupied by the executor. | +| [OH_NNDevice_GetAllDevicesID](_neural_nework_runtime.md#oh_nndevice_getalldevicesid) (const size_t \*\*allDevicesID, uint32_t \*deviceCount) | Obtains the ID of the device connected to Neural Network Runtime. | +| [OH_NNDevice_GetName](_neural_nework_runtime.md#oh_nndevice_getname) (size_t deviceID, const char \*\*name) | Obtains the name of the specified device. | +| [OH_NNDevice_GetType](_neural_nework_runtime.md#oh_nndevice_gettype) (size_t deviceID, [OH_NN_DeviceType](_neural_nework_runtime.md#oh_nn_devicetype) \*deviceType) | Obtains the type information of the specified device. | diff --git a/en/application-dev/reference/native-apis/neural__network__runtime__type_8h.md b/en/application-dev/reference/native-apis/neural__network__runtime__type_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..f49c86b1dd2a2563cfd738c623a30e28b8b00e70 --- /dev/null +++ b/en/application-dev/reference/native-apis/neural__network__runtime__type_8h.md @@ -0,0 +1,54 @@ +# neural_network_runtime_type.h + + +## Overview + +Defines the structure and enumeration for Neural Network Runtime. + +**Since:** +9 + +**Related Modules:** + +[NeuralNeworkRuntime](_neural_nework_runtime.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [OH_NN_UInt32Array](_o_h___n_n___u_int32_array.md) | This structure is used to store a 32-bit unsigned integer array. | +| [OH_NN_QuantParam](_o_h___n_n___quant_param.md) | Quantization information. | +| [OH_NN_Tensor](_o_h___n_n___tensor.md) | Defines the tensor structure. | +| [OH_NN_Memory](_o_h___n_n___memory.md) | Defines the memory structure. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_NNModel](_neural_nework_runtime.md#oh_nnmodel) | Defines the handles of models for Neural Network Runtime. | +| [OH_NNCompilation](_neural_nework_runtime.md#oh_nncompilation) | Defines the compiler handle for Neural Network Runtime. | +| [OH_NNExecutor](_neural_nework_runtime.md#oh_nnexecutor) | Defines the executor handle for Neural Network Runtime. | +| [OH_NN_UInt32Array](_neural_nework_runtime.md#oh_nn_uint32array) | This structure is used to store a 32-bit unsigned integer array. | +| [OH_NN_QuantParam](_neural_nework_runtime.md#oh_nn_quantparam) | Quantization information. | +| [OH_NN_Tensor](_neural_nework_runtime.md#oh_nn_tensor) | Defines the tensor structure. | +| [OH_NN_Memory](_neural_nework_runtime.md#oh_nn_memory) | Defines the memory structure. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_NN_PerformanceMode](_neural_nework_runtime.md#oh_nn_performancemode) {
OH_NN_PERFORMANCE_NONE = 0, OH_NN_PERFORMANCE_LOW = 1, OH_NN_PERFORMANCE_MEDIUM = 2, OH_NN_PERFORMANCE_HIGH = 3,
OH_NN_PERFORMANCE_EXTREME = 4
} | Defines the hardware performance mode. | +| [OH_NN_Priority](_neural_nework_runtime.md#oh_nn_priority) { OH_NN_PRIORITY_NONE = 0, OH_NN_PRIORITY_LOW = 1, OH_NN_PRIORITY_MEDIUM = 2, OH_NN_PRIORITY_HIGH = 3 } | Defines the model inference task priority. | +| [OH_NN_ReturnCode](_neural_nework_runtime.md#oh_nn_returncode) {
OH_NN_SUCCESS = 0, OH_NN_FAILED = 1, OH_NN_INVALID_PARAMETER = 2, OH_NN_MEMORY_ERROR = 3,
OH_NN_OPERATION_FORBIDDEN = 4, OH_NN_NULL_PTR = 5, OH_NN_INVALID_FILE = 6, OH_NN_UNAVALIDABLE_DEVICE = 7,
OH_NN_INVALID_PATH = 8
} | Defines error codes for Neural Network Runtime. | +| [OH_NN_FuseType](_neural_nework_runtime.md#oh_nn_fusetype) : int8_t { OH_NN_FUSED_NONE = 0, OH_NN_FUSED_RELU = 1, OH_NN_FUSED_RELU6 = 2 } | Defines activation function types in the fusion operator for Neural Network Runtime. | +| [OH_NN_Format](_neural_nework_runtime.md#oh_nn_format) { OH_NN_FORMAT_NONE = 0, OH_NN_FORMAT_NCHW = 1, OH_NN_FORMAT_NHWC = 2 } | Defines the layout type of tensor data. | +| [OH_NN_DeviceType](_neural_nework_runtime.md#oh_nn_devicetype) { OH_NN_OTHERS = 0, OH_NN_CPU = 1, OH_NN_GPU = 2, OH_NN_ACCELERATOR = 3 } | Defines device types supported by Neural Network Runtime. | +| [OH_NN_DataType](_neural_nework_runtime.md#oh_nn_datatype) {
OH_NN_UNKNOWN = 0, OH_NN_BOOL = 1, OH_NN_INT8 = 2, OH_NN_INT16 = 3,
OH_NN_INT32 = 4, OH_NN_INT64 = 5, OH_NN_UINT8 = 6, OH_NN_UINT16 = 7,
OH_NN_UINT32 = 8, OH_NN_UINT64 = 9, OH_NN_FLOAT16 = 10, OH_NN_FLOAT32 = 11,
OH_NN_FLOAT64 = 12
} | Defines tensor data types supported by Neural Network Runtime. | +| [OH_NN_OperationType](_neural_nework_runtime.md#oh_nn_operationtype) {
OH_NN_OPS_ADD = 1, OH_NN_OPS_AVG_POOL = 2, OH_NN_OPS_BATCH_NORM = 3, OH_NN_OPS_BATCH_TO_SPACE_ND = 4,
OH_NN_OPS_BIAS_ADD = 5, OH_NN_OPS_CAST = 6, OH_NN_OPS_CONCAT = 7, OH_NN_OPS_CONV2D = 8,
OH_NN_OPS_CONV2D_TRANSPOSE = 9, OH_NN_OPS_DEPTHWISE_CONV2D_NATIVE = 10, OH_NN_OPS_DIV = 11, OH_NN_OPS_ELTWISE = 12,
OH_NN_OPS_EXPAND_DIMS = 13, OH_NN_OPS_FILL = 14, OH_NN_OPS_FULL_CONNECTION = 15, OH_NN_OPS_GATHER = 16,
OH_NN_OPS_HSWISH = 17, OH_NN_OPS_LESS_EQUAL = 18, OH_NN_OPS_MATMUL = 19, OH_NN_OPS_MAXIMUM = 20,
OH_NN_OPS_MAX_POOL = 21, OH_NN_OPS_MUL = 22, OH_NN_OPS_ONE_HOT = 23, OH_NN_OPS_PAD = 24,
OH_NN_OPS_POW = 25, OH_NN_OPS_SCALE = 26, OH_NN_OPS_SHAPE = 27, OH_NN_OPS_SIGMOID = 28,
OH_NN_OPS_SLICE = 29, OH_NN_OPS_SOFTMAX = 30, OH_NN_OPS_SPACE_TO_BATCH_ND = 31, OH_NN_OPS_SPLIT = 32,
OH_NN_OPS_SQRT = 33, OH_NN_OPS_SQUARED_DIFFERENCE = 34, OH_NN_OPS_SQUEEZE = 35, OH_NN_OPS_STACK = 36,
OH_NN_OPS_STRIDED_SLICE = 37, OH_NN_OPS_SUB = 38, OH_NN_OPS_TANH = 39, OH_NN_OPS_TILE = 40,
OH_NN_OPS_TRANSPOSE = 41, OH_NN_OPS_REDUCE_MEAN = 42, OH_NN_OPS_RESIZE_BILINEAR = 43, OH_NN_OPS_RSQRT = 44,
OH_NN_OPS_RESHAPE = 45, OH_NN_OPS_PRELU = 46, OH_NN_OPS_RELU = 47, OH_NN_OPS_RELU6 = 48,
OH_NN_OPS_LAYER_NORM = 49, OH_NN_OPS_REDUCE_PROD = 50, OH_NN_OPS_REDUCE_ALL = 51, OH_NN_OPS_QUANT_DTYPE_CAST = 52,
OH_NN_OPS_TOP_K = 53, OH_NN_OPS_ARG_MAX = 54, OH_NN_OPS_UNSQUEEZE = 55, OH_NN_OPS_GELU = 56
} | Defines operator types supported by Neural Network Runtime. | +| [OH_NN_TensorType](_neural_nework_runtime.md#oh_nn_tensortype) {
OH_NN_TENSOR = 0, OH_NN_ADD_ACTIVATIONTYPE = 1, OH_NN_AVG_POOL_KERNEL_SIZE = 2, OH_NN_AVG_POOL_STRIDE = 3,
OH_NN_AVG_POOL_PAD_MODE = 4, OH_NN_AVG_POOL_PAD = 5, OH_NN_AVG_POOL_ACTIVATION_TYPE = 6, OH_NN_BATCH_NORM_EPSILON = 7,
OH_NN_BATCH_TO_SPACE_ND_BLOCKSIZE = 8, OH_NN_BATCH_TO_SPACE_ND_CROPS = 9, OH_NN_CONCAT_AXIS = 10, OH_NN_CONV2D_STRIDES = 11,
OH_NN_CONV2D_PAD = 12, OH_NN_CONV2D_DILATION = 13, OH_NN_CONV2D_PAD_MODE = 14, OH_NN_CONV2D_ACTIVATION_TYPE = 15,
OH_NN_CONV2D_GROUP = 16, OH_NN_CONV2D_TRANSPOSE_STRIDES = 17, OH_NN_CONV2D_TRANSPOSE_PAD = 18, OH_NN_CONV2D_TRANSPOSE_DILATION = 19,
OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS = 20, OH_NN_CONV2D_TRANSPOSE_PAD_MODE = 21, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE = 22, OH_NN_CONV2D_TRANSPOSE_GROUP = 23,
OH_NN_DEPTHWISE_CONV2D_NATIVE_STRIDES = 24, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD = 25, OH_NN_DEPTHWISE_CONV2D_NATIVE_DILATION = 26, OH_NN_DEPTHWISE_CONV2D_NATIVE_PAD_MODE = 27,
OH_NN_DEPTHWISE_CONV2D_NATIVE_ACTIVATION_TYPE = 28, OH_NN_DIV_ACTIVATIONTYPE = 29, OH_NN_ELTWISE_MODE = 30, OH_NN_FULL_CONNECTION_AXIS = 31,
OH_NN_FULL_CONNECTION_ACTIVATIONTYPE = 32, OH_NN_MATMUL_TRANSPOSE_A = 33, OH_NN_MATMUL_TRANSPOSE_B = 34, OH_NN_MATMUL_ACTIVATION_TYPE = 35,
OH_NN_MAX_POOL_KERNEL_SIZE = 36, OH_NN_MAX_POOL_STRIDE = 37, OH_NN_MAX_POOL_PAD_MODE = 38, OH_NN_MAX_POOL_PAD = 39,
OH_NN_MAX_POOL_ACTIVATION_TYPE = 40, OH_NN_MUL_ACTIVATION_TYPE = 41, OH_NN_ONE_HOT_AXIS = 42, OH_NN_PAD_CONSTANT_VALUE = 43,
OH_NN_SCALE_ACTIVATIONTYPE = 44, OH_NN_SCALE_AXIS = 45, OH_NN_SOFTMAX_AXIS = 46, OH_NN_SPACE_TO_BATCH_ND_BLOCK_SHAPE = 47,
OH_NN_SPACE_TO_BATCH_ND_PADDINGS = 48, OH_NN_SPLIT_AXIS = 49, OH_NN_SPLIT_OUTPUT_NUM = 50, OH_NN_SPLIT_SIZE_SPLITS = 51,
OH_NN_SQUEEZE_AXIS = 52, OH_NN_STACK_AXIS = 53, OH_NN_STRIDED_SLICE_BEGIN_MASK = 54, OH_NN_STRIDED_SLICE_END_MASK = 55,
OH_NN_STRIDED_SLICE_ELLIPSIS_MASK = 56, OH_NN_STRIDED_SLICE_NEW_AXIS_MASK = 57, OH_NN_STRIDED_SLICE_SHRINK_AXIS_MASK = 58, OH_NN_SUB_ACTIVATIONTYPE = 59,
OH_NN_REDUCE_MEAN_KEEP_DIMS = 60, OH_NN_RESIZE_BILINEAR_NEW_HEIGHT = 61, OH_NN_RESIZE_BILINEAR_NEW_WIDTH = 62, OH_NN_RESIZE_BILINEAR_PRESERVE_ASPECT_RATIO = 63,
OH_NN_RESIZE_BILINEAR_COORDINATE_TRANSFORM_MODE = 64, OH_NN_RESIZE_BILINEAR_EXCLUDE_OUTSIDE = 65, OH_NN_LAYER_NORM_BEGIN_NORM_AXIS = 66, OH_NN_LAYER_NORM_EPSILON = 67,
OH_NN_LAYER_NORM_BEGIN_PARAM_AXIS = 68, OH_NN_LAYER_NORM_ELEMENTWISE_AFFINE = 69, OH_NN_REDUCE_PROD_KEEP_DIMS = 70, OH_NN_REDUCE_ALL_KEEP_DIMS = 71,
OH_NN_QUANT_DTYPE_CAST_SRC_T = 72, OH_NN_QUANT_DTYPE_CAST_DST_T = 73, OH_NN_TOP_K_SORTED = 74, OH_NN_ARG_MAX_AXIS = 75,
OH_NN_ARG_MAX_KEEPDIMS = 76, OH_NN_UNSQUEEZE_AXIS = 77
} | Enumerates the tensor data types. | diff --git a/en/application-dev/reference/native-apis/raw__dir_8h.md b/en/application-dev/reference/native-apis/raw__dir_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d510bd8a495ac00706b01b4552f01669d6c53133 --- /dev/null +++ b/en/application-dev/reference/native-apis/raw__dir_8h.md @@ -0,0 +1,34 @@ +# raw_dir.h + + +## Overview + +Provides functions for operating rawfile directories. + +These functions include traversing and closing rawfile directories. + +**Since:** +8 + +**Related Modules:** + +[Rawfile](rawfile.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [RawDir](rawfile.md#rawdir) | Provides the function of accessing rawfile directories. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_ResourceManager_GetRawFileName](rawfile.md#oh_resourcemanager_getrawfilename) ([RawDir](rawfile.md#rawdir) \*rawDir, int index) | Obtains the rawfile name via an index. | +| [OH_ResourceManager_GetRawFileCount](rawfile.md#oh_resourcemanager_getrawfilecount) ([RawDir](rawfile.md#rawdir) \*rawDir) |Obtains the number of rawfiles in [RawDir](rawfile.md#rawdir). | +| [OH_ResourceManager_CloseRawDir](rawfile.md#oh_resourcemanager_closerawdir) ([RawDir](rawfile.md#rawdir) \*rawDir) | Closes an opened [RawDir](rawfile.md#rawdir) and releases all associated resources. | diff --git a/en/application-dev/reference/native-apis/raw__file_8h.md b/en/application-dev/reference/native-apis/raw__file_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..d9788a68b24e266daa1b7b8754ba4fbe33255024 --- /dev/null +++ b/en/application-dev/reference/native-apis/raw__file_8h.md @@ -0,0 +1,45 @@ +# raw_file.h + + +## Overview + +Provides functions for operating rawfiles. + +These functions include searching, reading, and closing rawfiles. + +**Since:** +8 + +**Related Modules:** + +[Rawfile](rawfile.md) + + +## Summary + + +### Structs + +| Name | Description | +| -------- | -------- | +| [RawFileDescriptor](_raw_file_descriptor.md) | Provides rawfile descriptor information. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [RawFile](rawfile.md#rawfile) | Provides the function of accessing rawfiles. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_ResourceManager_ReadRawFile](rawfile.md#oh_resourcemanager_readrawfile) (const [RawFile](rawfile.md#rawfile) \*rawFile, void \*buf, size_t length) |Reads a rawfile. | +| [OH_ResourceManager_SeekRawFile](rawfile.md#oh_resourcemanager_seekrawfile) (const [RawFile](rawfile.md#rawfile) \*rawFile, long offset, int whence) |Seeks for the data read/write position in the rawfile based on the specified offset. | +| [OH_ResourceManager_GetRawFileSize](rawfile.md#oh_resourcemanager_getrawfilesize) ([RawFile](rawfile.md#rawfile) \*rawFile) | Obtains the length of a rawfile in int32_t. | +| [OH_ResourceManager_CloseRawFile](rawfile.md#oh_resourcemanager_closerawfile) ([RawFile](rawfile.md#rawfile) \*rawFile) | Closes an opened [RawFile](rawfile.md#rawfile) and releases all associated resources. | +| [OH_ResourceManager_GetRawFileOffset](rawfile.md#oh_resourcemanager_getrawfileoffset) (const [RawFile](rawfile.md#rawfile) \*rawFile) | Obtains the current offset of the rawfile in int32_t. | +| [OH_ResourceManager_GetRawFileDescriptor](rawfile.md#oh_resourcemanager_getrawfiledescriptor) (const [RawFile](rawfile.md#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Opens a rawfile descriptor. | +| [OH_ResourceManager_ReleaseRawFileDescriptor](rawfile.md#oh_resourcemanager_releaserawfiledescriptor) (const [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Closes a rawfile descriptor. | diff --git a/en/application-dev/reference/native-apis/raw__file__manager_8h.md b/en/application-dev/reference/native-apis/raw__file__manager_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..632fc0ab713dd34fdcce7f1a97754cce7a38b4a6 --- /dev/null +++ b/en/application-dev/reference/native-apis/raw__file__manager_8h.md @@ -0,0 +1,35 @@ +# raw_file_manager.h + + +## Overview + +Provides functions for managing rawfile resources. + +You can use the resource manager to open a rawfile and perform operations such as data search and reading. + +**Since:** +8 + +**Related Modules:** + +[Rawfile](rawfile.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [NativeResourceManager](rawfile.md#nativeresourcemanager) | Implements the resource manager. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_ResourceManager_InitNativeResourceManager](rawfile.md#oh_resourcemanager_initnativeresourcemanager) (napi_env env, napi_value jsResMgr) | Obtains the native resource manager based on JavaScipt resource manager. | +| [OH_ResourceManager_ReleaseNativeResourceManager](rawfile.md#oh_resourcemanager_releasenativeresourcemanager) ([NativeResourceManager](rawfile.md#nativeresourcemanager) \*resMgr) | Releases a native resource manager. | +| [OH_ResourceManager_OpenRawDir](rawfile.md#oh_resourcemanager_openrawdir) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*dirName) | Opens a rawfile directory. | +| [OH_ResourceManager_OpenRawFile](rawfile.md#oh_resourcemanager_openrawfile) (const [NativeResourceManager](rawfile.md#nativeresourcemanager) \*mgr, const char \*fileName) | Opens a rawfile. | diff --git a/en/application-dev/reference/native-apis/rawfile.md b/en/application-dev/reference/native-apis/rawfile.md new file mode 100644 index 0000000000000000000000000000000000000000..7314b4b36ea9eac50bf23972ef35833f5a828537 --- /dev/null +++ b/en/application-dev/reference/native-apis/rawfile.md @@ -0,0 +1,414 @@ +# Rawfile + + +## Overview + +Provides the function of operating rawfile directories and rawfiles. + +These functions include traversing, opening, searching, reading, and closing rawfiles. + +**Since:** +8 + + +## Summary + + +### Files + +| Name | Description | +| -------- | -------- | +| [raw_dir.h](raw__dir_8h.md) | Provides functions for operating rawfile directories.
File to Include: | +| [raw_file.h](raw__file_8h.md) | Provides functions for operating rawfiles.
File to Include: | +| [raw_file_manager.h](raw__file__manager_8h.md) | Provides functions for managing rawfile resources.
File to Include: | + + +### Structs + +| Name | Description | +| -------- | -------- | +| [RawFileDescriptor](_raw_file_descriptor.md) | Provides rawfile descriptor information. | + + +### Types + +| Name | Description | +| -------- | -------- | +| [RawDir](#rawdir) | Provides the function of accessing rawfile directories. | +| [RawFile](#rawfile) | Provides the function of accessing rawfiles. | +| [NativeResourceManager](#nativeresourcemanager) | Implements the resource manager. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename) ([RawDir](#rawdir) \*rawDir, int index) | Obtains the rawfile name via an index. | +| [OH_ResourceManager_GetRawFileCount](#oh_resourcemanager_getrawfilecount) ([RawDir](#rawdir) \*rawDir) |Obtains the number of rawfiles in [RawDir](#rawdir). | +| [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) ([RawDir](#rawdir) \*rawDir) | Closes an opened [RawDir](#rawdir) and releases all associated resources. | +| [OH_ResourceManager_ReadRawFile](#oh_resourcemanager_readrawfile) (const [RawFile](#rawfile) \*rawFile, void \*buf, size_t length) |Reads a rawfile. | +| [OH_ResourceManager_SeekRawFile](#oh_resourcemanager_seekrawfile) (const [RawFile](#rawfile) \*rawFile, long offset, int whence) |Seeks for the data read/write position in the rawfile based on the specified offset. | +| [OH_ResourceManager_GetRawFileSize](#oh_resourcemanager_getrawfilesize) ([RawFile](#rawfile) \*rawFile) | Obtains the length of a rawfile in int32_t. | +| [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) ([RawFile](#rawfile) \*rawFile) | Closes an opened [RawFile](#rawfile) and releases all associated resources. | +| [OH_ResourceManager_GetRawFileOffset](#oh_resourcemanager_getrawfileoffset) (const [RawFile](#rawfile) \*rawFile) | Obtains the current offset of the rawfile in int32_t. | +| [OH_ResourceManager_GetRawFileDescriptor](#oh_resourcemanager_getrawfiledescriptor) (const [RawFile](#rawfile) \*rawFile, [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Opens a rawfile descriptor. | +| [OH_ResourceManager_ReleaseRawFileDescriptor](#oh_resourcemanager_releaserawfiledescriptor) (const [RawFileDescriptor](_raw_file_descriptor.md) &descriptor) | Closes a rawfile descriptor. | +| [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) (napi_env env, napi_value jsResMgr) | Obtains the native resource manager based on JavaScipt resource manager. | +| [OH_ResourceManager_ReleaseNativeResourceManager](#oh_resourcemanager_releasenativeresourcemanager) ([NativeResourceManager](#nativeresourcemanager) \*resMgr) | Releases a native resource manager. | +| [OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*dirName) | Opens a rawfile directory. | +| [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) (const [NativeResourceManager](#nativeresourcemanager) \*mgr, const char \*fileName) | Opens a rawfile. | + + +## Type Description + + +### NativeResourceManager + + +``` +typedef struct NativeResourceManagerNativeResourceManager +``` +**Description**
+Implements the resource manager. + +This class encapsulates the native implementation of the JavaScript resource manager. You can obtain the pointer to **ResourceManager** by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). + + +### RawDir + + +``` +typedef struct RawDirRawDir +``` +**Description**
+Provides the function of accessing rawfile directories. + + +### RawFile + + +``` +typedef struct RawFileRawFile +``` +**Description**
+Provides the function of accessing rawfiles. + + +## Function Description + + +### OH_ResourceManager_CloseRawDir() + + +``` +void OH_ResourceManager_CloseRawDir (RawDir * rawDir) +``` +**Description**
+Closes an opened [RawDir](#rawdir) and releases all associated resources. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawDir | Indicates the pointer to [RawDir](#rawdir). | + + **See** + +[OH_ResourceManager_OpenRawDir](#oh_resourcemanager_openrawdir) + + +### OH_ResourceManager_CloseRawFile() + + +``` +void OH_ResourceManager_CloseRawFile (RawFile * rawFile) +``` +**Description**
+Closes an opened [RawFile](#rawfile) and releases all associated resources. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | + + **See** + +[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) + + +### OH_ResourceManager_GetRawFileCount() + + +``` +int OH_ResourceManager_GetRawFileCount (RawDir * rawDir) +``` +**Description**
+Obtains the number of rawfiles in [RawDir](#rawdir). + +You can use this function to obtain available indexes in [OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename). + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawDir | Indicates the pointer to [RawDir](#rawdir). | + + **See** + +[OH_ResourceManager_GetRawFileName](#oh_resourcemanager_getrawfilename) + + +### OH_ResourceManager_GetRawFileDescriptor() + + +``` +bool OH_ResourceManager_GetRawFileDescriptor (const RawFile * rawFile, RawFileDescriptor & descriptor ) +``` +**Description**
+Opens a rawfile descriptor. + +After the descriptor is opened, you can use it to read the rawfile based on the offset (in int32_t) and file length. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | +| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. | + +**Returns** + +Returns **true** if the rawfile descriptor is opened successfully; returns **false** if the rawfile cannot be accessed. + + +### OH_ResourceManager_GetRawFileName() + + +``` +const char* OH_ResourceManager_GetRawFileName (RawDir * rawDir, int index ) +``` +**Description**
+Obtains the rawfile name via an index. + +You can use this function to traverse a rawfile directory. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawDir | Indicates the pointer to [RawDir](#rawdir). | +| index | Indicates the index of the file in [RawDir](#rawdir). | + +**Returns** + +Returns the rawfile name via an index. The return value can be used as the input parameter of [OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile). If no rawfile is found after all rawfiles are traversed, **NULL** will be returned. + + **See** + +[OH_ResourceManager_OpenRawFile](#oh_resourcemanager_openrawfile) + + +### OH_ResourceManager_GetRawFileOffset() + + +``` +long OH_ResourceManager_GetRawFileOffset (const RawFile * rawFile) +``` +**Description**
+Obtains the current offset of the rawfile in int32_t. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | + +**Returns** + +Returns the current offset of the rawfile. + + +### OH_ResourceManager_GetRawFileSize() + + +``` +long OH_ResourceManager_GetRawFileSize (RawFile * rawFile) +``` +**Description**
+Obtains the length of a rawfile in int32_t. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | + +**Returns** + +Returns the total length of the rawfile. + + +### OH_ResourceManager_InitNativeResourceManager() + + +``` +NativeResourceManager* OH_ResourceManager_InitNativeResourceManager (napi_env env, napi_value jsResMgr ) +``` +**Description**
+Obtains the native resource manager based on JavaScipt resource manager. + +After obtaining a resource manager, you can use it complete various rawfile operations. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| env | Indicates the pointer to the JavaScipt Native Interface (napi) environment. | +| jsResMgr | Indicates the JavaScipt resource manager. | + +**Returns** + +Returns the pointer to [NativeResourceManager](#nativeresourcemanager). + + +### OH_ResourceManager_OpenRawDir() + + +``` +RawDir* OH_ResourceManager_OpenRawDir (const NativeResourceManager * mgr, const char * dirName ) +``` +**Description**
+Opens a rawfile directory. + +After opening a rawfile directory, you can traverse all the rawfile files in it. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). | +| dirName | Indicates the name of the rawfile directory to open. If this field is left empty, the root directory of rawfile will be opened. | + +**Returns** + +Returns the pointer to [RawDir](#rawdir). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) to release it. + + **See** + +[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) + +[OH_ResourceManager_CloseRawDir](#oh_resourcemanager_closerawdir) + + +### OH_ResourceManager_OpenRawFile() + + +``` +RawFile* OH_ResourceManager_OpenRawFile (const NativeResourceManager * mgr, const char * fileName ) +``` +**Description**
+Opens a rawfile. + +After a rawfile is opened, you can read the data in it. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| mgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). You can obtain this pointer by calling [OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager). | +| fileName | Indicates the file name in the relative path of the rawfile root directory. | + +**Returns** + +Returns the pointer to [RawFile](#rawfile). If this pointer is no longer needed after use, call [OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) to release it. + + **See** + +[OH_ResourceManager_InitNativeResourceManager](#oh_resourcemanager_initnativeresourcemanager) + +[OH_ResourceManager_CloseRawFile](#oh_resourcemanager_closerawfile) + + +### OH_ResourceManager_ReadRawFile() + + +``` +int OH_ResourceManager_ReadRawFile (const RawFile * rawFile, void * buf, size_t length ) +``` +**Description**
+Reads a rawfile. + +You can use this function to read data of the specified length from the current position. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | +| buf | Indicates the pointer to the buffer for storing the read data. | +| length | Indicates the length of the read data, in bytes. | + +**Returns** + +Returns the length of the read data in bytes. If the length is beyond the end of the rawfile, **0** will be returned. + + +### OH_ResourceManager_ReleaseNativeResourceManager() + + +``` +void OH_ResourceManager_ReleaseNativeResourceManager (NativeResourceManager * resMgr) +``` +**Description**
+Releases a native resource manager. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| resMgr | Indicates the pointer to [NativeResourceManager](#nativeresourcemanager). | + + +### OH_ResourceManager_ReleaseRawFileDescriptor() + + +``` +bool OH_ResourceManager_ReleaseRawFileDescriptor (const RawFileDescriptor & descriptor) +``` +**Description**
+Closes a rawfile descriptor. + +To prevent file descriptor leakage, you are advised to release a rawfile descriptor after use. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| descriptor | Indicates the rawfile descriptor, and the start position and length of the rawfile file in the HAP package. | + +**Returns** + +Returns **true** if the rawfile descriptor is closed successfully; returns **false** otherwise. + + +### OH_ResourceManager_SeekRawFile() + + +``` +int OH_ResourceManager_SeekRawFile (const RawFile * rawFile, long offset, int whence ) +``` +**Description**
+Seeks for the data read/write position in the rawfile based on the specified offset. + + **Parameters** + +| Name | Description | +| -------- | -------- | +| rawFile | Indicates the pointer to [RawFile](#rawfile). | +| offset | Indicates the specified offset. | +| whence | Indicates the data read/write position. The options are as follows:
**0**: The read/write position is **offset**.
**1**: The read/write position is the current position plus **offset**.
**2**: The read/write position is the end of the file (EOF) plus **offset**. | + +**Returns** + +Returns the new data read/write position if the operation is successful; returns **(long) -1** otherwise. diff --git a/en/application-dev/reference/native-apis/status_8h.md b/en/application-dev/reference/native-apis/status_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..8fbf8c27c8474b490a8bb9e872f1ff5f238960d5 --- /dev/null +++ b/en/application-dev/reference/native-apis/status_8h.md @@ -0,0 +1,31 @@ +# status.h + + +## Overview + +Provides the status codes of MindSpore Lite. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_Status](_mind_spore.md#oh_ai_status) | Defines MindSpore status codes. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AI_CompCode](_mind_spore.md#oh_ai_compcode) { OH_AI_COMPCODE_CORE = 0x00000000u, OH_AI_COMPCODE_LITE = 0xF0000000u } | Defines MinSpore component codes. | +| [OH_AI_Status](_mind_spore.md#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. | diff --git a/en/application-dev/reference/native-apis/tensor_8h.md b/en/application-dev/reference/native-apis/tensor_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..bf194ef55a762a07924826925ec1f0817ac28f6c --- /dev/null +++ b/en/application-dev/reference/native-apis/tensor_8h.md @@ -0,0 +1,45 @@ +# tensor.h + + +## Overview + +Provides APIs for creating and modifying tensor information. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) | Defines the handle of a tensor object. | + + +### Functions + +| Name | Description | +| -------- | -------- | +| [OH_AI_TensorCreate](_mind_spore.md#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](_mind_spore.md#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](_mind_spore.md#oh_ai_tensordestroy) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | +| [OH_AI_TensorClone](_mind_spore.md#oh_ai_tensorclone) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Clones a tensor. | +| [OH_AI_TensorSetName](_mind_spore.md#oh_ai_tensorsetname) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. | +| [OH_AI_TensorGetName](_mind_spore.md#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. | +| [OH_AI_TensorSetDataType](_mind_spore.md#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_DataType](_mind_spore.md#oh_ai_datatype) type) | Sets the data type of a tensor. | +| [OH_AI_TensorGetDataType](_mind_spore.md#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. | +| [OH_AI_TensorSetShape](_mind_spore.md#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. | +| [OH_AI_TensorGetShape](_mind_spore.md#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. | +| [OH_AI_TensorSetFormat](_mind_spore.md#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, [OH_AI_Format](_mind_spore.md#oh_ai_format) format) | Sets the tensor data format. | +| [OH_AI_TensorGetFormat](_mind_spore.md#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | +| [OH_AI_TensorSetData](_mind_spore.md#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | +| [OH_AI_TensorGetData](_mind_spore.md#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | +| [OH_AI_TensorGetMutableData](_mind_spore.md#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | +| [OH_AI_TensorGetElementNum](_mind_spore.md#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | +| [OH_AI_TensorGetDataSize](_mind_spore.md#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](_mind_spore.md#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | diff --git a/en/application-dev/reference/native-apis/types_8h.md b/en/application-dev/reference/native-apis/types_8h.md new file mode 100644 index 0000000000000000000000000000000000000000..daf7c2c55c28129566aa63714b5a71774c22a6dc --- /dev/null +++ b/en/application-dev/reference/native-apis/types_8h.md @@ -0,0 +1,32 @@ +# types.h + + +## Overview + +Provides the model file types and device types supported by MindSpore Lite. + +**Since:** +9 + +**Related Modules:** + +[MindSpore](_mind_spore.md) + + +## Summary + + +### Types + +| Name | Description | +| -------- | -------- | +| [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) | Defines model file types. | +| [OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) | Defines the supported device types. | + + +### Enums + +| Name | Description | +| -------- | -------- | +| [OH_AI_ModelType](_mind_spore.md#oh_ai_modeltype) { OH_AI_MODELTYPE_MINDIR = 0, OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF } | Defines model file types. | +| [OH_AI_DeviceType](_mind_spore.md#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. | diff --git a/en/application-dev/reference/native-lib/Readme-EN.md b/en/application-dev/reference/native-lib/Readme-EN.md index 9c12f39504aa2d6bc0e21dfb44b0b47aee13af4a..e57d19d10689c860c3a0f5f5904986e9d7e40742 100644 --- a/en/application-dev/reference/native-lib/Readme-EN.md +++ b/en/application-dev/reference/native-lib/Readme-EN.md @@ -6,4 +6,4 @@ - [Native API Symbols Not Exported](third_party_libc/musl-peculiar-symbol.md) - [EGL Symbols Exported from Native APIs](third_party_opengl/egl-symbol.md) - [OpenGL ES 3.0 Symbols Exported from Native APIs](third_party_opengl/openglesv3-symbol.md) - + - [OpenSL ES Interfaces Supported by Native APIs](third_party_opensles/opensles.md) \ No newline at end of file diff --git a/en/application-dev/reference/native-lib/third_party_libc/musl.md b/en/application-dev/reference/native-lib/third_party_libc/musl.md index 360f9527a5a06466e9faf66137e29526c425b388..cf74c7efdf1a796acd0de7f27883cec9a7cbb85f 100644 --- a/en/application-dev/reference/native-lib/third_party_libc/musl.md +++ b/en/application-dev/reference/native-lib/third_party_libc/musl.md @@ -9,7 +9,7 @@ | C standard library | C11 standard library implemented by [libc, libm, and libdl](https://en.cppreference.com/w/c/header). | | C++ standard library ([libc++](https://libcxx.llvm.org/))| An implementation of the C++ standard library. | | Open Sound Library for Embedded Systems ([OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/))| An embedded, cross-platform audio processing library.| -| [zlib](https://zlib.net/) | A general data compression library implemented in C/C++.| +| [zlib](https://zlib.net/) | A general data compression library implemented in C/C++.| | [EGL](https://www.khronos.org/egl/) | A standard software interface between rendering APIs and the underlying native window system.| | Open Graphics Library for Embedded Systems ([OpenGL ES](https://www.khronos.org/opengles/))| A cross-platform software interface for rendering 3D graphics on embedded and mobile systems.| @@ -19,8 +19,10 @@ The C standard library is a C11 standard library implemented by: - libc: provides thread-related functions and a majority of standard functions. + - libm: provides basic mathematical functions. + - libdl: provides functions related to dynamic linking, such as **dlopen**. @@ -32,7 +34,7 @@ The C standard library is a C11 standard library implemented by: C standard library includes a set of header files in accordance with standard C and provides common functions, such as the functions related to input/output (I/O) and string control. -**musl** +**musl** [Native API Symbols Not Exported](musl-peculiar-symbol.md) @@ -52,7 +54,11 @@ The C++11 and C++14 standards are supported, and the C++17 and C++20 standards a ## OpenSL ES -[OpenSL ES](https://www.khronos.org/registry/OpenSL-ES/) is an embedded, cross-platform audio processing library. +[OpenGL ES](https://www.khronos.org/opengles/) is an embedded, cross-platform audio processing library. + +**Capabilities** + +[OpenSL ES Interfaces Supported by Native APIs](../third_party_opensles/opensles.md) ## zlib diff --git a/en/application-dev/reference/native-lib/third_party_opensles/opensles.md b/en/application-dev/reference/native-lib/third_party_opensles/opensles.md new file mode 100644 index 0000000000000000000000000000000000000000..d1d9473df3acd3bcaddb9c9cfe924ff08e541926 --- /dev/null +++ b/en/application-dev/reference/native-lib/third_party_opensles/opensles.md @@ -0,0 +1,29 @@ +# OpenSL ES Interfaces Supported by Native APIs + +## Introduction + +Open Sound Library for Embedded Systems (OpenSL ES) is a set of audio acceleration standards for embedded systems. It provides objects and APIs for developers to implement high-performance, low-latency audio features. OpenHarmony implements some native APIs based on [OpenSL ES](https://www.khronos.org/opensles/) 1.0.1 API specifications. The following table lists the related APIs. + +## Supported APIs + +|Object |External Interface |Interface Invocation |Supported |Description | +| ------------------ | -------------------- | -------------------------------------------------------------------------------------|----------| -------------------- | +|SLEngineItf |CreateAudioPlayer |CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) |Yes |Creates an audio player. | +|SLEngineItf |CreateAudioRecorder |reateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio recorder. | +|SLEngineItf |CreateAudioOutputMix |CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio output mixer. | +|SLObjectItf |Realize |Realize(SLObjectItf self, SLboolean async) |Yes |Realizes an audio player. | +|SLObjectItf |getState |GetState(SLObjectItf self, SLuint32 *state) |Yes |Obtains the state. | +|SLObjectItf |getInterface |GetInterface(SLObjectItf self, const SLInterfaceID iid, void *interface) |Yes |Obtains the interface. | +|SLObjectItf |Destroy |Destroy(SLObjectItf self) |Yes |Destroys an object. | +|SLOHBufferQueueItf |Enqueue |Enqueue(SLOHBufferQueueItf self, const void *buffer, SLuint32 size) |Yes |Adds a buffer to the queue.| +|SLOHBufferQueueItf |clear |Clear(SLOHBufferQueueItf self) |Yes |Releases the buffer queue. | +|SLOHBufferQueueItf |getState |GetState(SLOHBufferQueueItf self, SLOHBufferQueueState *state) |Yes |Obtains the BufferQueue status. | +|SLOHBufferQueueItf |getBuffer |GetBuffer(SLOHBufferQueueItf self, SLuint8 **buffer, SLuint32 *size) |Yes |Obtains a buffer. | +|SLOHBufferQueueItf |RegisterCallback |RegisterCallback(SLOHBufferQueueItf self, SlOHBufferQueueCallback callback, void *pContext) |Yes |Registers a callback. | +|SLPlayItf |SetPlayState |SetPlayState(SLPlayItf self, SLuint32 state) |Yes |Sets the playback state. | +|SLPlayItf |GetPlayState |GetPlayState(SLPlayItf self, SLuint32 *state) |Yes |Obtains the playback state. | +|SLRecordItf |SetRecordState |SetRecordState(SLRecordItf self, SLuint32 state) |Yes |Sets the recording state. | +|SLRecordItf |GetRecordState |GetRecordState(SLRecordItf self, SLuint32 *pState) |Yes |Obtains the recording state. | +|SLVolumeItf |SetVolumeLevel |SetVolumeLevel(SLVolumeItf self, SLmillibel *level) |Yes |Sets the volume. | +|SLVolumeItf |GetVolumeLevel |GetVolumeLevel(SLVolumeItf self, SLmillibel level) |Yes |Obtains the volume. | +|SLVolumeItf |GetMaxVolumeLevel |GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *maxLevel) |Yes |Obtains the maximum volume. | diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index 4898235299bef9f194b70f20ae20dd48303aa915..504f6643b3929cf423f0f6196d80fd06a46171e2 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -110,7 +110,7 @@ For example, if an application needs to access audio clips of a user and capture "acls":{ "allowed-acls":[ "ohos.permission.WRITE_AUDIO", - "ohos.permission.CAPTURE_SCREEN" + "ohos.permission.CAPTURE_SCREEN" ] } } @@ -131,7 +131,7 @@ User authorization is required when an application needs to access user privacy Example: Apply for the permission for an application to access the Calendar. -1. Declare the **ohos.permission.READ_CALENDAR** permission in the configuration file.
For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). +1. Declare the **ohos.permission.READ_CALENDAR** permission in the configuration file. For details, see [Declaring Permissions in the Configuration File](#declaring-permissions-in-the-configuration-file). 2. Check whether the user has granted the permission. diff --git a/en/application-dev/website.md b/en/application-dev/website.md index 40a5c8bd53fb06344a61e98a421706cf9dd89038..f4e2dd62dd1d8fa65dc8052437c6b1705a5c07d8 100644 --- a/en/application-dev/website.md +++ b/en/application-dev/website.md @@ -1132,7 +1132,6 @@ - [@ohos.systemParameter (System Parameter)](reference/apis/js-apis-system-parameter.md) - [@ohos.systemTime (System Time and Time Zone)](reference/apis/js-apis-system-time.md) - [@ohos.usb (USB Management)](reference/apis/js-apis-usb-deprecated.md) - - [@ohos.usbV9 (USB Management)](reference/apis/js-apis-usb.md) - [@system.app (Application Context)](reference/apis/js-apis-system-app.md) - [@system.battery (Battery Information)](reference/apis/js-apis-system-battery.md) - [@system.bluetooth (Bluetooth)](reference/apis/js-apis-system-bluetooth.md) @@ -1281,5 +1280,4 @@ - [Native API Usage](faqs/faqs-native.md) - [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-party-library.md) - [IDE Usage](faqs/faqs-ide.md) - - [hdc_std Command Usage](faqs/faqs-hdc-std.md) - [Development Board](faqs/faqs-development-board.md) diff --git a/en/contribute/FAQ.md b/en/contribute/FAQ.md index 64f2375abe23b2735f77fc72d74f39826cc2d6cc..2c6852a521d719112f42ec9a314e4b2712ff8f02 100644 --- a/en/contribute/FAQ.md +++ b/en/contribute/FAQ.md @@ -41,7 +41,7 @@ The possible causes for a verification failure include: **Solution** - Click [https://dco.openharmony.io/sign/Z2l0ZWUlMkZvcGVuX2hhcm1vbnk=) to sign the DCO or check the signing status. + Click [here](https://dco.openharmony.cn/sign) to sign the DCO or check the signing status. Enter **check dco** in the Pull Requests comment box and click **Comment**. The system will check the DCO signing status again. diff --git a/en/device-dev/get-code/sourcecode-acquire.md b/en/device-dev/get-code/sourcecode-acquire.md index 109210ddca1b8bb0c1b99fc7c38bfd68a08e8ea1..aa782e6988cf05b1c4aa94169a7085c605118da2 100644 --- a/en/device-dev/get-code/sourcecode-acquire.md +++ b/en/device-dev/get-code/sourcecode-acquire.md @@ -65,9 +65,9 @@ The OpenHarmony source code is open to you as [HPM parts](../hpm-part/hpm-part-a ### How to Use -> **NOTE** -> -> Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development. +>![](../public_sys-resources/icon-note.gif) **NOTE** +> +>Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development. - **Obtaining OpenHarmony release code** @@ -168,7 +168,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below. -The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](../../release-notes/Readme.md). +The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](../../release-notes/Readme.md). **Table 1** Sites for acquiring source code @@ -182,19 +182,19 @@ The table below provides only the sites for downloading the latest OpenHarmony L | Hi3516 solution-Linux (binary)| 3.0 | [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.0/hispark_taurus_linux.tar.gz.sha256) | 418.1 MB | | RELEASE-NOTES | 3.0 | [Download](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.0-LTS/en/release-notes/OpenHarmony-v3.0-LTS.md)| - | - | | **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| -| Full code base (for mini, small, and standard systems)| 3.2 Beta5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/code-v3.2-Beta5.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/code-v3.2-Beta5.tar.gz.sha256) | 21.3 GB | -| Hi3861 solution (binary) | 3.2 Beta5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/hispark_pegasus.tar.gz.sha256) | 22.9 MB | -| Hi3516 solution-LiteOS (binary)| 3.2 Beta5 | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_LiteOS.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_LiteOS.tar.gz.sha256) | 293.6 MB | -| Hi3516 solution-Linux (binary) | 3.2 Beta5 | [Download](hispark_taurus_Linux.tar.gz) | [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Beta5/hispark_taurus_Linux.tar.gz.sha256) | 174.3 MB | -| RK3568 standard system solution (binary) | 3.2 Beta5 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/dayu200_standard_arm32_20230201.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta5/dayu200_standard_arm32_20230201.tar.gz.sha256) | 3.9 GB | -| RELEASE-NOTES | 3.2 Beta5 | [Download](../../release-notes/OpenHarmony-v3.2-beta5.md)| - | - | +| Full code base (for mini, small, and standard systems)| 3.2 Release | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/code-v3.2-Release.tar.gz.sha256)| 21.8 GB | +| Hi3861 solution (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release/hispark_pegasus.tar.gz.sha256)| 22.9 MB | +| Hi3516 solution-LiteOS (binary)| 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_LiteOS.tar.gz.sha256)| 294.3 MB | +| Hi3516 solution-Linux (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz)| [Download](https://repo.huaweicloud.com/openharmony/os/3.2-Release/hispark_taurus_Linux.tar.gz.sha256)| 174.3 MB | +| RK3568 standard system solution (binary) | 3.2 Release| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz)| [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Release//dayu200_standard_arm32.tar.gz.sha256)| 3.9 GB | +| RELEASE-NOTES | 3.2 Release| [Download](../../release-notes/OpenHarmony-v3.2-release.md)| - | - | | **Compiler Toolchain**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**| | Compiler toolchain| - | [Download](https://repo.huaweicloud.com/openharmony/os/2.0/tool_chain/)| - | - | ## Method 4: Acquiring Source Code from the GitHub Image Repository -> **NOTE** -> +>![](../public_sys-resources/icon-note.gif) **NOTE** +> > The image repository is synchronized at 23:00 (UTC +8:00) every day. Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\) @@ -219,82 +219,21 @@ The following table describes the OpenHarmony source code directories. **Table 2** Source code directories - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Description

-

applications

-

Application samples, for example, camera

-

base

-

Basic software service subsystem set and hardware service subsystem set

-

build

-

Bundle-based compilation, build, and configuration scripts

-

docs

-

Reference documents

-

domains

-

Enhanced software service subsystem set

-

drivers

-

Driver subsystem

-

foundation

-

Basic system capability subsystem set

-

kernel

-

Kernel subsystem

-

prebuilts

-

Compiler and toolchain subsystem

-

test

-

Testing subsystem

-

third_party

-

Open-source third-party software

-

utils

-

Commonly used development tools

-

vendor

-

Vendor-provided software

-

build.py

-

Compilation script file

-
+| Directory| Description| +| -------- | -------- | +| applications | Application samples, for example, **camera**.| +| base | Basic software service subsystem set and hardware service subsystem set.| +| build | Bundle-based compilation, building, and configuration scripts.| +| docs | Reference documents.| +| domains | Enhanced software service subsystem set.| +| drivers | Driver subsystem.| +| foundation | Basic system capability subsystem set.| +| kernel | Kernel subsystem.| +| prebuilts | Compiler and tool chain subsystem.| +| test | Test subsystem.| +| third_party | Open-source third-party software.| +| utils | Commonly used development utilities.| +| vendor | Vendor-provided software.| +| build.py | Build script file.| + + diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 63dfb30426ef5a4e92d650e884115884a05eddbf..d34ba6e53dbbd1abe91f145f34d8a04a7ed7965f 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -38,7 +38,9 @@ - [Audio/Video Playback Development](subsys-multimedia-video-play-guide.md) - [Audio/Video Recording Development](subsys-multimedia-video-record-guide.md) - [Utils Development](subsys-utils-guide.md) -- [AI Framework Development](subsys-ai-aiframework-devguide.md) +- AI + - [AI Framework Development](subsys-ai-aiframework-devguide.md) + - [NNRt Development](subsys-ai-nnrt-guide.md) - Data Management - RDB - [RDB Overview](subsys-data-relational-database-overview.md) @@ -105,6 +107,23 @@ - [hdc](subsys-toolchain-hdc-guide.md) - [hiperf](subsys-toolchain-hiperf.md) - [HiDumper](subsys-dfx-hidumper.md) -- Power Management +- Power - Display Management - [System Brightness Customization](subsys-power-brightness-customization.md) + - Battery Management + - [Battery Level and LED Color Mapping Customization](subsys-power-level-LED-color.md) + - [Battery Temperature Protection Customization](subsys-power-temperature-protection.md) + - [Battery Level Customization](subsys-power-battery-level-customization.md) + - [Charging Current and Voltage Limit Customization](subsys-power-charge-current-voltage-limit.md) + - [Charging Type Customization](subsys-power-charge-type-customization.md) + - [Power-off Charging Animation Customization](subsys-power-poweroff-charge-animation.md) + - Power Consumption Statistics + - [Power Consumption Statistics Customization](subsys-power-stats-power-average-customization.md) + - Thermal Management + - [Charging Idle State Customization](subsys-thermal_charging_idle_state.md) + - [Thermal Control Customization](subsys-thermal_control.md) + - [Thermal Detection Customization](subsys-thermal_detection.md) + - [Thermal Level Customization](subsys-thermal_level.md) + - [Thermal Log Customization](subsys-thermal_log.md) + - [Thermal Policy Customization](subsys-thermal_policy.md) + - [Thermal Scene Customization](subsys-thermal_scene.md) \ No newline at end of file diff --git a/en/device-dev/subsystems/figures/animation_charging_power2.jpg b/en/device-dev/subsystems/figures/animation_charging_power2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4ddfc92f26d3fede4a878e449a2364140085d745 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_charging_power2.jpg differ diff --git a/en/device-dev/subsystems/figures/animation_charing_power.jpg b/en/device-dev/subsystems/figures/animation_charing_power.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6da51e0ee4e353007f2c78b0a6a47a79c2771907 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_charing_power.jpg differ diff --git a/en/device-dev/subsystems/figures/animation_initial_power.jpg b/en/device-dev/subsystems/figures/animation_initial_power.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c1417a4cc98fe5a413bba5facf5998ed48310f48 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_initial_power.jpg differ diff --git a/en/device-dev/subsystems/figures/animation_initial_power2.jpg b/en/device-dev/subsystems/figures/animation_initial_power2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..72e77043f06ac4298604b7798ca79597c2b30153 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_initial_power2.jpg differ diff --git a/en/device-dev/subsystems/figures/animation_low_power.jpg b/en/device-dev/subsystems/figures/animation_low_power.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6402f621caf50209bdeff33164752918d40fb7d9 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_low_power.jpg differ diff --git a/en/device-dev/subsystems/figures/animation_low_power2.jpg b/en/device-dev/subsystems/figures/animation_low_power2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6c6fec553776ca484cb3eced815cf75cb0cbd050 Binary files /dev/null and b/en/device-dev/subsystems/figures/animation_low_power2.jpg differ diff --git a/en/device-dev/subsystems/figures/battery_limit_current_test_report.jpg b/en/device-dev/subsystems/figures/battery_limit_current_test_report.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fa16e626dfa1aef0609d14a6cb073fe87a15a02c Binary files /dev/null and b/en/device-dev/subsystems/figures/battery_limit_current_test_report.jpg differ diff --git a/en/device-dev/subsystems/figures/charger_type1.jpg b/en/device-dev/subsystems/figures/charger_type1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..878f4a682a0f698defee6df66ecce54ca140a04d Binary files /dev/null and b/en/device-dev/subsystems/figures/charger_type1.jpg differ diff --git a/en/device-dev/subsystems/figures/high_power_led.jpg b/en/device-dev/subsystems/figures/high_power_led.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e9dbb9c347d0a0c05d286257a29ffbb940964e9b Binary files /dev/null and b/en/device-dev/subsystems/figures/high_power_led.jpg differ diff --git a/en/device-dev/subsystems/figures/high_power_led_alter.jpg b/en/device-dev/subsystems/figures/high_power_led_alter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6557a55c7dc7c502bd9c37011d9cab7e6005504d Binary files /dev/null and b/en/device-dev/subsystems/figures/high_power_led_alter.jpg differ diff --git a/en/device-dev/subsystems/figures/low_power_led.jpg b/en/device-dev/subsystems/figures/low_power_led.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ce9f005ef08061fb4475ced34983cb9a3df82cb0 Binary files /dev/null and b/en/device-dev/subsystems/figures/low_power_led.jpg differ diff --git a/en/device-dev/subsystems/figures/low_power_led_alter.jpg b/en/device-dev/subsystems/figures/low_power_led_alter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7156f28712106629be96177ef654c4820cb9b189 Binary files /dev/null and b/en/device-dev/subsystems/figures/low_power_led_alter.jpg differ diff --git a/en/device-dev/subsystems/figures/normal_power_led.jpg b/en/device-dev/subsystems/figures/normal_power_led.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dacb5083b679885d1ab786291b081114b883c57b Binary files /dev/null and b/en/device-dev/subsystems/figures/normal_power_led.jpg differ diff --git a/en/device-dev/subsystems/figures/normal_power_led_alter.jpg b/en/device-dev/subsystems/figures/normal_power_led_alter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c0b974a1b70dd4f455de48775a9bf607e835c44c Binary files /dev/null and b/en/device-dev/subsystems/figures/normal_power_led_alter.jpg differ diff --git a/en/device-dev/subsystems/subsys-power-battery-level-customization.md b/en/device-dev/subsystems/subsys-power-battery-level-customization.md new file mode 100644 index 0000000000000000000000000000000000000000..9bf7ec042827f0994f20c4a4212e8a8a041c619c --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-battery-level-customization.md @@ -0,0 +1,309 @@ +# Battery Level Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the battery level based on the current battery power, such as the full battery level, high battery level, low battery level, and extremely low battery level. It can generate an alert or take required service processing based on the current battery level. However, the battery level specifications vary according to products. To address this issue, OpenHarmony provides the function of customizing battery levels. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate battery level customization. + +1. Create the `battery` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of battery level configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── battery_config.json + ``` + +3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of battery level configuration. For example: + + ```json + { + "soc": { + "shutdown": 5, + "critical": 10, + "warning": 15, + "low": 30, + "normal": 60, + "high": 90, + "full": 100 + } + } + ``` + + **Table 1** Battery level configuration + + | Battery Bevel| Battery Volume| Description| + | -------- | -------- | -------- | + | shutdown | 5 | Power-off battery level| + | critical | 10 | Extremely low battery level| + | warning | 15 | Alarm battery level| + | low | 30 | Low battery level| + | normal | 60 | Normal battery level| + | high | 90 | High battery level| + | full | 100 | Full battery level| + + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of battery level configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("battery_config") { + source = "battery_config.json" + relative_install_dir = "battery" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/battery/` is the folder path, `profile` is the folder name, and `battery_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ``` + hdc shell + ``` + +2. Go to the custom battery level configuration directory. The path of DAYU200 is used as an example. + ``` + cd /data/service/el0/battery/battery/ + ``` + +3. Modify the charging status, simulate reporting of the battery power change, and check whether the returned battery level is correct. The following uses the default charging type as an example. + + 1. Modify the battery power. + ``` + echo 100 > capacity + ``` + 2. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 3. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:22:48.589 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 1 + + ······ + ``` + + 4. Modify the battery power. + ``` + echo 90 > capacity + ``` + 5. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 6. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:24:29.716 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 2 + + ······ + ``` + + 7. Modify the battery power. + ``` + echo 60 > capacity + ``` + 8. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 9. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:25:09.837 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 3 + + ······ + ``` + + 10. Modify the battery power. + ``` + echo 30 > capacity + ``` + 11. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 12. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:26:20.495 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 4 + + ······ + ``` + + 13. Modify the battery power. + ``` + echo 15 > capacity + ``` + 14. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 15. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:27:05.312 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 5 + + ······ + ``` + + 16. Modify the battery power. + ``` + echo 10 > capacity + ``` + 17. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 18. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:27:56.270 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 6 + + ······ + ``` + + 19. Modify the battery power. + ``` + echo 5 > capacity + ``` + 20. Report the battery power change to obtain the current battery level. + ``` + hidumper -s 3302 -a -i + ``` + 21. Check whether the battery level is correct. + + ``` + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryService--------------------------------- + Current time: 2017-08-05 17:28:38.066 + + ··· (Only the battery level configuration is displayed here. Other information is omitted.) + + batteryLevel: 7 + + ······ + ``` + +## Reference +During development, you can refer to the [default battery level configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below: + +```json +{ + "soc": { + "shutdown": 1, + "critical": 5, + "warning": 10, + "low": 20, + "normal": 90, + "high": 99, + "full": 100 + } +} +``` + +Packing path: `/system/etc/battery` diff --git a/en/device-dev/subsystems/subsys-power-brightness-customization.md b/en/device-dev/subsystems/subsys-power-brightness-customization.md index 75604d60d5495105a380899d0815c4cc8f2b0098..a0939f4d34d48c3336168793816c3eeadacdaac5 100644 --- a/en/device-dev/subsystems/subsys-power-brightness-customization.md +++ b/en/device-dev/subsystems/subsys-power-brightness-customization.md @@ -30,9 +30,9 @@ Development board running the standard system, for example, the DAYU200 or Hi351 For details about the requirements on the Linux environment, see [Quick Start](../quick-start/Readme-EN.md). -### How to Develop +### Getting Started with Development -1. In the target directory, create a target folder by referring to the [default brightness value configuration folder](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc). The file format is as follows: +1. In the target directory, create a target folder by referring to the [default brightness value configuration folder](https://gitee.com/openharmony/powermgr_display_manager/tree/master/service/etc). The content is as follows: ```text etc diff --git a/en/device-dev/subsystems/subsys-power-charge-current-voltage-limit.md b/en/device-dev/subsystems/subsys-power-charge-current-voltage-limit.md new file mode 100644 index 0000000000000000000000000000000000000000..edca1494648a4030c0c74dc8248bc9093f7cb6f0 --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-charge-current-voltage-limit.md @@ -0,0 +1,121 @@ +# Charging Current and Voltage Limit Customization + +## Overview + +### Introduction + +By default, OpenHarmony supports setting of charging current and voltage limits. When a device is being charged, the battery temperature may become excessively high due to the impact of ambient environment. In such a case, the charging current or voltage needs to be limited to ensure safety use of the device. However, the impact of charging current or voltage on device safety varies according to product specifications. To address this issue, OpenHarmony provides the function of customizing charging current and voltage limits. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate customization of charging current and voltage limits. + +1. Create the `battery` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of charging current and voltage limit configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── battery_config.json + ``` + +3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of charging current and voltage limit configuration. For example: + + ```json + { + "charger": { + "current_limit":{ + "path": "/data/service/el0/battery/current_limit" + }, + "voltage_limit":{ + "path": "/data/service/el0/battery/voltage_limit" + } + } + } + ``` + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of charging current and voltage limit configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("battery_config") { + source = "battery_config.json" + relative_install_dir = "battery" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/battery/` is the folder path, `profile` is the folder name, and `battery_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. Build the battery-specific hats test cases. For details about the build commands and framework setup, see [XTS Subsystem](https://gitee.com/openharmony/xts_hats). + +2. Run the test cases, and check the test report. + + ![battery_limit_current_test_report](figures/battery_limit_current_test_report.jpg) + +## Reference + +During development, you can refer to the [default charging current and voltage configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below: + +```json +{ + "charger": { + "current_limit":{ + "path": "/data/service/el0/battery/current_limit" + }, + "voltage_limit":{ + "path": "/data/service/el0/battery/voltage_limit" + } + } +} +``` + +Packing path: `/system/etc/battery` diff --git a/en/device-dev/subsystems/subsys-power-charge-type-customization.md b/en/device-dev/subsystems/subsys-power-charge-type-customization.md new file mode 100644 index 0000000000000000000000000000000000000000..b865e1d610fa522912c319c2100ffe9eba97fad3 --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-charge-type-customization.md @@ -0,0 +1,154 @@ +# Charging Type Customization + +## Overview + +### Introduction + +By default, OpenHarmony supports multiple charging types. You can charge devices through different types of charging, for example, wired fast charging and wireless fast charging. OpenHarmony can display appropriate animations or take required service processing based on the charging type. However, the supported charging types vary according to products. To address this issue, OpenHarmony provides the charging type customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate charging type customization. + +1. Create the `battery` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of charging type configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── battery_config.json + ``` + +3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of charging type configuration. For example: + + ```shell + { + "charger": { + "type": { + "path": "/data/service/el0/battery/charger_type" + } + } + } + ``` + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of charging type configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("battery_config") { + source = "battery_config.json" + relative_install_dir = "battery" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/battery/` is the folder path, `profile` is the folder name, and `battery_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + + +1. After startup, run the following command to launch the shell command line: + ``` + hdc shell + ``` + +2. Go to the custom battery level configuration directory. The path of DAYU200 is used as an example. + ``` + cd /data/service/el0/battery/ + ``` + +3. Modify the charging status, simulate reporting of the charging status, and check whether the displayed animation is correct. The following uses the default charging type and animation mapping as an example. + 1. Modify the charging type. + ``` + echo 1 > charger_type + ``` + 2. Report the charging status change to trigger mapping between the charging type and animation. + ``` + hidumper -s 3302 -a -r + ``` + 3. Check the output for the charging type. + ``` + hidumper -s 3302 -a -i + ``` + ``` + -------------------------------[ability]---------------------------- + ------------------------------BatteryService------------------------ + capacity: 11 + batteryLevel: 4 + chargingStatus: 1 + healthState: 1 + pluggedType: 2 + voltage: 4123456 + present: 0 + technology: Li-ion + nowCurrent: 1000 + currentAverage: 1000 + totalEnergy: 4000000 + remainingEnergy: 4000000 + remainingChargeTime: 0 + temperature: 222 + chargeType: 1 + ``` + ![charger_type1](figures/charger_type1.jpg) + + +## Reference +During development, you can refer to the [default charging type configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below: + + ```shell + { + "charger": { + "type": { + "path": "/data/service/el0/battery/charger_type" + } + } + } + ``` + +Packing path: `/system/etc/battery` diff --git a/en/device-dev/subsystems/subsys-power-level-LED-color.md b/en/device-dev/subsystems/subsys-power-level-LED-color.md new file mode 100644 index 0000000000000000000000000000000000000000..ea940bed43c65616f61dcd15c0d16f892c7593a6 --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-level-LED-color.md @@ -0,0 +1,229 @@ +# Battery Level and LED Color Mapping Customization + +## Overview + +### Introduction + +OpenHarmony provides the battery level and LED color mapping by default. Some products, tablets for example, may use LED colors to display the battery level during charging. For example, green indicates a high battery level is high, yellow indicates a low battery level, and red indicates an extremely low battery level. The battery level and LED color mapping varies according to products. To address this issue, OpenHarmony provides the function of customizing the battery level and LED color mapping. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate customization of the battery level and LED color mapping. + +1. Create the `battery` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of battery level and LED color mapping configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── battery_config.json + ``` + +3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of battery level and LED color mapping configuration. For example: + + ```json + { + "light": { + "low": { + "soc": [0, 20], + "rgb": [255, 192, 203] + }, + "normal": { + "soc": [20, 95], + "rgb": [255, 0, 255] + }, + "high": { + "soc": [95, 100], + "rgb": [0, 0, 255] + } + } + } + ``` + + **Table 1** Description of the battery level and LED color mapping configuration + + | Item| Description| + | -------- | -------- | + | low | Low battery level| + | normal | Normal battery level| + | high | High battery level| + | soc | Battery level range| + | rgb | LED RGB combination| + + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of battery level and LED color mapping configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("battery_config") { + source = "battery_config.json" + relative_install_dir = "battery" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, //vendor/hihope/rk3568/battery/ is the folder path, profile is the folder name, and battery_config is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ``` + hdc shell + ``` + +2. Go to the custom battery level configuration directory. The path of DAYU200 is used as an example. + ``` + cd /data/service/el0/battery/battery + ``` + +3. Modify the charging status, simulate reporting of the battery power change, and check whether the LED color is correct. The following uses the default battery level and LED color mapping configuration as an example. + + 1. Modify the battery power. + ``` + echo 5 > capacity + ``` + 2. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![low_power_led](figures/low_power_led.jpg) + + 3. Modify the battery power. + ``` + echo 50 > capacity + ``` + 4. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![normal_power_led](figures/normal_power_led.jpg) + + 5. Modify the battery power. + ``` + echo 100 > capacity + ``` + 6. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![high_power_led](figures/high_power_led.jpg) + +4. Customize the battery level and LED color mapping configuration. For example: + ```json + { + "light": { + "low": { + "soc": [0, 20], + "rgb": [255, 192, 203] + }, + "normal": { + "soc": [20, 95], + "rgb": [255, 0, 255] + }, + "high": { + "soc": [95, 100], + "rgb": [0, 0, 255] + } + } + } + ``` + + 1. Modify the battery power. + ``` + echo 15 > capacity + ``` + 2. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![low_power_led_alter](figures/low_power_led_alter.jpg) + + 3. Modify the battery power. + ``` + echo 95 > capacity + ``` + 4. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![normal_power_led_alter](figures/normal_power_led_alter.jpg) + + 5. Modify the battery power. + ``` + echo 99 > capacity + ``` + 6. Report the battery power change to trigger the LED mapping. + ``` + hidumper -s 3302 -a -r + ``` + ![high_power_led_alter](figures/high_power_led_alter.jpg) + +## Reference +During development, you can refer to the [default battery level and LED color mapping configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below: + +```json +{ + "light": { + "low": { + "soc": [0, 10], + "rgb": [255, 0, 0] + }, + "normal": { + "soc": [10, 90], + "rgb": [255, 255, 0] + }, + "high": { + "soc": [90, 100], + "rgb": [0, 255, 0] + } + } +} +``` + +Packing path: `/system/etc/battery` diff --git a/en/device-dev/subsystems/subsys-power-poweroff-charge-animation.md b/en/device-dev/subsystems/subsys-power-poweroff-charge-animation.md new file mode 100644 index 0000000000000000000000000000000000000000..d782f5b121bb1ab4acf0fa00691e72c015f55db1 --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-poweroff-charge-animation.md @@ -0,0 +1,433 @@ +# Power-off Charging Animation Customization + +## Overview + +### Introduction + +By default, the OpenHarmony provides the animation that displays information such as the battery level during power-off charging. However, some vendors may expect to use custom power-off charging animations for their products. To address this requirement, OpenHarmony provides the function of customizing power-off charging animations. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate charging type customization. + +1. Create the `animation` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of power-off charging animation configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/charger/sa_profile), and install it in `//vendor/hihope/rk3568/animation`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── animation.json + ``` + +3. Create the `resources` folder by referring to [default folder of power-off charging animation image resources](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/charger/resources) to store the images that form the animation, and install the folder in `//vendor/hihope/rk3568/animation`. The content is as follows: + + ```text + animation + ├── resources + ├── profile + ``` + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of power-off charging animation configuration, and put it to the `//vendor/hihope/rk3568/animation/resource` directory. The configuration is as follows: + ```shell + import("//build/ohos.gni") + + ohos_prebuilt_etc("resources_config0") { + source = "loop00000.png" # Image resource + relative_install_dir = "poweroff_charger_animation/resources" + install_images = [ chipset_base_dir ] # Required configuration for installing the resources folder in the vendor directory. + part_name = "product_rk3568" + } + +5. Write the custom `animation.json` file by referring to the `animation.json` file in the default folder of power-off charging animation image resources. For example: + + ```json + { + "id": "Charger", + "screenWidth": 720, + "screenHeight": 1280, + "dir": "/vendor/etc/charger/resources", + "bgColor": "#000000ff", + "subpages": [ + { + "id": "Animation", + "coms": [ + "Charging_Animation_Image", + "Charging_Percent_Label" + ], + "bgColor": "#000000ff" + }, + { + "id": "Lackpower_Charging_Prompt", + "coms": [ + "LackPower_Charging_Label" + ], + "bgColor": "#000000ff" + }, + { + "id": "Lackpower_Not_Charging_Prompt", + "coms": [ + "LackPower_Not_Charging_Label" + ], + "bgColor": "#000000ff" + } + ], + "default": { + "Common": { + "visible": false + }, + "UILabel": { + "bgColor": "#00000000", + "fontColor": "#ffffffe6", + "align": "center" + }, + "UIImageView": { + "imgCnt": 1, + "updInterval": 0, + "filePrefix": "" + } + }, + "coms": [ + { + "type": "UIImageView", + "id": "Charging_Animation_Image", + "x": 180, + "y": 410, + "w": 400, + "h": 400, + "resPath": "/vendor/etc/charger/resources/", + "imgCnt": 62, + "updInterval": 60, + "filePrefix": "loop" + }, + { + "type": "UILabel", + "id": "Charging_Percent_Label", + "text": "", + "x": 365, + "y": 580, + "w": 65, + "h": 43, + "fontSize": 32 + }, + { + "type": "UILabel", + "id": "LackPower_Charging_Label", + "text": "Low battery level", + "x": 229, + "y": 1037, + "w": 250, + "h": 45, + "fontSize": 42, + "fontColor": "#ff0000ff" + }, + { + "type": "UILabel", + "id": "LackPower_Not_Charging_Label", + "text": "Low battery level. Please connect the power supply.", + "x": 110, + "y": 1037, + "w": 500, + "h": 45, + "fontSize": 42, + "fontColor": "#ff0000ff" + } + ] + } + ``` + + **Table 1** Description of the power-off charging animation configuration + | Item| Description| + | -------- | -------- | + | id | Unique ID of the charging screen.| + | screenWidth | Width of the charging screen, in pixels.| + | screenHeight | Height of the charging screen, in pixels.| + | dir | Resource path.| + | bgColor | Background color of the charging screen.| + | subpages | Subpage of the charging screen.| + | coms | All components on the charging screen.| + | visible | Whether elements are visible.| + | text | Text content of a component.| + | x | X coordinate of the component.| + | y | Y coordinate of the component.| + | w | Component width, in pixels.| + | h | Component height, in pixels.| + | fontSize | Font size of the component.| + | fontColor | Font color of the text.| + | align | Text alignment mode.| + | imgCnt | Number of images.| + | updInterval | Image updating interval, in ms.| + | filePrefix | Prefix of an image file name.| + | type | Component type.| + | resPath | Resource file path of the component.| + + + +6. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of power-off charging animation configuration to pack the `animation_config.json` file to the `//vendor/etc/charger` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") + + ohos_prebuilt_etc("animation_config") { + source = "animation.json" # Reference build/ohos.gni. + relative_install_dir = "animation/resources" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +7. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config", + "//vendor/hihope/rk3568/animation/profile:animation_config" # Add the configuration for building of animation_config. + "//vendor/hihope/rk3568/animation/resource/resources_config0" # Add the configuration for building of image resources. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/animation/` is the folder path, `profile` is the folder name, and `animation_config` is the build target. + +8. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +9. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. Modify the code configuration. + + Code path: `base/startup/init/services/init/init_config.c` + + Function: `ReadConfig` + ``` + After modification: + void ReadConfig(void) + { + // parse cfg + char buffer[32] = {0}; // 32 reason max leb + uint32_t len = sizeof(buffer); + SystemReadParam("ohos.boot.reboot_reason", buffer, &len); + INIT_LOGV("ohos.boot.reboot_reason %s", buffer); + ParseInitCfg(INIT_CONFIGURATION_FILE, NULL); // New code + ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL); // New code + if (strcmp(buffer, "poweroff_charge") == 0) { + ParseInitCfg(INIT_CONFIGURATION_FILE, NULL); + ReadFileInDir(OTHER_CHARGE_PATH, ".cfg", ParseInitCfg, NULL); + } else if (InUpdaterMode() == 0) { + ParseInitCfg(INIT_CONFIGURATION_FILE, NULL); + ParseInitCfgByPriority(); + } else { + ReadFileInDir("/etc", ".cfg", ParseInitCfg, NULL); + } + } + ``` + +2. Use the hdc tool to run the following commands to force the development board to enter the power-off charging state. + ``` + hdc shell + reboot charger + ``` + + ![animation_initial_power](figures/animation_initial_power.jpg) + +3. Go to the custom battery level configuration directory. The path of DAYU200 is used as an example. + ``` + cd /data/service/el0/battery/battery + ``` + +4. Change the battery power, and observe the number change on the charging animation. + ``` + cat capacity + ``` + Change the current battery power to **3**. + ``` + echo 3 > capacity + ``` + ![animation_charing_power](figures/animation_charing_power.jpg) + +5. Change the charging status when the battery level is extremely low (1% by default). This can trigger the mapping animation or device shutdown. + + 1. Go to the custom battery level configuration directory. + ``` + cd /data/service/el0/battery/battery + ``` + ``` + cat capacity + ``` + 2. Change the current battery power to **1**. + ``` + echo 1 > capacity + ``` + 3. Check the charging status. + ``` + cat status + ``` + The current status is **Charging**. + + ![animation_low_power](figures/animation_low_power.jpg) + + 4. Change to the **Not charging** state. + ``` + echo Not charging > status + ``` + ![animation_low_power2](figures/animation_low_power2.jpg) + + 5. Change to the **Discharging** state. The system enters the power-off state. + ``` + echo Discharging > status + ``` + +6. Test the power-off animation customization function by changing related images. The procedure is the same as that described above. + + 1. Initial state + + ![animation_charging_power2](figures/animation_charging_power2.jpg) + + 2. %3 battery power + + ![animation_initial_power2](figures/animation_initial_power2.jpg) + + 3. 1% battery power, **Charging** state + + ![animation_low_power](figures/animation_low_power.jpg) + + 4. 1% battery power, **Not charging** state + + ![animation_low_power2](figures/animation_low_power2.jpg) + + 5. 1% battery power, **Discharging** state + + The device is powered off. + + + +## Reference +During development, you can refer to the [default power-off animation configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/charger/sa_profile/animation.json), as shown below: + +```json + { + "id": "Charger", + "screenWidth": 720, + "screenHeight": 1280, + "dir": "/vendor/etc/charger/resources", + "bgColor": "#000000ff", + "subpages": [ + { + "id": "Animation", + "coms": [ + "Charging_Animation_Image", + "Charging_Percent_Label" + ], + "bgColor": "#000000ff" + }, + { + "id": "Lackpower_Charging_Prompt", + "coms": [ + "LackPower_Charging_Label" + ], + "bgColor": "#000000ff" + }, + { + "id": "Lackpower_Not_Charging_Prompt", + "coms": [ + "LackPower_Not_Charging_Label" + ], + "bgColor": "#000000ff" + } + ], + "default": { + "Common": { + "visible": false + }, + "UILabel": { + "bgColor": "#00000000", + "fontColor": "#ffffffe6", + "align": "center" + }, + "UIImageView": { + "imgCnt": 1, + "updInterval": 0, + "filePrefix": "" + } + }, + "coms": [ + { + "type": "UIImageView", + "id": "Charging_Animation_Image", + "x": 180, + "y": 410, + "w": 400, + "h": 400, + "resPath": "/vendor/etc/charger/resources/", + "imgCnt": 62, + "updInterval": 60, + "filePrefix": "loop" + }, + { + "type": "UILabel", + "id": "Charging_Percent_Label", + "text": "", + "x": 365, + "y": 580, + "w": 65, + "h": 43, + "fontSize": 32 + }, + { + "type": "UILabel", + "id": "LackPower_Charging_Label", + "text": "Low battery level", + "x": 229, + "y": 1037, + "w": 250, + "h": 45, + "fontSize": 42, + "fontColor": "#ff0000ff" + }, + { + "type": "UILabel", + "id": "LackPower_Not_Charging_Label", + "text": "Low battery level. Please connect the power supply.", + "x": 110, + "y": 1037, + "w": 500, + "h": 45, + "fontSize": 42, + "fontColor": "#ff0000ff" + } + ] + } +``` + +Packing path: `/system/etc/charger/resource` diff --git a/en/device-dev/subsystems/subsys-power-stats-power-average-customization.md b/en/device-dev/subsystems/subsys-power-stats-power-average-customization.md new file mode 100644 index 0000000000000000000000000000000000000000..d7867ed30ad70c2088416d5668441803a4d6ebfb --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-stats-power-average-customization.md @@ -0,0 +1,202 @@ +# Power Consumption Statistics Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the power consumption statistics feature. However, the power consumption benchmarks vary according to hardware specifications of different products. To address this issue, OpenHarmony provides the power consumption statistics customization function, allowing you to customize power consumption benchmarks depending on your hardware specifications. + +### Basic Concepts + +Power consumption statistics: When a user uses a device, software and hardware services running on the device report usage events through [HiSysEvent](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-overview.md). The usage duration of software and hardware can be calculated based on these reported events. Then, the power consumption of the software and hardware can be calculated based on the hardware power consumption benchmarks. + +Power consumption benchmark: baseline power consumption (unit: mA) of the product hardware in various states, for example, the baseline power consumption when the camera is turned on and the baseline power consumption of the CPU at different frequencies. + +### Constraints + +The configuration path for power consumption statistics customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate power consumption statistics customization. + +1. Create the `battery_statistics` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + + +2. Create a target folder by referring to the [default folder of power consumption statistics configuration](https://gitee.com/openharmony/powermgr_battery_statistics/tree/master/services/profile), and install it in `//vendor/hihope/rk3568/battery_statistics`. The content is as follows: + + ```shell + profile + ├── BUILD.gn # BUILD.gn file + └── power_average.json # Configuration file for power consumption statistics, including the hardware power consumption benchmarks + ``` + +3. Write the custom `power_average.json` file by referring to the [power_average.json](https://gitee.com/openharmony/powermgr_battery_statistics/blob/master/services/profile/power_average.json) file in the default folder of power consumption statistics configuration. The following table describes the configuration items for power consumption benchmarks. + + **Table 1** Description of the configuration items for power consumption benchmarks + | Configuration Item| Hardware Type| Data Type| Description| + |----------|------|---------|-------------------------------------------------------------------------| + | alarm_on | - | Double | Power consumption when the timer is triggered by the system or application once; that is, the baseline power consumption.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Number of triggering times x Power consumption benchmark| + | bluetooth_br_on | Bluetooth | Double | Baseline power consumption when Bluetooth is enabled.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | bluetooth_br_scan | Bluetooth | Double | Baseline power consumption for Bluetooth scanning.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | bluetooth_ble_on | Bluetooth | Double | Baseline power consumption when Bluetooth Low Energy (BLE) is enabled.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | bluetooth_ble_scan | Bluetooth | Double | Baseline power consumption for Bluetooth Low Energy (BLE) scanning.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | wifi_on | WIFI | Double | Baseline power consumption when Wi-Fi is enabled.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | wifi_scan | WIFI | Double | Power consumption when Wi-Fi scanning is performed once.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Number of triggering times x Power consumption benchmark| + | radio_on | Phone | Double array| Baseline power consumption when the call service is enabled. The value is in array format and is used to configure the baseline power consumption for different signal strength levels. The default configuration provides the baseline power consumption for four signal strength levels.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | radio_data | Phone | Double array| Baseline power consumption when the network service is enabled. The value is in array format and is used to configure the baseline power consumption for different signal strength levels. The default configuration provides the baseline power consumption for four signal strength levels.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | camera_on | Camera | Double | Baseline power consumption when the camera is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | flashlight_on | Flashlight | Double | Baseline power consumption when the flashlight is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | gnss_on | GNSS | Double | Baseline power consumption when the Global Navigation Satellite System (GNSS) is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | sensor_gravity_on | Gravity Sensor | Double | Baseline power consumption when the gravity sensor is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | sensor_proximity_on | Proximity Sensor | Double | Baseline power consumption when the proximity sensor is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | audio_on | Audio | Double | Baseline power consumption when the audio is enabled.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | screen_on
screen_brightness | Screen | Double | **screen\_on**: baseline power consumption of the screen in the basic state (excluding power consumption generated by screen brightness).
**screen\_brightness**: baseline power consumption additionally required when the screen brightness increases by one level.
For example, if **screen_on** is **90**, **screen_brightness** is **2**, and the screen brightness is **100**, then the baseline power consumption is calculated as follows: 90 + 2 x 100 = 290.
- Power consumption type: hardware power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | cpu_awake | CPU | Double | Baseline power consumption when the CPU wakes up the lock from the lock holding state.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | cpu_idle | CPU | Double | Baseline power consumption when the CPU is in the idle state.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | cpu_suspend | CPU | Double | Baseline power consumption when the CPU is in the sleep state.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | cpu_active | CPU | Double | Baseline power consumption when the CPU is in the active state.
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + | cpu_clusters
cpu_speed_clusterX | CPU | Double array| **cpu\_clusters**: baseline power consumption of a CPU cluster. The value is in array format and is used to configure the baseline power consumption for different CPU clusters. The default configuration provides the baseline power consumption for three CPU clusters.
**cpu\_speed\_clusterX**: baseline power consumption of a CPU cluster at different frequencies, in array format. **X** indicates the sequence number. By default, its value ranges from **0** to **2**, corresponding to the size of the **cpu_clusters** array. For example, if the default size of the **cpu_clusters** array is **3**, the sequence number corresponds to the configuration items **cpu_speed_cluster0**, **cpu_speed_cluster1**, and **cpu_speed_cluster2**.
- Scalability: scalability of CPU clusters
- Power consumption type: software power consumption
- Statistical method: Power consumption = Usage duration x Power consumption benchmark| + + >**NOTE**
The hardware type described in the table is the actual hardware name and does not represent the power consumption statistics type. For details about the power consumption statistics type, see [ConsumptionType](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-batteryStatistics.md#consumptiontype). + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_battery_statistics/blob/master/services/profile/BUILD.gn) file in the default folder of power consumption statistics configuration to pack the `power_average.json` file to the `//vendor/etc/profile` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + # Install power_average.json to /vendor/etc/profile/power_average.json + ohos_prebuilt_etc("power_average_config") { # Custom name, for example, power_average_config. + source = "power_average.json" + relative_install_dir = "profile" + install_images = [ chipset_base_dir ] # Required configuration for installing the power_average_config file in the vendor directory, where chipset_base_dir = "vendor". If this field is left unspecified, the power_average_config file is installed in the system directory by default. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/battery_statistics/profile:power_average_config", # Add the configuration for building of power_average_config. + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf" + ] + } + }, + "subsystem": "product_hihope" + } + ``` + + In the preceding code, `//vendor/hihope/rk3568/power/battery_statistics/` is the folder path, `profile` is the folder name, and `power_average_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + + ```shell + hdc shell + ``` + +2. Run the following command to check whether the `power\_average\_config` file is successfully created in the `vendor` directory: + + ```shell + ls -l /vendor/etc/profile/ + ``` + + The `power\_average\_config` file is successfully created if it exists in `/vendor/etc/profile/`. + + ```shell + # ls -l /vendor/etc/profile/ + total 4 + -rw-r--r-- 1 root root 1446 2023-03-26 16:47 power_average.json + # + ``` + +3. If the `power_average_config` file is successfully created, run the following command to check whether the information in the `power_average_config` file in the `vendor` directory is consistent with the customized information: + + ```shell + cat /vendor/etc/profile/power_average.json + ``` + +4. If the information is consistent, run the following command to view the power consumption statistics: + + ```shell + hidumper -s 3304 -a -poweraverage + ``` + +5. Check the console output for the custom power consumption benchmark information. + + For example, the default power consumption benchmark information is as follows: + + ```shell + # hidumper -s 3304 -a -poweraverage + + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryStatisticsService--------------------------------- + POWER AVERAGE CONFIGATION DUMP: + + ··· (Only the camera configuration is displayed here. Other information is omitted.) + + camera_on : 810.000000 + + ······ + ``` + + If the power consumption statistics benchmark is set to **camera_on:3000** (default value: **810**), the console output is as follows: + + ```shell + # hidumper -s 3304 -a -poweraverage + + -------------------------------[ability]------------------------------- + + + ----------------------------------BatteryStatisticsService--------------------------------- + POWER AVERAGE CONFIGATION DUMP: + + ··· (Only the camera configuration is displayed here. Other information is omitted.) + + camera_on : 3000.000000 # Set the power consumption benchmark to "camera_on": 3000. + + ······ + ``` + +6. Check whether the power consumption statistics are calculated according to the custom power consumption benchmark in the `power_average_config` file. + +7. You can use the [JS APIs](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.batteryStatistics.d.ts) or [Inner APIs](https://gitee.com/openharmony/powermgr_battery_statistics/blob/master/interfaces/inner_api/include/battery_stats_client.h) provided by the **batterystatistics** module to obtain detailed power consumption information and verify the custom power consumption benchmark. + +## Reference + +During development, you can refer to the [default power consumption statistics configuration](https://gitee.com/openharmony/powermgr_battery_statistics/blob/master/services/profile/power_average.json). + +Default packing path: `/system/etc/profile` + +Customization path: `/vendor/etc/profile` diff --git a/en/device-dev/subsystems/subsys-power-temperature-protection.md b/en/device-dev/subsystems/subsys-power-temperature-protection.md new file mode 100644 index 0000000000000000000000000000000000000000..0dc460adc331f02dfe8ba3a51bda162bae96362e --- /dev/null +++ b/en/device-dev/subsystems/subsys-power-temperature-protection.md @@ -0,0 +1,175 @@ +# Battery Temperature Protection Customization + +## Overview + +### Introduction + +OpenHarmony provides battery temperature protection by default. When a device is used in different environments, the battery temperature may become excessively high or low due to the impact of ambient environment. In such a case, the protection measures, for example, device shutdown, must be taken to ensure the device safety. However, the supported temperature range varies according to products. To address this issue, OpenHarmony provides the function of customizing the temperature range for battery protection. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate charging type customization. + +1. Create the battery folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of power temperature projection configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/battery`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── battery_config.json + ``` + +3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of power temperature projection configuration. For example: + + ```json + { + "temperature": { + "high": 500, + "low": -400 + } + } + ``` + + **Table 1** Description of temperature protection configuration + | Temperature Protection Threshold| Temperature (°C)| + | -------- | -------- | + | high | 600 | + | low | -500 | + + +4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of power temperature projection configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("battery_config") { + source = "battery_config.json" + relative_install_dir = "battery" + install_images = [ chipset_base_dir ] # Required configuration for installing the battery_config.json file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/battery/profile:battery_config" # Add the configuration for building of battery_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/battery/` is the folder path, `profile` is the folder name, and `battery_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ``` + hdc shell + ``` + +2. Go to the custom battery temperature configuration directory. The path of DAYU200 is used as an example. + ``` + cd /data/service/el0/battery/battery + ``` + +3. Modify the battery temperature. The following uses the default power temperature protection configuration as an example. + + ``` + echo 700 > temp + ``` +4. Report the battery information change to trigger temperature protection. + ``` + hidumper -s 3302 -a -r + ``` + The device is powered off. + +5. Upon restarting, launch the shell command line, and modify the battery temperature. + ``` + echo -600 > temp + ``` +6. Report the battery information change to trigger temperature protection. + ``` + hidumper -s 3302 -a -r + ``` + The device is powered off. + +7. Customize the temperature protection threshold configuration. For example: + + ```json + { + "temperature": { + "high": 500, + "low": -400 + } + } + ``` + +8. Modify the temperature protection threshold. + ``` + echo 550 > temp + ``` + +9. Report the battery information change to trigger temperature protection. + ``` + hidumper -s 3302 -a -r + ``` + The device is powered off. + +10. Upon restarting, launch the shell command line, and modify the temperature protection threshold. + ``` + echo -450 > temp + ``` + +11. Report the battery information change to trigger temperature protection. + ``` + hidumper -s 3302 -a -r + ``` + The device is powered off. + +## Reference +During development, you can refer to the [default power temperature protection configuration](https://gitee.com/openharmony/powermgr_battery_manager/tree/master/services/native/profile/), as shown below: + +```json +{ + "temperature": { + "high": 600, + "low": -500 + } +} +``` +Packing path: `/system/etc/battery` diff --git a/en/device-dev/subsystems/subsys-security-huks-guide.md b/en/device-dev/subsystems/subsys-security-huks-guide.md index dcd6d6e0a01d1b5a3321ed3ce14893dc2382dc97..3f315b54ce4e2b57b03b89c1a4b9828ba2b0932a 100644 --- a/en/device-dev/subsystems/subsys-security-huks-guide.md +++ b/en/device-dev/subsystems/subsys-security-huks-guide.md @@ -24,7 +24,7 @@ HUKS supports key lifecycle management, which covers the following: - HUKS Core - A functional module that provides the key management service. This module must run in a secure environment, and the keys in plaintext must be kept inside the HUKS Core module throughout their lifecycle. + A functional module that provides the key management service. This module must run in a secure environment, and the keys in plaintext must be kept inside the HUKS Core module throughout the lifecycle. - TEE @@ -32,15 +32,15 @@ HUKS supports key lifecycle management, which covers the following: - Init-Update-Finish - **Init**: initializes data for a key operation. + **Init**: initializes data for a key operation. - **Update**: operates data by segment and returns the result, or appends data. + **Update**: operates data by segment and returns the result, or appends data. **Finish**: finalizes the **Update** operation, and returns the result. ### Working Principles -The following uses the key generation process as an example to describe communication between the HUKS Service and HUKS Core. Other key operations are similar. +The following uses the key generation process as an example to describe the communication between the HUKS Service and HUKS Core. Other key operations are similar. The upper-layer application invokes the HUKS Service through the key management SDK. The HUKS Service invokes the HUKS Core, which invokes the key management module to generate a key. The HUKS Core uses a work key derived from the root key to encrypt the generated key and sends the encrypted key to the HUKS Service. The HUKS Service stores the encrypted key in a file. ![](figures/HUKS-GenerateKey1.png) @@ -84,55 +84,57 @@ The HUKS Core provides KeyStore (KS) capabilities for applications, including ke | [HuksHdiGetKeyProperties()](#hukshdigetkeyproperties) | Obtains key properties. |– | getKeyProperties(keyAlias: string, options: HuksOptions)| | [HuksHdiAttestKey()](#hukshdiattestkey) | Obtains the key certificate. |The output parameter must be in the **certChain** format. | attestKey(keyAlias: string, options: HuksOptions)| | [HuksHdiExportChipsetPlatformPublicKey()](#hukshdiexportchipsetplatformpublickey) | Exports the public key of a chipset key pair. | The output parameters are the raw data of ECC P-256 x-axis and y-axis values, each of which are of 32 bytes. | –| +| [HuksHdiUpgradeKey()](#hukshdiupgradekey) | Updates the key file. | – | –| - - - #### HuksHdiModuleInit -**API description** +**API Description** Initializes the HUKS Core, including the lock, encryption algorithm library, authtoken key, and root key. **Prototype**
int32_t HuksHdiModuleInit();
+
- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. -
- - + - Other value: The operation failed. + +- - - #### HuksHdiRefresh -**API description** +**API Description** Refreshes the root key. **Prototype**
int32_t HuksHdiRefresh();
+
- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. -
- - + - Other value: The operation failed. + +- - - #### HuksHdiGenerateKey -**API description** +**API Description** Generates a key based on **paramSet**. **Prototype**
int32_t HuksHdiGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, const struct HksBlob *keyIn, struct HksBlob *keyOut);
+
Parameters
@@ -165,24 +167,24 @@ Generates a key based on **paramSet**.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. -
- - + - Other value: The operation failed. +
+- - - #### HuksHdiImportKey -**API description** +**API Description** Imports a key in plaintext. **Prototype**
int32_t HuksHdiImportKey(const struct HksBlob *keyAlias, const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *keyOut);
+
Parameters
@@ -219,23 +221,24 @@ Imports a key in plaintext.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiImportWrappedKey -**API description** +**API Description** Imports an encrypted key. **Prototype**
int32_t HuksHdiImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingUsedkey, const struct HksBlob *wrappedKeyData, const struct HksParamSet *paramSet, struct HksBlob *keyOut);
+
Parameters
@@ -277,23 +280,24 @@ Imports an encrypted key.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiExportPublicKey -**API description** +**API Description** Exports a public key. **Prototype**
int32_t HuksHdiExportPublicKey(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *keyOut);
+
Parameters
@@ -313,23 +317,24 @@ Exports a public key.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiInit -**API description** +**API Description** Initializes data for a key operation. This API is of the Init-Update-Final model. **Prototype**
int32_t HuksHdiInit(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *handle, struct HksBlob *token);
+
Parameters
@@ -352,23 +357,24 @@ Initializes data for a key operation. This API is of the Init-Update-Final model
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiUpdate -**API description** +**API Description** Operates data by segment or appends data for the key operation. This API is of the Init-Update-Final model. **Prototype**
int32_t HuksHdiUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, struct HksBlob *outData);
+
Parameters
@@ -396,23 +402,24 @@ Operates data by segment or appends data for the key operation. This API is of t
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiFinish -**API description** +**API Description** Finalizes the key operation. This API is of the Init-Update-Final model. **Prototype**
int32_t HuksHdiFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData, struct HksBlob *outData);
+
Parameters
@@ -440,23 +447,24 @@ Finalizes the key operation. This API is of the Init-Update-Final model.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiAbort -**API description** +**API Description** Aborts Init-Update-Finish. When an error occurs in any of the **Init**, **Update**, and **Finish** operations, call this API to terminate the use of the key. **Prototype**
int32_t HuksHdiAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet);
+
Parameters
@@ -470,23 +478,24 @@ Aborts Init-Update-Finish. When an error occurs in any of the **Init**, **Update
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiGetKeyProperties -**API description** +**API Description** Obtains key properties. **Prototype**
int32_t HuksHdiGetKeyProperties(const struct HksParamSet *paramSet, const struct HksBlob *key);
+
Parameters
@@ -500,23 +509,24 @@ Obtains key properties.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiAttestKey -**API description** +**API Description** Obtains the key certificate. **Prototype**
int32_t (*HuksHdiAttestKey)(const struct HksBlob *key, const struct HksParamSet *paramSet, struct HksBlob *certChain);
+
Parameters
@@ -541,23 +551,24 @@ Obtains the key certificate.
 

- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - #### HuksHdiExportChipsetPlatformPublicKey -**API description** +**API Description** Exports the public key of a chipset key pair. **Prototype**
int32_t (*HuksHdiExportChipsetPlatformPublicKey)(const struct HksBlob *salt, enum HksChipsetPlatformDecryptScene scene, struct HksBlob *publicKey);
+
Parameters
@@ -577,18 +588,51 @@ Exports the public key of a chipset key pair.
   Constraints
 
   1. The input parameter **salt** must be of 16 bytes, and the content of the last byte will be ignored and filled by HUKS based on **scene**.
+  Currently, the chipset key pairs of HUKS are implemented by software. An ECC P-256 key pair is hard-coded, and the **salt** value is ignored. That is, the derived keys are the same regardless of the **salt**. In the hardware-based implementation of chipset key pairs, **salt** is a factor used to derive the key. That is, the key pair derived varies with the **salt** value.
 
-    Currently, the chipset key pairs of HUKS are implemented by software. An ECC P-256 key pair is hard-coded, and the **salt** value is ignored. That is, the derived keys are the same regardless of the **salt**. In the hardware-based implementation of chipset key pairs, **salt** is a factor used to derive the key. That is, the key pair derived varies with the **salt** value.
+
+

+ +
+ Return Value + + - **HKS_SUCCESS**: The operation is successful. + + - Other value: The operation failed. +
+ +- - - + +#### HuksHdiUpgradeKey +**API Description** + +Updates the key file when the key file version is earlier than the latest version. + +**Prototype** +
int32_t (*HuksHdiUpgradeKey)(const struct HksBlob *oldKey, const struct HksParamSet *paramSet, struct HksBlob *newKey);
+ +
+ Parameters +
+  const struct HksBlob *oldKey
+  Key file data to update.
+  

+ const struct HksParamSet *paramSet + Parameters for updating the key file data. +

+ struct HksBlob *newKey + New key file data. +


- Return value + Return Value - **HKS_SUCCESS**: The operation is successful. - - Other value: The operation fails. + - Other value: The operation failed.
- - - @@ -599,15 +643,15 @@ The directory structure is as follows: ```undefined // base/security/user_auth/services/huks_standard/huks_engine/main -├── BUILD.gn # Build script +├── BUILD.gn # Build script ├── core_dependency # Dependencies of the implementation -└── core # Software implementation of the HUKS Core - ├── BUILD.gn # Build script +└── core # Software implementation of the HUKS Core + ├── BUILD.gn # Build script ├── include └── src ├── hks_core_interfaces.c # Adaptation of the HDI to the HUKS Core - └── hks_core_service.c # Specific implementation - └── ... # Other function code + └── hks_core_service.c # Specific implementation + └── ... # Other function code ``` Init-Update-Finish must be used to implement HUKS Core APIs. The following provides the development procedure of Init-Update-Finish and sample code of the HUKS Core. You can refer to the following code to implement all HDI APIs. diff --git a/en/device-dev/subsystems/subsys-thermal_charging_idle_state.md b/en/device-dev/subsystems/subsys-thermal_charging_idle_state.md new file mode 100644 index 0000000000000000000000000000000000000000..a90cce407a05f26b2a1349561a5cdcf2f87411d0 --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_charging_idle_state.md @@ -0,0 +1,128 @@ +# Charging Idle State Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the charging idle state feature. It determines whether a device is currently in the idle state according to a thermal level, battery level, charging state, and charging current of the device. A device in this state may execute some background intensive tasks. However, the conditions that determine the charging idle state vary according to product specifications. To address this issue, OpenHarmony provides the charging idle state customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate charging idle state customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default folder of battery idle state configuration](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_service_config.xml + ``` + +3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default folder of charging idle state configuration. The following table describes the related configuration items. + + **Table 1** Configuration items for the charging idle state + + | Configuration Item| Description| Data Type| Value Range| + | -------- | -------- | -------- | -------- | + | thermallevel | Thermal level threshold| int | This field is defined based on the thermal level of a device. If the thermal level of a device is less than or equal to the threshold, the device is in the charging idle state.| + | soc | Battery level threshold| int | The value of this field ranges from 0 to 100. If the battery level of the device is greater than or equal to the specified threshold, the device is in the charging idle state.| + | charging | Charging status| int | The value **1** indicates that the battery is being charged, and the value **0** indicates the opposite.| + | current | Battery charging current threshold| int | When the battery charging current is greater than or equal to the specified threshold (in mA), the battery is in the charging idle state.| + + ```shell + + 1 + 90 + 1 + 1000 + + ``` + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of charging idle state configuration to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("thermal_service_config") { + source = "thermal_service_config.xml" + relative_install_dir = "thermal_config" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Obtain the current charging idle state. + ```shell + hidumper -s 3303 -a -i + ``` + + The following is the reference charging idle state after customization: + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + thermallevel: 1 + soc: 100 + charging: 1 + current: 1000 + ``` + +## Reference +During development, you can refer to the [default charging idle state configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_control.md b/en/device-dev/subsystems/subsys-thermal_control.md new file mode 100644 index 0000000000000000000000000000000000000000..a97216aae23fdecff45affb2b3ed9331c8f6d3b2 --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_control.md @@ -0,0 +1,155 @@ +# Thermal Control Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the thermal control feature. If a device becomes overheated during usage, thermal control measures need to be taken for the device. For example, if the battery temperature is too high during charging, then thermal control needs to be applied to the charging device. However, thermal control varies according to product specifications. To address this issue, OpenHarmony provides the thermal control customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal control customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal control configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_service_config.xml + ``` + +3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal control configuration folder. The following table describes the related configuration items. + + **Table 1** Configuration items for thermal control + + | Configuration Item| Configuration Item Description| Parameter| Parameter Description| Data Type|Value Range| + | -------- | -------- | -------- | -------- | -------- | -------- | + | name="cpu_big" | Big-core CPU control (big-core CPU frequency)| N/A| N/A| N/A| N/A| + | name="cpu_med" | Medium-core CPU control (medium-core CPU frequency)| N/A| N/A| N/A| N/A| + | name="cpu_lit" | Small-core CPU control (small-core CPU frequency)| N/A| N/A| N/A| N/A| + | name="gpu" | GPU control (GPU frequency)| N/A| N/A| N/A| N/A| + | name="lcd" | LCD control (screen brightness)| N/A| N/A| N/A| N/A| + | name="volume" | Sound control (volume)| uid | User ID| int | Product-specific| + | name="current" | Charging current control (charging current during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck| + | name="current" | Charging current control | event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="voltage" | Charging voltage control (charging voltage during fast charging and slow charging)| protocol | Supported charging protocols: fast charging (supercharge) and slow charging (buck)| string | sc or buck| + | name="voltage" | Charging voltage control | event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="process_ctrl" | Process control (survival status of foreground and background processes)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="shut_down" | Shutdown control (device shutdown)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="thermallevel" | Thermal level control (thermal level reporting)| event | - **1**: event sending enabled
-**0**: event sending disabled| int | 0 or 1| + | name="popup" | Pop-up window control (pop-up window display)| N/A| N/A| N/A| N/A| + + ```shell + + + + + + + + + + + + + + + ``` + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal control configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("thermal_service_config") { + source = "thermal_service_config.xml" + relative_install_dir = "thermal_config" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Obtain the current thermal control information. + ```shell + hidumper -s 3303 -a -a + ``` + + The following is the reference thermal control result after customization: + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + name: cpu_big strict: 0 enableEvent: 0 + name: cpu_med strict: 0 enableEvent: 0 + name: cpu_lit strict: 0 enableEvent: 0 + name: gpu strict: 0 enableEvent: 0 + name: boost strict: 0 enableEvent: 0 + name: lcd strict: 0 enableEvent: 0 + name: volume uid: 2001,2002 strict: 0 enableEvent: 0 + name: current protocol: sc,buck strict: 0 enableEvent: 1 + name: voltage protocol: sc,buck strict: 0 enableEvent: 1 + name: process_ctrl params: 32,64,128,256 strict: 0 enableEvent: 0 + name: shut_down strict: 0 enableEvent: 0 + name: thermallevel strict: 0 enableEvent: 0 + name: popup strict: 0 enableEvent: 0 + ``` + +## Reference +During development, you can refer to the [default thermal control configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_detection.md b/en/device-dev/subsystems/subsys-thermal_detection.md new file mode 100644 index 0000000000000000000000000000000000000000..023153f2214f6ae79544480b84228cb11ac71d65 --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_detection.md @@ -0,0 +1,149 @@ +# Thermal Detection Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the thermal detection feature. A component, for example, the CPU or battery, generates heat while it is running. In this case, the component reports its temperature in real time through the corresponding temperature sensor. The thermal detection feature detects the temperature of components in real time and provides temperature input for the thermal management module. However, thermal detection on components varies according to product specifications. To address this issue, OpenHarmony provides the thermal detection customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal detection customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal detection configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_hdi_config.xml + ``` + +3. Write the custom `thermal_hdi_config.xml` file by referring to the [thermal_hdi_config.xml](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml) file in the default thermal detection configuration folder. The following table describes the related configuration items. + + **Table 1** Configuration items for thermal detection + + |Node| Configuration Item| Description| Value Type| + | -------- | -------- | -------- | -------- | + | item | tag | Temperature flag name of an actual or simulated node.| string | + | item | value | Temperature flag value. Value **1** means to obtain the temperature of a simulated node, and the value **0**, means to obtain the temperature of an actual node.| int | + | group | name | Name of the actual or simulated node group.| string | + | group | interval | Polling interval, in ms (default).| int | + | thermal_zone | type | Thermal zone name.| string | + | thermal_zone | path | Path for obtaining the thermal zone temperature of an actual node.| string | + | thermal_node | type | Thermal node name.| string | + | thermal_node | path | Path for obtaining the thermal node temperature of a simulated node.| string | + + ```shell + + + + + + + + + + + + + + + + + + + + + ``` + For details about the path for obtaining the actual node temperature, see the path for obtaining the thermal zone temperature in [Thermal Log](../subsystems/subsys-thermal_log.md). For details about the path for obtaining the simulated node temperature, see [Default Thermal Detection Configuration](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml). + +5. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal detection configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") + + ohos_prebuilt_etc("thermal_hdf_config") { + source = "thermal_hdi_config.xml" + relative_install_dir = "thermal_config/hdf" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +6. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_hdf_config", // Add the configuration for building of thermal_hdf_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +7. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +8. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Obtain the thermal detection result of the thermal zone. + ```shell + hidumper -s 3303 -a -t + ``` + + The following is the reference thermal detection result of the thermal zone. The value of **Temperature** is in unit of 0.001°C by default. + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + ········· (Only the thermal detection result is displayed here. Other information is omitted.) + Type: gpu-thermal + Temperature: 35555 + Type: soc-thermal + Temperature: 35000 + ······ + ``` + +## Reference +During development, you can refer to the [default thermal detection configuration](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_level.md b/en/device-dev/subsystems/subsys-thermal_level.md new file mode 100644 index 0000000000000000000000000000000000000000..b7afd9404d6e24417fd6d0f957d0c8ab18ce64fc --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_level.md @@ -0,0 +1,162 @@ +# Thermal Level Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the thermal level feature. Different hardware devices generate different amounts of heat and can tolerate different maximum temperatures. Therefore, for different components, the thermal level standard needs to be defined based on their temperatures to clearly indicate the thermal status and provide input for thermal control. However, the thermal level of components at different temperatures varies according to product specifications. To address this issue, OpenHarmony provides the thermal level customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal level customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal level configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_service_config.xml + ``` + +3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal level configuration folder. The following tables describe the related configuration items. + + **Table 1** Description of the base configuration + | Configuration Item| Description| Parameter| Parameter Description| Type| Value Range| + | -------- | -------- | -------- | -------- | -------- | -------- | + | tag="history_temp_count" | Name of the tag indicating the number of historical temperature reporting times.| value | Number of historical temperature reporting times.| int | >0 | + | tag="temperature_query_enum" | Tag name of the device list for obtaining the temperature.| value | Device list for obtaining the temperature.| enum | soc, battery, shell, cpu, charger, ambient, ap, and pa| + + + **Table 2** Description of the sensor_cluster configuration + + | Configuration Item | Description | Data Type | Value Range | + | -------- | -------- | -------- | -------- | + | name | Sensor cluster name | string | None | + | sensor | Sensors in the cluster | string | soc, battery, shell, cpu, charger, ambient, ap, and pa | + | aux_sensor | Auxiliary sensors in the cluster | string | soc, battery, shell, cpu, charger, ambient, ap, and pa | + + **Table 3** Description of the item configuration + + | Configuration Item | Description | Data Type | Value Range | + | -------- | -------- | -------- | -------- | + | level | Thermal level defined for each sensor cluster | int | >0 | + | threshold | Temperature threshold for each sensor in the cluster to reach the corresponding thermal level. The value is in unit of 0.001°C by default and can be changed as needed. | int | Product-specific | + | threshold_clr | Temperature threshold for each sensor in the cluster to roll back to the previous thermal level. | int | Product-specific | + | temp_rise_rate | Temperature rise frequency. | double | Product-specific | + + ```shell + + + + + + + + + + + + + + + ``` + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal level configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("thermal_service_config") { + source = "thermal_service_config.xml" + relative_install_dir = "thermal_config" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Go to the `data/service/el0/thermal/sensor/soc/` directory. + ```shell + cd data/service/el0/thermal/sensor/soc + ``` + +3. Change the SOC temperature. + ```shell + echo 42000 > temp + ``` + +4. Obtain the current thermal level information. + ```shell + hidumper -s 3303 -a -l + ``` + + The following is the reference thermal level information after customization: + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + name: base_safe level: 2 + name: cold_safe level: 0 + name: high_safe level: 0 + name: warm_5G level: 0 + name: warm_safe level: 1 + ``` + +## Reference +During development, you can refer to the [default thermal level configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_log.md b/en/device-dev/subsystems/subsys-thermal_log.md new file mode 100644 index 0000000000000000000000000000000000000000..2e889e833a99a13a492ce58c2c2cc04ab0643423 --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_log.md @@ -0,0 +1,200 @@ +# Thermal Log Customization + +## Overview + +### Introduction + +By default, the OpenHarmony provides the thermal log feature. Thermal logs record the temperature of device components during usage. However, the content and path of thermal logs vary according to product specifications. To address this issue, OpenHarmony provides the thermal log customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_hdi_config.xml + ``` + +3. Create a target folder by referring to the [default thermal log parameter configuration folder] (https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/etc) and install it in `//vendor/hihope/rk3568/thermal`. The file format is as follows: + ```text + etc + ├── BUILD.gn + ├── thermal.para + ├── thermal.para.dac + ``` + +4. Write the custom `thermal_hdi_config.xml` file by referring to the [thermal_hdi_config.xml](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/thermal_hdi_config.xml) file in the default thermal log configuration folder. The following tables describe the related configuration items. + + **Table 1** Description of the tracing configuration + + | Configuration Item| Description| Data Type| Value Range| + | -------- | -------- | -------- | -------- | + | interval | Interval for recording temperature tracing logs, in ms.| int | >0 | + | width | Width of the temperature tracing log, in characters.| int | >0 | + | outpath | Path for storing temperature tracing logs.| string | N/A| + + **Table 2** Description of the node configuration + + | Node| Configuration Item| Description| + | -------- | -------- | -------- | + | title | path | Path for obtaining the thermal zone name.| + | title | name | Thermal zone name.| + | value | path | Path for obtaining the thermal zone temperature.| + + ```shell + + + + <value path="sys/class/thermal/thermal_zone0/temp"/> + </node> + <node> + <title name="gpu-thermal"/> + <value path="sys/class/thermal/thermal_zone1/temp"/> + </node> + </tracing> + ``` + +5. Write the custom `thermal.para` and `thermal.para.dac` files by referring to the [thermal.para](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/thermal.para) and [thermal.para.dac](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/thermal.para.dac) files in the default hot log parameter configuration folder. The custom configuration is as follows: + + thermal.para: + ```text + persist.thermal.log.enable=true # Enable the thermal log function. + persist.thermal.log.interval=5000 # Set the interval for recording temperature tracing logs, in ms. + persist.thermal.log.width=20 # Set the width of the temperature tracing log, in characters. + ``` + + thermal.para.dac: + ```text + persist.thermal.log.="power_host:power_host:600" # Configure access permissions. + ``` + +6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") + + ohos_prebuilt_etc("thermal_hdf_config") { + source = "thermal_hdi_config.xml" + relative_install_dir = "thermal_config/hdf" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +7. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/etc/BUILD.gn) file in the default thermal log parameter configuration folder to pack the `thermal.para` and `thermal.para.dac` files to the `//vendor/etc/param/thermal.para` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") + + ## Install thermal.para to /vendor/etc/param/thermal.para + + ohos_prebuilt_etc("thermal.para") { + source = "thermal.para" + relative_install_dir = "param" + install_images = [ chipset_base_dir ] + part_name = "product_rk3568" + } + + ohos_prebuilt_etc("thermal.para.dac") { + source = "thermal.para.dac" + relative_install_dir = "param" + install_images = [ chipset_base_dir ] + part_name = "product_rk3568" + } + + group("param_files") { + deps = [ + ":thermal.para", + ":thermal.para.dac", + ] + } + ``` + +8. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_hdf_config", // Add the configuration for building of thermal_hdf_config. + "//vendor/hihope/rk3568/thermal/etc:param_files" // Add the configuration for building of thermal.para and thermal.para.dac. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` and `etc` are folder names, and `thermal_hdf_config` and `param_files` are the build targets. + +9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +10. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Go to the customized directory. + ```shell + cd /data/log/thermal/ + ``` + + View thermal logs. + ```shell + cat thermal.000.20170805-175756 + ``` + + The following is the reference thermal log after customization: + ```shell + timestamp soc-thermal gpu-thermal + 2017-08-05 17:57:56 37777 37222 + 2017-08-05 17:58:01 38333 37777 + 2017-08-05 17:58:06 36666 37222 + 2017-08-05 17:58:11 36666 37222 + 2017-08-05 17:58:16 36666 37222 + 2017-08-05 17:58:21 36111 37222 + 2017-08-05 17:58:26 36111 37222 + 2017-08-05 17:58:31 36666 37222 + 2017-08-05 17:58:36 36111 37222 + 2017-08-05 17:58:41 36111 37222 + 2017-08-05 17:58:46 36666 36666 + ``` + +## Reference +During development, you can refer to the [default thermal log configuration](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile/) and [default thermal log parameter configuration](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/etc). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_policy.md b/en/device-dev/subsystems/subsys-thermal_policy.md new file mode 100644 index 0000000000000000000000000000000000000000..a93ccd57335a9fab1af4abfc7843063973fcf3ca --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_policy.md @@ -0,0 +1,229 @@ +# Thermal Policy Customization + +## Overview + +### Introduction + +By default, the OpenHarmony provides the thermal policy feature. Various components on a device can generate heat. Therefore, for different components, the thermal policy needs to be defined based on their thermal levels and thermal scenes. However, thermal control at different thermal levels varies according to product specifications. To address this issue, OpenHarmony provides the thermal policy customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal policy customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal policy configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_service_config.xml + ``` + +3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal policy configuration folder. The following tables describe the related configuration items. + + **Table 1** Description of the config configuration + + | Configuration Item| Description| Type| Value Range| + | -------- | -------- | -------- | -------- | + | name | Name of the sensor cluster corresponding to the thermal policy.| string | Corresponding to the sensor cluster name defined in [Thermal Level](../subsystems/subsys-thermal_level.md).| + | level | Thermal level corresponding to the thermal policy.| int | Corresponding to the thermal level defined for the sensor cluster in [Thermal Level](../subsystems/subsys-thermal_level.md).| + + **Table 2** Description of configuration items + + | Configuration Item| Description| Type| Value Range| + | -------- | -------- | -------- | -------- | + | scene | Application scenario.| string | Corresponding to the application scenario defined in [Thermal Scene](../subsystems/subsys-thermal_scene.md).| + | charge | Charging status.| int | The value **1** indicates charging, and the value **0** indicates the opposite.| + | screen | Screen status.| int | The value **1** indicates that the screen is on, and the value **0** indicates the opposite.| + + **Table 3** Description of the node configuration + + | Node| Value Type| Value Range| Description| + | -------- | -------- | -------- | -------- | + | lcd | double | 0.00~1.00 | Percentage of the screen brightness (represented by a floating point number).| + | cpu_big | int | Product-specific| CPU big core frequency.| + | cpu_med | int | Product-specific| CPU medium-core frequency.| + | cpu_lit | int | Product-specific| CPU small-core frequency.| + | process_ctrl | enum | 1: KILL_FG_PROCESS_APP<br>2: KILL_BG_PROCESS_APP<br>3: KILL_ALL_PROCESS_APP| Process control.| + | gpu | int | Product-specific| GPU frequency.| + | thermallevel | int | Corresponding to **level** defined in the **config** node| Thermal level.| + | current_sc | int | Product-specific| Fast charging current.| + | current_buck | int | Product-specific| Slow charging current.| + | voltage_sc | int | Product-specific| Fast charging voltage.| + | voltage_buck | int | Product-specific| Slow charging voltage.| + | volume | double | 0.00~1.00 | Volume percentage (represented by a floating point number).| + + ```shell + <policy> + <config name="base_safe" level="1"> + <lcd>1.00</lcd> + <lcd scene="cam">0.99</lcd> + <lcd scene="call">0.98</lcd> + <lcd scene="game">0.95</lcd> + <cpu_big>1992000</cpu_big> + <cpu_med>1991500</cpu_med> + <cpu_lit>1991200</cpu_lit> + <process_ctrl>3</process_ctrl> + <cpu_big scene="cam" charge="1">1991800</cpu_big> + <cpu_big scene="cam" charge="0">1991600</cpu_big> + <gpu screen="0">524288</gpu> + <gpu screen="1">512000</gpu> + <thermallevel>1</thermallevel> + <current_sc>1800</current_sc> + <current_sc scene="cam">1200</current_sc> + <current_buck>1200</current_buck> + <voltage_sc>4000</voltage_sc> + <voltage_buck>3000</voltage_buck> + <volume>1.0</volume> + </config> + <policy> + <config name="base_safe" level="2"> + <lcd>0.90</lcd> + <lcd scene="cam">0.89</lcd> + <lcd scene="call">0.88</lcd> + <lcd scene="game">0.87</lcd> + <cpu_big>1991000</cpu_big> + <cpu_med>1990500</cpu_med> + <cpu_lit>1990200</cpu_lit> + <process_ctrl>2</process_ctrl> + <cpu_big scene="cam" charge="1">1990800</cpu_big> + <cpu_big scene="cam" charge="0">1990600</cpu_big> + <gpu screen="0">499712</gpu> + <gpu screen="1">487424</gpu> + <thermallevel>2</thermallevel> + <current_sc>1500</current_sc> + <current_sc scene="cam">1000</current_sc> + <current_buck>1000</current_buck> + <voltage_sc>3000</voltage_sc> + <voltage_buck>2000</voltage_buck> + <volume>0.8</volume> + </config> + </policy> + ``` + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal policy configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("thermal_service_config") { + source = "thermal_service_config.xml" + relative_install_dir = "thermal_config" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Obtain the current thermal policy information. + ```shell + hidumper -s 3303 -a -p + ``` + + The following is the reference thermal policy result after customization: + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + name: base_safe level: 1 + actionName: lcd actionValue: 1.00 isProp: 0 + actionName: lcd actionValue: 0.99 scene: cam isProp: 1 + actionName: lcd actionValue: 0.98 scene: call isProp: 1 + actionName: lcd actionValue: 0.95 scene: game isProp: 1 + actionName: cpu_big actionValue: 1992000 isProp: 0 + actionName: cpu_med actionValue: 1991500 isProp: 0 + actionName: cpu_lit actionValue: 1991200 isProp: 0 + actionName: process_ctrl actionValue: 3 isProp: 0 + actionName: cpu_big actionValue: 1991800 charge: 1 scene: cam isProp: 1 + actionName: cpu_big actionValue: 1991600 charge: 0 scene: cam isProp: 1 + actionName: gpu actionValue: 524288 screen: 0 isProp: 1 + actionName: gpu actionValue: 512000 screen: 1 isProp: 1 + actionName: thermallevel actionValue: 1 isProp: 0 + actionName: current_sc actionValue: 1800 isProp: 0 + actionName: current_sc actionValue: 1200 scene: cam isProp: 1 + actionName: current_buck actionValue: 1200 isProp: 0 + actionName: voltage_sc actionValue: 4000 isProp: 0 + actionName: voltage_buck actionValue: 3000 isProp: 0 + actionName: volume actionValue: 1.0 isProp: 0 + actionName: boost actionValue: 1 isProp: 0 + + level: 2 + actionName: lcd actionValue: 0.90 isProp: 0 + actionName: lcd actionValue: 0.89 scene: cam isProp: 1 + actionName: lcd actionValue: 0.88 scene: call isProp: 1 + actionName: lcd actionValue: 0.87 scene: game isProp: 1 + actionName: cpu_big actionValue: 1991000 isProp: 0 + actionName: cpu_med actionValue: 1990500 isProp: 0 + actionName: cpu_lit actionValue: 1990200 isProp: 0 + actionName: process_ctrl actionValue: 2 isProp: 0 + actionName: cpu_big actionValue: 1990800 charge: 1 scene: cam isProp: 1 + actionName: cpu_big actionValue: 1990600 charge: 0 scene: cam isProp: 1 + actionName: gpu actionValue: 499712 screen: 0 isProp: 1 + actionName: gpu actionValue: 487424 screen: 1 isProp: 1 + actionName: thermallevel actionValue: 2 isProp: 0 + actionName: current_sc actionValue: 1500 isProp: 0 + actionName: current_sc actionValue: 1000 scene: cam isProp: 1 + actionName: current_buck actionValue: 1000 isProp: 0 + actionName: voltage_sc actionValue: 3000 isProp: 0 + actionName: voltage_buck actionValue: 2000 isProp: 0 + actionName: volume actionValue: 0.8 isProp: 0 + actionName: boost actionValue: 1 isProp: 0 + ``` + +## Reference +During development, you can refer to the [default thermal policy configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/subsystems/subsys-thermal_scene.md b/en/device-dev/subsystems/subsys-thermal_scene.md new file mode 100644 index 0000000000000000000000000000000000000000..4db0af2defc5600c56e1af750553a3e50a770530 --- /dev/null +++ b/en/device-dev/subsystems/subsys-thermal_scene.md @@ -0,0 +1,125 @@ +# Thermal Scene Customization + +## Overview + +### Introduction + +By default, OpenHarmony provides the thermal scene feature. During device usage, for example, gaming, photographing, or calling, the system will try to balance the performance, temperature, and power consumption. The thermal policy is usually scenario-specific. For example, the thermal policy in the gaming scenario does not decrease the screen brightness. However, the thermal scene definition varies according to product specifications. To address this issue, OpenHarmony provides the thermal scene customization function. + +### Constraints + +The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy. + +## How to Develop + +### Setting Up the Environment + +**Hardware requirements:** + +Development board running the standard system, for example, the DAYU200 or Hi3516D V300 open source suite. + +**Environment requirements:** + +For details about the requirements on the Linux environment, see [Quick Start](../quick-start/quickstart-overview.md). + +### Getting Started with Development + +The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal scene customization. + +1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). + +2. Create a target folder by referring to the [default thermal scene configuration folder](https://gitee.com/openharmony/powermgr_thermal_manager/tree/master/services/native/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: + + ```text + profile + ├── BUILD.gn + ├── thermal_service_config.xml + ``` + +3. Write the custom `thermal_service_config.xml` file by referring to the [thermal_service_config.xml](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml) file in the default thermal scene configuration folder. The following table describes the related configuration items. + + **Table 1** Configuration items for the thermal scene + + | Configuration Item| Configuration Item Description| Parameter| Parameter Description| Parameter Type| Value Range| + | -------- | -------- | -------- | -------- | -------- | -------- | + | name="scene" | One or more application scenarios specified by enum values.| param | Application scenarios: photographing, calling, and gaming.| enum | cam, call, and game| + + **screen** and **charge** indicate the status of the application scenario; and specifically, whether the screen is turned on and whether the battery is being charged. + + ```shell + <state> + <item name="scene" param="cam,call,game"/> + <item name="screen"/> + <item name="charge"/> + </state> + ``` + +4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/BUILD.gn) file in the default thermal scene configuration folder to pack the `thermal_service_config.xml` file to the `/vendor/etc/thermal_config` directory. The configuration is as follows: + + ```shell + import("//build/ohos.gni") # Reference build/ohos.gni. + + ohos_prebuilt_etc("thermal_service_config") { + source = "thermal_service_config.xml" + relative_install_dir = "thermal_config" + install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory. + part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. + } + ``` + +5. Add the build target to `module_list` in [ohos.build](https://gitee.com/openharmony/vendor_hihope/blob/master/rk3568/ohos.build) in the `/vendor/hihope/rk3568` directory. For example: + + ```json + { + "parts": { + "product_rk3568": { + "module_list": [ + "//vendor/hihope/rk3568/default_app_config:default_app_config", + "//vendor/hihope/rk3568/image_conf:custom_image_conf", + "//vendor/hihope/rk3568/preinstall-config:preinstall-config", + "//vendor/hihope/rk3568/resourceschedule:resourceschedule", + "//vendor/hihope/rk3568/etc:product_etc_conf", + "//vendor/hihope/rk3568/thermal/profile:thermal_service_config", // Add the configuration for building of thermal_service_config. + ] + } + }, + "subsystem": "product_hihope" + } + ``` + In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` is the folder name, and `thermal_hdf_config` is the build target. + +6. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). + + ```shell + ./build.sh --product-name rk3568 --ccache + ``` + +7. Burn the customized version to the DAYU200 development board. + +### Debugging and Verification + +1. After startup, run the following command to launch the shell command line: + ```shell + hdc shell + ``` + +2. Obtain the current thermal scene information. + ```shell + hidumper -s 3303 -a -s + ``` + + The following is the reference thermal scene result after customization: + ```shell + -------------------------------[ability]------------------------------- + + + ----------------------------------ThermalService--------------------------------- + name: scene params: cam,call,game + name: screen + name: charge + ``` + +## Reference +During development, you can refer to the [default thermal scene configuration](https://gitee.com/openharmony/powermgr_thermal_manager/blob/master/services/native/profile/thermal_service_config.xml). + +Packing path: `/vendor/etc/thermal_config/hdf` diff --git a/en/device-dev/website.md b/en/device-dev/website.md index a78fa5d61b45ec22f5cc6ce5aa5dc164e346144f..ab50b73700c613e03a320fd03ae94cf61de4bada 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -391,7 +391,9 @@ - [Audio/Video Playback Development](subsystems/subsys-multimedia-video-play-guide.md) - [Audio/Video Recording Development](subsystems/subsys-multimedia-video-record-guide.md) - [Utils Development](subsystems/subsys-utils-guide.md) - - [AI Framework Development](subsystems/subsys-ai-aiframework-devguide.md) + - AI + - [AI Framework Development](subsystems/subsys-ai-aiframework-devguide.md) + - [NNRt Development](subsystems/subsys-ai-nnrt-guide.md) - Data Management - RDB - [RDB Overview](subsystems/subsys-data-relational-database-overview.md) @@ -454,7 +456,24 @@ - [HiChecker Development](subsystems/subsys-dfx-hichecker.md) - [FaultLogger Development](subsystems/subsys-dfx-faultlogger.md) - [Hiview Development](subsystems/subsys-dfx-hiview.md) - + - Power + - Power Consumption Statistics + - [Power Consumption Statistics Customization](subsystems/subsys-power-stats-power-average-customization.md) + - Battery Management + - [Battery Level and LED Color Mapping Customization](subsystems/subsys-power-level-LED-color.md) + - [Battery Temperature Protection Customization](subsystems/subsys-power-temperature-protection.md) + - [Battery Level Customization](subsystems/subsys-power-battery-level-customization.md) + - [Charging Current and Voltage Limit Customization](subsystems/subsys-power-charge-current-voltage-limit.md) + - [Charging Type Customization](subsystems/subsys-power-charge-type-customization.md) + - [Power-off Charging Animation Customization](subsystems/subsys-power-poweroff-charge-animation.md) + - Thermal Management + - [Charging Idle State Customization](subsystems/subsys-thermal_charging_idle_state.md) + - [Thermal Control Customization](subsystems/subsys-thermal_control.md) + - [Thermal Detection Customization](subsystems/subsys-thermal_detection.md) + - [Thermal Level Customization](subsystems/subsys-thermal_level.md) + - [Thermal Log Customization](subsystems/subsys-thermal_log.md) + - [Thermal Policy Customization](subsystems/subsys-thermal_policy.md) + - [Thermal Scene Customization](subsystems/subsys-thermal_scene.md) - Featured Topics - HPM Part - [HPM Part Overview](hpm-part/hpm-part-about.md) diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.2.1/changelogs-usb.md b/en/release-notes/changelogs/OpenHarmony_4.0.2.1/changelogs-usb.md index 9a5e30e4a4c8d24266d966f9ac6dc249748cfa60..4802e2b0ab8c74e9fabe42238cf13e95a8657599 100644 --- a/en/release-notes/changelogs/OpenHarmony_4.0.2.1/changelogs-usb.md +++ b/en/release-notes/changelogs/OpenHarmony_4.0.2.1/changelogs-usb.md @@ -1,4 +1,4 @@ -USB Manager ChangeLog +# USB Subsystem API Changelog ## cl.usb_manager.1 System API Change @@ -13,6 +13,16 @@ If your application is developed based on earlier versions, modify the return va | ohos.usbV9.d.ts | function setCurrentFunctions(funcs: FunctionType): Promise<boolean>; | function setCurrentFunctions(funcs: FunctionType): Promise<void>; | | ohos.usbV9.d.ts | function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<boolean>; | function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<void>; | +## cl.usb_manager.2 SDK API Deletion + +The **@ohos.usbV9.d.ts** file was deleted in OpenHarmony 4.0.5.5. + +You need to import **@ohos.usbManager** to use USB service APIs. + + ```ts + import usbManager from '@ohos.usbManager'; + ``` + **Adaptation Guide** -For details, see the [reference](../../../application-dev/reference/errorcodes/errorcode-universal.md) for each API. +For details about usage of each API, see the [API Reference](../../../application-dev/reference/apis/js-apis-usbManager.md). diff --git a/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelogs-usb.md b/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelogs-usb.md new file mode 100644 index 0000000000000000000000000000000000000000..b8218c69f1ccde8d6f8e283f410e1dee64bb4364 --- /dev/null +++ b/en/release-notes/changelogs/OpenHarmony_4.0.6.1/changelogs-usb.md @@ -0,0 +1,23 @@ +# USB Subsystem API Changelog + +## cl.usb_manager.1 SDK API Deletion + +For applications developed based on earlier versions, you need to change the name of the imported bundle. Otherwise, the original service logic will be affected. + +**Key API/Component Changes** + +The **@ohos.usbV9.d.ts** file is replaced by the **@ohos.usbManager.d.ts** file. + +| New Bundle | Original Bundle | Deleted Bundle | +| -------------------- | ------------- | --------------- | +| ohos.usbManager.d.ts | ohos.usb.d.ts | ohos.usbV9.d.ts | + +You need to import **@ohos.usbManager** to use USB service APIs. + + ```ts + import usbManager from '@ohos.usbManager'; + ``` + +**Adaptation Guide** + +For details about usage of each API, see the [API Reference](../../../application-dev/reference/apis/js-apis-usbManager.md). diff --git a/zh-cn/application-dev/ability-deprecated/fa-dataability.md b/zh-cn/application-dev/ability-deprecated/fa-dataability.md index 9ea4cb09d15cfe4005041de376f8a38924beb6f9..c52f0f9ffe951fa30c3588841180aa685f3c9956 100644 --- a/zh-cn/application-dev/ability-deprecated/fa-dataability.md +++ b/zh-cn/application-dev/ability-deprecated/fa-dataability.md @@ -116,7 +116,7 @@ URI示例: | "name" | Ability名称,对应Ability派生的Data类名。 | | "type" | Ability类型,Data对应的Ability类型为”data“。 | | "uri" | 通信使用的URI。 | - | "exported" | 对其他应用是否可见,设置为true时,Data才能与其他应用进行通信传输数据。 | + | "visible" | 对其他应用是否可见,设置为true时,Data才能与其他应用进行通信传输数据。 | **config.json配置样例** @@ -128,7 +128,7 @@ URI示例: "srcLanguage": "ets", "description": "$string:description_dataability", "type": "data", - "exported": true, + "visible": true, "uri": "dataability://ohos.samples.etsdataability.DataAbility" }] ``` diff --git a/zh-cn/application-dev/ability-deprecated/fa-pageability.md b/zh-cn/application-dev/ability-deprecated/fa-pageability.md index e50a45e59324dc5d9f6a0200913ec378e6e7ce2c..11738e71b001b079bc55f1ddfe623fb08a9aeb27 100644 --- a/zh-cn/application-dev/ability-deprecated/fa-pageability.md +++ b/zh-cn/application-dev/ability-deprecated/fa-pageability.md @@ -47,7 +47,7 @@ ability支持单实例和多实例两种启动模式。 | 启动模式 | 描述 |说明 | | ----------- | ------- |---------------- | -| multiton | 多实例 | 每次startAbility都会启动一个新的实例。 | +| standard | 多实例 | 每次startAbility都会启动一个新的实例。 | | singleton | 单实例 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例。 | 缺省情况下是singleton模式。 diff --git a/zh-cn/application-dev/ability-deprecated/fa-serviceability.md b/zh-cn/application-dev/ability-deprecated/fa-serviceability.md index 9185da2d29effc51ef21df7185056a16d1fdaf1b..9c77755ddb73bf095bd172d4607601bfe6ae9161 100644 --- a/zh-cn/application-dev/ability-deprecated/fa-serviceability.md +++ b/zh-cn/application-dev/ability-deprecated/fa-serviceability.md @@ -59,7 +59,7 @@ onCommand()与onConnect()的区别在于: { "name": ".ServiceAbility", "type": "service", - "exported": true + "visible": true ... } ] diff --git a/zh-cn/application-dev/ability-deprecated/stage-ability.md b/zh-cn/application-dev/ability-deprecated/stage-ability.md index 35111d3cb2fbff644c534253e4a9a7c715975fd0..bd50e24180a9d3e2e8bd2a81d025617e40196dd5 100644 --- a/zh-cn/application-dev/ability-deprecated/stage-ability.md +++ b/zh-cn/application-dev/ability-deprecated/stage-ability.md @@ -12,8 +12,8 @@ Ability支持单实例、多实例和指定实例3种启动模式,在module.js | 启动模式 | 描述 |说明 | | ----------- | ------- |---------------- | -| multiton | 标准模式 | 每次startAbility都会启动一个新的实例。 | -| singleton | 单实例模式 | 系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例。 | +| multiton | 多实例模式 | 每次startAbility都会启动一个新的实例。 | +| singleton | 单实例模式 | 也是默认情况下的启动模式。系统中只存在唯一一个实例,startAbility时,如果已存在,则复用系统中的唯一一个实例。 | | specified | 指定实例 | 运行时由Ability内部业务决定是否创建多实例。 | 缺省情况下是singleton模式,module.json5示例如下: diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index 8340df1b0b9a61a684958a4c375d0c505ac3feea..be256c3ab7af5323710445dfa8d98cd36b0bbfe8 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -33,7 +33,7 @@ - [安全](security/userauth-overview.md) - [网络与连接](connectivity/ipc-rpc-overview.md) - [电话服务](telephony/telephony-overview.md) -- [数据管理](database/database-mdds-overview.md) +- [数据管理](database/data-mgmt-overview.md) - [文件管理](file-management/file-management-overview.md) - [任务管理](task-management/background-task-overview.md) - [设备管理](device/usb-overview.md) diff --git a/zh-cn/application-dev/application-models/Readme-CN.md b/zh-cn/application-dev/application-models/Readme-CN.md index 1e72b5673a150e73184db163ddc5ad79005ec8f6..12ad483618be5512ca2c3f1c75cedd5602f07866 100644 --- a/zh-cn/application-dev/application-models/Readme-CN.md +++ b/zh-cn/application-dev/application-models/Readme-CN.md @@ -1,8 +1,8 @@ # 应用模型 - 应用模型概述 - - [OpenHarmony应用模型的构成要素](application-model-composition.md) - - [OpenHarmony应用模型解读](application-model-description.md) + - [应用模型的构成要素](application-model-composition.md) + - [应用模型解读](application-model-description.md) - Stage模型开发指导 - [Stage模型开发概述](stage-model-development-overview.md) - Stage模型应用组件 diff --git a/zh-cn/application-dev/application-models/application-context-stage.md b/zh-cn/application-dev/application-models/application-context-stage.md index b734131b18246d0ec6ce82399cca6957dd91dd45..3605144f6b1268fc26a724dded5afb70e564d2f9 100644 --- a/zh-cn/application-dev/application-models/application-context-stage.md +++ b/zh-cn/application-dev/application-models/application-context-stage.md @@ -84,7 +84,7 @@ | 属性名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| bundleCodeDir | string | 是 | 否 | 安装文件路径。应用在内部存储上的安装路径。 | +| bundleCodeDir | string | 是 | 否 | 安装文件路径。应用在内部存储上的安装路径。不能拼接路径访问资源文件,请使用[资源管理接口](../reference/apis/js-apis-resource-manager.md)访问资源。 | | cacheDir | string | 是 | 否 | 应用缓存文件路径。应用在内部存储上的缓存路径。<br/>对应于“设置 > 应用管理”,找到对应应用的“存储”中的缓存内容。 | | filesDir | string | 是 | 否 | 应用通用文件路径。应用在内部存储上的文件路径。<br/>本目录下存放的文件可能会被应用迁移或者备份的时候同步到其他目录中。 | | preferencesDir | string | 是 | 是 | 应用首选项文件路径。指示应用程序首选项目录。 | @@ -247,7 +247,7 @@ export default class EntryAbility extends UIAbility { 在应用内的DFX统计场景中,如需要统计对应页面停留时间和访问频率等信息,可以使用订阅进程内UIAbility生命周期变化功能。 -通过[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext)提供的能力,可以订阅进程内UIAbility生命周期变化。当进程内的UIAbility生命周期变化时,如创建、可见/不可见、获焦/失焦、销毁等,会触发相应的回调函数。每次注册回调函数时,都会返回一个监听生命周期的ID,此ID会自增+1。当超过监听上限数量2^63-1时,会返回-1。以[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md)中的使用为例进行说明。 +通过[ApplicationContext](../reference/apis/js-apis-inner-application-applicationContext.md)提供的能力,可以订阅进程内UIAbility生命周期变化。当进程内的UIAbility生命周期变化时,如创建、可见/不可见、获焦/失焦、销毁等,会触发相应的回调函数。每次注册回调函数时,都会返回一个监听生命周期的ID,此ID会自增+1。当超过监听上限数量2^63-1时,会返回-1。以[UIAbilityContext](../reference/apis/js-apis-inner-application-uiAbilityContext.md)中的使用为例进行说明。 ```ts diff --git a/zh-cn/application-dev/application-models/component-startup-rules-fa.md b/zh-cn/application-dev/application-models/component-startup-rules-fa.md index 15dcd2e6b42acf2d33ae877b3364d72a0cb42607..e5d4cb541b39af727c7721b9469cae606d9f56b2 100644 --- a/zh-cn/application-dev/application-models/component-startup-rules-fa.md +++ b/zh-cn/application-dev/application-models/component-startup-rules-fa.md @@ -24,8 +24,8 @@ - **跨应用启动组件,需校验目标组件Visible** - 只针对跨应用场景 - - 若目标组件exported字段配置为false,则需校验`ohos.permission.START_INVISIBLE_ABILITY`权限 - - [组件exported配置参考](../quick-start/module-configuration-file.md#abilities标签) + - 若目标组件visible字段配置为false,则需校验`ohos.permission.START_INVISIBLE_ABILITY`权限 + - [组件visible配置参考](../quick-start/module-configuration-file.md#abilities标签) - **位于后台的应用,启动组件需校验BACKGROUND权限** - 应用前后台判断标准:若应用进程获焦或所属的UIAbility位于前台则判定为前台应用,否则为后台应用 diff --git a/zh-cn/application-dev/application-models/create-pageability.md b/zh-cn/application-dev/application-models/create-pageability.md index 2e33384edda2ade9d40b92f62bde369163f0021e..c653379c1c938e6fd595f3acd4f66b5061be577b 100644 --- a/zh-cn/application-dev/application-models/create-pageability.md +++ b/zh-cn/application-dev/application-models/create-pageability.md @@ -47,7 +47,7 @@ PageAbility创建成功后,其abilities相关的配置项在config.json中体 } ], "orientation": "unspecified", - "exported": true, + "visible": true, "srcPath": "EntryAbility", "name": ".EntryAbility", "srcLanguage": "ets", diff --git a/zh-cn/application-dev/application-models/create-serviceability.md b/zh-cn/application-dev/application-models/create-serviceability.md index f1152b65ebac9cb005f6ae6710b2e1fb3e7cc843..2fb1b03cc53a166951c620ff31986a9fd5652a95 100644 --- a/zh-cn/application-dev/application-models/create-serviceability.md +++ b/zh-cn/application-dev/application-models/create-serviceability.md @@ -40,7 +40,7 @@ 2. 注册ServiceAbility。 - ServiceAbility需要在应用配置文件config.json中进行注册,注册类型type需要设置为service。"exported"属性表示ServiceAbility是否可以被其他应用调用,true表示可以被其他应用调用,false表示不能被其他应用调用(仅应用内可以调用)。若ServiceAbility需要被其他应用调用,注册ServiceAbility时需要设置"exported"为true,同时需要设置支持关联启动。ServiceAbility的启动规则详见[组件启动规则](component-startup-rules.md)章节。 + ServiceAbility需要在应用配置文件config.json中进行注册,注册类型type需要设置为service。"visible"属性表示ServiceAbility是否可以被其他应用调用,true表示可以被其他应用调用,false表示不能被其他应用调用(仅应用内可以调用)。若ServiceAbility需要被其他应用调用,注册ServiceAbility时需要设置"visible"为true,同时需要设置支持关联启动。ServiceAbility的启动规则详见[组件启动规则](component-startup-rules.md)章节。 ```json { @@ -53,7 +53,7 @@ "icon": "$media:icon", "description": "hap sample empty service", "type": "service", - "exported": true + "visible": true } ] } diff --git a/zh-cn/application-dev/application-models/dataability-configuration.md b/zh-cn/application-dev/application-models/dataability-configuration.md index 5708ec04e53c3d7101f13b419a4bb9250866d2f2..88b57ca8f5b8b9f999adcdfc5b4eabe795eaa7f8 100644 --- a/zh-cn/application-dev/application-models/dataability-configuration.md +++ b/zh-cn/application-dev/application-models/dataability-configuration.md @@ -38,7 +38,7 @@ URI示例: | "name" | Ability名称。 | | "type" | UIAbility类型,DataAbility的类型为"data"。 | | "uri" | 通信使用的URI。 | -| "exported" | 对其他应用是否可见,设置为true时,DataAbility才能与其他应用进行通信传输数据。 | +| "visible" | 对其他应用是否可见,设置为true时,DataAbility才能与其他应用进行通信传输数据。 | config.json配置样例 @@ -51,7 +51,7 @@ config.json配置样例 "srcLanguage": "ets", "description": "$string:description_dataability", "type": "data", - "exported": true, + "visible": true, "uri": "dataability://ohos.samples.etsdataability.DataAbility" }] ``` diff --git a/zh-cn/application-dev/application-models/dataability-permission-control.md b/zh-cn/application-dev/application-models/dataability-permission-control.md index 9d1a460a01cbb83f15084b161ecd4a4239bc8f6f..6e377d16fc71ba83cc394c42b11c97583497f0cc 100644 --- a/zh-cn/application-dev/application-models/dataability-permission-control.md +++ b/zh-cn/application-dev/application-models/dataability-permission-control.md @@ -17,7 +17,7 @@ DataAbility作为服务端,在被拉起的时候,会根据config.json里面 "srcLanguage": "ets", "description": "$string:description_dataability", "type": "data", - "exported": true, + "visible": true, "uri": "dataability://ohos.samples.etsdataability.DataAbility", "readPermission":"ohos.permission.READ_CONTACTS", "writePermission":"ohos.permission.WRITE_CONTACTS" diff --git a/zh-cn/application-dev/application-models/datashareextensionability.md b/zh-cn/application-dev/application-models/datashareextensionability.md index d051ef1705c2d346c8e3c4082f8ede0aa55ffaec..9b20dbce43e538872b6a6f117f87fce6a8391e20 100644 --- a/zh-cn/application-dev/application-models/datashareextensionability.md +++ b/zh-cn/application-dev/application-models/datashareextensionability.md @@ -1,4 +1,4 @@ # DataShareExtensionAbility(仅对系统应用开放) -DataShareExtensionAbility提供了数据分享的能力,系统应用可以实现一个DataShareExtensionAbility,也可以访问系统中已有的DataShareExtensionAbility,针对三方应用仅开放访问系统中已有DataShareExtensionAbility的能力,详细介绍请参见[数据共享开发指导](../database/database-datashare-guidelines.md)。 +DataShareExtensionAbility提供了数据分享的能力,系统应用可以实现一个DataShareExtensionAbility,也可以访问系统中已有的DataShareExtensionAbility,针对三方应用仅开放访问系统中已有DataShareExtensionAbility的能力,详细介绍请参见[同设备跨应用数据共享](../database/share-device-data-across-apps-overview.md)。 diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type1.gif b/zh-cn/application-dev/application-models/figures/uiability-launch-type1.gif new file mode 100644 index 0000000000000000000000000000000000000000..941f5de94532129d78965bb8a83b786a6ce7bcd0 Binary files /dev/null and b/zh-cn/application-dev/application-models/figures/uiability-launch-type1.gif differ diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type1.png b/zh-cn/application-dev/application-models/figures/uiability-launch-type1.png deleted file mode 100644 index f282915d8c5be11fdc8ce07fb0f42b0d8c562a8c..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/application-models/figures/uiability-launch-type1.png and /dev/null differ diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type2.gif b/zh-cn/application-dev/application-models/figures/uiability-launch-type2.gif new file mode 100644 index 0000000000000000000000000000000000000000..89a2f8b3ea5d486f74e9536442141b1822f61082 Binary files /dev/null and b/zh-cn/application-dev/application-models/figures/uiability-launch-type2.gif differ diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type2.png b/zh-cn/application-dev/application-models/figures/uiability-launch-type2.png deleted file mode 100644 index f392471c0361cbf04e531b12403b7b00d773bef5..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/application-models/figures/uiability-launch-type2.png and /dev/null differ diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type3.gif b/zh-cn/application-dev/application-models/figures/uiability-launch-type3.gif new file mode 100644 index 0000000000000000000000000000000000000000..4e9de02d3fb35798b3214f79c6458b3cbbcb4cb1 Binary files /dev/null and b/zh-cn/application-dev/application-models/figures/uiability-launch-type3.gif differ diff --git a/zh-cn/application-dev/application-models/figures/uiability-launch-type3.png b/zh-cn/application-dev/application-models/figures/uiability-launch-type3.png deleted file mode 100644 index 43cd96e6e4cbcc2a291e08d109d4f8958f47a1e6..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/application-models/figures/uiability-launch-type3.png and /dev/null differ diff --git a/zh-cn/application-dev/application-models/lifecycleapp-switch.md b/zh-cn/application-dev/application-models/lifecycleapp-switch.md index c49ad78ea70e4e01048065885987b87720dc9b74..d1d37d01d3f44ed1c86ccb53a461ac20bfafed32 100644 --- a/zh-cn/application-dev/application-models/lifecycleapp-switch.md +++ b/zh-cn/application-dev/application-models/lifecycleapp-switch.md @@ -1,17 +1,17 @@ # LifecycleApp接口切换 - | FA模型接口 | Stage模型接口对应d.ts文件 | Stage模型对应接口 | +| FA模型接口 | Stage模型接口对应d.ts文件 | Stage模型对应接口 | | -------- | -------- | -------- | | onShow?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br/>监听[FOREGROUND](../reference/apis/js-apis-window.md#windowstageeventtype9)切到前台状态 | | onHide?(): void; | \@ohos.window.d.ts | [on(eventType: 'windowStageEvent', callback: Callback<WindowStageEventType>): void;](../reference/apis/js-apis-window.md#onwindowstageevent9)<br/>监听[BACKGROUND](../reference/apis/js-apis-window.md#windowstageeventtype9)切到后台状态 | -| onDestroy?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onDestroy(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityondestroy) | +| onDestroy?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onDestroy(): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityondestroy) | | onCreate?(): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate) | | onWindowDisplayModeChanged?(isShownInMultiWindow: boolean, newConfig: resourceManager.Configuration): void; | Stage模型无对应接口 | 暂时未提供对应接口 | | onStartContinuation?(): boolean; | Stage模型无对应接口 | Stage模型上,应用无需感知迁移是否成功(由应用发起迁移请求时感知),onStartContinuation废弃 | | onSaveData?(data: Object): boolean; | \@ohos.app.ability.UIAbility.d.ts | [onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncontinue) | | onCompleteContinuation?(result: number): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) | -| onRestoreData?(data: Object): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br/>[onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)<br/>标准实例模式Ability迁移目标端在onCreate回调中完成数据恢复,单实例应用迁移目标端在onCreate回调中完成数据恢复,回调中通过判断launchParam.launchReason可获取迁移启动的场景,从而可以从Want中获取迁移前保存的数据 | +| onRestoreData?(data: Object): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br/>[onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)<br/>多实例模式Ability迁移目标端在onCreate回调中完成数据恢复,单实例模式应用迁移目标端在onCreate回调中完成数据恢复,回调中通过判断launchParam.launchReason可获取迁移启动的场景,从而可以从Want中获取迁移前保存的数据 | | onRemoteTerminated?(): void; | application\ContinueCallback.d.ts | [onContinueDone(result: number): void;](../reference/apis/js-apis-distributedMissionManager.md#continuecallback) | | onSaveAbilityState?(outState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonsavestate) | | onRestoreAbilityState?(inState: PacMap): void; | \@ohos.app.ability.UIAbility.d.ts | [onCreate(want: Want, param: AbilityConstant.LaunchParam): void;](../reference/apis/js-apis-app-ability-uiAbility.md#abilityoncreate)<br/>应用重启后会触发Ability的onCreate方法,通过判断launchParam.launchReason可获取自恢复的场景,从而可以从Want中获取重启前保存的数据 | diff --git a/zh-cn/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md b/zh-cn/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md index 8698bbfff4bdf2202a1198c8c4182445537ca642..e0ff7f945c0bd09e8b12997b14d69acfa9e26cd7 100644 --- a/zh-cn/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md +++ b/zh-cn/application-dev/application-models/mission-set-icon-name-for-task-snapshot.md @@ -7,7 +7,7 @@ 图1 UIAbility对应的任务快照 ![](figures/mission-list-recent.png) -也可以使用[UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon)和[UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel)方法,根据需要自定义任务快照的图标和名称。例如,对于UIAbility的标准实例启动模式,可以根据不同的功能配置相应的任务快照的图标和名称。 +也可以使用[UIAbilityContext.setMissionIcon()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionicon)和[UIAbilityContext.setMissionLabel()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextsetmissionlabel)方法,根据需要自定义任务快照的图标和名称。例如,对于UIAbility的多实例启动模式,可以根据不同的功能配置相应的任务快照的图标和名称。 本文将从以下两个方面介绍。 diff --git a/zh-cn/application-dev/application-models/pageability-launch-type.md b/zh-cn/application-dev/application-models/pageability-launch-type.md index 8e666167314e1c1af2274ff7b54ba0549968809d..38b0c82c58ac39afbf598476069e545e536197a1 100644 --- a/zh-cn/application-dev/application-models/pageability-launch-type.md +++ b/zh-cn/application-dev/application-models/pageability-launch-type.md @@ -1,7 +1,7 @@ # PageAbility的启动模式 -启动模式对应PageAbility被启动时的行为,支持单实例模式、标准模式两种启动模式。 +启动模式对应PageAbility被启动时的行为,支持单实例模式、多实例模式两种启动模式。 **表1** PageAbility的启动模式 @@ -9,7 +9,7 @@ | 启动模式 | 描述 | 说明 | | -------- | -------- | -------- | | singleton | 单实例模式 | 每次调用startAbility方法时,如果应用进程中该类型的Ability实例已经存在,则复用已有的实例,系统中只存在唯一一个实例。表现为在最近任务列表中只有一个Ability实例。<br/>典型场景:当用户打开视频播放应用并观看视频,回到桌面后,再次打开视频播放应用,应用仍为回到桌面之前正在观看的视频。 | -| multiton | 标准模式 | 缺省启动模式。每次调用startAbility方法时,都会在应用进程中创建一个新的Ability实例。表现为在最近任务列表中可以看到有多个该类型的Ability实例。<br/>典型场景:当用户打开文档应用,选择新建文档的时候,每次点击新建文档,都会创建一个新的文档任务,在最近任务列表中可以看到多个新建的文档任务。 | +| standard | 多实例模式 | 缺省启动模式。每次调用startAbility方法时,都会在应用进程中创建一个新的Ability实例。表现为在最近任务列表中可以看到有多个该类型的Ability实例。<br/>典型场景:当用户打开文档应用,选择新建文档的时候,每次点击新建文档,都会创建一个新的文档任务,在最近任务列表中可以看到多个新建的文档任务。 | 应用开发者可在config.json配置文件中通过“launchType”配置启动模式。示例如下: @@ -21,8 +21,8 @@ "abilities": [ { // singleton: 单实例模式 - // multiton: 标准模式 - "launchType": "multiton", + // standard: 多实例模式 + "launchType": "standard", // ... } ] @@ -31,7 +31,7 @@ ``` -启动PageAbility时,对于标准启动模式(多实例启动模式)以及单实例启动模式首次启动,[PageAbility生命周期回调](pageability-lifecycle.md#table13118194914476)均会被触发。单实例非首次启动时不会再触发onCreate()接口,而是触发onNewWant(),onNewWant()的说明如下表2所示。 +启动PageAbility时,对于多实例模式启动,以及单实例模式进行首次启动时,,[PageAbility生命周期回调](pageability-lifecycle.md#table13118194914476)均会被触发。单实例非首次启动时不会再触发onCreate()接口,而是触发onNewWant(),onNewWant()的说明如下表2所示。 **表2** 单实例启动模式特有的回调函数说明 diff --git a/zh-cn/application-dev/application-models/redirection-rules.md b/zh-cn/application-dev/application-models/redirection-rules.md index 86e36b0983256546465a380fa5a5c0271416165e..59424cf042861c70b31cffe0a62735458ad6ed3a 100644 --- a/zh-cn/application-dev/application-models/redirection-rules.md +++ b/zh-cn/application-dev/application-models/redirection-rules.md @@ -7,14 +7,14 @@ PageAbility作为可见Ability,可以通过startAbility启动有界面的且对外可见的Ability。 -应用可通过在config.json中设置"abilities"中的"exported"属性设置Ability是否可由其他应用的组件启动,"exported"属性的具体参数和意义如下表所示。 +应用可通过在config.json中设置"abilities"中的"visible"属性设置Ability是否可由其他应用的组件启动,"visible"属性的具体参数和意义如下表所示。 - **表1** exported属性说明 + **表1** visible属性说明 | 属性名称 | 描述 | 是否可缺省 | | -------- | -------- | -------- | -| exported | 表示Ability是否可以被其他应用调用。<br/>true:该Ability可以被任何应用调用。<br/>false:该Ability只能被同一应用的其他组件调用。 | 可缺省,缺省时默认属性值为"false"。 | +| visible | 表示Ability是否可以被其他应用调用。<br/>true:该Ability可以被任何应用调用。<br/>false:该Ability只能被同一应用的其他组件调用。 | 可缺省,缺省时默认属性值为"false"。 | 如果需设置当前Ability可由任何应用访问,对应config.json文件的示例代码如下所示: @@ -25,7 +25,7 @@ PageAbility作为可见Ability,可以通过startAbility启动有界面的且 // ... "abilities": [ { - "exported": "true", + "visible": "true", // ... } ] @@ -34,4 +34,4 @@ PageAbility作为可见Ability,可以通过startAbility启动有界面的且 ``` -如果应用中的Ability包含skills过滤器,建议此属性设置为"true",以允许其他应用通过[隐式调用](explicit-implicit-want-mappings.md)启动该Ability。如果此属性设为"false",其他应用尝试启动该Ability时系统会返回PERMISSION_DENIED。这种情况下系统应用可以通过申请[START_INVISIBLE_ABILITY](../security/permission-list.md)权限启动exported为false的组件,例如系统桌面、语音助手、搜索助手等。 +如果应用中的Ability包含skills过滤器,建议此属性设置为"true",以允许其他应用通过[隐式调用](explicit-implicit-want-mappings.md)启动该Ability。如果此属性设为"false",其他应用尝试启动该Ability时系统会返回PERMISSION_DENIED。这种情况下系统应用可以通过申请[START_INVISIBLE_ABILITY](../security/permission-list.md)权限启动visible为false的组件,例如系统桌面、语音助手、搜索助手等。 diff --git a/zh-cn/application-dev/application-models/start-page.md b/zh-cn/application-dev/application-models/start-page.md index 3796a710438f415ecaaad00dbb884bb13e11644a..fb2c8c2ffec52b21740d646566d48d7b1d7aa325 100644 --- a/zh-cn/application-dev/application-models/start-page.md +++ b/zh-cn/application-dev/application-models/start-page.md @@ -70,7 +70,7 @@ struct Index { ``` -当PageAbility的启动模式设置为标准模式或为首次启动单例模式的PageAbility时(具体设置方法和典型场景示例见[PageAbility的启动模式](pageability-launch-type.md)),在调用方PageAbility中,通过want中的parameters参数传递要启动的指定页面的pages信息,调用startAbility()方法启动PageAbility。被调用方可以在onCreate中使用featureAbility的getWant方法获取want,再通过调用router.push实现启动指定页面。 +当PageAbility的启动模式设置为多实例模式或为首次启动单例模式的PageAbility时(具体设置方法和典型场景示例见[PageAbility的启动模式](pageability-launch-type.md)),在调用方PageAbility中,通过want中的parameters参数传递要启动的指定页面的pages信息,调用startAbility()方法启动PageAbility。被调用方可以在onCreate中使用featureAbility的getWant方法获取want,再通过调用router.push实现启动指定页面。 调用方的页面中实现按钮点击触发startAbility方法启动目标端PageAbility,startAbility方法的入参want中携带指定页面信息,示例代码如下: diff --git a/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md b/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md index fafbe6935b781117851968f32e87ad339fcfc252..43cd394dc79795c47c07227e35589b396f8ae266 100644 --- a/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md +++ b/zh-cn/application-dev/application-models/uiability-intra-device-interaction.md @@ -486,7 +486,7 @@ export default class FuncAbility extends UIAbility { ``` > **说明:** -> 当被调用方[UIAbility组件启动模式](uiability-launch-type.md)设置为standard启动模式时,每次启动都会创建一个新的实例,那么[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调就不会被用到。 +> 当被调用方[UIAbility组件启动模式](uiability-launch-type.md)设置为multiton启动模式时,每次启动都会创建一个新的实例,那么[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调就不会被用到。 ## 通过Call调用实现UIAbility交互(仅对系统应用开放) diff --git a/zh-cn/application-dev/application-models/uiability-launch-type.md b/zh-cn/application-dev/application-models/uiability-launch-type.md index 531464065f819d1d0f6c278c228aa666ae257bb9..f806a642db085e84dedcdee359a13505b7f5557d 100644 --- a/zh-cn/application-dev/application-models/uiability-launch-type.md +++ b/zh-cn/application-dev/application-models/uiability-launch-type.md @@ -6,7 +6,7 @@ UIAbility的启动模式是指UIAbility实例在启动时的不同呈现状态 - [singleton(单实例模式)](#singleton启动模式) -- [multiton(标准实例模式)](#multiton启动模式) +- [multiton(多实例模式)](#multiton启动模式) - [specified(指定实例模式)](#specified启动模式) @@ -17,8 +17,8 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式 每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,如果应用进程中该类型的UIAbility实例已经存在,则复用系统中的UIAbility实例。系统中只存在唯一一个该UIAbility实例,即在最近任务列表中只存在一个该类型的UIAbility实例。 -**图1** 单实例模式演示效果 -![uiability-launch-type1](figures/uiability-launch-type1.png) +**图1** 单实例模式演示效果 +![uiability-launch-type1](figures/uiability-launch-type1.gif) > **说明**:应用的UIAbility实例已创建,该UIAbility配置为单实例模式,再次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法启动该UIAbility实例。由于启动的还是原来的UIAbility实例,并未重新创建一个新的UIAbility实例,此时只会进入该UIAbility的[onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant)回调,不会进入其[onCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityoncreate)和[onWindowStageCreate()](../reference/apis/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)生命周期回调。 @@ -42,10 +42,10 @@ singleton启动模式为单实例模式,也是默认情况下的启动模式 ## multiton启动模式 -multiton启动模式为标准实例模式,每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,都会在应用进程中创建一个新的该类型UIAbility实例。即在最近任务列表中可以看到有多个该类型的UIAbility实例。这种情况下可以将UIAbility配置为multiton(标准实例模式)。 +multiton启动模式为多实例模式,每次调用[startAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability)方法时,都会在应用进程中创建一个新的该类型UIAbility实例。即在最近任务列表中可以看到有多个该类型的UIAbility实例。这种情况下可以将UIAbility配置为multiton(多实例模式)。 -**图2** 标准实例模式演示效果 -![uiability-launch-type2](figures/uiability-launch-type2.png) +**图2** 多实例模式演示效果 +![uiability-launch-type2](figures/uiability-launch-type2.gif) multiton启动模式的开发使用,在[module.json5配置文件](../quick-start/module-configuration-file.md)中的`launchType`字段配置为`multiton`即可。 @@ -69,8 +69,8 @@ multiton启动模式的开发使用,在[module.json5配置文件](../quick-sta specified启动模式为指定实例模式,针对一些特殊场景使用(例如文档应用中每次新建文档希望都能新建一个文档实例,重复打开一个已保存的文档希望打开的都是同一个文档实例)。 -**图3** 指定实例模式演示效果 -![uiability-launch-type3](figures/uiability-launch-type3.png) +**图3** 指定实例模式演示效果 +![uiability-launch-type3](figures/uiability-launch-type3.gif) 例如有两个UIAbility:EntryAbility和SpecifiedAbility,SpecifiedAbility配置为指定实例模式启动,需要从EntryAbility的页面中启动SpecifiedAbility。 diff --git a/zh-cn/application-dev/application-models/widget-development-fa.md b/zh-cn/application-dev/application-models/widget-development-fa.md index 921903c0c6e36368880ae5876498cff44cbbbcb5..8278000a12195515820ec2877fc8122e9f3433c9 100644 --- a/zh-cn/application-dev/application-models/widget-development-fa.md +++ b/zh-cn/application-dev/application-models/widget-development-fa.md @@ -321,7 +321,7 @@ async function deleteFormInfo(formId: string) { // ... ``` -具体的持久化方法可以参考[轻量级数据存储开发指导](../database/database-preference-guidelines.md)。 +具体的持久化方法可以参考[数据管理开发指导](../database/app-data-persistence-overview.md)。 需要注意的是,卡片使用方在请求卡片时传递给提供方应用的Want数据中存在临时标记字段,表示此次请求的卡片是否为临时卡片: diff --git a/zh-cn/application-dev/database/figures/relationStore_local.jpg b/zh-cn/application-dev/database/figures/relationStore_local.jpg index c6b69c19565a7c7b05b57eb5a3cf303d05c82d0e..9f5a2b951e82792ac69bd8d11422219f9299d983 100644 Binary files a/zh-cn/application-dev/database/figures/relationStore_local.jpg and b/zh-cn/application-dev/database/figures/relationStore_local.jpg differ diff --git a/zh-cn/application-dev/database/share-device-data-across-apps-overview.md b/zh-cn/application-dev/database/share-device-data-across-apps-overview.md index 1dc4ae9e99e5712af37f1311caa9c50a1cd2f748..79febf4b4653891bb2587ab4665bca2fdf4790e6 100644 --- a/zh-cn/application-dev/database/share-device-data-across-apps-overview.md +++ b/zh-cn/application-dev/database/share-device-data-across-apps-overview.md @@ -12,11 +12,13 @@ 跨应用数据共享有两种方式: - **使用DataShareExtensionAbility实现数据共享** + 这种方式通过在HAP中实现一个extension,在extension中可以实现回调,在访问方调用对应接口时,会自动拉起提供方对应的extension,并调用对应回调。 这种方式适用于跨应用数据访问时有业务的操作,不仅是对数据库的增删改查的情况。 - **通过静默访问实现数据共享** + 这种方式通过在HAP中配置数据库的访问规则,在访问方调用对应接口时,会自动通过系统服务读取HAP配置规则,按照规则返回数据,不会拉起数据提供方。 这种方式适用于跨应用数据访问仅为数据库的增删改查,没有特殊业务的情况。 diff --git a/zh-cn/application-dev/database/sync-app-data-across-devices-overview.md b/zh-cn/application-dev/database/sync-app-data-across-devices-overview.md index c4d09d08da110e5f5e8c658a41ad808f47317bcb..4f1faa0c8ad2b3db42833790983760b558157279 100644 --- a/zh-cn/application-dev/database/sync-app-data-across-devices-overview.md +++ b/zh-cn/application-dev/database/sync-app-data-across-devices-overview.md @@ -7,13 +7,13 @@ 例如:当设备1上的应用A在分布式数据库中增、删、改数据后,设备2上的应用A也可以获取到该数据库变化。可在分布式图库、备忘录、联系人、文件管理器等场景中使用。 -不同应用间订阅数据库变化通知,请参考[同设备跨应用数据共享](share-device-data-across-apps-overview.md)实现。 +不同应用间订阅数据库变化通知,则请参考[同设备跨应用数据共享](share-device-data-across-apps-overview.md)实现。 -根据跨设备同步数据生命周期不同,可以分为: +根据跨设备同步数据生命周期的不同,可以分为: -- 临时数据生命周期较短,通常保存内存中。比如游戏应用产生的过程数据,建议使用分布式数据对象; +- 临时数据生命周期较短,通常保存到内存中。比如游戏应用产生的过程数据,建议使用分布式数据对象。 -- 持久数据生命周期较长,需要保存到存储的数据库中,根据数据关系和特点,选择关系型或者键值型数据库。比如图库应用的各种相册、封面、图片等属性信息,建议使用关系型数据库;图库应用的具体图片缩略图,建议使用键值型数据库。 +- 持久数据生命周期较长,需要保存到存储的数据库中,根据数据关系和特点,可以选择关系型数据库或者键值型数据库。比如图库应用的各种相册、封面、图片等属性信息,建议使用关系型数据库;图库应用的具体图片缩略图,建议使用键值型数据库。 ## 基本概念 diff --git a/zh-cn/application-dev/dfx/apprecovery-guidelines.md b/zh-cn/application-dev/dfx/apprecovery-guidelines.md index 7733738e30e1f3dba3fa05c970fbf1869df2ee29..c3df1e3aed2d5a522e28497ce1c0c724ac9aca65 100644 --- a/zh-cn/application-dev/dfx/apprecovery-guidelines.md +++ b/zh-cn/application-dev/dfx/apprecovery-guidelines.md @@ -222,3 +222,20 @@ export default class EntryAbility extends Ability { } ``` +#### 故障Ability的重启恢复标记 + +发生故障的Ability再次重新启动时,在调度onCreate生命周期里,参数want的parameters成员会有[ABILITY_RECOVERY_RESTART](../reference/apis/js-apis-app-ability-wantConstant.md#wantconstantparams)标记数据,并且值为true。 + +```ts +import UIAbility from '@ohos.app.ability.UIAbility'; +import wantConstant from '@ohos.app.ability.wantConstant'; +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + if (want.parameters[wantConstant.Params.ABILITY_RECOVERY_RESTART] != undefined && + want.parameters[wantConstant.Params.ABILITY_RECOVERY_RESTART] == true) { + console.log("This ability need to recovery"); + } + } +} +``` + diff --git a/zh-cn/application-dev/file-management/app-sandbox-directory.md b/zh-cn/application-dev/file-management/app-sandbox-directory.md index f0724bdefac2eacbe3adbec572d27a237ba77c50..1598808622ee08419d843546ba094cbc7ee58c55 100644 --- a/zh-cn/application-dev/file-management/app-sandbox-directory.md +++ b/zh-cn/application-dev/file-management/app-sandbox-directory.md @@ -64,7 +64,7 @@ | 目录名 | Context属性名称 | 类型 | 说明 | | -------- | -------- | -------- | -------- | - | bundle | bundleCodeDir | 安装文件路径 | 应用安装后的app的hap资源包所在目录;随应用卸载而清理。 | + | bundle | bundleCodeDir | 安装文件路径 | 应用安装后的app的hap资源包所在目录;随应用卸载而清理。不能拼接路径访问资源文件,请使用[资源管理接口](../reference/apis/js-apis-resource-manager.md)访问资源。 | | base | NA | 本设备文件路径 | 应用在本设备上存放持久化数据的目录,子目录包含files/、cache/、temp/和haps/;随应用卸载而清理。 | | database | databaseDir | 数据库路径 | 应用在el1加密条件下存放通过分布式数据库服务操作的文件目录;随应用卸载而清理。 | | distributedfiles | distributedFilesDir | 分布式文件路径 | 应用在el2加密条件下存放分布式文件的目录,应用将文件放入该目录可分布式跨设备直接访问;随应用卸载而清理。 | diff --git a/zh-cn/application-dev/file-management/distributed-fs-overview.md b/zh-cn/application-dev/file-management/distributed-fs-overview.md index e9507db47ad53fe24e164ed054677adbcff24781..97af1b3bdce8a2dc4863dba3a432289a7c77a4fd 100644 --- a/zh-cn/application-dev/file-management/distributed-fs-overview.md +++ b/zh-cn/application-dev/file-management/distributed-fs-overview.md @@ -1,6 +1,6 @@ # 分布式文件系统概述 -分布式文件系统(hmdfs,Harmony Distributed File System)提供跨设备的文件访问能力,适用于如下场景: +分布式文件系统(hmdfs,OpenHarmony Distributed File System)提供跨设备的文件访问能力,适用于如下场景: - 两台设备组网,用户可以利用一台设备上的编辑软件编辑另外一台设备上的文档。 diff --git a/zh-cn/application-dev/media/audio-call-development.md b/zh-cn/application-dev/media/audio-call-development.md index fc3fa68da197a5fc1d72b6009328c20e07b65ad6..397ed6372921128db7dc8820c8069e53b2326801 100644 --- a/zh-cn/application-dev/media/audio-call-development.md +++ b/zh-cn/application-dev/media/audio-call-development.md @@ -8,13 +8,13 @@ ## 使用AudioRenderer播放对端的通话声音 - 该过程与[使用AudioRenderer开发音频播放功能](using-audiorenderer-for-playback.md)过程相似,关键区别在于audioRenderInfo参数和音频数据来源。audioRenderInfo参数中,音频内容类型需设置为语音,CONTENT_TYPE_SPEECH,音频流使用类型需设置为语音通信,STREAM_USAGE_VOICE_COMMUNICATION。 + 该过程与[使用AudioRenderer开发音频播放功能](using-audiorenderer-for-playback.md)过程相似,关键区别在于audioRendererInfo参数和音频数据来源。audioRendererInfo参数中,音频内容类型需设置为语音,CONTENT_TYPE_SPEECH,音频流使用类型需设置为语音通信,STREAM_USAGE_VOICE_COMMUNICATION。 ```ts import audio from '@ohos.multimedia.audio'; import fs from '@ohos.file.fs'; const TAG = 'VoiceCallDemoForAudioRenderer'; -// 与使用AudioRenderer开发音频播放功能过程相似,关键区别在于audioRenderInfo参数和音频数据来源 +// 与使用AudioRenderer开发音频播放功能过程相似,关键区别在于audioRendererInfo参数和音频数据来源 export default class VoiceCallDemoForAudioRenderer { private renderModel = undefined; private audioStreamInfo = { diff --git a/zh-cn/application-dev/media/audio-call-overview.md b/zh-cn/application-dev/media/audio-call-overview.md index 93eaace16a24a560c7ff09c0d990e81d8f99489e..0a021c1a2fbc103a7a84acfb889e1dd907a4ac2e 100644 --- a/zh-cn/application-dev/media/audio-call-overview.md +++ b/zh-cn/application-dev/media/audio-call-overview.md @@ -14,7 +14,7 @@ 应用使用音频通话相关功能时,系统会切换至与通话相关的音频场景模式([AudioScene](../reference/apis/js-apis-audio.md#audioscene8)),当前预置了多种音频场景,包括响铃、通话、语音聊天等,在不同的场景下,系统会采用不同的策略来处理音频。 -如在蜂窝通话场景中会更注重人声的清晰度。系统会使用3A算法对音频数据进行预处理,抑制通话回声,消除背景噪音,调整音量范围,从而达到清晰人声的效果。3A算法,指声学回声消除(Acoustic Echo Cancelling, AEC)、背景噪声抑制(Acitve Noise Control, ANC)、自动增益控制(Automatic Gain Control, AGC)三种音频处理算法。 +如在蜂窝通话场景中会更注重人声的清晰度。系统会使用3A算法对音频数据进行预处理,抑制通话回声,消除背景噪音,调整音量范围,从而达到清晰人声的效果。3A算法,指声学回声消除(Acoustic Echo Cancellation, AEC)、背景噪声抑制(Active Noise Control, ANC)、自动增益控制(Automatic Gain Control, AGC)三种音频处理算法。 当前预置的四种音频场景: diff --git a/zh-cn/application-dev/media/audio-output-device-management.md b/zh-cn/application-dev/media/audio-output-device-management.md index 45d9fd3d68a9dd0efe346ce6b0fc65272bc71b9e..192efbfa08c217912ee4ebc2bdbcb9a0538d382e 100644 --- a/zh-cn/application-dev/media/audio-output-device-management.md +++ b/zh-cn/application-dev/media/audio-output-device-management.md @@ -1,6 +1,6 @@ # 音频输出设备管理 -有时设备同时连接多个音频输出设备,需要指定音频输出设备进行音频播放,此时需要使用AudioRoutingManager接口进行输出设备的管理,API说明可以参考[AudioRoutingManager API文档](../reference/apis/js-apis-audio.md#audiomanager)。 +有时设备同时连接多个音频输出设备,需要指定音频输出设备进行音频播放,此时需要使用AudioRoutingManager接口进行输出设备的管理,API说明可以参考[AudioRoutingManager API文档](../reference/apis/js-apis-audio.md#audioroutingmanager9)。 ## 创建AudioRoutingManager实例 diff --git a/zh-cn/application-dev/media/audio-recording-overview.md b/zh-cn/application-dev/media/audio-recording-overview.md index 6b9dca9f9c6b40d7f0dc6c5a983df851d22d71b2..0fc4a867eb37a17bb77a75441ab5aa41e03eabba 100644 --- a/zh-cn/application-dev/media/audio-recording-overview.md +++ b/zh-cn/application-dev/media/audio-recording-overview.md @@ -6,7 +6,7 @@ - [AVRecorder](using-avrecorder-for-recording.md):功能较完善的音频、视频录制ArkTS/JS API,集成了音频输入录制、音频编码和媒体封装的功能。开发者可以直接调用设备硬件如麦克风录音,并生成m4a音频文件。 -- [AudioCapturer](using-audiocapturer-for-recording.md):用于音频输入的的ArkTS/JS API,仅支持PCM格式,需要应用持续读取音频数据进行工作。应用可以在音频输出后添加数据处理,要求开发者具备音频处理的基础知识,适用于更专业、更多样化的媒体播放应用开发。 +- [AudioCapturer](using-audiocapturer-for-recording.md):用于音频输入的的ArkTS/JS API,仅支持PCM格式,需要应用持续读取音频数据进行工作。应用可以在音频输出后添加数据处理,要求开发者具备音频处理的基础知识,适用于更专业、更多样化的媒体录制应用开发。 - [OpenSLES](using-opensl-es-for-recording.md):一套跨平台标准化的音频Native API,目前阶段唯一的音频类Native API,同样提供音频输入原子能力,仅支持PCM格式,适用于从其他嵌入式平台移植,或依赖在Native层实现音频输入功能的录音应用使用。 diff --git a/zh-cn/application-dev/media/audio-recording-stream-management.md b/zh-cn/application-dev/media/audio-recording-stream-management.md index 801876008a7824085479664edd8e721695591b19..f7739a00c474f1a1f21ad4c0629f8d453a91d862 100644 --- a/zh-cn/application-dev/media/audio-recording-stream-management.md +++ b/zh-cn/application-dev/media/audio-recording-stream-management.md @@ -1,10 +1,10 @@ # 音频录制流管理 -对于播放音频类的应用,开发者需要关注该应用的音频流的状态以做出相应的操作,比如监听到状态为结束时,及时提示用户录制已结束。 +对于录制音频类的应用,开发者需要关注该应用的音频流的状态以做出相应的操作,比如监听到状态为结束时,及时提示用户录制已结束。 ## 读取或监听应用内音频流状态变化 -参考[使用AudioCapturer开发音频录制功能](using-audiocapturer-for-recording.md)或[audio.createAudioCapturer](../reference/apis/js-apis-audio.md#audiocreateaudiocapturer8),完成AudioRenderer的创建,然后可以通过以下两种方式查看音频流状态的变化: +参考[使用AudioCapturer开发音频录制功能](using-audiocapturer-for-recording.md)或[audio.createAudioCapturer](../reference/apis/js-apis-audio.md#audiocreateaudiocapturer8),完成AudioCapturer的创建,然后可以通过以下两种方式查看音频流状态的变化: - 方法1:直接查看AudioCapturer的[state](../reference/apis/js-apis-audio.md#属性): diff --git a/zh-cn/application-dev/media/mic-management.md b/zh-cn/application-dev/media/mic-management.md index f8fe096ee24b6484066135bf9fada876d60c839c..575271681514dcadfda8e2ed8047324a66000c9a 100644 --- a/zh-cn/application-dev/media/mic-management.md +++ b/zh-cn/application-dev/media/mic-management.md @@ -44,7 +44,7 @@ } ``` -4. 根据查询结果的实际情况,调用setMicrophoneMute设置麦克风静音状态,入参输入true为静音,false为非静音。设置成功返回true,否则返回false。 +4. 根据查询结果的实际情况,调用setMicrophoneMute设置麦克风静音状态,入参输入true为静音,false为非静音。 ```ts async function setMicrophoneMuteTrue() { //设置麦克风静音,入参为true diff --git a/zh-cn/application-dev/media/using-audiocapturer-for-recording.md b/zh-cn/application-dev/media/using-audiocapturer-for-recording.md index 189093159072f5ad7b987ba493ed8d2e5cc1d990..76548cbe10a909340cddf0d1e570d4de08e10139 100644 --- a/zh-cn/application-dev/media/using-audiocapturer-for-recording.md +++ b/zh-cn/application-dev/media/using-audiocapturer-for-recording.md @@ -147,7 +147,7 @@ export default class AudioCapturerDemo { // 开始一次音频采集 async start() { let stateGroup = [audio.AudioState.STATE_PREPARED, audio.AudioState.STATE_PAUSED, audio.AudioState.STATE_STOPPED]; - if (stateGroup.indexOf(this.audioCapturer.state) === -1) { // 当且仅当状态为prepared、paused和stopped之一时才能启动采集 + if (stateGroup.indexOf(this.audioCapturer.state) === -1) { // 当且仅当状态为STATE_PREPARED、STATE_PAUSED和STATE_STOPPED之一时才能启动采集 console.error(`${TAG}: start failed`); return; } diff --git a/zh-cn/application-dev/media/using-avrecorder-for-recording.md b/zh-cn/application-dev/media/using-avrecorder-for-recording.md index f3c62923a7fa5ed418c1c18a8d316e893d9fa25d..98c9c4633eb25462ed4d8a6f09ab78a7b9883b4e 100644 --- a/zh-cn/application-dev/media/using-avrecorder-for-recording.md +++ b/zh-cn/application-dev/media/using-avrecorder-for-recording.md @@ -31,8 +31,8 @@ 2. 设置业务需要的监听事件,监听状态变化及错误上报。 | 事件类型 | 说明 | | -------- | -------- | - | stateChange | 必要事件,监听播放器的state属性改变 | - | error | 必要事件,监听播放器的错误信息 | + | stateChange | 必要事件,监听AVRecorder的state属性改变 | + | error | 必要事件,监听AVRecorder的错误信息 | ```ts diff --git a/zh-cn/application-dev/media/using-opensl-es-for-recording.md b/zh-cn/application-dev/media/using-opensl-es-for-recording.md index 5dc7772809f8e552ecb7e139d3ef5e1eaada06fb..70e57a8fa95e23509736329dd7ccc88a8d3420c1 100644 --- a/zh-cn/application-dev/media/using-opensl-es-for-recording.md +++ b/zh-cn/application-dev/media/using-opensl-es-for-recording.md @@ -1,10 +1,10 @@ -# 使用OpenSLES开发音频录制功能 +# 使用OpenSL ES开发音频录制功能 OpenSL ES全称为Open Sound Library for Embedded Systems,是一个嵌入式、跨平台、免费的音频处理库。为嵌入式移动多媒体设备上的应用开发者提供标准化、高性能、低延迟的API。OpenHarmony的Native API基于[Khronos Group](https://www.khronos.org/)开发的[OpenSL ES](https://www.khronos.org/opensles/) 1.0.1 API 规范实现,开发者可以通过<OpenSLES.h>和<OpenSLES_OpenHarmony.h>在OpenHarmony上使用相关API。 ## OpenHarmony上的OpenSL ES -OpenSL ES中提供了以下的接口,OpenHarmony当前仅实现了部分[接口](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h),可以实现音频播放的基础功能。 +OpenSL ES中提供了以下的接口,OpenHarmony当前仅实现了部分[接口](https://gitee.com/openharmony/third_party_opensles/blob/master/api/1.0.1/OpenSLES.h),可以实现音频录制的基础功能。 调用未实现接口后会返回**SL_RESULT_FEATURE_UNSUPPORTED,**当前没有相关扩展可以使用。 diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 7bbf8400ed151eaa94a9acfd5833c0b318fe4ac4..127ae791d09ed1c214eec01672c7bb09f20cb152 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -16,7 +16,7 @@ ![Playback status change](figures/video-playback-status-change.png) -状态的详细说明请参考[AVPlayerState](../reference/apis/js-apis-media.md#avplayerstate9)。当播放处于prepared / playing / paused / compeled状态时,播放引擎处于工作状态,这需要占用系统较多的运行内存。当客户端暂时不使用播放器时,调用reset()或release()回收内存资源,做好资源利用。 +状态的详细说明请参考[AVPlayerState](../reference/apis/js-apis-media.md#avplayerstate9)。当播放处于prepared / playing / paused / completed状态时,播放引擎处于工作状态,这需要占用系统较多的运行内存。当客户端暂时不使用播放器时,调用reset()或release()回收内存资源,做好资源利用。 ### 开发步骤及注意事项 @@ -32,8 +32,8 @@ | durationUpdate | 用于进度条,监听进度条长度,刷新资源时长。 | | timeUpdate | 用于进度条,监听进度条当前位置,刷新当前时间。 | | seekDone | 响应API调用,监听seek()请求完成情况。<br/>当使用seek()跳转到指定播放位置后,如果seek操作成功,将上报该事件。 | - | speedDone | 响应API调用,监听setSpeed()请求完成情况。<br/>当使用setSpeed()跳转到指定播放位置后,如果setSpeed操作成功,将上报该事件。 | - | volumeChange | 响应API调用,监听setVolume()请求完成情况。<br/>当使用setVolume()跳转到指定播放位置后,如果setVolume操作成功,将上报该事件。 | + | speedDone | 响应API调用,监听setSpeed()请求完成情况。<br/>当使用setSpeed()设置播放倍速后,如果setSpeed操作成功,将上报该事件。 | + | volumeChange | 响应API调用,监听setVolume()请求完成情况。<br/>当使用setVolume()调节播放音量后,如果setVolume操作成功,将上报该事件。 | | bitrateDone | 响应API调用,用于HLS协议流,监听setBitrate()请求完成情况。<br/>当使用setBitrate()指定播放比特率后,如果setBitrate操作成功,将上报该事件。 | | availableBitrates | 用于HLS协议流,监听HLS资源的可选bitrates,用于setBitrate()。 | | bufferingUpdate | 用于网络播放,监听网络播放缓冲信息。 | @@ -46,7 +46,7 @@ > > 下面代码示例中的url仅作示意使用,开发者需根据实际情况,确认资源有效性并设置: > - > - 确认相应的资源文件可用,并使用应用沙箱路径访问对应资源,参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用开发路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)。 + > - 如果使用本地资源播放,必须确认相应的资源文件可用,并使用应用沙箱路径访问对应资源,参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用开发路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)。 > > - 如果使用网络播放路径,需[申请相关权限](../security/accesstoken-guidelines.md):ohos.permission.INTERNET。 > @@ -61,9 +61,9 @@ 6. 视频播控:播放play(),暂停pause(),跳转seek(),停止stop() 等操作。 -7. 调用reset()重置资源,AVPlayer重新进入idle状态,允许更换资源url。 +7. (可选)更换资源:调用reset()重置资源,AVPlayer重新进入idle状态,允许更换资源url。 -8. 调用release()销毁实例,AVPlayer进入released状态,退出播放。 +8. 退出播放:调用release()销毁实例,AVPlayer进入released状态,退出播放。 ### 完整示例 diff --git a/zh-cn/application-dev/quick-start/application-configuration-file-overview-fa.md b/zh-cn/application-dev/quick-start/application-configuration-file-overview-fa.md index 9a176a9edcdd3400517f3032af75054897f04ce0..449b54e6ed40176171c1eba58da09524a2e86099 100644 --- a/zh-cn/application-dev/quick-start/application-configuration-file-overview-fa.md +++ b/zh-cn/application-dev/quick-start/application-configuration-file-overview-fa.md @@ -74,7 +74,7 @@ config.json示例: } ], "orientation": "unspecified", - "exported": true, + "visible": true, "srcPath": "MainAbility_entry", "name": ".MainAbility_entry", "srcLanguage": "ets", @@ -85,7 +85,7 @@ config.json示例: // $string:MainAbility_entry_label为资源索引 "label": "$string:MainAbility_entry_label", "type": "page", - "launchType": "multiton" + "launchType": "standard" } ], "distro": { diff --git a/zh-cn/application-dev/quick-start/figures/01.png b/zh-cn/application-dev/quick-start/figures/01.png deleted file mode 100644 index 8342856ec6643e20a941187852e6aef3ead11010..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/01.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/02.png b/zh-cn/application-dev/quick-start/figures/02.png deleted file mode 100644 index eef374a1fd63f2b1e4d72e3323e7f4c23f5705fb..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/02.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/04.png b/zh-cn/application-dev/quick-start/figures/04.png deleted file mode 100644 index 1190d1e5aa631b12171632d258e4c4fae32e9bba..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/04.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/07.png b/zh-cn/application-dev/quick-start/figures/07.png deleted file mode 100644 index 17f2b060d300667ff250935b6a37485843e854ce..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/07.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/chooseFAModel_ets.png b/zh-cn/application-dev/quick-start/figures/chooseFAModel_ets.png new file mode 100644 index 0000000000000000000000000000000000000000..784659f8b0efaf71620d06dd0df5c58d22ac47f4 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/chooseFAModel_ets.png differ diff --git a/zh-cn/application-dev/quick-start/figures/chooseFAModel_js.png b/zh-cn/application-dev/quick-start/figures/chooseFAModel_js.png new file mode 100644 index 0000000000000000000000000000000000000000..4d121aa3a9a1e3ba68cc5f70f6944fcfa3cef792 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/chooseFAModel_js.png differ diff --git a/zh-cn/application-dev/quick-start/figures/chooseStageModel.png b/zh-cn/application-dev/quick-start/figures/chooseStageModel.png new file mode 100644 index 0000000000000000000000000000000000000000..3125c8ba0591ce0c53344f35fb780eb956601624 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/chooseStageModel.png differ diff --git a/zh-cn/application-dev/quick-start/figures/createProject.png b/zh-cn/application-dev/quick-start/figures/createProject.png new file mode 100644 index 0000000000000000000000000000000000000000..7a56a44e0e7f80671b86c521792352db625ccad7 Binary files /dev/null and b/zh-cn/application-dev/quick-start/figures/createProject.png differ diff --git a/zh-cn/application-dev/quick-start/figures/09.png b/zh-cn/application-dev/quick-start/figures/secondPage.png similarity index 100% rename from zh-cn/application-dev/quick-start/figures/09.png rename to zh-cn/application-dev/quick-start/figures/secondPage.png diff --git a/zh-cn/application-dev/quick-start/figures/06.png b/zh-cn/application-dev/quick-start/figures/signConfig.png similarity index 100% rename from zh-cn/application-dev/quick-start/figures/06.png rename to zh-cn/application-dev/quick-start/figures/signConfig.png diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png index bcc45efdddb87a39201661c5f6d3ccbce9bfd3e6..8959cbb51a89df8142870313881bd45c2974d2ba 100644 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png and b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001364054489.png differ diff --git a/zh-cn/application-dev/quick-start/module-structure.md b/zh-cn/application-dev/quick-start/module-structure.md index 16534e58587ab1f6e55603e96f2ebbbcfc6ac814..d859c9c54f5fd7fe1557dba0053b361b3c90b076 100644 --- a/zh-cn/application-dev/quick-start/module-structure.md +++ b/zh-cn/application-dev/quick-start/module-structure.md @@ -48,7 +48,7 @@ module示例: } ], "orientation": "unspecified", - "exported": true, + "visible": true, "srcPath": "EntryAbility", "name": ".EntryAbility", "srcLanguage": "ets", @@ -57,7 +57,7 @@ module示例: "formsEnabled": false, "label": "$string:MainAbility_label", "type": "page", - "launchType": "multiton" + "launchType": "standard" } ], "distro": { @@ -263,8 +263,8 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口 | icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含 "action.system.home",entities取值中包含"entity.system.home",则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。<br/>说明:应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 | | label | 标识Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含 "action.system.home",entities取值中包含"entity.system.home",则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。<br/>说明: 应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 | | uri | 标识Ability的统一资源标识符。该标签最大长度为255个字节。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 | -| launchType | 标识Ability的启动模式,支持"multiton"和"singleton"两种模式:<br/>multiton:表示该Ability可以有多实例。该模式适用于大多数应用场景。<br/>singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用"singleton"模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"singleton"。 | -| exported | 标识Ability是否可以被其他应用调用。<br/>true:可以被其他应用调用。<br/>false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为"false"。 | +| launchType | 标识Ability的启动模式,支持"standard"和"singleton"两种模式:<br/>standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。<br/>singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用"singleton"模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"singleton"。 | +| visible | 标识Ability是否可以被其他应用调用。<br/>true:可以被其他应用调用。<br/>false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为"false"。 | | permissions | 标识其他应用的Ability调用此Ability时需要申请的权限集合,一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | |skills | 标识Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 | | deviceCapability | 标识Ability运行时要求设备具有的能力,采用字符串数组的格式表示。该标签为数组,支持最多配置512个元素,单个元素最大字节长度为64。 | 字符串数组 | 可缺省,缺省值为空。 | @@ -277,7 +277,7 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口 | writePermission | 标识向Ability写数据所需的权限。该标签仅适用于data类型的Ability。取值为长度不超过255字节的字符串。 | 字符串 | 可缺省,缺省为空。 | | configChanges | 标识Ability关注的系统配置集合。当已关注的配置发生变更后,Ability会收到onConfigurationUpdated回调。取值范围:<br/>mcc:表示IMSI移动设备国家/地区代码(MCC)发生变更。典型场景:检测到SIM并更新MCC。<br/>mnc:IMSI移动设备网络代码(MNC)发生变更。典型场景:检测到SIM并更新MNC。<br/>locale:表示语言区域发生变更。典型场景:用户已为设备文本的文本显示选择新的语言类型。<br/>layout:表示屏幕布局发生变更。典型场景:当前有不同的显示形态都处于活跃状态。<br/>fontSize:表示字号发生变更。典型场景:用户已设置新的全局字号。<br/>orientation:表示屏幕方向发生变更。典型场景:用户旋转设备。<br/>density:表示显示密度发生变更。典型场景:用户可能指定不同的显示比例,或当前有不同的显示形态同时处于活跃状态。<br/>size:显示窗口大小发生变更。<br/>smallestSize:显示窗口较短边的边长发生变更。<br/>colorMode:颜色模式发生变更。 | 字符串数组 | 可缺省,缺省为空。 | | mission | 标识Ability指定的任务栈。该标签仅适用于page类型的Ability。默认情况下应用中所有Ability同属一个任务栈。 | 字符串 | 可缺省,缺省为应用的包名。 | -| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、exported、permissions、skills生效,其他属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | +| targetAbility | 标识当前Ability重用的目标Ability。该标签仅适用于page类型的Ability。如果配置了targetAbility属性,则当前Ability(即别名Ability)的属性中仅name、icon、label、visible、permissions、skills生效,其他属性均沿用targetAbility中的属性值。目标Ability必须与别名Ability在同一应用中,且在配置文件中目标Ability必须在别名之前进行声明。 | 字符串 | 可缺省,缺省值为空。表示当前Ability不是一个别名Ability。 | | formsEnabled | 标识Ability是否支持卡片(forms)功能。该标签仅适用于page类型的Ability。<br/>true:支持卡片能力。<br/>false:不支持卡片能力。 | 布尔值 | 可缺省,缺省值为false。 | | forms | 标识服务卡片的属性。该标签仅当formsEnabled为"true"时,才能生效。 | 对象数组 | 可缺省,缺省值为空。 | | srcLanguage | Ability开发语言的类型,开发者创建工程时由开发者手动选择开发语言。 | 字符串 | 可缺省,缺省值为“js”。 | @@ -308,10 +308,10 @@ abilities示例: "icon": "$media:ic_launcher", // $string:example 为字符串类资源 "label": "$string:example", - "launchType": "multiton", + "launchType": "standard", "orientation": "unspecified", "permissions": [], - "exported": true, + "visible": true, "skills": [ { "actions": [ @@ -338,9 +338,9 @@ abilities示例: "description": "example play ability", "icon": "$media:ic_launcher", "label": "$string:example", - "launchType": "multiton", + "launchType": "standard", "orientation": "unspecified", - "exported": false, + "visible": false, "skills": [ { "actions": [ @@ -361,7 +361,7 @@ abilities示例: "name": ".UserADataAbility", "type": "data", "uri": "dataability://com.example.world.test.UserADataAbility", - "exported": true + "visible": true } ] ``` diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md index 17cfcb5a1cff589cbddf6bffb394eb122e882b3b..d3a3528883a02dbeb91d210de97606e0109455bc 100644 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ b/zh-cn/application-dev/quick-start/start-overview.md @@ -41,6 +41,6 @@ FA模型和Stage模型的整体架构和设计思想等更多区别,请见[应 1. 安装最新版[DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio)。 -2. 请参考[配置OpenHarmony SDK](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-setting-up-environment-0000001263160443-V3),完成**DevEco Studio**的安装和开发环境配置。 +2. 请参考[配置开发环境](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3),完成**DevEco Studio**的安装和开发环境配置。 完成上述操作及基本概念的理解后,可参照[使用ArkTS语言进行开发(Stage模型)](start-with-ets-stage.md)、[使用ArkTS语言开发(FA模型)](start-with-ets-fa.md)、[使用JS语言开发(FA模型)](../quick-start/start-with-js-fa.md)中的任一章节进行下一步体验和学习。 \ No newline at end of file diff --git a/zh-cn/application-dev/quick-start/start-with-ets-fa.md b/zh-cn/application-dev/quick-start/start-with-ets-fa.md index 00fdfdbd088ba060a8d86bcaf31ac03df3326c03..e04557d126081c36aced089576003df3e26b6002 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-fa.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-fa.md @@ -5,28 +5,29 @@ > > 请使用**DevEco Studio V3.0.0.601 Beta1**及更高版本。 > -> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta1**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio)获取下载链接。 ## 创建ArkTS工程 -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**OpenHarmony**模板库,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**Application**应用开发(本文以应用开发为例,**Atomic Service**对应为原子化服务开发),选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![01](figures/01.png) + ![createProject](figures/createProject.png) 2. 进入配置工程界面,**Compile SDK** 选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择**Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**ArkTS**”,其他参数保持默认设置即可。 - ![02](figures/02.png) + ![chooseFAModel_ets](figures/chooseFAModel_ets.png) > **说明:** > - > DevEco Studio V3.0 Beta3及更高版本支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-ide-low-code-overview-0000001445605884-V3)方式。 + > DevEco Studio V3.0 Beta3及更高版本支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ide-low-code-overview-0000001480179573-V3)方式。 > > 低代码开发方式具有丰富的UI界面编辑功能,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。 > > 如需使用低代码开发方式,请打开上图中的Enable Super Visual开关。 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 +4. 工程创建完成后,在**entry > build-profile.json5**文件中,将targets中的runtimeOS改为“OpenHarmony”,然后点击右上角提示框的**Sync Now**以进行OpenHarmony应用开发。 ## ArkTS工程目录结构(FA模型) @@ -34,18 +35,16 @@ ![zh-cn_image_0000001384652328](figures/zh-cn_image_0000001384652328.png) - **entry**:OpenHarmony工程模块,编译构建生成一个[HAP](../../glossary.md#hap)包。 - - **src > main > ets**:用于存放ets源码。 + - **src > main > ets**:用于存放ArkTS源码。 - **src > main > ets > MainAbility**:应用/服务的入口。 - **src > main > ets > MainAbility > pages**:MainAbility包含的页面。 - **src > main > ets > MainAbility > pages > index.ets**:pages列表中的第一个页面,即应用的首页入口。 - **src > main > ets > MainAbility > app.ets**:承载Ability生命周期。 - **src > main > resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)。 - **src > main > config.json**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用配置文件(FA模型)](application-configuration-file-overview-fa.md)。 - - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。 + - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。 - **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - - **build-profile.json5**:应用级配置信息,包括签名、产品配置等。 - - **hvigorfile.ts**:应用级编译构建任务脚本。 @@ -291,7 +290,7 @@ 2. 点击**File** > **Project Structure...** > **Project** > **SigningConfigs** 界面勾选“**Automatically generate signature**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![06](figures/06.png) + ![signConfig](figures/signConfig.png) 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001364054485](figures/zh-cn_image_0000001364054485.png)按钮运行。效果如下图所示: diff --git a/zh-cn/application-dev/quick-start/start-with-ets-stage.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md index f913187c82312cb47d3316d36cdf8e1a1998152d..309d69cc9868c8e29311564cf74c2a16c80eeb43 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-stage.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -5,22 +5,22 @@ > > 请使用**DevEco Studio V3.0.0.900 Beta3**及更高版本。 > -> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta1**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio)获取下载链接。 ## 创建ArkTS工程 -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**OpenHarmony**模板库,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**Application**应用开发(本文以应用开发为例,**Atomic Service**对应为原子化服务开发),选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![01](figures/01.png) + ![createProject](figures/createProject.png) 2. 进入配置工程界面,**Compile SDK**选择“**9**”,**Model** 选择“**Stage**”,其他参数保持默认设置即可。 - ![07](figures/07.png) + ![chooseStageModel](figures/chooseStageModel.png) > **说明:** > - > 支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-ide-low-code-overview-0000001445605884-V3)方式。 + > 支持使用ArkTS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ide-low-code-overview-0000001480179573-V3)方式。 > > 低代码开发方式具有丰富的UI界面编辑功能,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。 > @@ -28,22 +28,24 @@ 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 +4. 工程创建完成后,在**entry > build-profile.json5**文件中,将targets中的runtimeOS改为“OpenHarmony”,然后点击右上角提示框的**Sync Now**以进行OpenHarmony应用开发。 + ## ArkTS工程目录结构(Stage模型) ![zh-cn_image_0000001364054489](figures/zh-cn_image_0000001364054489.png) +- **AppStore > app.json5**:应用的全局配置信息。 - **entry**:OpenHarmony工程模块,编译构建生成一个[HAP](../../glossary.md#hap)包。 - - **src > main > ets**:用于存放ets源码。 + - **oh_modules**:用于存放三方库依赖信息。关于原npm工程适配ohpm操作,请参考[历史工程手动迁移](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212)。 + - **src > main > ets**:用于存放ArkTS源码。 - **src > main > ets > entryability**:应用/服务的入口。 - **src > main > ets > pages**:应用/服务包含的页面。 - **src > main > resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源文件的分类](resource-categories-and-access.md#资源分类)。 - **src > main > module.json5**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[module.json5配置文件](module-configuration-file.md)。 - - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。 - - **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - + - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。 +- **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **build-profile.json5**:应用级配置信息,包括签名、产品配置等。 - - **hvigorfile.ts**:应用级编译构建任务脚本。 @@ -123,7 +125,7 @@ - 新建第二个页面文件。在“**Project**”窗口,打开“**entry > src > main > ets**”,右键点击“**pages**”文件夹,选择“**New > ArkTS File**”,命名为“**Second**”,点击“**Finish**”。可以看到文件目录结构如下: - ![09](figures/09.png) + ![secondPage](figures/secondPage.png) > **说明:** > @@ -281,7 +283,7 @@ 2. 点击**File** > **Project Structure...** > **Project** > **SigningConfigs**界面勾选“**Automatically generate signature**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![06](figures/06.png) + ![signConfig](figures/signConfig.png) 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001364054485](figures/zh-cn_image_0000001364054485.png)按钮运行。效果如下图所示: diff --git a/zh-cn/application-dev/quick-start/start-with-js-fa.md b/zh-cn/application-dev/quick-start/start-with-js-fa.md index e1bc75285c9d17d4731418e272001dc865edb16c..027047b98c7f9f57dde812613cff25a3601a5927 100644 --- a/zh-cn/application-dev/quick-start/start-with-js-fa.md +++ b/zh-cn/application-dev/quick-start/start-with-js-fa.md @@ -3,22 +3,22 @@ > **说明:** > -> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta1**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download)获取下载链接。 +> 为确保运行效果,本文以使用**DevEco Studio 3.1 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download)获取下载链接。 ## 创建JS工程 -1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**OpenHarmony**模板库,选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 +1. 若首次打开**DevEco Studio**,请点击**Create Project**创建工程。如果已经打开了一个工程,请在菜单栏选择**File** > **New** > **Create Project**来创建一个新工程。选择**Application**应用开发(本文以应用开发为例,**Atomic Service**对应为原子化服务开发),选择模板“**Empty Ability**”,点击**Next**进行下一步配置。 - ![01](figures/01.png) + ![createProject](figures/createProject.png) 2. 进入配置工程界面,**Compile SDK**选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择 **Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**JS**”,其他参数保持默认设置即可。 - ![04](figures/04.png) + ![chooseFAModel_js](figures/chooseFAModel_js.png) > **说明:** > - > DevEco Studio V2.2 Beta1及更高版本支持使用JS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-ide-low-code-overview-0000001445605884-V3)方式。 + > DevEco Studio V2.2 Beta1及更高版本支持使用JS[低代码开发](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ide-low-code-overview-0000001480179573-V3)方式。 > > 低代码开发方式具有丰富的UI界面编辑功能,通过可视化界面开发方式快速构建布局,可有效降低开发者的上手成本并提升开发者构建UI界面的效率。 > @@ -26,6 +26,8 @@ 3. 点击**Finish**,工具会自动生成示例代码和相关资源,等待工程创建完成。 +4. 工程创建完成后,在**entry > build-profile.json5**文件中,将targets中的runtimeOS改为“OpenHarmony”,然后点击右上角提示框的**Sync Now**以进行OpenHarmony应用开发。 + ## JS工程目录结构 @@ -40,7 +42,7 @@ - **src > main > resources**:用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。关于资源文件,详见[资源限定与访问](../ui/js-framework-resource-restriction.md)。 - **src > main > config.json**:模块配置文件。主要包含HAP的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用配置文件(FA模型)](application-configuration-file-overview-fa.md)。 - - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。 + - **build-profile.json5**:当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。其中targets中可配置当前运行环境,默认为HarmonyOS。若需开发OpenHarmony应用,则需开发者自行修改为OpenHarmony。 - **hvigorfile.ts**:模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **build-profile.json5**:应用级配置信息,包括签名、产品配置等。 @@ -226,11 +228,10 @@ 2. 点击**File** > **Project Structure...** > **Project** > **Signing Configs**界面勾选“**Automatically generate signature**”,等待自动签名完成即可,点击“**OK**”。如下图所示: - ![06](figures/06.png) + ![signConfig](figures/signConfig.png) 3. 在编辑窗口右上角的工具栏,点击![zh-cn_image_0000001364054485](figures/zh-cn_image_0000001364054485.png)按钮运行。效果如下图所示: ![zh-cn_image_0000001311175132](figures/zh-cn_image_0000001311175132.png) 恭喜您已经使用JS语言开发(FA模型)完成了第一个OpenHarmony应用,快来[探索更多的OpenHarmony功能](../application-dev-guide.md)吧。 - diff --git a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md index c7f5608e6f679afad5f6162c343533011d38ed6a..79eb98c313cecc829b95f67828b8d79a82743a56 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md @@ -110,7 +110,7 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil onAppStart(bundleName: string): void -应用卸载事件回调。 +应用启动事件回调。 **系统能力**:SystemCapability.Customization.EnterpriseDeviceManager @@ -136,7 +136,7 @@ export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbil onAppStop(bundleName: string): void -应用卸载事件回调。 +应用停止事件回调。 **系统能力**:SystemCapability.Customization.EnterpriseDeviceManager diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md index daed6bc605c3ae6430f947f0d973591e62d506d5..4220b7883f52d7072d0447c1c3a7f0aef11f8287 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-featureAbility.md @@ -25,7 +25,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>) 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -77,7 +77,7 @@ startAbility(parameter: StartAbilityParameter): Promise\<number> 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -128,7 +128,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper 使用规则: - 跨应用访问dataAbility,对端应用需配置关联启动 - 调用方应用位于后台时,使用该接口访问dataAbility需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标dataAbility的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标dataAbility的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -165,7 +165,7 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -218,7 +218,7 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult> 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -564,7 +564,7 @@ connectAbility(request: Want, options:ConnectOptions): number 使用规则: - 跨应用连接serviceAbility,对端应用需配置关联启动 - 调用方应用位于后台时,使用该接口连接serviceAbility需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标serviceAbility的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标serviceAbility的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md index 18e1da6b38a7925c334934fe2e43bf1b87b2e00a..ef0d0134d8a7f645ddd16d166a5086c0598a33e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-particleAbility.md @@ -25,7 +25,7 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -75,7 +75,7 @@ startAbility(parameter: StartAbilityParameter): Promise\<void>; 使用规则: - 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标Ability的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -182,7 +182,7 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper 使用规则: - 跨应用访问dataAbility,对端应用需配置关联启动 - 调用方应用位于后台时,使用该接口访问dataAbility需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标dataAbility的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标dataAbility的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel @@ -405,7 +405,7 @@ connectAbility(request: Want, options:ConnectOptions): number 使用规则: - 跨应用连接serviceAbility,对端应用需配置关联启动 - 调用方应用位于后台时,使用该接口连接serviceAbility需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限 - - 跨应用场景下,目标serviceAbility的exported属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 + - 跨应用场景下,目标serviceAbility的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限 - 组件启动规则详见:[组件启动规则(FA模型)](../../application-models/component-startup-rules-fa.md) **系统能力**:SystemCapability.Ability.AbilityRuntime.FAModel diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md index 3ffc94c818de97cc9b2c1e515f89ecd0265f239f..640b08d8cd0ffe1a259e663a9df514bdc175a61b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-errorManager.md @@ -32,6 +32,14 @@ on(type: 'error', observer: ErrorObserver): number; | -------- | -------- | | number | 观察器的index值,和观察器一一对应。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000003 | Id does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -71,6 +79,14 @@ off(type: 'error', observerId: number, callback: AsyncCallback\<void>): void; | observerId | number | 是 | 由on方法返回的观察器的index值。 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000003 | Id does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -109,6 +125,14 @@ off(type: 'error', observerId: number): Promise\<void>; | -------- | -------- | | Promise\<void> | 返回执行结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000003 | Id does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md index 566ae59852950a9c918485661e57fee21474faae..4f41fa7a307f7584da825acbf4c8232799d837ce 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-missionManager.md @@ -122,6 +122,14 @@ off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): v | listenerId | number | 是 | 系统任务状态监器法的index值,和监听器一一对应,由on方法返回。 | | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300002 | Input error. The specified mission listener does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -209,6 +217,14 @@ off(type: 'mission', listenerId: number): Promise<void>; | -------- | -------- | | Promise<void> | promise方式返回执行结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300002 | Input error. The specified mission listener does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -624,6 +640,14 @@ lockMission(missionId: number, callback: AsyncCallback<void>): void; | missionId | number | 是 | 任务ID。 | | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300001 | Mission not found. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -667,6 +691,14 @@ lockMission(missionId: number): Promise<void>; | -------- | -------- | | Promise<void> | promise方式返回执行结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300001 | Mission not found. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts import missionManager from '@ohos.app.ability.missionManager'; @@ -702,6 +734,14 @@ unlockMission(missionId: number, callback: AsyncCallback<void>): void; | missionId | number | 是 | 任务ID。 | | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300001 | Mission not found. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts import missionManager from '@ohos.app.ability.missionManager'; @@ -744,6 +784,14 @@ unlockMission(missionId: number): Promise<void>; | -------- | -------- | | Promise<void> | promise方式返回执行结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16300001 | Mission not found. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -924,6 +972,14 @@ moveMissionToFront(missionId: number, callback: AsyncCallback<void>): void | missionId | number | 是 | 任务ID。 | | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -963,6 +1019,14 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall | options | [StartOptions](js-apis-app-ability-startOptions.md) | 是 | 启动参数选项,用于指定任务切到前台时的窗口模式,设备ID等。 | | callback | AsyncCallback<void> | 是 | 执行结果回调函数。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1007,6 +1071,14 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise<void&g | -------- | -------- | | Promise<void> | promise方式返回执行结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md index b9ae553c8814f479412f04c6e016492306396727..0b908a0bd49caa2dcd9020a731818e17fa7af889 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md @@ -62,6 +62,25 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v | hapModuleQuickFixFiles | Array\<string> | 是 | 快速修复补丁文件(补丁文件需包含有效的文件路径)。 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500002 | Copy file failed, maybe not exist or inaccessible. | +| 18500008 | Internal error. | + +在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500003 | Deploy hqf failed. | +| 18500004 | Switch hqf failed. | +| 18500005 | Delete hqf failed. | +| 18500006 | Load patch failed. | +| 18500007 | Unload patch failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + > 说明:调用applyQuickFix接口时,补丁文件所在路径为应用沙箱路径。沙箱路径的获取参考[获取应用的沙箱路径](js-apis-bundle-BundleInstaller.md#获取应用的沙箱路径),映射到设备上的路径为/proc/<应用进程Id>/root/沙箱路径。 **示例:** @@ -105,6 +124,25 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>; | -------- | -------- | | Promise\<void> | 返回相应结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500002 | Copy file failed, maybe not exist or inaccessible. | +| 18500008 | Internal error. | + +在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500003 | Deploy hqf failed. | +| 18500004 | Switch hqf failed. | +| 18500005 | Delete hqf failed. | +| 18500006 | Load patch failed. | +| 18500007 | Unload patch failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -139,6 +177,15 @@ getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<Applicat | bundleName | string | 是 |应用Bundle名称。 | | callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | 是 | 应用的快速修复信息。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500001 | The bundle is not exist. | +| 18500008 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -180,6 +227,15 @@ getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo | -------- | -------- | | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | 返回应用的快速修复信息。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 18500001 | The bundle is not exist. | +| 18500008 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md index 2301738bc5f83b30c6139ed963e20eac4c260930..da52ea4a49fc2b6c10123538a887f08ee4310357 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md @@ -358,7 +358,9 @@ call(method: string, data: rpc.Parcelable): Promise<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | +| 16200002 | Callee invalid. The callee does not exist. | +| 16000050 | Internal Error. | 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 @@ -437,7 +439,9 @@ callWithResult(method: string, data: rpc.Parcelable): Promise<rpc.MessageSequ | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | +| 16200002 | Callee invalid. The callee does not exist. | +| 16000050 | Internal Error. | 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 @@ -505,10 +509,10 @@ release(): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | Invalid input parameter. | | 16200001 | Caller released. The caller has been released. | | 16200002 | Callee invalid. The callee does not exist. | -| 16000050 | Internal Error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -542,6 +546,14 @@ release(): void; **系统能力**:SystemCapability.Ability.AbilityRuntime.AbilityCore +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16200001 | Caller released. The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -588,6 +600,14 @@ release(): void; | -------- | -------- | -------- | -------- | | callback | [OnRemoteStateChangeCallback](#onremotestatechangecallback) | 是 | 返回onRemoteStateChange回调结果。 | +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16200001 | Caller released. The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -636,7 +656,7 @@ release(): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200001 | Caller released. The caller has been released. | 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 @@ -681,13 +701,6 @@ off(type: 'release', callback: OnReleaseCallback): void; | type | string | 是 | 监听releaseCall事件,固定为'release'。 | | callback | [OnReleaseCallback](#onreleasecallback) | 是 | 返回off回调结果。 | -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | -其他ID见[元能力子系统错误码](../errorcodes/errorcode-ability.md) - **示例:** ```ts @@ -730,13 +743,6 @@ off(type: 'release'): void; | -------- | -------- | -------- | -------- | | type | string | 是 | 监听releaseCall事件,固定为'release'。 | -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | -其他ID见[元能力子系统错误码](../errorcodes/errorcode-ability.md) - **示例:** ```ts @@ -788,7 +794,8 @@ on(method: string, callback: CalleeCallback): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200004 | Method registered. The method has registered. | +| 16000050 | Internal error. | 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 @@ -853,7 +860,8 @@ off(method: string): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | +| 16200005 | Method not registered. The method has not registered. | +| 16000050 | Internal error. | 以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md index 540592747ed6c478f156cfb3fe9aea85e2bebb6b..be50fee49f3337029f03f67e39383cfc4a49366b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantAgent.md @@ -28,31 +28,13 @@ getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void | callback | AsyncCallback\<WantAgent\> | 是 | 创建WantAgent的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -125,31 +107,13 @@ getWantAgent(info: WantAgentInfo): Promise\<WantAgent\> | Promise\<WantAgent\> | 以Promise形式返回WantAgent。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -211,31 +175,13 @@ getBundleName(agent: WantAgent, callback: AsyncCallback\<string\>): void | callback | AsyncCallback\<string\> | 是 | 获取WantAgent实例的包名的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -321,31 +267,13 @@ getBundleName(agent: WantAgent): Promise\<string\> | Promise\<string\> | 以Promise形式返回获取WantAgent实例的包名。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -422,31 +350,13 @@ getUid(agent: WantAgent, callback: AsyncCallback\<number\>): void | callback | AsyncCallback\<number\> | 是 | 获取WantAgent实例的用户ID的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -533,31 +443,13 @@ getUid(agent: WantAgent): Promise\<number\> | Promise\<number\> | 以Promise形式返回获取WantAgent实例的用户ID。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -635,31 +527,14 @@ getWant(agent: WantAgent, callback: AsyncCallback\<Want\>): void | callback | AsyncCallback\<[Want](js-apis-app-ability-want.md)\> | 是 | 获取WantAgent对象want的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| +| 16000015 | Service timeout.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -747,31 +622,14 @@ getWant(agent: WantAgent): Promise\<Want\> | Promise\<Want\> | 以Promise形式返回获取WantAgent对象的want。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| +| 16000015 | Service timeout.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -848,31 +706,13 @@ cancel(agent: WantAgent, callback: AsyncCallback\<void\>): void | callback | AsyncCallback\<void\> | 是 | 取消WantAgent实例的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -958,31 +798,13 @@ cancel(agent: WantAgent): Promise\<void\> | Promise\<void\> | 以Promise形式获取异步返回结果。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -1057,33 +879,6 @@ trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\<Co | triggerInfo | [TriggerInfo](js-apis-inner-wantAgent-triggerInfo.md) | 是 | TriggerInfo对象。 | | callback | AsyncCallback\<[CompleteData](#completedata)\> | 否 | 主动激发WantAgent实例的回调方法。 | -**错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) -| 错误码ID | 错误信息 | -|-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| -| 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| - **示例:** ```ts @@ -1167,33 +962,6 @@ equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\ | otherAgent | WantAgent | 是 | WantAgent对象。 | | callback | AsyncCallback\<boolean\> | 是 | 判断两个WantAgent实例是否相等的回调方法。 | -**错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) -| 错误码ID | 错误信息 | -|-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| -| 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| - **示例:** ```ts @@ -1280,33 +1048,6 @@ equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\> | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\<boolean\> | 以Promise形式返回获取判断两个WantAgent实例是否相等的结果。 | -**错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) -| 错误码ID | 错误信息 | -|-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| -| 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| - **示例:** ```ts @@ -1382,31 +1123,14 @@ getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void; | callback | AsyncCallback\<number> | 是 | 获取一个WantAgent的OperationType信息的回调方法。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| +| 16000015 | Service timeout.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -1490,31 +1214,14 @@ getOperationType(agent: WantAgent): Promise\<number>; | Promise\<number> | 以Promise形式返回获取operationType的结果。 | **错误码:** -错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + | 错误码ID | 错误信息 | |-----------|--------------------| -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong.| -| 16000003 | Input error. The specified id does not exist.| -| 16000004 | Visibility verification failed.| -| 16000006 | Can not cross user operations.| | 16000007 | Service busyness. There are concurrent tasks, waiting for retry.| -| 16000008 | Crowdtest App Expiration.| -| 16000009 | Can not start ability in wukong mode.| -| 16000010 | Can not operation with continue flag.| -| 16000011 | Context does not exist.| -| 16000050 | Internal Error.| -| 16000051 | Network error. The network is abnormal.| -| 16000052 | Free install not support. The applicaiotn dose not support free install.| -| 16000053 | Not top ability. The application is not top ability.| -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.| -| 16000055 | Free install timeout.| -| 16000056 | Can not free install other ability.| -| 16000057 | Not support cross device free install.| -| 16000101 | execute shell command failed.| +| 16000015 | Service timeout.| | 16000151 | Invalid wantagent object.| -| 16000152 | wantAgent object not found.| -| 16000153 | wangAgent object canceled.| + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md index 67da9ed4ddafd4f68b1adc2f2c0a8d1d3d2d162b..6ae0d2a5caa5faacd943fe578668e5ad2e3f6d90 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-ability-wantConstant.md @@ -23,6 +23,7 @@ want的Params操作的常量。 | DLP_PARAMS_MODULE_NAME | ohos.dlp.params.moduleName | 指示DLP模块名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_ABILITY_NAME | ohos.dlp.params.abilityName | 指示DLP能力名称的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | DLP_PARAMS_INDEX | ohos.dlp.params.index | 指示DLP索引参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | +| ABILITY_RECOVERY_RESTART | ohos.ability.params.abilityRecoveryRestart | 指示当前Ability是否发生了故障恢复重启。 | | CONTENT_TITLE_KEY | ohos.extra.param.key.contentTitle | 指示原子化服务支持分享标题的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | SHARE_ABSTRACT_KEY | ohos.extra.param.key.shareAbstract | 指示原子化服务支持分享内容的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | | SHARE_URL_KEY | ohos.extra.param.key.shareUrl | 指示原子化服务支持分享链接的参数的操作。 <br>**系统API**:该接口为系统接口,三方应用不支持调用。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md index d12a34d5b0e790448ffff671b0ab2203b5e8939c..d584a3236072e8cc952a8a709774c997ee77dff3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md @@ -34,7 +34,14 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 202 | The application is not a system application. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -83,7 +90,14 @@ deleteForm(formId: string): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **参数:** @@ -124,7 +138,14 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -166,7 +187,14 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback< | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -213,7 +241,14 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -254,7 +289,14 @@ requestForm(formId: string, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -300,7 +342,14 @@ requestForm(formId: string): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -342,7 +391,14 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds upper bound. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -388,7 +444,14 @@ castToNormalForm(formId: string): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds upper bound. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -429,7 +492,12 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -475,7 +543,12 @@ notifyVisibleForms(formIds: Array<string>): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -516,7 +589,12 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -562,7 +640,12 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -603,7 +686,13 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void& | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -649,7 +738,13 @@ enableFormsUpdate(formIds: Array<string>): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -690,7 +785,14 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -736,7 +838,14 @@ disableFormsUpdate(formIds: Array<string>): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -770,6 +879,14 @@ isSystemReady(callback: AsyncCallback<void>): void | ------ | ------ | ---- | ------- | | callback | AsyncCallback<void> | 是 | 回调函数。当检查系统是否准备好成功,error为undefined,否则为错误对象。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -800,6 +917,13 @@ isSystemReady(): Promise<void> | -------- | -------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -826,6 +950,18 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): **系统能力**:SystemCapability.Ability.Form +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -860,6 +996,17 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>> **系统能力**:SystemCapability.Ability.Form +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **返回值:** | 类型 | 说明 | @@ -903,7 +1050,13 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -946,7 +1099,13 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback< | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -994,7 +1153,13 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1030,6 +1195,18 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb | formIds | Array<string> | 是 | 有效卡片标识列表。 | | callback | AsyncCallback<number> | 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,error为undefined,data为删除的卡片个数;否则为错误对象。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -1071,6 +1248,18 @@ deleteInvalidForms(formIds: Array<string>): Promise<number> | :------------ | :---------------------------------- | | Promise<number> | Promise对象,返回删除的卡片个数。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -1109,7 +1298,13 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1166,7 +1361,13 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1210,6 +1411,14 @@ on(type: 'formUninstall', callback: Callback<string>): void | type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 是 | 回调函数。返回卡片标识。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -1236,6 +1445,14 @@ off(type: 'formUninstall', callback?: Callback<string>): void | type | string | 是 | 填写'formUninstall',表示卡片卸载事件。 | | callback | Callback<string> | 否 | 回调函数。返回卡片标识。缺省时,表示注销所有已注册事件回调。<br> 需与对应on('formUninstall')的callback一致。| +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -1269,7 +1486,13 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1316,7 +1539,13 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise< | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1358,7 +1587,13 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1405,7 +1640,13 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean): | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1446,7 +1687,13 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>) | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1494,7 +1741,13 @@ shareForm(formId: string, deviceId: string): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -1535,9 +1788,14 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb **错误码:** -| 错误码ID | 错误信息 | -| ------------------------------------------------------------ | ------------------ | -| 401 | 调用接口入参错误。 | +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | | 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | | **示例:** @@ -1582,9 +1840,14 @@ function notifyFormsPrivacyProtected(formIds: Array\<string\>, isProtected: bool **错误码:** -| 错误码ID | 错误信息 | -| ------------------------------------------------------------ | ------------------ | -| 401 | 调用接口入参错误。 | +| 错误码ID | 错误信息 | +| -------- | -------- | +| 201 | Permissions denied. | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16501000 | An internal functional error occurred. | | 以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。 | | ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md b/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md index 5e1b17549769c8d6155a9432129cc6c1becadc55..fb8f7c9550781443922636e90feea08de80caf72 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md @@ -31,7 +31,14 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds upper bound. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -78,7 +85,14 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void> | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501002 | The number of forms exceeds upper bound. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -118,7 +132,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -167,7 +187,13 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500060 | A service connection error happened, please try again later. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | +| 16501001 | The ID of the form to be operated does not exist. | +| 16501003 | The form can not be operated by the current application. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -204,10 +230,12 @@ getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): voi | callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | 是 | 回调函数。返回查询到的卡片信息。 | **错误码:** - | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| @@ -247,7 +275,10 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -297,7 +328,10 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -343,7 +377,11 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -395,7 +433,11 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -451,7 +493,11 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData | 错误码ID | 错误信息 | | -------- | -------- | -| 401 | 调用接口入参错误。 | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16501000 | An internal functional error occurred. | |以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| **示例:** @@ -494,6 +540,16 @@ isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void | ------ | ------ | ---- | ------- | | callback | AsyncCallback<boolean> | 是 | 回调函数。返回是否支持发布一张卡片到使用方。| +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts @@ -548,6 +604,15 @@ isRequestPublishFormSupported(): Promise<boolean> | :------------ | :---------------------------------- | | Promise<boolean> | Promise对象。返回是否支持发布一张卡片到使用方。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 16500050 | An IPC connection error happened. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md index c1e20856bc517f82791a6e365645d88015b9d1d3..5410dd74cd29becf202eb439a888ea9df22a4885 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ApplicationInfo.md @@ -26,11 +26,11 @@ | iconId | string | 是 | 否 | 应用程序图标的资源id值。 | | process | string | 是 | 否 | 应用程序的进程,如果不设置,默认为包的名称。 | | supportedModes | number | 是 | 否 | 标识应用支持的运行模式,当前只定义了驾驶模式(drive)。该标签只适用于车机。 | -| moduleSourceDirs | Array\<string> | 是 | 否 | 应用程序的资源存放的相对路径。 | +| moduleSourceDirs | Array\<string> | 是 | 否 | 应用程序的资源存放的相对路径。不能拼接路径访问资源文件,请使用[资源管理接口](js-apis-resource-manager.md)访问资源。 | | permissions | Array\<string> | 是 | 否 | 访问应用程序所需的权限。<br />通过调用[bundle.getApplicationInfo](js-apis-Bundle.md#bundlegetapplicationinfodeprecated)接口时,传入GET_APPLICATION_INFO_WITH_PERMISSION获取。 | | moduleInfos | Array\<[ModuleInfo](js-apis-bundle-ModuleInfo.md)> | 是 | 否 | 应用程序的模块信息。 | -| entryDir | string | 是 | 否 | 应用程序的文件保存路径。 | -| codePath<sup>8+</sup> | string | 是 | 否 | 应用程序的安装目录。 | +| entryDir | string | 是 | 否 | 应用程序的文件保存路径。不能拼接路径访问资源文件,请使用[资源管理接口](js-apis-resource-manager.md)访问资源。 | +| codePath<sup>8+</sup> | string | 是 | 否 | 应用程序的安装目录。不能拼接路径访问资源文件,请使用[资源管理接口](js-apis-resource-manager.md)访问资源。 | | metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | 是 | 否 | 应用程序的自定义元信息。<br />通过调用[bundle.getApplicationInfo](js-apis-Bundle.md#bundlegetapplicationinfodeprecated)接口时,传入GET_APPLICATION_INFO_WITH_METADATA获取。 | | removable<sup>8+</sup> | boolean | 是 | 否 | 应用程序是否可以被移除。 | | accessTokenId<sup>8+</sup> | number | 是 | 否 | 应用程序的accessTokenId。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md b/zh-cn/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md index a3221812add7f5461b29281968e1fd24ae7c3c76..8cfbeddf13b70ba4de142d77d7c0d6289ea22aa4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bundle-ModuleInfo.md @@ -12,4 +12,4 @@ | 名称 | 类型 | 可读 | 可写 | 说明 | | --------------- | ------ | ---- | ---- | -------- | | moduleName | string | 是 | 否 | 模块名称。 | -| moduleSourceDir | string | 是 | 否 | 安装目录。 | \ No newline at end of file +| moduleSourceDir | string | 是 | 否 | 安装目录。不能拼接路径访问资源文件,请使用[资源管理接口](js-apis-resource-manager.md)访问资源。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md index 71359cac05b2716a4ed36012a18c4734cdc4e60b..8ed865ef1cf2b5265c43037b8ef1a125d92ce2ea 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md @@ -37,6 +37,14 @@ publish(event: string, callback: AsyncCallback<void>): void 错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | + **示例:** ```ts @@ -77,6 +85,14 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback< 错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | + **示例:** ```ts @@ -126,6 +142,15 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): voi 错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | + **示例:** ```ts @@ -172,6 +197,15 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca 错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | + **示例:** @@ -217,6 +251,14 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | 是 | 表示订阅信息。 | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 是 | 表示创建订阅者的回调方法。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | + **示例:** @@ -265,6 +307,14 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSu | --------------------------------------------------------- | ---------------- | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | 返回订阅者对象。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | + **示例:** ```ts @@ -300,6 +350,17 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEvent | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | | callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | 是 | 表示接收公共事件数据的回调函数。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 801 | capability not supported. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | + **示例:** ```ts @@ -359,6 +420,17 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | 是 | 表示订阅者对象。 | | callback | AsyncCallback\<void> | 否 | 表示取消订阅的回调方法。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 801 | capability not supported. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | + **示例:** ```ts @@ -430,6 +502,19 @@ removeStickyCommonEvent(event: string, callback: AsyncCallback<void>): void | event | string | 是 | 表示被移除的粘性公共事件。 | | callback | AsyncCallback\<void> | 是 | 表示移除粘性公共事件的回调方法。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 201 | The application dose not have permission to call the interface. | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not system service. | +| 1500007 | The message send error. | +| 1500008 | The CEMS error. | + **示例:** @@ -466,6 +551,19 @@ removeStickyCommonEvent(event: string): Promise<void> | -------------- | ---------------------------- | | Promise\<void> | 表示移除粘性公共事件的对象。 | +**错误码:** + +错误码介绍请参考[@ohos.commonEventManager(事件)](../errorcodes/errorcode-CommonEventService.md) + +| 错误码ID | 错误信息 | +| -------- | ----------------------------------- | +| 201 | The application dose not have permission to call the interface. | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not system service. | +| 1500007 | The message send error. | +| 1500008 | The CEMS error. | + **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md index bee6cc69d5bcacfdbbea479f2f56958c283e4193..ae6c7f9e45e34b18e8c502982bd51e78d72ea9d8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-accountManager.md @@ -16,7 +16,7 @@ import accountManager from '@ohos.enterprise.accountManager'; disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback<void>): void -是否禁止创建本地用户接口,使用callback异步回调。 +指定设备管理员应用禁止创建本地用户接口,使用callback形式返回设置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY @@ -28,9 +28,9 @@ disallowAddLocalAccount(admin: Want, disallow: boolean, callback: AsyncCallback& | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止,false表示解除禁止。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止创建本地用户,false表示允许创建本地用户。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -59,7 +59,7 @@ accountManager.disallowAddLocalAccount(admin, true, (error) => { disallowAddLocalAccount(admin: Want, disallow: boolean): Promise<void> -是否禁止创建本地用户,使用promise异步回调。 +指定设备管理员应用禁止创建本地用户,使用Promise形式返回设置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_ACCOUNT_POLICY @@ -71,14 +71,14 @@ disallowAddLocalAccount(admin: Want, disallow: boolean): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止,false表示解除禁止。 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| disallow | boolean | 是 | 是否禁止创建本地用户,true表示禁止创建本地用户,false表示允许创建本地用户。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| Promise<void> | 无返回结果的Promise对象。当禁止创建本地用户失败时抛出错误对象。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md index b590eaabcd37d55076372d91e1827ca98e9e79ea..a2a47106d0b1a5f329b7e9ed58d24b152a2b89d5 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md @@ -16,7 +16,7 @@ import adminManager from '@ohos.enterprise.adminManager'; enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<void>): void -以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。 +激活当前用户下的指定设备管理员应用,使用callback形式返回是否激活成功。其中超级管理员应用只能在管理员用户下被激活。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -28,10 +28,10 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callba | 参数名 | 类型 | 必填 | 说明 | | -------------- | ----------------------------------- | ---- | ------------------ | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型 | -| callback | AsyncCallback\<void> | 是 | callback方式返回是否激活成功 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息。 | +| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型。 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -67,7 +67,7 @@ adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<void>): void -以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。 +激活指定用户下的指定设备管理员应用,使用callback形式返回是否激活成功。其中超级管理员应用只能在管理员用户下被激活。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -79,11 +79,11 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId | 参数名 | 类型 | 必填 | 说明 | | -------------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息。 | +| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\<void> | 是 | callback方式返回是否激活成功 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -119,7 +119,7 @@ adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<void> -以异步方法根据给定的包名和类名激活设备管理员应用,使用Promise形式返回是否激活成功。 +如果调用接口时传入了可选参数userId,则激活指定用户下的指定设备管理员应用,否则激活当前用户下的指定设备管理员应用,使用Promise形式返回是否激活成功。其中超级管理员应用只能在管理员用户下被激活。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -131,16 +131,16 @@ enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId | 参数名 | 类型 | 必填 | 说明 | | -------------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | -| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息。 | +| type | [AdminType](#admintype) | 是 | 激活的设备管理员类型。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\<void> | Promise形式返回是否激活成功 | +| Promise\<void> | 无返回结果的Promise对象。当激活设备管理员应用失败时会抛出错误对象。 | **错误码**: @@ -173,7 +173,7 @@ adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void -以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。 +将当前用户下的指定普通管理员应用去激活,使用callback形式返回是否去激活成功。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -185,8 +185,8 @@ disableAdmin(admin: Want, callback: AsyncCallback\<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用 | -| callback | AsyncCallback\<void> | 是 | callback方式返回是否去激活成功 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用。 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -216,7 +216,7 @@ adminManager.disableAdmin(wantTemp, error => { disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void -以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。 +将指定用户下的指定普通管理员应用去激活,使用callback形式返回是否去激活成功。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -228,9 +228,9 @@ disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\<void> | 是 | callback方式返回是否去激活成功 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -260,7 +260,7 @@ adminManager.disableAdmin(wantTemp, 100, error => { disableAdmin(admin: Want, userId?: number): Promise\<void> -以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Promise形式返回是否去激活成功。 +如果调用接口时传入了可选参数userId,则将指定用户下的指定普通管理员应用去激活,否则将当前用户下的指定普通管理员应用去激活,使用Promise形式返回是否去激活成功。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -272,14 +272,14 @@ disableAdmin(admin: Want, userId?: number): Promise\<void> | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 普通设备管理员应用。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\<void> | Promise形式返回是否激活成功 | +| Promise\<void> | 无返回结果的Promise对象。当去激活普通管理员应用失败时会抛出错误对象。 | **错误码**: @@ -305,7 +305,7 @@ adminManager.disableAdmin(wantTemp, 100).catch(error => { disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void -以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。 +根据bundleName将管理员用户下的超级管理员应用去激活,使用callback形式返回是否去激活成功。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -317,8 +317,8 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------- | ---- | ------------------- | -| bundleName | String | 是 | 超级设备管理员应用的包名 | -| callback | AsyncCallback\<void> | 是 | callback方式返回是否去激活成功 | +| bundleName | String | 是 | 超级设备管理员应用的包名。 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -345,7 +345,7 @@ adminManager.disableSuperAdmin(bundleName, error => { disableSuperAdmin(bundleName: String): Promise\<void> -以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。 +根据bundleName将管理员用户下的超级管理员应用去激活,使用Promise形式返回是否去激活成功。 **需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN @@ -357,13 +357,13 @@ disableSuperAdmin(bundleName: String): Promise\<void> | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | ------------ | -| bundleName | String | 是 | 超级设备管理员应用的包名 | +| bundleName | String | 是 | 超级设备管理员应用的包名。 | **返回值:** | 类型 | 说明 | | ----------------- | ----------------- | -| Promise\<void> | Promise形式返回是否激活成功 | +| Promise\<void> | 无返回结果的Promise对象。当去激活超级管理员应用失败时会抛出错误对象。 | **错误码**: @@ -386,7 +386,7 @@ adminManager.disableSuperAdmin(bundleName).catch(error => { isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void -以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Callback形式返回是否处于激活状态。 +查询当前用户下的指定设备管理员应用是否被激活,使用callback形式返回是否处于激活状态。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -396,8 +396,8 @@ isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | -------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback\<boolean> | 是 | 回调函数,当接口调用成功,err为null,data为boolean值,true表示当前用户下的指定设备管理员应用被激活,false表示当前用户下的指定设备管理员应用未激活,否则err为错误对象。 | **示例**: @@ -419,7 +419,7 @@ adminManager.isAdminEnabled(wantTemp, (error, result) => { isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void -以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Callback形式返回是否处于激活状态。 +查询指定用户下的指定设备管理员应用是否被激活,使用callback形式返回是否处于激活状态。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -429,9 +429,9 @@ isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 | +| callback | AsyncCallback\<boolean> | 是 | 回调函数,当接口调用成功,err为null,data为boolean值,true表示当前用户下的指定设备管理员应用被激活,false表示当前用户下的指定设备管理员应用未激活,否则err为错误对象。 | **示例**: @@ -453,7 +453,7 @@ adminManager.isAdminEnabled(wantTemp, 100, (error, result) => { isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> -以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 +如果调用接口时传入参数userId,则查询指定用户下的设备管理员应用是否被激活,否则判断当前用户下的设备管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -463,14 +463,14 @@ isAdminEnabled(admin: Want, userId?: number): Promise\<boolean> | 参数名 | 类型 | 必填 | 说明 | | ------ | ----------------------------------- | ---- | ---------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | ----------------- | ------------------- | -| Promise\<boolean> | Promise形式返回是否处于激活状态 | +| Promise\<boolean> | Promise对象, 返回true表示指定的管理员应用被激活,返回false表示指定的管理员应用未激活。| **示例**: @@ -490,7 +490,7 @@ adminManager.isAdminEnabled(wantTemp, 100).then((result) => { isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void -以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Callback形式返回是否处于激活状态。 +根据bundleName查询管理员用户下的超级管理员应用是否被激活,使用callback形式返回是否处于激活状态。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -500,8 +500,8 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | ---------- | ----------------------- | ---- | -------------------- | -| bundleName | String | 是 | 设备管理员应用 | -| callback | AsyncCallback\<boolean> | 是 | callback方式返回是否处于激活状态 | +| bundleName | String | 是 | 设备管理员应用。 | +| callback | AsyncCallback\<boolean> | 是 | 回调函数,当接口调用成功,err为null,data为boolean类型值,true表示当前用户下的指定设备管理员应用被激活,false表示当前用户下的指定设备管理员应用未激活,否则err为错误对象。 | **示例**: @@ -520,7 +520,7 @@ adminManager.isSuperAdmin(bundleName, (error, result) => { isSuperAdmin(bundleName: String): Promise\<boolean> -以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 +根据bundleName查询管理员用户下的超级管理员应用是否被激活,使用Promise形式返回是否处于激活状态。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -530,13 +530,13 @@ isSuperAdmin(bundleName: String): Promise\<boolean> | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------ | ---- | --------- | -| bundleName | String | 是 | 超级设备管理员应用 | +| bundleName | String | 是 | 超级设备管理员应用。 | **返回值:** | 错误码ID | 错误信息 | | ----------------- | ------------------- | -| Promise\<boolean> | Promise形式返回是否处于激活状态 | +| Promise\<boolean> | Promise对象, 返回true表示指定的超级管理员应用被激活,返回false表示指定的超级管理员应用未激活。 | **示例**: @@ -553,7 +553,7 @@ adminManager.isSuperAdmin(bundleName).then((result) => { setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>;): void -设置设备管理员应用的企业信息,使用callback形式返回是否设置成功。 +设置指定设备管理员应用的企业信息,使用callback形式返回是否设置成功。 **需要权限:** ohos.permission.SET_ENTERPRISE_INFO @@ -565,9 +565,9 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCa | 参数名 | 类型 | 必填 | 说明 | | -------------- | ----------------------------------- | ---- | ---------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息 | -| callback | AsyncCallback\<void>; | 是 | callback方式返回是否设置企业信息成功 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo) | 是 | 设备管理员应用的企业信息。 | +| callback | AsyncCallback\<void>; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -601,7 +601,7 @@ adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => { setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>; -设置设备管理员应用的企业信息,使用Promise形式返回是否设置成功。 +设置指定设备管理员应用的企业信息,使用Promise形式返回是否设置成功。 **需要权限:** ohos.permission.SET_ENTERPRISE_INFO @@ -620,7 +620,7 @@ setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>; | 类型 | 说明 | | ----------------- | --------------------- | -| Promise\<void> | Promise方式返回是否设置企业信息成功 | +| Promise\<void> | 无返回结果的Promise对象。当设置设备管理员应用企业信息失败时会抛出错误对象。 | **错误码**: @@ -650,7 +650,7 @@ adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => { getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): void -获取设备管理员应用的企业信息,使用callback形式返回设备管理员应用的企业信息。 +获取指定设备管理员应用的企业信息,使用callback形式返回设备管理员应用的企业信息。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -661,7 +661,7 @@ getEnterpriseInfo(admin: Want, callback: AsyncCallback<EnterpriseInfo>): v | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------ | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<[EnterpriseInfo](#enterpriseinfo)> | 是 | callback方式返回设备管理员应用的企业信息 | +| callback | AsyncCallback<[EnterpriseInfo](#enterpriseinfo)> | 是 | 回调函数,当接口调用成功,err为null,data为设备管理员应用的企业信息,否则err为错误对象。 | **错误码**: @@ -692,7 +692,7 @@ adminManager.getEnterpriseInfo(wantTemp, (error, result) => { getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> -获取设备管理员应用的企业信息,使用Promise形式返回设备管理员应用的企业信息。 +获取指定设备管理员应用的企业信息,使用Promise形式返回设备管理员应用的企业信息。 **系统能力:** SystemCapability.Customization.EnterpriseDeviceManager @@ -708,7 +708,7 @@ getEnterpriseInfo(admin: Want): Promise<EnterpriseInfo> | 类型 | 说明 | | ---------------------------------------- | ------------------------- | -| Promise<[EnterpriseInfo](#enterpriseinfo)> | Promise方式返回设备管理员应用的企业信息对象 | +| Promise<[EnterpriseInfo](#enterpriseinfo)> | Promise对象,返回指定设备管理员应用的企业信息。 | **错误码**: @@ -737,7 +737,7 @@ adminManager.getEnterpriseInfo(wantTemp).then((result) => { subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void -订阅系统管理事件。使用callback异步回调。 +指定设备管理员应用订阅系统管理事件。使用callback形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT @@ -751,7 +751,7 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 订阅事件数组。 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当系统管理事件订阅成功err为null,否则为错误对象。 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -781,7 +781,7 @@ adminManager.subscribeManagedEvent(wantTemp, events, (error) => { subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void> -订阅系统管理事件。使用Promise异步回调。 +指定设备管理员应用订阅系统管理事件。使用Promise形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT @@ -800,7 +800,7 @@ subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise | 类型 | 说明 | | ----- | ----------------------------------- | -| Promise\<void> | Promise对象。无返回结果的Promise对象。 | +| Promise\<void> | 无返回结果的Promise对象。当指定设备管理员应用订阅系统事件失败时会抛出错误对象。 | **错误码**: @@ -829,7 +829,7 @@ adminManager.subscribeManagedEvent(wantTemp, events).then(() => { unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void -取消订阅系统管理事件。使用callback异步回调。 +指定设备管理员应用取消订阅系统管理事件。使用callback形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT @@ -843,7 +843,7 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callba | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | managedEvents | Array\<[ManagedEvent](#managedevent)> | 是 | 取消订阅事件数组。 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当系统管理事件取消订阅成功err为null,否则为错误对象。 | +| callback | AsyncCallback\<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -873,7 +873,7 @@ adminManager.unsubscribeManagedEvent(wantTemp, events, (error) => { unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void> -取消订阅系统管理事件。使用callback异步回调。 +指定设备管理员应用取消订阅系统管理事件。使用Promise形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT @@ -892,7 +892,7 @@ unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promi | 类型 | 说明 | | ----- | ----------------------------------- | -| Promise\<void> | Promise对象。无返回结果的Promise对象。 | +| Promise\<void> | 无返回结果的Promise对象。当指定设备管理员应用取消订阅系统管理时间失败时会抛出错误对象。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md index 66249739bb2d229bb2a855b5cb71e76cc70d9b4e..1f07f73ff0ef1c72242ced25dd950f3d97e0d5eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-bundleManager.md @@ -16,7 +16,7 @@ import bundleManager from '@ohos.enterprise.bundleManager'; addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; -添加包安装白名单接口,使用callback异步回调。 +指定设备管理员应用添加包安装白名单接口,添加至白名单的应用允许在管理员用户下安装,否则不允许安装,使用callback形式返回是否添加成功。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -28,9 +28,9 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCal | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array<string> | 是 | 允许安装包的白名单 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array<string> | 是 | 允许安装包的白名单。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -61,7 +61,7 @@ bundleManager.AddAllowedInstallBundles(wantTemp, appIds, (error) => { addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; -添加包安装白名单接口,使用callback异步回调。 +指定设备管理员应用添加包安装白名单接口,添加至白名单的应用允许在指定用户下安装,否则不允许安装,使用callback形式返回是否添加成功。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -73,10 +73,10 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, ca | 参数 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array<string> | 是 | 允许安装包的白名单 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array<string> | 是 | 允许安装包的白名单。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -107,7 +107,7 @@ bundleManager.AddAllowedInstallBundles(wantTemp, appIds, 100, (error) => { addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; -添加包安装白名单接口,使用promise异步回调。 +指定设备管理员应用添加包安装白名单接口,如果调用接口时传入了可选参数userId,则添加至白名单的应用允许在指定用户下安装,如果调用接口时没有传入参数userId,则添加至白名单的应用允许在当前用户下安装,使用promise形式返回是否添加成功。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -119,15 +119,15 @@ addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): | 参数 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array<string> | 是 | 允许安装包的白名单 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array<string> | 是 | 允许安装包的白名单。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| Promise<void> | 无返回结果的Promise对象。当指定设备管理员应用添加包安装白名单失败时会抛出错误对象。 | **错误码**: @@ -158,7 +158,7 @@ bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void; -移除包安装白名单接口,使用callback异步回调。 +指定设备管理员应用移除包安装白名单接口,在白名单存在的情况下,不在包安装白名单中的应用不允许在当前用户下安装,使用callback形式返回移除结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -170,9 +170,9 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: Async | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array<string> | 是 | 移除允许安装包的白名单 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array<string> | 是 | 移除允许安装包的白名单。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -203,7 +203,7 @@ bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (error) => { removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void; -移除包安装白名单接口,使用callback异步回调。 +指定设备管理员应用移除包安装白名单接口,在白名单存在的情况下,不在包安装白名单中的应用不允许在指定用户下安装,使用callback形式返回移除结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -215,10 +215,10 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, | 参数 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array<string> | 是 | 允许安装包的白名单 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array<string> | 是 | 允许安装包的白名单。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -249,7 +249,7 @@ bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (error) => { removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void>; -移除包安装白名单接口,使用promise异步回调。 +指定设备管理员应用移除包安装白名单接口,在白名单存在的情况下,如果调用接口时传入参数userId,则不在包安装白名单中的应用不允许在指定用户下安装,如果调用接口时没有传入参数userId,则不在包安装白名单中的应用不允许在当前用户下安装,使用promise形式返回移除结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -261,15 +261,15 @@ removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number | 参数 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| appIds | Array\<string> | 是 | 允许安装包的白名单 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| appIds | Array\<string> | 是 | 允许安装包的白名单。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| Promise<void> | 无返回结果的Promise对象。当指定设备管理员应用移除包安装白名单失败时会抛出错误对象。 | **错误码**: @@ -298,9 +298,52 @@ bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { ## bundleManager.getAllowedInstallBundles +getAllowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void; + +指定管理员应用获取管理员用户下的包安装白名单接口,使用callback形式返回获取包安装白名单。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200003 | the administrator ability component is invalid. | +| 9200007 | the system ability work abnormally. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; + +bundleManager.getAllowedInstallBundles(wantTemp, (error) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + } +}); +``` + +## bundleManager.getAllowedInstallBundles + getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void; -获取包安装白名单接口,使用callback异步回调。 +指定管理员应用获取指定用户下的包安装白名单接口,使用callback形式返回获取包安装白名单。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -312,9 +355,9 @@ getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback< | 参数 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | -| callback | AsyncCallback<Array<string>> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -344,7 +387,7 @@ bundleManager.getAllowedInstallBundles(wantTemp, 100, (error) => { getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>>; -获取包安装白名单接口,使用promise异步回调。 +指定管理员应用获取管理员用户下包安装白名单接口,使用promise形式返回获取包安装白名单。 **需要权限:** ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY @@ -356,14 +399,14 @@ getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<stri | 参数 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<void> | 返回结果为String类型数组的Promise对象。 | +| Promise<Array<string>> | Promise对象,返回管理员用户下的包安装白名单。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md index 23cdc4b26795752e36031617b57a4bebc8d352f0..b3a7bb6eef5d14b0104e1bb053c68e37af2caf5f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md @@ -16,7 +16,7 @@ import dateTimeManager from '@ohos.enterprise.dateTimeManager' setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void -设置系统时间。使用callback异步回调。 +指定设备管理员应用设置系统时间。使用callback形式返回设置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -30,7 +30,7 @@ setDateTime(admin: Want, time: number, callback: AsyncCallback\<void>): void | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | time | number | 是 | 时间戳(ms)。 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当系统时间设置成功err为null,否则为错误对象。 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -59,7 +59,7 @@ dateTimeManager.setDateTime(wantTemp, 1526003846000, (error) => { setDateTime(admin: Want, time: number): Promise\<void> -设置系统时间。使用Promise异步回调。 +指定设备管理员应用设置系统时间。使用Promise形式返回设置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -106,7 +106,7 @@ dateTimeManager.setDateTime(wantTemp, 1526003846000).then(() => { disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\<void>): void -禁止修改系统时间。使用callback异步回调。 +指定设备管理员应用禁止修改系统时间。使用callback形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -120,7 +120,7 @@ disallowModifyDateTime(admin: Want, disallow: boolean, callback: AsyncCallback\< | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | | disallow | boolean | 是 | true 表示禁止修改系统时间,false表示允许修改系统时间。 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当禁止修改系统时间设置成功err为null,否则为错误对象。 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -149,7 +149,7 @@ dateTimeManager.disallowModifyDateTime(wantTemp, true, (error) => { disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void> -禁止修改系统时间。使用Promise异步回调。 +指定设备管理员应用禁止修改系统时间。使用Promise形式返回结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -168,7 +168,7 @@ disallowModifyDateTime(admin: Want, disallow: boolean): Promise\<void> | 类型 | 说明 | | ----- | ----------------------------------- | -| Promise\<void> | Promise对象。无返回结果的Promise对象。 | +| Promise\<void> | 无返回结果的Promise对象。当指定设备管理员应用禁止修改系统时间失败时抛出错误对象。 | **错误码**: @@ -196,7 +196,7 @@ dateTimeManager.disallowModifyDateTime(wantTemp, true).then(() => { isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void -查询是否允许修改系统时间。使用callback异步回调。 +指定设备管理员应用查询是否允许修改系统时间。使用callback形式返回是否禁止修改系统时间策略。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -209,7 +209,7 @@ isModifyDateTimeDisallowed(admin: Want, callback: AsyncCallback\<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | -| callback | AsyncCallback\<boolean> | 是 | 回调函数。callbac方式返回是否禁止修改系统时间策略。true表示禁止修改系统时间,否则表示允许修改系统时间。 | +| callback | AsyncCallback\<boolean> | 是 | 回调函数,callbac方式返回是否禁止修改系统时间策略,true表示禁止修改系统时间,否则表示允许修改系统时间。 | **错误码**: @@ -238,7 +238,7 @@ dateTimeManager.isModifyDateTimeDisallowed(wantTemp, (error) => { isModifyDateTimeDisallowed(admin: Want): Promise\<boolean> -查询是否允许修改系统时间。使用Promise异步回调。 +指定设备管理员应用查询是否允许修改系统时间。使用Promise形式返回是否禁止修改系统时间策略。 **需要权限:** ohos.permission.ENTERPRISE_SET_DATETIME @@ -256,7 +256,7 @@ isModifyDateTimeDisallowed(admin: Want): Promise\<boolean> | 类型 | 说明 | | ----- | ----------------------------------- | -| Promise\<boolean> | Promise对象。promise方式返回是否禁止修改系统时间策略。true表示禁止修改系统时间,否则表示允许修改系统时间。 | +| Promise\<boolean> | Promise对象。promise方式返回是否禁止修改系统时间策略,true表示禁止修改系统时间,否则表示允许修改系统时间。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceControl.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceControl.md index d497f07be910d4aeba6949dce61f4ac7b94e9cf6..00dd06e183b4188caa4b800b444e5afc4f21c1fc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceControl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceControl.md @@ -16,7 +16,7 @@ import deviceControl from '@ohos.enterprise.deviceControl' resetFactory(admin: Want, callback: AsyncCallback<void>): void -恢复出厂设置。使用callback异步回调。 +指定设备管理员应用恢复出厂设置。使用callback异步回调。 **需要权限:** ohos.permission.ENTERPRISE_RESET_DEVICE @@ -29,7 +29,7 @@ resetFactory(admin: Want, callback: AsyncCallback<void>): void | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | | admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | -| callback | AsyncCallback\<void> | 是 | 回调函数。当系统时间设置成功err为null,否则为错误对象。 | +| callback | AsyncCallback\<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -58,7 +58,7 @@ deviceControl.resetFactory(wantTemp, (error) => { resetFactory(admin: Want): Promise<void> -恢复出厂设置。使用Promise异步回调。 +恢复出厂设置。使用Promise形式返回设置结果。 **需要权限:** ohos.permission.ENTERPRISE_RESET_DEVICE @@ -76,7 +76,7 @@ resetFactory(admin: Want): Promise<void> | 类型 | 说明 | | ----- | ----------------------------------- | -| Promise\<void> | Promise对象。无返回结果的Promise对象。 | +| Promise\<void> | 无返回结果的Promise对象。当恢复出厂设置失败时抛出错误对象。| **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md index 0fc0db10c4ceca845a55eda4d93d6ea54f4cbc66..c62ff21885856223fec6dabe5cbc7fbed5b238a7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md @@ -16,7 +16,7 @@ import deviceInfo from '@ohos.enterprise.deviceInfo'; getDeviceSerial(admin: Want, callback: AsyncCallback<string>): void -获取设备序列号,使用callback形式返回设备序列号。 +指定设备管理员应用获取设备序列号,使用callback形式返回设备序列号。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -28,8 +28,8 @@ getDeviceSerial(admin: Want, callback: AsyncCallback<string>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备序列号 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<string> | 是 | 回调函数。当接口调用成功,err为null,data为设备序列号,否则err为错误对象。 | **错误码**: @@ -60,7 +60,7 @@ deviceInfo.getDeviceSerial(wantTemp, (error, result) => { getDeviceSerial(admin: Want): Promise<string> -获取设备序列号,使用callback形式返回设备序列号。 +指定设备管理员应用获取设备序列号,使用Promise形式返回设备序列号。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -72,13 +72,13 @@ getDeviceSerial(admin: Want): Promise<string> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备序列号 | +| Promise<string> | Promise对象,返回设备序列号。 | **错误码**: @@ -107,7 +107,7 @@ deviceInfo.getDeviceSerial(wantTemp).then((result) => { getDisplayVersion(admin: Want, callback: AsyncCallback<string>): void; -获取设备版本号,使用callback形式返回设备版本号。 +指定设备管理员应用获取设备版本号,使用callback形式返回设备版本号。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -119,8 +119,8 @@ getDisplayVersion(admin: Want, callback: AsyncCallback<string>): void; | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备版本号 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<string> | 是 | 回调函数。当接口调用成功,err为null,data为设备版本号,否则err为错误对象。 | **错误码**: @@ -151,7 +151,7 @@ deviceInfo.getDisplayVersion(wantTemp, (error, result) => { getDisplayVersion(admin: Want): Promise<string> -获取设备版本号,使用callback形式返回设备版本号。 +指定设备管理员应用获取设备版本号,使用Promise形式返回设备版本号。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -163,13 +163,13 @@ getDisplayVersion(admin: Want): Promise<string> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备版本号 | +| Promise<string> | Promise对象,返回设备版本号。 | **错误码**: @@ -198,7 +198,7 @@ deviceInfo.getDisplayVersion(wantTemp).then((result) => { getDeviceName(admin: Want, callback: AsyncCallback<string>): void -获取设备名称,使用callback形式返回设备名称。 +指定设备管理员应用获取设备名称,使用callback形式返回设备名称。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -210,8 +210,8 @@ getDeviceName(admin: Want, callback: AsyncCallback<string>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备名称 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<string> | 是 | 回调函数。当接口调用成功,err为null,data为设备名称,否则err为错误对象。 | **错误码**: @@ -242,7 +242,7 @@ deviceInfo.getDeviceName(wantTemp, (error, result) => { getDeviceName(admin: Want): Promise<string> -获取设备名称,使用callback形式返回设备名称。 +指定设备管理员应用获取设备名称,使用Promise形式返回设备名称。 **需要权限:** ohos.permission.ENTERPRISE_GET_DEVICE_INFO @@ -254,13 +254,13 @@ getDeviceName(admin: Want): Promise<string> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备名称 | +| Promise<string> | Promise结果,返回设备名称。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md index d42ddca63e9e1e464bbc68ca5eecba4798837a0e..cbe54b4d8f951d5bd317d03de2bde061c309fa44 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md @@ -16,7 +16,7 @@ import networkManager from '@ohos.enterprise.networkManager'; getAllNetworkInterfaces(admin: Want, callback: AsyncCallback<Array<string>>): void -获取所有活动的网络接口,使用callback形式返回网络接口名称数组。 +指定设备管理员应用获取所有活动的网络接口,使用callback形式返回网络接口名称数组。 **需要权限:** ohos.permission.GET_NETWORK_INFO @@ -28,8 +28,8 @@ getAllNetworkInterfaces(admin: Want, callback: AsyncCallback<Array<string& | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<Array<string>> | 是 | callback方式返回网络接口名称数组 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调函数。当接口调用成功,err为null,data为网络接口名称数组,否则err为错误对象。 | **错误码**: @@ -60,7 +60,7 @@ networkManager.getAllNetworkInterfaces(admin, (error, result) => { getAllNetworkInterfaces(admin: Want): Promise<Array<string>> -获取所有活动的网络接口,使用promise形式返回网络接口名称数组。 +指定设备管理员应用获取所有活动的网络接口,使用Promise形式返回网络接口名称数组。 **需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO @@ -72,13 +72,13 @@ getAllNetworkInterfaces(admin: Want): Promise<Array<string>> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<Array<string>> | Promise方式返回网络接口名称数组 | +| Promise<Array<string>> | Promise结果,返回网络接口名称数组。 | **错误码**: @@ -107,7 +107,7 @@ networkManager.getAllNetworkInterfaces(wantTemp).then((result) => { getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void -获取设备IP地址,使用callback形式返回设备IP地址。 +指定设备管理员应用根据networkInterface获取设备IP地址,使用callback形式返回设备IP地址。 **需要权限:** ohos.permission.GET_NETWORK_INFO @@ -119,9 +119,9 @@ getIpAddress(admin: Want, networkInterface: string, callback: AsyncCallback<s | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| networkInterface | string | 是 | 指定网络接口 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备IP地址 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| networkInterface | string | 是 | 指定网络接口。 | +| callback | AsyncCallback<string> | 是 | 回调函数。当接口调用成功,err为null,data为IP地址,否则err为错误对象。 | **错误码**: @@ -152,7 +152,7 @@ networkManager.getIpAddress(wantTemp, "eth0", (error, result) => { getIpAddress(admin: Want, networkInterface: string): Promise<string> -获取设备IP地址,使用promise形式返回设备IP地址。 +指定设备管理员应用根据networkInterface获取设备IP地址,使用Promise形式返回设备IP地址。 **需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO @@ -164,14 +164,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise<string> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| networkInterface | string | 是 | 指定网络接口 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| networkInterface | string | 是 | 指定网络接口。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备IP地址 | +| Promise<string> | Promise结果,返回设备IP地址。 | **错误码**: @@ -200,7 +200,7 @@ networkManager.getIpAddress(wantTemp, "eth0").then((result) => { getMac(admin: Want, networkInterface: string, callback: AsyncCallback<string>): void -获取设备MAC地址,使用callback形式返回设备MAC地址。 +指定设备管理员应用根据networkInterface获取设备MAC地址,使用callback形式返回设备MAC地址。 **需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO @@ -212,9 +212,9 @@ getMac(admin: Want, networkInterface: string, callback: AsyncCallback<string& | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| networkInterface | string | 是 | 指定网络接口 | -| callback | AsyncCallback<string> | 是 | callback方式返回设备MAC地址 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| networkInterface | string | 是 | 指定网络接口。 | +| callback | AsyncCallback<string> | 是 | 回调函数。当接口调用成功,err为null,data为设备MAC地址,否则err为错误对象。 | **错误码**: @@ -245,7 +245,7 @@ networkManager.getMac(wantTemp, "eth0", (error, result) => { getIpAddress(admin: Want, networkInterface: string): Promise<string> -获取设备MAC地址,使用promise形式返回设备IP地址。 +指定设备管理员应用根据networkInterface获取设备MAC地址,使用Promise形式返回设备IP地址。 **需要权限:** ohos.permission.ENTERPRISE_GET_NETWORK_INFO @@ -257,14 +257,14 @@ getIpAddress(admin: Want, networkInterface: string): Promise<string> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| networkInterface | string | 是 | 指定网络接口 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| networkInterface | string | 是 | 指定网络接口。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<string> | Promise方式返回设备MAC地址 | +| Promise<string> | Promise结果,返回设备MAC地址。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md index 5969fa90986b14987c0463006e69a47c080d1d9a..2450bf9cb6a746dbaca55ddb6590ef11e86007bd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md @@ -16,7 +16,7 @@ import wifiManager from '@ohos.enterprise.wifiManager'; isWifiActive(admin: Want, callback: AsyncCallback<boolean>): void -查询wifi开启状态,使用callback形式返回wifi开启状态。 +指定设备管理员应用查询wifi开启状态,使用callback形式返回wifi开启状态。 **需要权限:** ohos.permission.ENTERPRISE_SET_WIFI @@ -28,8 +28,8 @@ isWifiActive(admin: Want, callback: AsyncCallback<boolean>): void | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| callback | AsyncCallback<boolean> | 是 | callback方式返回wifi开启状态 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| callback | AsyncCallback<boolean> | 是 | 回调函数,当接口调用成功,err为null,data为boolean值,true表示wifi开启,false表示wifi关闭,否则err为错误对象。 | **错误码**: @@ -60,7 +60,7 @@ wifiManager.isWifiActive(wantTemp, (error, result) => { isWifiActive(admin: Want): Promise<boolean> -获取wifi开启状态,使用promise形式返回wifi开启状态。 +获取wifi开启状态,使用Promise形式返回wifi开启状态。 **需要权限:** ohos.permission.ENTERPRISE_SET_WIFI @@ -72,13 +72,13 @@ isWifiActive(admin: Want): Promise<boolean> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<boolean> | Promise方式返回wifi开启状态 | +| Promise<boolean> | Promise结果,返回wifi开启状态,true表示wifi开启,false表示wifi关闭。 | **错误码**: @@ -107,7 +107,7 @@ wifiManager.isWifiActive(wantTemp).then((result) => { setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback<void>): void -配置wifi连接到指定网络,使用callback异步回调。 +配置wifi,使连接到指定网络,使用callback返回配置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_WIFI @@ -119,9 +119,9 @@ setWifiProfile(admin: Want, profile: WifiProfile, callback: AsyncCallback<voi | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ------------------------------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息 | -| callback | AsyncCallback<void> | 是 | 回调函数。当接口调用成功err为null,否则为错误对象。 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息。 | +| callback | AsyncCallback<void> | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 | **错误码**: @@ -157,7 +157,7 @@ wifiManager.setWifiProfile(wantTemp, profile, (error) => { setWifiProfile(admin: Want, profile: WifiProfile): Promise<void> -配置wifi连接到指定网络,使用promise异步回调。 +配置wifi,使连接到指定网络,使用Promise返回配置结果。 **需要权限:** ohos.permission.ENTERPRISE_SET_WIFI @@ -169,14 +169,14 @@ setWifiProfile(admin: Want, profile: WifiProfile): Promise<void> | 参数名 | 类型 | 必填 | 说明 | | ----- | ----------------------------------- | ---- | ------- | -| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | -| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息 | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 | +| profile | [WifiProfile](#wifiprofile) | 是 | WLAN配置信息。 | **返回值:** | 类型 | 说明 | | --------------------- | ------------------------- | -| Promise<void> | 无返回结果的Promise对象。 | +| Promise<void> | 无返回结果的Promise对象。当配置wifi连接到指定网络失败时会抛出错误对象。 | **错误码**: diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md index dcaf26d5b4cc123caf8eb62d8accf752fc2d8b3b..56c2266effef1f7a5ce8e4a27091b294f06146f1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @@ -1253,6 +1253,82 @@ try { }; ``` +## FileAccessHelper.query<sup>10+</sup> + +query(uri:string, metaJson: string) : Promise<string> + +通过uri查询文件或目录的相关信息,使用Promise异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------------------------------------- | +| uri | string | 是 | 所选文件或目录的uri(从[FileInfo](#fileinfo)中获取) | +| metaJson | string | 是 | json字符串,包含查询属性[FILEKEY](#filekey10) | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :------------------------------- | +| Promise<string> | 返回json字符串,包括查询属性和值 | + +**示例:** + +```js +var imageFileRelativePath = "Download/queryTest/image/01.jpg"; +var jsonStrSingleRelativepath = JSON.stringify({ [fileAccess.FileKey.RELATIVE_PATH]: "" }); +try { + // fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取 + var fileInfo = await fileAccessHelper.getFileInfoFromRelativePath(imageFileRelativePath); + let queryResult = await fileAccessHelper.query(fileInfo.uri, jsonStrSingleRelativepath); + console.log("query_file_single faf query, queryResult.relative_path: " + JSON.parse(queryResult).relative_path); +} catch (error) { + console.error("query_file_single faf query failed, error.code :" + error.code + ", errorMessage :" + error.message); +}; +``` + +## FileAccessHelper.query<sup>10+</sup> + +query(uri:string, metaJson: string, callback: AsyncCallback<string>) : void + +通过uri查询文件或目录的相关信息,使用callback异步回调。 + +**系统能力**:SystemCapability.FileManagement.UserFileService + +**需要权限**:ohos.permission.FILE_ACCESS_MANAGER + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------------------------------- | +| uri | string | 是 | 所选文件或目录的uri(从[FileInfo](#fileinfo)中获取) | +| metaJson | string | 是 | json字符串,包含查询属性[FILEKEY](#filekey10) | +| callback | AsyncCallback<string> | 是 | 返回json字符串,包括查询属性和值 | + +**示例:** + +```js +var imageFileRelativePath = "Download/queryTest/image/01.jpg"; +var jsonStrSingleRelativepath = JSON.stringify({ [fileAccess.FileKey.RELATIVE_PATH]: "" }); +try { + // fileAccessHelper 参考 fileAccess.createFileAccessHelper 示例代码获取 + var fileInfo = await fileAccessHelper.getFileInfoFromRelativePath(imageFileRelativePath); + fileAccessHelper.query(fileInfo.uri, jsonStrSingleRelativepath, (err, queryResult)=>{ + if (err) { + console.log("query_file_single faf query Failed, errCode:" + err.code + ", errMessage:" + err.message); + return; + } + console.log("query_file_single faf query, queryResult.relative_path: " + JSON.parse(queryResult).relative_path); + }) +} catch (error) { + console.error("query_file_single faf query failed, error.code :" + error.code + ", errorMessage :" + error.message); +}; +``` + ## RootIterator.next next( ) : { value: RootInfo, done: boolean } @@ -1334,3 +1410,20 @@ FileIterator表示文件夹的迭代器对象,可以通过next同步方法获 | READ | 0o0 | 读模式。 | | WRITE | 0o1 | 写模式。 | | WRITE_READ | 0o2 | 读写模式。 | + +## FILEKEY<sup>10+</sup> + +支持查询的键。 + +**系统能力:** SystemCapability.FileManagement.UserFileService + +| 名称 | 值 | 说明 | +| ------------- | ------------- | ----------------------------------- | +| DISPLAY_NAME | display_name | 文件名 | +| DATE_ADDED | date_added | 文件创建的日期,例如1501925454 | +| DATE_MODIFIED | date_modified | 文件的修改日期,例如1665310670 | +| RELATIVE_PATH | relative_path | 相对路径,例如Pictures/Screenshots/ | +| FILE_SIZE | size | 文件(夹)大小(单位:字节) | +| WIDTH | width | 图像文件的宽度(单位:像素) | +| HEIGHT | height | 图像文件的高度(单位:像素) | +| DURATION | duration | 音频和视频文件的时长(单位:毫秒) | diff --git a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md index 8e113385b7371271107f7afd45c99adc546205f1..1e7eccc4c18451a0c1521c7d0b47c344e586d8fd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-geolocation.md +++ b/zh-cn/application-dev/reference/apis/js-apis-geolocation.md @@ -1,4 +1,4 @@ -# 位置服务 +# @ohos.geolocation (位置服务) 位置服务提供GNSS定位、网络定位、地理编码、逆地理编码、国家码和地理围栏等基本功能。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md index 820115f2635703da5b71e40a5d1e4c572c473393..38cf79906cf55377de45f345b94c32b70a76fb1a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md @@ -30,6 +30,14 @@ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void | monitor | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor)实例 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | AddAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -70,6 +78,14 @@ addAbilityMonitor(monitor: AbilityMonitor): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | AddAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -105,6 +121,14 @@ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): v | monitor | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor)实例 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | RemoveAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -145,6 +169,14 @@ removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | RemoveAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + - 示例 ```ts @@ -180,6 +212,14 @@ waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<UIAbility>) | monitor | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor) | 是 | [AbilityMonitor](js-apis-inner-application-abilityMonitor.md#AbilityMonitor)实例 | | callback | AsyncCallback\<[UIAbility](js-apis-app-ability-uiAbility.md)> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -220,6 +260,14 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCall | timeout | number | 否 | 最大等待时间,单位毫秒(ms) | | callback | AsyncCallback\<[UIAbility](js-apis-app-ability-uiAbility.md)> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -268,6 +316,14 @@ waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<UIAbilit | ----------------------------------------------------------- | -------------------------- | | Promise\<[UIAbility](js-apis-app-ability-uiAbility.md)> | 以Promise形式返回Ability。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -360,6 +416,14 @@ getCurrentTopAbility(callback: AsyncCallback\<UIAbility>): void; | -------- | ------------------------------------------------------------ | ---- | ------------------ | | callback | AsyncCallback\<[UIAbility](js-apis-app-ability-uiAbility.md)> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | GetCurrentTopAbility failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -387,6 +451,14 @@ getCurrentTopAbility(): Promise\<UIAbility>; | ----------------------------------------------------------- | -------------------------------------- | | Promise\<[UIAbility](js-apis-app-ability-uiAbility.md)> | 以Promise形式返回当前应用顶部ability。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | GetCurrentTopAbility failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -415,6 +487,26 @@ startAbility(want: Want, callback: AsyncCallback\<void>): void; | want | [Want](js-apis-application-want.md) | 是 | 启动Ability参数 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -450,6 +542,26 @@ startAbility(want: Want): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -480,6 +592,14 @@ doAbilityForeground(ability: UIAbility, callback: AsyncCallback\<void>): void; | ability | UIAbility | 是 | 指定Ability对象 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法<br/>\- true:成功<br/>\- false:失败 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | DoAbilityForeground failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -516,6 +636,14 @@ doAbilityForeground(ability: UIAbility): Promise\<void>; | ----------------- | ------------------------------------------------------------ | | Promise\<boolean> | 以Promise形式返回执行结果。<br/>\- true:成功<br/>\- false:失败 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | DoAbilityForeground failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -547,6 +675,14 @@ doAbilityBackground(ability: UIAbility, callback: AsyncCallback\<void>): void; | ability | UIAbility | 是 | 指定Ability对象 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法<br/>\- true:成功<br/>\- false:失败 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | DoAbilityBackground failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -583,6 +719,14 @@ doAbilityBackground(ability: UIAbility): Promise\<void>; | ----------------- | ------------------------------------------------------------ | | Promise\<boolean> | 以Promise形式返回执行结果。<br/>\- true:成功<br/>\- false:失败 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | DoAbilityBackground failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -788,6 +932,14 @@ finishTest(msg: string, code: number, callback: AsyncCallback\<void>): void; | code | number | 是 | 日志码 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | FinishTest failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -821,6 +973,14 @@ finishTest(msg: string, code: number): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | FinishTest failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -848,6 +1008,14 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<vo | monitor | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) | 是 | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) 实例 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | AddAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -884,6 +1052,14 @@ addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | AddAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -915,6 +1091,14 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\ | monitor | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) | 是 | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) 实例 | | callback | AsyncCallback\<void> | 是 | 表示指定的回调方法 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | RemoveAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -951,6 +1135,14 @@ removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>; | -------------- | ------------------- | | Promise\<void> | 以Promise形式返回。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | RemoveAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -982,6 +1174,14 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<A | monitor | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) | 是 | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) 实例 | | callback | AsyncCallback\<AbilityStage> | 是 | 成功返回AbilityStage对象,失败返回空。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1023,6 +1223,14 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise | -------------- | ------------------- | | Promise\<AbilityStage> | 成功返回AbilityStage对象,失败返回空。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1059,6 +1267,14 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: | timeout | number | 否 | 超时最大等待时间,以毫秒为单位。 | | callback | AsyncCallback\<AbilityStage> | 是 | 成功返回AbilityStage对象,失败返回空。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000100 | WaitAbilityStageMonitor failed. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md index 3d448221a104a1f763276380995ab36911123888..44e683a0961defa502ef29e61f2d5914b1420096 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-applicationContext.md @@ -291,6 +291,15 @@ getRunningProcessInformation(): Promise\<Array\<ProcessInformation>>; | -------- | -------- | | Promise\<Array\<[ProcessInformation](js-apis-inner-application-processInformation.md)>> | 以Promise方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -320,6 +329,15 @@ getRunningProcessInformation(callback: AsyncCallback\<Array\<ProcessInformation> | -------- | -------- | |AsyncCallback\<Array\<[ProcessInformation](js-apis-inner-application-processInformation.md)>> | 以回调方式返回接口运行结果及有关运行进程的信息,可进行错误处理或其他自定义处理。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -347,6 +365,14 @@ killAllProcesses(): Promise\<void\>; | -------- | -------- | | Promise\<void\> | 以Promise方式返回杀死应用所在的进程结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000011 | The context does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -368,6 +394,14 @@ killAllProcesses(callback: AsyncCallback\<void\>); | -------- | -------- | |AsyncCallback\<void\> | 以callback方式返回杀死应用所在的进程结果。 | +**错误码**: + +| 错误码ID | 错误信息 | +| ------- | -------- | +| 16000011 | The context does not exist. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md index 618cae585d94f5d1bbfbfd1204672925147bd38d..8fe7e62465b288d5468dee12bb58174c4d62eec6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-context.md @@ -20,7 +20,7 @@ Context模块提供了ability或application的上下文的能力,包括访问 | filesDir | string | 是 | 否 | 文件目录。 | | databaseDir | string | 是 | 否 | 数据库目录。 | | preferencesDir | string | 是 | 否 | preferences目录。 | -| bundleCodeDir | string | 是 | 否 | 安装包目录。 | +| bundleCodeDir | string | 是 | 否 | 安装包目录。不能拼接路径访问资源文件,请使用[资源管理接口](js-apis-resource-manager.md)访问资源。 | | distributedFilesDir | string | 是 | 否 | 分布式文件目录。 | | eventHub | [EventHub](js-apis-inner-application-eventHub.md) | 是 | 否 | 事件中心,提供订阅、取消订阅、触发事件对象。 | | area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | 是 | 否 | 文件分区信息。 | @@ -47,14 +47,6 @@ createBundleContext(bundleName: string): Context; | -------- | -------- | | Context | 安装包的上下文。 | -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | - -以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 - **示例:** ```ts @@ -86,14 +78,6 @@ createModuleContext(moduleName: string): Context; | -------- | -------- | | Context | 模块的上下文。 | -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | - -以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 - **示例:** ```ts @@ -126,14 +110,6 @@ createModuleContext(bundleName: string, moduleName: string): Context; | -------- | -------- | | Context | 模块的上下文。 | -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | -------------------------------- | -| 401 | If the input parameter is not valid parameter. | - -以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 - **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md index 15734b7eb09bd941548b4ec9f1cfd6a63fe4697d..5b67f57681d99f95499a3d05165e8db1a95ad265 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md @@ -41,6 +41,18 @@ startAbility(want: Want, callback: AsyncCallback<void>): void **系统能力**:SystemCapability.Ability.Form +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16500101 | The application is not a system application. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -98,6 +110,18 @@ startAbility(want: Want): Promise<void> | ------------ | ---------------------------------- | | Promise<void> | 无返回结果的Promise对象。 | +**错误码:** + +| 错误码ID | 错误信息 | +| -------- | -------- | +| 202 | The application is not a system application. | +| 401 | If the input parameter is not valid parameter. | +| 16500050 | An IPC connection error happened. | +| 16500100 | Failed to obtain the configuration information. | +| 16500101 | The application is not a system application. | +| 16501000 | An internal functional error occurred. | +|以上错误码的详细介绍请参见[卡片错误码](../errorcodes/errorcode-form.md)。|| + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md index 38e5c8b92677af47b7493f8d841b425c75460387..70bf03ef4bfefc91a671814da61b308c289cbf25 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md @@ -46,26 +46,21 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -118,26 +113,21 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -188,26 +178,21 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -264,27 +249,21 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -340,27 +319,21 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -425,27 +398,21 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000010 | Can not operation with continue flag. | -| 16000011 | Context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | -| 16000051 | Network error. The network is abnormal. | -| 16000052 | Free install not support. The application does not support freeinstall | -| 16000053 | Not top ability. The application is not top ability. | -| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry. | -| 16000055 | Free install timeout. | -| 16000056 | Can not free install other ability. | -| 16000057 | Not support cross device free install. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -497,18 +464,16 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -561,18 +526,16 @@ startServiceExtensionAbility(want: Want): Promise\<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -623,19 +586,16 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -693,19 +653,16 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\ | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -754,15 +711,15 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -815,15 +772,15 @@ stopServiceExtensionAbility(want: Want): Promise\<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -874,16 +831,15 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -940,16 +896,15 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\< | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000006 | Can not cross user operations. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16200001 | Caller released. The caller has been released. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -997,12 +952,14 @@ terminateSelf(callback: AsyncCallback<void>): void; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -1038,12 +995,14 @@ terminateSelf(): Promise<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | -| 16000011 | Context does not exist. | -| 16000050 | Internal Error. | +| 16000001 | The specified ability does not exist. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** @@ -1084,14 +1043,13 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | | 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000011 | Context does not exist. | +| 16000005 | The specified process does not have the permission. | +| 16000011 | The context does not exist. | | 16000050 | Internal Error. | +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1145,15 +1103,13 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | | 16000001 | Input error. The specified ability name does not exist. | -| 16000002 | Ability type error. The specified ability type is wrong. | -| 16000004 | Visibility verification failed. | -| 16000006 | Can not cross user operations. | -| 16000011 | Context does not exist. | +| 16000005 | The specified process does not have the permission. | +| 16000011 | The context does not exist. | | 16000050 | Internal Error. | +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1202,13 +1158,11 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback< | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000003 | Input error. The specified id does not exist. | -| 16000011 | Context does not exist. | +| 16000011 | The context does not exist. | | 16000050 | Internal Error. | +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1259,13 +1213,11 @@ disconnectServiceExtensionAbility(connection: number): Promise<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | -| 16000001 | Input error. The specified ability name does not exist. | -| 16000003 | Input error. The specified id does not exist. | -| 16000011 | Context does not exist. | +| 16000011 | The context does not exist. | | 16000050 | Internal Error. | +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 + **示例:** ```ts @@ -1322,16 +1274,17 @@ startAbilityByCall(want: Want): Promise<Caller>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 201 | The application does not have permission to call the interface. | -| 401 | Invalid input parameter. | | 16000001 | Input error. The specified ability name does not exist. | +| 16000002 | Incorrect ability type. | | 16000004 | Visibility verification failed. | | 16000005 | Static permission denied. The specified process does not have the permission. | -| 16000007 | Service busyness. There are concurrent tasks, waiting for retry. | +| 16000006 | Cross-user operations are not allowed. | | 16000008 | Crowdtest App Expiration. | -| 16000009 | Can not start ability in wukong mode. | -| 16000017 | The previous ability is starting, wait start later. | +| 16000011 | The context does not exist. | | 16000050 | Internal Error. | +| 16200001 | The caller has been released. | + +以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)。 **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md index 014aef08334b4be383b7f56529ba5be43f2caa83..af98dbea4d4b39c5800d3f9ff5ee606929da3c71 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md @@ -54,12 +54,13 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -118,12 +119,13 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -191,12 +193,13 @@ startAbility(want: Want, options?: StartOptions): Promise<void>; | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -260,12 +263,13 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -328,12 +332,13 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -406,12 +411,13 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityRes | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -477,12 +483,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncC | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -549,12 +556,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOp | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -629,12 +637,13 @@ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartO | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -693,6 +702,8 @@ startServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -747,6 +758,8 @@ startServiceExtensionAbility(want: Want): Promise\<void>; | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -805,6 +818,8 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -863,6 +878,8 @@ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\ | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -917,6 +934,8 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void; | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -970,6 +989,8 @@ stopServiceExtensionAbility(want: Want): Promise\<void>; | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1027,6 +1048,8 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1084,6 +1107,8 @@ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\< | 16000050 | Internal error. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1135,6 +1160,8 @@ terminateSelf(callback: AsyncCallback<void>): void; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1180,6 +1207,8 @@ terminateSelf(): Promise<void>; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1226,6 +1255,8 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1288,6 +1319,8 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1348,6 +1381,8 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1414,6 +1449,8 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1469,11 +1506,11 @@ disconnectServiceExtensionAbility(connection: number): Promise\<void>; | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 16000001 | The specified ability does not exist. | -| 16000005 | The specified process does not have the permission. | | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1517,11 +1554,11 @@ disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\<vo | 错误码ID | 错误信息 | | ------- | -------------------------------- | -| 16000001 | The specified ability does not exist. | -| 16000005 | The specified process does not have the permission. | | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1581,15 +1618,12 @@ startAbilityByCall(want: Want): Promise<Caller>; | 16000005 | The specified process does not have the permission. | | 16000006 | Cross-user operations are not allowed. | | 16000008 | The crowdtesting application expires. | -| 16000009 | An ability cannot be started or stopped in Wukong mode. | -| 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | -| 16000053 | The ability is not on the top of the UI. | -| 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** 后台启动: @@ -1691,12 +1725,13 @@ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\< | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1763,12 +1798,13 @@ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, ca | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1837,12 +1873,13 @@ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): | 16000009 | An ability cannot be started or stopped in Wukong mode. | | 16000010 | The call with the continuation flag is forbidden. | | 16000011 | The context does not exist. | -| 16000017 | The previous ability is starting, wait start later. | | 16000050 | Internal error. | | 16000053 | The ability is not on the top of the UI. | | 16000055 | Installation-free timed out. | | 16200001 | The caller has been released. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1887,6 +1924,15 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; | label | string | 是 | 显示名称。 | | callback | AsyncCallback<void> | 是 | 回调函数,返回接口调用是否成功的结果。 | +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1922,6 +1968,8 @@ setMissionLabel(label: string): Promise<void>; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -1955,6 +2003,8 @@ setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -2010,6 +2060,8 @@ setMissionIcon(icon: image.PixelMap): Promise\<void>; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -2057,6 +2109,8 @@ restoreWindowStage(localStorage: LocalStorage) : void; | 16000011 | The context does not exist. | | 16000050 | Internal error. | +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -2083,7 +2137,8 @@ isTerminating(): boolean; | 错误码ID | 错误信息 | | ------- | -------------------------------- | | 16000011 | The context does not exist. | -| 16000050 | Internal error. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) **示例:** @@ -2112,6 +2167,26 @@ requestDialogService(want: Want, result: AsyncCallback<dialogRequest.RequestR | want |[Want](js-apis-application-want.md) | 是 | 启动ServiceExtensionAbility的want信息。 | | result | AsyncCallback<[dialogRequest.RequestResult](js-apis-app-ability-dialogRequest.md)> | 是 | 执行结果回调函数。 | +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts @@ -2165,6 +2240,26 @@ requestDialogService(want: Want): Promise<dialogRequest.RequestResult>; | -------- | -------- | | Promise<[dialogRequest.RequestResult](js-apis-app-ability-dialogRequest.md)> | Promise形式返回执行结果。 +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | -------------------------------- | +| 16000001 | The specified ability does not exist. | +| 16000002 | Incorrect ability type. | +| 16000004 | Can not start invisible component. | +| 16000005 | The specified process does not have the permission. | +| 16000006 | Cross-user operations are not allowed. | +| 16000008 | The crowdtesting application expires. | +| 16000009 | An ability cannot be started or stopped in Wukong mode. | +| 16000010 | The call with the continuation flag is forbidden. | +| 16000011 | The context does not exist. | +| 16000050 | Internal error. | +| 16000053 | The ability is not on the top of the UI. | +| 16000055 | Installation-free timed out. | +| 16200001 | The caller has been released. | + +错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md) + **示例:** ```ts diff --git a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md index f2db1e53ae0af47c9e82a6998952f0ed256afbdb..c2463df35c5ce4a5c4cf18bd2d9f4fd122417817 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md +++ b/zh-cn/application-dev/reference/apis/js-apis-nfcTag.md @@ -766,7 +766,7 @@ NFC服务在读取到标签时给出的对象,通过改对象属性,应用 | -------- | -------- | -------- | -------- | -------- | | uid<sup>9+</sup> | number[] | 是 | 否 | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。| | technology<sup>9+</sup> | number[] | 是 | 否 | 支持的技术类型,每个number值表示所支持技术类型的常量值。 | -| supportedProfiles | number[] | 是 | 否 | 支持的技术类型,从API9开始不支持,使用[tag.TagInfo#technology](#taginfo)替代。| +| supportedProfiles | number[] | 是 | 否 | 支持的技术类型,从API9开始不支持,使用[tag.TagInfo#technology](#tagtaginfo)替代。| | extrasData<sup>9+</sup> | [PacMap](js-apis-inner-application-pacMap.md)[] | 是 | 否 | 标签所支持技术的扩展属性值。<br>**系统接口:** 此接口为系统接口。| | tagRfDiscId<sup>9+</sup> | number | 是 | 否 | 标签发现时分配的ID值。<br>**系统接口:** 此接口为系统接口。| | remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 否 | NFC服务进程的远端对象,用于客户端和服务之间的接口通信。<br>**系统接口:** 此接口为系统接口。| diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md index c1c30a09a349303b3daaa6c28f8df9216421a066..7384faeb10636aa3850ae29e789a07cc47d1d079 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationManager.md @@ -33,12 +33,14 @@ publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600004 | Notification is not enabled. | | 1600005 | Notification slot is not enabled. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -86,12 +88,15 @@ publish(request: NotificationRequest): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600004 | Notification is not enabled. | | 1600005 | Notification slot is not enabled. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -140,6 +145,8 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -147,6 +154,7 @@ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<v | 1600005 | Notification slot is not enabled. | | 1600008 | The user is not exist. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -201,6 +209,8 @@ publish(request: NotificationRequest, userId: number): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 201 | Permission denied. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -208,6 +218,7 @@ publish(request: NotificationRequest, userId: number): Promise\<void\> | 1600005 | Notification slot is not enabled. | | 1600008 | The user is not exist. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -254,6 +265,7 @@ cancel(id: number, label: string, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -294,6 +306,7 @@ cancel(id: number, label?: string): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -328,6 +341,7 @@ cancel(id: number, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -361,6 +375,7 @@ cancelAll(callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -399,6 +414,7 @@ cancelAll(): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -436,9 +452,13 @@ addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -482,9 +502,13 @@ addSlot(slot: NotificationSlot): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -519,9 +543,11 @@ addSlot(type: SlotType, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -557,9 +583,11 @@ addSlot(type: SlotType): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -594,9 +622,13 @@ addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): voi | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -644,9 +676,13 @@ addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -685,6 +721,7 @@ getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -730,6 +767,7 @@ getSlot(slotType: SlotType): Promise\<NotificationSlot\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -763,6 +801,7 @@ getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -801,6 +840,7 @@ getSlots(): Promise\<Array\<NotificationSlot\>> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -834,6 +874,7 @@ removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -873,6 +914,7 @@ removeSlot(slotType: SlotType): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -906,6 +948,7 @@ removeAllSlots(callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -937,6 +980,7 @@ removeAllSlots(): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -975,6 +1019,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1021,6 +1068,9 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1062,6 +1112,9 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1113,6 +1166,9 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1153,6 +1209,9 @@ isNotificationEnabled(callback: AsyncCallback\<boolean\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1201,6 +1260,9 @@ isNotificationEnabled(): Promise\<boolean\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1240,6 +1302,9 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1286,6 +1351,9 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1327,6 +1395,9 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1378,6 +1449,9 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1412,10 +1486,11 @@ setBadgeNumber(badgeNumber: number): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600012 | No memory space. | +| 1600012 | No memory space. | **示例:** @@ -1447,10 +1522,11 @@ setBadgeNumber(badgeNumber: number, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | -| 1600012 | No memory space. | +| 1600012 | No memory space. | **示例:** @@ -1493,6 +1569,9 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1542,6 +1621,9 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1586,6 +1668,9 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1637,6 +1722,9 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1678,6 +1766,9 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1729,6 +1820,9 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1768,6 +1862,9 @@ getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>) | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1810,6 +1907,9 @@ getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1842,6 +1942,7 @@ getActiveNotificationCount(callback: AsyncCallback\<number\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1880,6 +1981,7 @@ getActiveNotificationCount(): Promise\<number\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1912,6 +2014,7 @@ getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): v | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1950,6 +2053,7 @@ getActiveNotifications(): Promise\<Array\<[NotificationRequest](js-apis-inner-no | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -1983,6 +2087,7 @@ cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2023,6 +2128,7 @@ cancelGroup(groupName: string): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2062,6 +2168,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2109,6 +2218,9 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2149,9 +2261,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): vo | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -2197,9 +2313,13 @@ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -2241,10 +2361,14 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallb | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600008 | The user is not exist. | +| 1600012 | No memory space. | **示例:** @@ -2293,10 +2417,14 @@ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600008 | The user is not exist. | +| 1600012 | No memory space. | **示例:** @@ -2339,9 +2467,13 @@ getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -2381,9 +2513,13 @@ getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -2419,10 +2555,14 @@ getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>) | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600008 | The user is not exist. | +| 1600012 | No memory space. | **示例:** @@ -2470,10 +2610,14 @@ getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | | 1600008 | The user is not exist. | +| 1600012 | No memory space. | **示例:** @@ -2508,6 +2652,9 @@ notificationManager.getDoNotDisturbDate(userId).then((data) => { | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2550,6 +2697,9 @@ isSupportDoNotDisturbMode(): Promise\<boolean\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2583,6 +2733,7 @@ isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): voi | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2629,6 +2780,7 @@ isSupportTemplate(templateName: string): Promise\<boolean\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2664,6 +2816,7 @@ requestEnableNotification(callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2696,6 +2849,7 @@ requestEnableNotification(): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2735,6 +2889,9 @@ setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2780,6 +2937,9 @@ setDistributedEnable(enable: boolean): Promise\<void> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2816,6 +2976,7 @@ isDistributedEnabled(callback: AsyncCallback\<boolean>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2857,6 +3018,7 @@ isDistributedEnabled(): Promise\<boolean> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2898,6 +3060,9 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2951,6 +3116,9 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -2996,6 +3164,9 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3050,6 +3221,9 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3093,6 +3267,9 @@ getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3135,6 +3312,9 @@ getDeviceRemindType(): Promise\<DeviceRemindType\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3175,6 +3355,9 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3182,6 +3365,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 1600005 | Notification slot is not enabled. | | 1600008 | The user is not exist. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -3241,6 +3425,9 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 错误码ID | 错误信息 | | -------- | ----------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3248,6 +3435,7 @@ publishAsBundle(request: NotificationRequest, representativeBundle: string, user | 1600005 | Notification slot is not enabled. | | 1600008 | The user is not exist. | | 1600009 | Over max number notifications per second. | +| 1600012 | No memory space. | **示例:** @@ -3303,6 +3491,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number, callbac | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3356,6 +3547,9 @@ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promis | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3402,6 +3596,9 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3452,6 +3649,9 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3495,6 +3695,9 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3549,6 +3752,9 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3591,6 +3797,9 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3645,6 +3854,9 @@ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\< | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3689,6 +3901,9 @@ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<bo | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -3741,6 +3956,9 @@ getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md index cfc61dacf914744662371b7530e785f3d0e97474..0d986594532e10b6a7e6070b0d7db089322fabd6 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -40,9 +40,13 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -92,9 +96,13 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -142,9 +150,13 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | +| 1600012 | No memory space. | **示例:** @@ -187,6 +199,9 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>) | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -234,6 +249,9 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -279,6 +297,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -334,6 +355,9 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -382,6 +406,9 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -428,6 +455,9 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -468,6 +498,9 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -513,6 +546,9 @@ removeAll(callback: AsyncCallback\<void\>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -555,6 +591,9 @@ removeAll(bundle?: BundleOption): Promise\<void\> | 错误码ID | 错误信息 | | -------- | ---------------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -594,6 +633,9 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | @@ -639,6 +681,9 @@ removeAll(userId: number): Promise\<void> | 错误码ID | 错误信息 | | -------- | ----------------------------------- | +| 201 | Permission denied. | +| 202 | Not system application to call the interface. | +| 401 | The parameter check failed. | | 1600001 | Internal error. | | 1600002 | Marshalling or unmarshalling error. | | 1600003 | Failed to connect service. | diff --git a/zh-cn/application-dev/reference/apis/js-apis-router.md b/zh-cn/application-dev/reference/apis/js-apis-router.md index fde185a857f3003328e25b39b80d3838061c6fd2..327ed78c6492ac9cd1e821841783e9f7116f7219 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-router.md +++ b/zh-cn/application-dev/reference/apis/js-apis-router.md @@ -573,8 +573,8 @@ router.getParams(); | 名称 | 说明 | | -------- | ------------------------------------------------------------ | -| Standard | 标准模式。 <br/>目标页面会被添加到页面路由栈顶,无论栈中是否存在相同url的页面。<br/>**说明:** 不使用路由跳转模式时,按标准模式跳转。 | -| Single | 单实例模式。<br/>如果目标页面的url在页面栈中已经存在同url页面,离栈顶最近的页面会被移动到栈顶,移动后的页面为新建页。<br/>如目标页面的url在页面栈中不存在同url页面,按标准模式跳转。 | +| Standard | 多实例模式,也是默认情况下的跳转模式。 <br/>目标页面会被添加到页面栈顶,无论栈中是否存在相同url的页面。<br/>**说明:** 不使用路由跳转模式时,则按照默认的多实例模式进行跳转。 | +| Single | 单实例模式。<br/>如果目标页面的url已经存在于页面栈中,则会将离栈顶最近的同url页面移动到栈顶,该页面成为新建页。<br />如果目标页面的url在页面栈中不存在同url页面,则按照默认的多实例模式进行跳转。 | ## 完整示例 diff --git a/zh-cn/application-dev/reference/apis/js-apis-rpc.md b/zh-cn/application-dev/reference/apis/js-apis-rpc.md index edf7e7169821b9950ddd0f7cd28cd2e6df300c16..b5e1808f23bee943f177affcdf7d733e883975a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-rpc.md +++ b/zh-cn/application-dev/reference/apis/js-apis-rpc.md @@ -97,9 +97,9 @@ writeRemoteObject(object: [IRemoteObject](#iremoteobject)): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900008 | proxy or remote object is invalid | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | + | 1900009 | write data to message sequence failed | **示例:** @@ -138,9 +138,9 @@ readRemoteObject(): IRemoteObject 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | + | 1900010 | read data from message sequence failed | **示例:** @@ -180,8 +180,8 @@ writeInterfaceToken(token: string): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -214,8 +214,8 @@ readInterfaceToken(): string 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ----- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -266,7 +266,7 @@ getCapacity(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ----- | | number | 获取的MessageSequence实例的容量大小。以字节为单位。 | @@ -288,7 +288,7 @@ setSize(size: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------ | | size | number | 是 | MessageSequence实例的数据大小。以字节为单位。 | @@ -324,8 +324,8 @@ setCapacity(size: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------ | - | 1900011 | parcel memory alloc failed | + | -------- | -------- | + | 1900011 | parcel memory alloc failed | **示例:** @@ -350,7 +350,7 @@ getWritableBytes(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ------ | | number | 获取到的MessageSequence实例的可写字节空间。以字节为单位。 | @@ -376,7 +376,7 @@ getReadableBytes(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ------- | | number | 获取到的MessageSequence实例的可读字节空间。以字节为单位。 | @@ -402,7 +402,7 @@ getReadPosition(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ------ | | number | 返回MessageSequence实例中的当前读取位置。 | @@ -424,7 +424,7 @@ getWritePosition(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ----- | | number | 返回MessageSequence实例中的当前写入位置。 | @@ -447,7 +447,7 @@ rewindRead(pos: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------- | | pos | number | 是 | 开始读取数据的目标位置。 | @@ -479,7 +479,7 @@ rewindWrite(pos: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ----- | | pos | number | 是 | 开始写入数据的目标位置。 | @@ -509,17 +509,17 @@ writeByte(val: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----- | ------ | ---- | ----- | - | val | number | 是 | 要写入的字节值。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ----- | + | val | number | 是 | 要写入的字节值。 | **错误码:** 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | ------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -543,7 +543,7 @@ readByte(): number **返回值:** - | 类型 | 说明 | + | 类型 | 说明 | | ------ | ----- | | number | 返回字节值。 | @@ -585,16 +585,16 @@ writeShort(val: number): void **参数:** | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | --- | --- | - | val | number | 是 | 要写入的短整数值。 | + | ------ | ------ | --- | --- | + | val | number | 是 | 要写入的短整数值。 | **错误码:** 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------ | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -627,8 +627,8 @@ readShort(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -668,8 +668,8 @@ writeInt(val: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -702,8 +702,8 @@ readInt(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -743,8 +743,8 @@ writeLong(val: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -777,8 +777,8 @@ readLong(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -809,17 +809,17 @@ writeFloat(val: number): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----- | ---- | ---- | ----- | - | val | number | 是 | 要写入的浮点值。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ----- | + | val | number | 是 | 要写入的浮点值。 | **错误码:** 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -852,8 +852,8 @@ readFloat(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -893,8 +893,8 @@ writeDouble(val: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -927,8 +927,8 @@ readDouble(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -968,8 +968,8 @@ writeBoolean(val: boolean): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1002,8 +1002,8 @@ readBoolean(): boolean 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1043,8 +1043,8 @@ writeChar(val: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1077,8 +1077,8 @@ readChar(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------ | --------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1118,8 +1118,8 @@ writeString(val: string): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1152,8 +1152,8 @@ readString(): string 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1193,8 +1193,8 @@ writeParcelable(val: Parcelable): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1239,16 +1239,16 @@ readParcelable(dataIn: Parcelable): void | 参数名 | 类型 | 必填 | 说明 | | ------ | ------------------------- | ---- | ----------------------------------------- | - | dataIn | Parcelable | 是 | 需要从MessageSequence读取成员变量的对象。 | + | dataIn | Parcelable | 是 | 需要从MessageSequence读取成员变量的对象。 | **错误码:** 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900010 | read data from message sequence failed | - | 1900012 | call js callback function failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **示例:** @@ -1302,8 +1302,8 @@ writeByteArray(byteArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1337,8 +1337,8 @@ readByteArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1379,8 +1379,8 @@ readByteArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1421,8 +1421,8 @@ writeShortArray(shortArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ----- | ----- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1455,8 +1455,8 @@ readShortArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------ | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1496,8 +1496,8 @@ readShortArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1537,8 +1537,8 @@ writeIntArray(intArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ----- | --------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1571,8 +1571,8 @@ readIntArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1612,8 +1612,8 @@ readIntArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ----- | ------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1653,8 +1653,8 @@ writeLongArray(longArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ----- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1687,8 +1687,8 @@ readLongArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------ | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1728,8 +1728,8 @@ readLongArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1769,8 +1769,8 @@ writeFloatArray(floatArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1803,8 +1803,8 @@ readFloatArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1844,8 +1844,8 @@ readFloatArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1885,8 +1885,8 @@ writeDoubleArray(doubleArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -1919,8 +1919,8 @@ readDoubleArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -1960,8 +1960,8 @@ readDoubleArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2001,8 +2001,8 @@ writeBooleanArray(booleanArray: boolean[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2035,8 +2035,8 @@ readBooleanArray(dataIn: boolean[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2076,8 +2076,8 @@ readBooleanArray(): boolean[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2117,8 +2117,8 @@ writeCharArray(charArray: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------ | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2151,8 +2151,8 @@ readCharArray(dataIn: number[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2192,8 +2192,8 @@ readCharArray(): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2234,8 +2234,8 @@ writeStringArray(stringArray: string[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2268,8 +2268,8 @@ readStringArray(dataIn: string[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2309,8 +2309,8 @@ readStringArray(): string[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2344,8 +2344,8 @@ writeNoException(): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2386,15 +2386,17 @@ readException(): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -2412,7 +2414,11 @@ readException(): void "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息 @@ -2466,8 +2472,8 @@ writeParcelableArray(parcelableArray: Parcelable[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2522,9 +2528,9 @@ readParcelableArray(parcelableArray: Parcelable[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | - | 1900012 | call js callback function failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | + | 1900012 | call js callback function failed | **示例:** @@ -2583,8 +2589,8 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -2630,8 +2636,8 @@ readRemoteObjectArray(objects: IRemoteObject[]): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2683,8 +2689,8 @@ readRemoteObjectArray(): IRemoteObject[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -2729,11 +2735,11 @@ static closeFileDescriptor(fd: number): void **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); try { - rpc.MessageSequence.closeFileDescriptor(fd); + rpc.MessageSequence.closeFileDescriptor(file.fd); } catch(error) { console.info("rpc close file descriptor fail, errorCode " + error.code); console.info("rpc close file descriptor fail, errorMessage" + error.message); @@ -2765,17 +2771,17 @@ static dupFileDescriptor(fd: number) :number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900013 | call os dup function failed | + | -------- | -------- | + | 1900013 | call os dup function failed | **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); try { - let newFd = rpc.MessageSequence.dupFileDescriptor(fd); + let newFd = rpc.MessageSequence.dupFileDescriptor(file.fd); } catch(error) { console.info("rpc dup file descriptor fail, errorCode " + error.code); console.info("rpc dup file descriptor fail, errorMessage" + error.message); @@ -2800,13 +2806,13 @@ containFileDescriptors(): boolean ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; let r1 = sequence.containFileDescriptors(); - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); try { - sequence.writeFileDescriptor(fd); + sequence.writeFileDescriptor(file.fd); } catch(error) { console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorMessage" + error.message); @@ -2839,18 +2845,18 @@ writeFileDescriptor(fd: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------ | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); try { - sequence.writeFileDescriptor(fd); + sequence.writeFileDescriptor(file.fd); } catch(error) { console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorMessage" + error.message); @@ -2876,18 +2882,18 @@ readFileDescriptor(): number 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let sequence = new rpc.MessageSequence(); let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); try { - sequence.writeFileDescriptor(fd); + sequence.writeFileDescriptor(file.fd); } catch(error) { console.info("rpc write file descriptor fail, errorCode " + error.code); console.info("rpc write file descriptor fail, errorMessage" + error.message); @@ -2919,8 +2925,8 @@ writeAshmem(ashmem: Ashmem): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------- | - | 1900003 | write to ashmem failed | + | -------- | ------- | + | 1900003 | write to ashmem failed | **示例:** @@ -2961,8 +2967,8 @@ readAshmem(): Ashmem 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900004 | read from ashmem failed | + | -------- | -------- | + | 1900004 | read from ashmem failed | **示例:** @@ -3032,8 +3038,8 @@ writeRawData(rawData: number[], size: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------ | - | 1900009 | write data to message sequence failed | + | -------- | -------- | + | 1900009 | write data to message sequence failed | **示例:** @@ -3073,8 +3079,8 @@ readRawData(size: number): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900010 | read data from message sequence failed | + | -------- | -------- | + | 1900010 | read data from message sequence failed | **示例:** @@ -4027,8 +4033,8 @@ writeSequenceable(val: Sequenceable): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4068,14 +4074,14 @@ readSequenceable(dataIn: Sequenceable): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ----------------------------- | ---- | --------------------------------------- | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------- | ------- | ---------------------------------------------- | | dataIn | [Sequenceable](#sequenceabledeprecated) | 是 | 需要从MessageParcel读取成员变量的对象。 | **返回值:** - | 类型 | 说明 | - | ------- | ------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:反序列化成功,false:反序列化失败。| **示例:** @@ -4124,8 +4130,8 @@ writeByteArray(byteArray: number[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4203,8 +4209,8 @@ writeShortArray(shortArray: number[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4279,8 +4285,8 @@ writeIntArray(intArray: number[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4425,14 +4431,14 @@ writeFloatArray(floatArray: number[]): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ---------- | -------- | ---- | --- | | floatArray | number[] | 是 | 要写入的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4453,7 +4459,7 @@ readFloatArray(dataIn: number[]): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------ | -------- | ---- | ------ | | dataIn | number[] | 是 | 要读取的浮点数组。由于系统内部对float类型的数据是按照double处理的,使用时对于数组所占的总字节数应按照double类型来计算。 | @@ -4507,8 +4513,8 @@ writeDoubleArray(doubleArray: number[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4583,8 +4589,8 @@ writeBooleanArray(booleanArray: boolean[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4659,8 +4665,8 @@ writeCharArray(charArray: number[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4729,14 +4735,14 @@ writeStringArray(stringArray: string[]): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ----------- | -------- | ---- | ---------------- | | stringArray | string[] | 是 | 要写入的字符串数组,数组单个元素的长度应小于40960字节。 | **返回值:** | 类型 | 说明 | - | ------- | --------------------------------- | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -4846,11 +4852,13 @@ readException(): void **系统能力**:SystemCapability.Communication.IPC.Core **示例:** - - 获取服务 + + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.;featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -4868,7 +4876,11 @@ readException(): void "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息 @@ -4914,8 +4926,8 @@ writeSequenceableArray(sequenceableArray: Sequenceable[]): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -5004,14 +5016,14 @@ writeRemoteObjectArray(objectArray: IRemoteObject[]): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ----------- | --------------- | ---- | ----- | | objectArray | IRemoteObject[] | 是 | 要写入MessageParcel的IRemoteObject对象数组。 | **返回值:** | 类型 | 说明 | - | ------- | -------------------------------------------------------------------------------------------------------------------- | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -5056,7 +5068,7 @@ readRemoteObjectArray(objects: IRemoteObject[]): void **参数:** - | 参数名 | 类型 | 必填 | 说明 | + | 参数名 | 类型 | 必填 | 说明 | | ------- | --------------- | ---- | --------- | | objects | IRemoteObject[] | 是 | 从MessageParcel读取的IRemoteObject对象数组。 | @@ -5103,8 +5115,8 @@ readRemoteObjectArray(): IRemoteObject[] **返回值:** - | 类型 | 说明 | - | --------------- | -------- | + | 类型 | 说明 | + | --------------- | --------------------------- | | IRemoteObject[] | 返回IRemoteObject对象数组。 | **示例:** @@ -5158,10 +5170,10 @@ static closeFileDescriptor(fd: number): void **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - rpc.MessageParcel.closeFileDescriptor(fd); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + rpc.MessageParcel.closeFileDescriptor(file.fd); ``` ### dupFileDescriptor<sup>8+</sup> @@ -5187,10 +5199,10 @@ static dupFileDescriptor(fd: number) :number **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let newFd = rpc.MessageParcel.dupFileDescriptor(fd); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let newFd = rpc.MessageParcel.dupFileDescriptor(file.fd); ``` ### containFileDescriptors<sup>8+</sup> @@ -5203,19 +5215,19 @@ containFileDescriptors(): boolean **返回值:** - | 类型 | 说明 | - | ------- | ------------------------------------------------------------------ | + | 类型 | 说明 | + | ------- | --------------------------------------------- | | boolean |true:包含文件描述符,false:未包含文件描述符。| **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let parcel = new rpc.MessageParcel(); let filePath = "path/to/file"; let r1 = parcel.containFileDescriptors(); - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let writeResult = parcel.writeFileDescriptor(file.fd); console.log("RpcTest: parcel writeFd result is : " + writeResult); let containFD = parcel.containFileDescriptors(); console.log("RpcTest: parcel after write fd containFd result is : " + containFD); @@ -5237,18 +5249,18 @@ writeFileDescriptor(fd: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:操作成功,false:操作失败。| **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let parcel = new rpc.MessageParcel(); let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let writeResult = parcel.writeFileDescriptor(file.fd); console.log("RpcTest: parcel writeFd result is : " + writeResult); ``` @@ -5269,11 +5281,11 @@ readFileDescriptor(): number **示例:** ```ts - import fileio from '@ohos.fileio'; + import fs from '@ohos.file.fs'; let parcel = new rpc.MessageParcel(); let filePath = "path/to/file"; - let fd = fileio.openSync(filePath, 0o2| 0o100, 0o666); - let writeResult = parcel.writeFileDescriptor(fd); + let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let writeResult = parcel.writeFileDescriptor(file.fd); let readFD = parcel.readFileDescriptor(); console.log("RpcTest: parcel read fd is : " + readFD); ``` @@ -5294,8 +5306,8 @@ writeAshmem(ashmem: Ashmem): boolean **返回值:** - | 类型 | 说明 | - | ------- | -------------------------------------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -5371,8 +5383,8 @@ writeRawData(rawData: number[], size: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:写入成功,false:写入失败。| **示例:** @@ -5435,9 +5447,9 @@ marshalling(dataOut: MessageSequence): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | - | boolean | true:封送成功,false:封送失败。 + | 类型 | 说明 | + | ------- | -------------------------------- | + | boolean | true:封送成功,false:封送失败。| **示例:** ```ts @@ -5484,8 +5496,8 @@ unmarshalling(dataIn: MessageSequence): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:反序列化成功,false:反序列化失败。| **示例:** @@ -5534,15 +5546,15 @@ marshalling(dataOut: MessageParcel): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | ----------------------------------------- | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | ----------------------------------------- | | dataOut | [MessageParcel](#messageparceldeprecated) | 是 | 可序列对象将被封送到的MessageParcel对象。 | **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | - | boolean | true:封送成功,false:封送失败。 + | 类型 | 说明 | + | ------- | -------------------------------- | + | boolean | true:封送成功,false:封送失败。 | **示例:** ```ts @@ -5583,14 +5595,14 @@ unmarshalling(dataIn: MessageParcel): boolean **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------------------------------- | ---- | --------------------------------------------- | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------------------- | ---- | --------------------------------------------- | | dataIn | [MessageParcel](#messageparceldeprecated) | 是 | 已将可序列对象封送到其中的MessageParcel对象。 | **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:反序列化成功,false:反序列化失败。| **示例:** @@ -5637,8 +5649,8 @@ asObject(): IRemoteObject **返回值:** - | 类型 | 说明 | - | ---- | ----- | + | 类型 | 说明 | + | ----- | ----- | | [IRemoteObject](#iremoteobject) | 如果调用者是RemoteObject对象,则直接返回本身;如果调用者是[RemoteProxy](#remoteproxy)对象,则返回它的持有者[IRemoteObject](#iremoteobject)。 | **示例:** @@ -5654,20 +5666,22 @@ asObject(): IRemoteObject **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { - onConnect: function (elementName, remoteProxy) { + onConnect: function(elementName, remoteProxy) { console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function (elementName) { + onDisconnect: function(elementName) { console.log("RpcClient: onDisconnect"); }, - onFailed: function () { + onFailed: function() { console.log("RpcClient: onFailed"); } }; @@ -5675,11 +5689,15 @@ asObject(): IRemoteObject "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` - 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的asObject接口方法获取代理或远端对象 + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的asObject接口方法获取代理或远端对象 + ```ts class TestProxy { remote: rpc.RemoteObject; @@ -5691,7 +5709,6 @@ asObject(): IRemoteObject } } let iRemoteObject = new TestProxy(proxy).asObject(); - ``` ## DeathRecipient @@ -5802,17 +5819,17 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | ---- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:发送成功,false:发送失败。| @@ -5828,12 +5845,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ---------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -5852,12 +5869,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -5876,13 +5893,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | ### sendRequest<sup>8+(deprecated)</sup> @@ -5896,13 +5913,13 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | ### registerDeathRecipient<sup>9+</sup> @@ -5924,8 +5941,8 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | ### addDeathrecipient<sup>(deprecated)</sup> @@ -5946,8 +5963,8 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:回调注册成功,false:回调注册失败。| @@ -5971,8 +5988,8 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | ### removeDeathRecipient<sup>(deprecated)</sup> @@ -5993,8 +6010,8 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | -----------------------------------------| | boolean | true:回调注销成功,false:回调注销失败。| ### getDescriptor<sup>9+</sup> @@ -6016,8 +6033,8 @@ getDescriptor(): string 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | ### getInterfaceDescriptor<sup>(deprecated)</sup> @@ -6047,8 +6064,8 @@ isObjectDead(): boolean **返回值:** - | 类型 | 说明 | - | ------- | ------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------- | | boolean | true:对象死亡,false:对象未死亡。| @@ -6078,25 +6095,27 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------| | boolean | true:发送成功,false:发送失败。| **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6114,11 +6133,15 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` - 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息 + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息 + ```ts let option = new rpc.MessageOption(); let data = rpc.MessageParcel.create(); @@ -6148,12 +6171,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | - | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -6163,10 +6186,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6184,9 +6209,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息 ```ts @@ -6226,12 +6255,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -6241,10 +6270,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6262,7 +6293,11 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息 @@ -6302,20 +6337,22 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | **示例:** - - 获取服务 + + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6346,7 +6383,11 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, result.data.reclaim(); result.reply.reclaim(); } - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendMessageRequest接口方法发送消息 @@ -6358,7 +6399,7 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, data.writeInt(1); data.writeString("hello"); try { - proxy.sendRequest(1, data, reply, option, sendRequestCallback); + proxy.sendMessageRequest(1, data, reply, option, sendRequestCallback); } catch(error) { console.info("rpc send sequence request fail, errorCode " + error.code); console.info("rpc send sequence request fail, errorMessage " + error.message); @@ -6377,20 +6418,22 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | callback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6408,7 +6451,7 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - function sendRequestCallback(result) { + function sendRequestCallback(result) { if (result.errCode === 0) { console.log("sendRequest got result"); result.reply.readException(); @@ -6421,7 +6464,11 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me result.data.reclaim(); result.reply.reclaim(); } - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的sendRequest接口方法发送消息 @@ -6460,22 +6507,24 @@ getLocalInterface(interface: string): IRemoteBroker 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900006 | only remote object permitted | + | -------- | -------- | + | 1900006 | only remote object permitted | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function (elementName) { + onDisconnect: function(elementName) { console.log("RpcClient: onDisconnect"); }, onFailed: function() { @@ -6483,10 +6532,14 @@ getLocalInterface(interface: string): IRemoteBroker } }; let want = { - "bundleName":"com.ohos.server", - "abilityName":"com.ohos.server.EntryAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getLocalInterface接口方法查询接口对象 @@ -6525,17 +6578,19 @@ queryLocalInterface(interface: string): IRemoteBroker **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { console.log("RpcClient: js onConnect called."); proxy = remoteProxy; }, - onDisconnect: function (elementName) { + onDisconnect: function(elementName) { console.log("RpcClient: onDisconnect"); }, onFailed: function() { @@ -6543,12 +6598,16 @@ queryLocalInterface(interface: string): IRemoteBroker } }; let want = { - "bundleName":"com.ohos.server", - "abilityName":"com.ohos.server.EntryAbility", + "bundleName": "com.ohos.server", + "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的queryLocalInterface接口获取接口对象 ```ts @@ -6576,15 +6635,17 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6602,11 +6663,15 @@ registerDeathRecipient(recipient: DeathRecipient, flags: number): void "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的registerDeathRecipient接口注册死亡回调 - + ```ts class MyDeathRecipient { onRemoteDied() { @@ -6641,16 +6706,18 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:回调注册成功,false:回调注册失败。| **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6668,9 +6735,13 @@ addDeathRecipient(recipient: DeathRecipient, flags: number): boolean "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的addDeathRecippient接口方法新增死亡回调 ```ts @@ -6703,15 +6774,17 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6729,9 +6802,13 @@ unregisterDeathRecipient(recipient: DeathRecipient, flags: number): void "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的unregisterDeathRecipient接口方法注销死亡回调 ```ts @@ -6769,16 +6846,18 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------------- | | boolean | true:回调注销成功,false:回调注销失败。| **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6796,9 +6875,13 @@ removeDeathRecipient(recipient: DeathRecipient, flags: number): boolean "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的removeDeathRecipient接口方法去注册死亡回调 ```ts @@ -6831,16 +6914,18 @@ getDescriptor(): string 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900008 | proxy or remote object is invalid | - | 1900007 | communication failed | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | + | 1900007 | communication failed | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6858,7 +6943,11 @@ getDescriptor(): string "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getDescriptor接口方法获取对象的接口描述符 @@ -6890,10 +6979,12 @@ getInterfaceDescriptor(): string **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6911,9 +7002,13 @@ getInterfaceDescriptor(): string "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); - ``` + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); + ``` + 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的getInterfaceDescriptor接口方法查询当前代理对象接口的描述符 ```ts @@ -6931,16 +7026,18 @@ isObjectDead(): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------------------- | - | boolean | true:对应的对象已经死亡,false:对应的对象未死亡| + | 类型 | 说明 | + | ------- | ------------------------------------------------- | + | boolean | true:对应的对象已经死亡,false:对应的对象未死亡 | **示例:** - 获取服务 + Stage模型的应用在获取服务前需要先获取context,具体方法可参考[获取context](#获取context) ```ts - import FA from "@ohos.ability.featureAbility"; + // 仅FA模型需要导入@ohos.ability.featureAbility + // import FA from "@ohos.ability.featureAbility"; + let proxy; let connect = { onConnect: function(elementName, remoteProxy) { @@ -6958,7 +7055,11 @@ isObjectDead(): boolean "bundleName": "com.ohos.server", "abilityName": "com.ohos.server.EntryAbility", }; - FA.connectAbility(want, connect); + + // FA模型使用此方法连接服务 + // FA.connectAbility(want,connect); + + globalThis.context.connectServiceExtensionAbility(want, connect); ``` 上述onConnect回调函数中的proxy对象需要等ability异步连接成功后才会被赋值,然后才可调用proxy对象的isObjectDead接口方法判断当前对象是否已经死亡 @@ -6976,10 +7077,10 @@ isObjectDead(): boolean | 名称 | 值 | 说明 | | ------------- | ---- | ----------------------------------------------------------- | - | TF_SYNC | 0 | 同步调用标识。 | - | TF_ASYNC | 1 | 异步调用标识。 | + | TF_SYNC | 0 | 同步调用标识。 | + | TF_ASYNC | 1 | 异步调用标识。 | | TF_ACCEPT_FDS | 0x10 | 指示sendMessageRequest<sup>9+</sup>接口可以返回文件描述符。 | - | TF_WAIT_TIME | 8 | 默认等待时间(单位/秒)。 | + | TF_WAIT_TIME | 8 | 默认等待时间(单位/秒)。 | ### constructor<sup>9+</sup> @@ -7041,9 +7142,9 @@ isAsync(): boolean; **返回值:** - | 类型 | 说明 | - | ------- | ------------------------------------ | - | boolean | true:同步调用成功,false:异步调用成功。 | + | 类型 | 说明 | + | ------- | ---------------------------------------- | + | boolean | true:同步调用成功,false:异步调用成功。| **示例:** @@ -7349,8 +7450,8 @@ static isLocalCalling(): boolean **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------------------------- | | boolean | true:调用在同一台设备,false:调用未在同一台设备。| **示例:** @@ -7522,8 +7623,8 @@ static setCallingIdentity(identity: string): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | ---------------------------------| | boolean | true:设置成功,false:设置失败。| **示例:** @@ -7575,17 +7676,17 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** - | 类型 | 说明 | - | ------- | --------------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:发送成功,false:发送失败。| **示例:** @@ -7641,12 +7742,12 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -7711,12 +7812,12 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | **返回值:** @@ -7767,13 +7868,13 @@ sendMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------------- | ---------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ------------------------------------ | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | | data | [MessageSequence](#messagesequence9) | 是 | 保存待发送数据的 MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 接收应答数据的MessageSequence对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | AsyncCallback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | AsyncCallback | AsyncCallback<RequestResult> | 是 | 接收发送结果的回调。 | **示例:** @@ -7817,13 +7918,13 @@ sendRequest(code: number, data: MessageParcel, reply: MessageParcel, options: Me **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------------- | -------------------------------------- | ---- | -------------------------------------------------------------------------------------- | - | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | - | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | - | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | - | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | - | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ----------------------------------------- | ---- | -------------------------------------------------------------------------------------- | + | code | number | 是 | 本次请求调用的消息码,由通信双方确定。如果接口由IDL工具生成,则消息代码由IDL自动生成。 | + | data | [MessageParcel](#messageparceldeprecated) | 是 | 保存待发送数据的 MessageParcel对象。 | + | reply | [MessageParcel](#messageparceldeprecated) | 是 | 接收应答数据的MessageParcel对象。 | + | options | [MessageOption](#messageoption) | 是 | 本次请求的同异步模式,默认同步调用。 | + | AsyncCallback | AsyncCallback<SendRequestResult> | 是 | 接收发送结果的回调。 | **示例:** @@ -7881,17 +7982,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里处理 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------------------------------- | ---- | --------------------------------------- | - | code | number | 是 | 对端发送的服务请求码。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ----------------------------------------- | ---- | --------------------------------------- | + | code | number | 是 | 对端发送的服务请求码。 | | data | [MessageParcel](#messageparceldeprecated) | 是 | 携带客户端调用参数的MessageParcel对象。 | | reply | [MessageParcel](#messageparceldeprecated) | 是 | 写入结果的MessageParcel对象。 | - | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | + | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:操作成功,false:操作失败。| **示例:** @@ -7942,17 +8043,17 @@ sendMessageRequest请求的响应处理函数,服务端在该函数里同步 **参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------------------------------- | ---- | ----------------------------------------- | - | code | number | 是 | 对端发送的服务请求码。 | + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------------------------------------ | ---- | ----------------------------------------- | + | code | number | 是 | 对端发送的服务请求码。 | | data | [MessageSequence](#messagesequence9) | 是 | 携带客户端调用参数的MessageSequence对象。 | | reply | [MessageSequence](#messagesequence9) | 是 | 写入结果的MessageSequence对象。 | - | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | + | option | [MessageOption](#messageoption) | 是 | 指示操作是同步还是异步。 | **返回值:** - | 类型 | 说明 | - | ----------------- | ---------------------------------------------------------------------------------------------- | + | 类型 | 说明 | + | ----------------- | ----------------------------------------------------------------------------------------------- | | boolean | 若在onRemoteMessageRequest中同步地处理请求,则返回一个布尔值:true:操作成功,false:操作失败。 | | Promise\<boolean> | 若在onRemoteMessageRequest中异步地处理请求,则返回一个Promise对象。 | @@ -8233,8 +8334,8 @@ getDescriptor(): string 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900008 | proxy or remote object is invalid | + | -------- | -------- | + | 1900008 | proxy or remote object is invalid | **示例:** @@ -8625,8 +8726,8 @@ mapTypedAshmem(mapType: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | ------ | - | 1900001 | call mmap function failed | + | -------- | -------- | + | 1900001 | call mmap function failed | **示例:** @@ -8658,8 +8759,8 @@ mapAshmem(mapType: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:映射成功,false:映射失败。| **示例:** @@ -8683,8 +8784,8 @@ mapReadWriteAshmem(): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900001 | call mmap function failed | + | -------- | -------- | + | 1900001 | call mmap function failed | **示例:** @@ -8710,8 +8811,8 @@ mapReadAndWriteAshmem(): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:映射成功,false:映射失败。| **示例:** @@ -8735,8 +8836,8 @@ mapReadonlyAshmem(): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900001 | call mmap function failed | + | -------- | -------- | + | 1900001 | call mmap function failed | **示例:** @@ -8762,8 +8863,8 @@ mapReadOnlyAshmem(): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:映射成功,false:映射失败。| **示例:** @@ -8793,8 +8894,8 @@ setProtectionType(protectionType: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | -------- | ------- | - | 1900002 | call os ioctl function failed | + | -------- | -------- | + | 1900002 | call os ioctl function failed | **示例:** @@ -8826,8 +8927,8 @@ setProtection(protectionType: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------- | + | 类型 | 说明 | + | ------- | -------------------------------- | | boolean | true:设置成功,false:设置失败。| **示例:** @@ -8859,8 +8960,8 @@ writeAshmem(buf: number[], size: number, offset: number): void 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) | 错误码ID | 错误信息 | - | ------- | -------- | - | 1900003 | write to ashmem failed | + | -------- | -------- | + | 1900003 | write to ashmem failed | **示例:** @@ -8896,9 +8997,9 @@ writeToAshmem(buf: number[], size: number, offset: number): boolean **返回值:** - | 类型 | 说明 | - | ------- | ----------------------------------------------------------------------------------------- | - | boolean | true:如果数据写入成功,false:在其他情况下,如数据写入越界或未获得写入权限。。 | + | 类型 | 说明 | + | ------- | ----------------------------------------------------------------------------- | + | boolean | true:如果数据写入成功,false:在其他情况下,如数据写入越界或未获得写入权限。 | **示例:** @@ -8936,9 +9037,9 @@ readAshmem(size: number, offset: number): number[] 以下错误码的详细介绍请参见[ohos.rpc错误码](../errorcodes/errorcode-rpc.md) - | 错误码ID | 错误信息 | + | 错误码ID | 错误信息 | | -------- | -------- | - | 1900004 | read from ashmem failed | + | 1900004 | read from ashmem failed | **示例:** @@ -8981,7 +9082,7 @@ readFromAshmem(size: number, offset: number): number[] **示例:** - ```ts + ``` ts let ashmem = rpc.Ashmem.createAshmem("ashmem", 1024*1024); let mapResult = ashmem.mapReadAndWriteAshmem(); console.info("RpcTest map ashmem result is " + mapResult); @@ -8990,4 +9091,38 @@ readFromAshmem(size: number, offset: number): number[] console.log("RpcTest: write to Ashmem result is : " + writeResult); let readResult = ashmem.readFromAshmem(5, 0); console.log("RpcTest: read to Ashmem result is : " + readResult); - ``` \ No newline at end of file + ``` + +## 获取context + +**示例:** + + ```ts + import Ability from '@ohos.app.ability.UIAbility'; + export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate"); + globalThis.context = this.context; + } + onDestroy() { + console.log("[Demo] MainAbility onDestroy"); + } + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate"); + } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy"); + } + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground"); + } + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground"); + } + }; + ``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md index 28402007b002e0f214060f8dc9a629d2d042a311..0eeca0657124675f5c8c21cf93fe4779d17fe028 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uiappearance.md @@ -1,4 +1,4 @@ -# 用户界面外观 +# @ohos.uiAppearance (用户界面外观) 用户界面外观提供管理系统外观的一些基础能力,目前仅包括深浅色模式配置。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index dace2c497344d7c126e240376c80b6ccf8f43872..429cb1e6599bfb168077d00918070a42edb6c451 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -66,7 +66,7 @@ import window from '@ohos.window'; | 名称 | 值 | 说明 | | -------------------------------- | ---- | ------------------------------------------------------------ | -| TYPE_SYSTEM | 0 | 表示系统默认区域。一般包括状态栏、导航栏和Dock栏,各设备系统定义可能不同。 | +| TYPE_SYSTEM | 0 | 表示系统默认区域。一般包括状态栏、导航栏,各设备系统定义可能不同。 | | TYPE_CUTOUT | 1 | 表示刘海屏区域。 | | TYPE_SYSTEM_GESTURE<sup>9+</sup> | 2 | 表示手势区域。 | | TYPE_KEYBOARD<sup>9+</sup> | 3 | 表示软键盘区域。 | @@ -4159,7 +4159,7 @@ promise.then((pixelMap)=> { opacity(opacity: number): void -设置窗口透明度。 +设置窗口不透明度。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。 **系统接口:** 此接口为系统接口。 @@ -4167,9 +4167,9 @@ opacity(opacity: number): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | --------------------- | -| opacity | number | 是 | 透明度,范围0.0~1.0。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ----------------------------------------------------------- | +| opacity | number | 是 | 不透明度,范围0.0~1.0。0.0表示完全透明,1.0表示完全不透明。 | **错误码:** @@ -4194,7 +4194,7 @@ try { scale(scaleOptions: ScaleOptions): void -设置窗口缩放参数。 +设置窗口缩放参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。 **系统接口:** 此接口为系统接口。 @@ -4235,7 +4235,7 @@ try { rotate(rotateOptions: RotateOptions): void -设置窗口旋转参数。 +设置窗口旋转参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。 **系统接口:** 此接口为系统接口。 @@ -4277,7 +4277,7 @@ try { translate(translateOptions: TranslateOptions): void -设置窗口平移参数。 +设置窗口平移参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。 **系统接口:** 此接口为系统接口。 @@ -4285,9 +4285,9 @@ translate(translateOptions: TranslateOptions): void **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| ---------------- | -------------------------------------- | ---- | ---------- | -| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------------- | -------------------------------------- | ---- | -------------------- | +| translateOptions | [TranslateOptions](#translateoptions9) | 是 | 平移参数,单位为px。 | **错误码:** diff --git a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md index f79c583bd930c9ba0439b80bef36aadf96d60fc2..77b4940269728279a8a07fcbcbfcc17f5f1c19c9 100644 --- a/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md +++ b/zh-cn/application-dev/reference/arkui-js-lite/js-framework-file.md @@ -20,18 +20,16 @@ JS FA应用的JS模块(entry/src/main/js/module)的典型开发目录结构如 各个文件夹的作用: - app.js文件用于全局JavaScript逻辑和应用生命周期管理。 - - pages目录用于存放所有组件页面。 - - common目录用于存放公共资源文件,比如:媒体资源和JS文件。 +- i18n目录用于配置不同语言场景资源内容,比如应用文本词条,图片路径等资源。 > **说明:** -> - 如下文件夹是开发保留文件夹,不可重命名: > +> - i18n是开发保留文件夹,不可重命名。 > -> -> -> - 在使用DevEco Studio进行应用开发时,目录结构中的可选文件夹需要开发者根据实际情况自行创建。 +> +>- 在使用DevEco Studio进行应用开发时,目录结构中的可选文件夹需要开发者根据实际情况自行创建。 ## 文件访问规则 @@ -62,6 +60,14 @@ JS FA应用的JS模块(entry/src/main/js/module)的典型开发目录结构如 | 格式 | 支持版本 | 支持的文件类型 | | -------- | -------- | -------- | -| BMP | API Version 3+ | .bmp | -| JPEG | API Version 3+ | .jpg | -| PNG | API Version 3+ | .png | +| BMP | API Version 4+ | .bmp | +| JPEG | API Version 4+ | .jpg | +| PNG | API Version 4+ | .png | + +## 存储目录定义 + +从API Version 5开始,[image](js-components-basic-image.md)组件支持应用私有目录内的图片资源访问。 + +| 目录类型 | 路径前缀 | 访问可见性 | 说明 | +| ------------ | --------------- | ------------ | --------------------------------------------------- | +| 应用私有目录 | internal://app/ | 仅本应用可见 | 目录随应用卸载删除,路径禁止使用../等方式访问父目录 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/imagespan.png b/zh-cn/application-dev/reference/arkui-ts/figures/imagespan.png new file mode 100644 index 0000000000000000000000000000000000000000..6b0684be4d1e785c4301f97ca50016b0ccd83623 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/imagespan.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001232775585.gif b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001232775585.gif index 070ae9d042d5211b2ccc6c187ec0f87a90d2c963..36e5cf928d08d719eab8bb0c417da0bc23472798 100644 Binary files a/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001232775585.gif and b/zh-cn/application-dev/reference/arkui-ts/figures/zh-cn_image_0000001232775585.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md index e5e6c4a4ad3df4aff34231c47d6ab238b0d55517..8d436ee457008f7271c4cf479c2f69fc6c145261 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-appendix-enums.md @@ -54,8 +54,6 @@ ## TouchType -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ------ | ------------------------------ | | Down | 手指按下时触发。 | @@ -65,8 +63,6 @@ ## MouseButton -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ------- | ---------------- | | Left | 鼠标左键。 | @@ -78,8 +74,6 @@ ## MouseAction -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ------- | -------------- | | Press | 鼠标按键按下。 | @@ -109,7 +103,7 @@ ## AnimationStatus -从API version 9开始,该接口支持在ArkTS卡片中使用。 +从API version 10开始,该接口支持在ArkTS卡片中使用。 | 名称 | 描述 | | ------- | ------------------ | @@ -120,7 +114,7 @@ ## FillMode -从API version 9开始,该接口支持在ArkTS卡片中使用。 +从API version 10开始,该接口支持在ArkTS卡片中使用。 | 名称 | 描述 | | --------- | ------------------------------------------------------------ | @@ -142,8 +136,6 @@ ## KeyType -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ---- | ---------- | | Down | 按键按下。 | @@ -151,8 +143,6 @@ ## KeySource -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | -------- | -------------------- | | Unknown | 输入设备类型未知。 | @@ -172,8 +162,6 @@ ## Week -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | -------- | ---------------------- | | Mon | 星期一 | @@ -242,8 +230,6 @@ ## RelateType -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ------ | ------------------------------- | | FILL | 缩放当前子组件以填充满父组件 | @@ -384,8 +370,6 @@ ## SharedTransitionEffectType -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ----------- | ---------- | | Static | 目标页面元素的位置保持不变,可以配置透明度动画。目前,只有为重定向到目标页面而配置的静态效果才会生效。 | @@ -458,8 +442,6 @@ ## ResponseType<sup>8+</sup> -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ---------- | -------------------------- | | LongPress | 通过长按触发菜单弹出。 | @@ -467,8 +449,6 @@ ## HoverEffect<sup>8+</sup> -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | --------- | ---------------------------- | | Auto | 使用组件的系统默认悬浮效果。 | @@ -478,8 +458,6 @@ ## Placement<sup>8+</sup> -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ------------- | ------------------------------------------------------------ | | Left | 气泡提示位于组件左侧,与组件左侧中心对齐。 | @@ -507,8 +485,6 @@ ## HitTestMode<sup>9+</sup> -从API version 9开始,该接口支持在ArkTS卡片中使用。 - | 名称 | 描述 | | ----------- | -------------------- | | Default | 自身节点和子节点都响应触摸事件的命中测试,但会阻止被该节点屏蔽的其他节点的命中测试。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imagespan.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imagespan.md new file mode 100644 index 0000000000000000000000000000000000000000..c17c931c135b54f67aef3fcd25271eef61784dfa --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imagespan.md @@ -0,0 +1,96 @@ +# ImageSpan + +[Text](ts-basic-components-text.md)组件的子组件,用于显示行内图片。 + +> **说明:** +> +> 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + +## 子组件 + +无 + + +## 接口 + +ImageSpan(value: ResourceStr | PixelMap) + +**参数:** + +| 参数名 | 参数类型 | 必填 | 参数描述 | +| -------- | -------- | -------- | -------- | +| value | [ResourceStr](ts-types.md#ResourceStr) \| [PixelMap](../apis/js-apis-image.md#pixelmap7)  | 是 | 图片的数据源,支持本地图片和网络图片。<br/>当使用相对路径引用图片资源时,例如`ImageSpan("common/test.jpg")`,不支持跨包/跨模块调用该ImageSpan组件,建议使用`$r`方式来管理需全局使用的图片资源。<br/>\- 支持的图片格式包括png、jpg、bmp、svg和gif。<br/>\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。<br/>\- 支持file:///data/storage路径前缀的字符串,用于读取本应用安装目录下files文件夹下的图片资源。需要保证目录包路径下的文件有可读权限。 | + + +## 属性 + +[通用属性](ts-universal-attributes-size.md)方法仅支持宽(width)、高(height)和size。 + +| 名称 | 参数类型 | 描述 | +| -------- | -------- | -------- | +| verticalAlign | [ImageSpanAlignment](#imagespanalignment) | 图片基于文本的对齐方式。 | +| objectFit | [ImageFit](ts-appendix-enums.md#imagefit) | 设置图片的缩放类型。<br/>默认值:ImageFit.Cover | + +## ImageSpanAlignment + +| 名称 | 描述 | +| -------- | ------------------------------ | +| TOP | 图片上边沿与文本上边沿对齐。 | +| CENTER | 图片中间与文本中间对齐。 | +| BOTTOM | 图片下边沿与文本下边沿对齐。 | +| BASELINE | 图片下边沿与文本BaseLine对齐。 | + +## 事件 + +通用事件仅支持[点击事件](ts-universal-attributes-click.md)。 + +## 示例 + +```ts +// xxx.ets +@Entry +@Component +struct SpanExample { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start}) { + Text() { + Span('This is the Span and ImageSpan component').fontSize(25).textCase(TextCase.Normal) + .decoration({ type: TextDecorationType.None, color: Color.Pink }) + }.width('100%') + Text() { + ImageSpan($r('app.media.icon')) + .width('200px') + .height('200px') + .objectFit(ImageFit.Fill) + .verticalAlign(ImageSpanAlignment.CENTER) + Span('I am LineThrough-span') + .decoration({ type: TextDecorationType.LineThrough, color: Color.Red }).fontSize(25) + ImageSpan($r('app.media.icon')) + .width('50px') + .height('50px') + .verticalAlign(ImageSpanAlignment.TOP) + Span('I am Underline-span') + .decoration({ type: TextDecorationType.Underline, color: Color.Red }).fontSize(25) + ImageSpan($r('app.media.icon')) + .size({width:'100px', height:'100px'}) + .verticalAlign(ImageSpanAlignment.BASELINE) + Span('I am Underline-span') + .decoration({ type: TextDecorationType.Underline, color: Color.Red }).fontSize(25) + ImageSpan($r('app.media.icon')) + .width('70px') + .height('70px') + .verticalAlign(ImageSpanAlignment.BOTTOM) + Span('I am Underline-span') + .decoration({ type: TextDecorationType.Underline, color: Color.Red }).fontSize(50) + } + .width('100%') + .backgroundColor(Color.Orange) + .textIndent(50) + }.width('100%').height('100%').padding({ left: 0, right: 0, top: 0 }) + } +} +``` + +![imagespan](figures/imagespan.png) + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md index fe680d987c2ac0dcea2deba8d22b63c0ba34f4bd..0f9582a81ce84019b6a6ab8703b6079b5cd749b8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-scrollbar.md @@ -46,7 +46,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B @Component struct ScrollBarExample { private scroller: Scroller = new Scroller() - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] build() { Column() { @@ -56,8 +56,8 @@ struct ScrollBarExample { ForEach(this.arr, (item) => { Row() { Text(item.toString()) - .width('90%') - .height(100) + .width('80%') + .height(60) .backgroundColor('#3366CC') .borderRadius(15) .fontSize(16) @@ -65,17 +65,18 @@ struct ScrollBarExample { .margin({ top: 5 }) } }, item => item) - }.margin({ right: 52 }) + }.margin({ right: 15 }) } + .width('90%') .scrollBar(BarState.Off) .scrollable(ScrollDirection.Vertical) ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,state: BarState.Auto }) { Text() - .width(30) + .width(20) .height(100) .borderRadius(10) .backgroundColor('#C0C0C0') - }.width(30).backgroundColor('#ededed') + }.width(20).backgroundColor('#ededed') } } } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 1dbc2dd6ebb99eb8f2716566a8903edd002ee848..dea844900b22ec00f066dec307340bb235d0fbbc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -9,7 +9,7 @@ ## 子组件 -可以包含[Span](ts-basic-components-span.md)子组件。 +可以包含[Span](ts-basic-components-span.md)和[ImageSpan](ts-basic-components-imagespan.md)子组件。 ## 接口 @@ -43,10 +43,11 @@ Text(content?: string | Resource) | copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。<br />默认值:CopyOptions.None <br/>该接口支持在ArkTS卡片中使用。 | | textShadow<sup>10+</sup> | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions对象说明) | 设置文字阴影效果。 | | heightAdaptivePolicy<sup>10+</sup> | [TextHeightAdaptivePolicy](ts-appendix-enums.md#TextHeightAdaptivePolicy10) | 设置文本自适应高度的方式。 | +| textIndent<sup>10+</sup> | number \| string | 设置首行文本缩进,默认值0。 | > **说明:** > -> 不支持Text内同时存在文本内容和Span子组件。如果同时存在,只显示Span内的内容。 +> 不支持Text内同时存在文本内容和Span或ImageSpan子组件。如果同时存在,只显示Span或ImageSpan内的内容。 ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index 44ba81748c5d0e3a5d6e4224a7710e8575dcce3a..c6243e6affdf3f13cec7b60afb0413db1a35b416 100755 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -3096,7 +3096,7 @@ onFaviconReceived(callback: (event: {favicon: image.PixelMap}) => void) Column() { Web({ src:'www.example.com', controller: this.controller }) .onFaviconReceived((event) => { - console.log('onFaviconReceived:' + JSON.stringify(event)) + console.log('onFaviconReceived'); this.icon = event.favicon; }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md index 15d41052c60c6c5942666e72f4cfb20e72a3495d..a68712f809050a77962d2b6e7c15fe481734b1e0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md @@ -12,6 +12,8 @@ CanvasRenderingContext2D(setting: RenderingContextSetting) +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | @@ -25,6 +27,8 @@ RenderingContextSettings(antialias?: boolean) 用来配置CanvasRenderingContext2D对象的参数,包括是否开启抗锯齿。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | @@ -36,23 +40,23 @@ RenderingContextSettings(antialias?: boolean) | 名称 | 类型 | 描述 | | ----------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 指定绘制的填充色。<br/>- 类型为string时,表示设置填充区域的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。 | +| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 指定绘制的填充色。<br/>- 类型为string时,表示设置填充区域的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | [lineWidth](#linewidth) | number | 设置绘制线条的宽度。 | -| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 设置描边的颜色。<br/>- 类型为string时,表示设置描边使用的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。 | -| [lineCap](#linecap) | CanvasLineCap | 指定线端点的样式,可选值为:<br/>- 'butt':线端点以方形结束。<br/>- 'round':线端点以圆形结束。<br/>- 'square':线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。<br/>默认值:'butt' | -| [lineJoin](#linejoin) | CanvasLineJoin | 指定线段间相交的交点样式,可选值为:<br/>- 'round':在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。<br/>- 'bevel':在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。<br/>- 'miter':在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。<br/>默认值:'miter' | -| [miterLimit](#miterlimit) | number | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 <br/>默认值:10 | -| [font](#font) | string | 设置文本绘制中的字体样式。<br/>语法:ctx.font='font-size font-family'<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列。<br/>语法:ctx.font='font-style font-weight font-size font-family'<br/>- font-style(可选),用于指定字体样式,支持如下几种样式:'normal','italic'。<br/>- font-weight(可选),用于指定字体的粗细,支持如下几种类型:'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900。<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列,支持如下几种类型:'sans-serif', 'serif', 'monospace'。<br/>默认值:'normal normal 14px sans-serif' | -| [textAlign](#textalign) | CanvasTextAlign | 设置文本绘制中的文本对齐方式,可选值为:<br/>- 'left':文本左对齐。<br/>- 'right':文本右对齐。<br/>- 'center':文本居中对齐。<br/>- 'start':文本对齐界线开始的地方。<br/>- 'end':文本对齐界线结束的地方。<br/>ltr布局模式下'start'和'left'一致,rtl布局模式下'start'和'right'一致·。<br/>默认值:'left' | -| [textBaseline](#textbaseline) | CanvasTextBaseline | 设置文本绘制中的水平对齐方式,可选值为:<br/>- 'alphabetic':文本基线是标准的字母基线。<br/>- 'top':文本基线在文本块的顶部。<br/>- 'hanging':文本基线是悬挂基线。<br/>- 'middle':文本基线在文本块的中间。<br/>- 'ideographic':文字基线是表意字基线;如果字符本身超出了alphabetic基线,那么ideograhpic基线位置在字符本身的底部。<br/>- 'bottom':文本基线在文本块的底部。 与ideographic基线的区别在于ideographic基线不需要考虑下行字母。<br/>默认值:'alphabetic' | -| [globalAlpha](#globalalpha) | number | 设置透明度,0.0为完全透明,1.0为完全不透明。 | -| [lineDashOffset](#linedashoffset) | number | 设置画布的虚线偏移量,精度为float。 <br/>默认值:0.0 | -| [globalCompositeOperation](#globalcompositeoperation) | string | 设置合成操作的方式。类型字段可选值有'source-over','source-atop','source-in','source-out','destination-over','destination-atop','destination-in','destination-out','lighter','copy','xor'。<br/>默认值:'source-over' | -| [shadowBlur](#shadowblur) | number | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 <br/>默认值:0.0 | -| [shadowColor](#shadowcolor) | string | 设置绘制阴影时的阴影颜色。 | -| [shadowOffsetX](#shadowoffsetx) | number | 设置绘制阴影时和原有对象的水平偏移值。 | -| [shadowOffsetY](#shadowoffsety) | number | 设置绘制阴影时和原有对象的垂直偏移值。 | -| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 <br/>默认值:true | +| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 设置描边的颜色。<br/>- 类型为string时,表示设置描边使用的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineCap](#linecap) | CanvasLineCap | 指定线端点的样式,可选值为:<br/>- 'butt':线端点以方形结束。<br/>- 'round':线端点以圆形结束。<br/>- 'square':线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。<br/>默认值:'butt'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineJoin](#linejoin) | CanvasLineJoin | 指定线段间相交的交点样式,可选值为:<br/>- 'round':在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。<br/>- 'bevel':在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。<br/>- 'miter':在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。<br/>默认值:'miter'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [miterLimit](#miterlimit) | number | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 <br/>默认值:10<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [font](#font) | string | 设置文本绘制中的字体样式。<br/>语法:ctx.font='font-size font-family'<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列。<br/>语法:ctx.font='font-style font-weight font-size font-family'<br/>- font-style(可选),用于指定字体样式,支持如下几种样式:'normal','italic'。<br/>- font-weight(可选),用于指定字体的粗细,支持如下几种类型:'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900。<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列,支持如下几种类型:'sans-serif', 'serif', 'monospace'。<br/>默认值:'normal normal 14px sans-serif'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [textAlign](#textalign) | CanvasTextAlign | 设置文本绘制中的文本对齐方式,可选值为:<br/>- 'left':文本左对齐。<br/>- 'right':文本右对齐。<br/>- 'center':文本居中对齐。<br/>- 'start':文本对齐界线开始的地方。<br/>- 'end':文本对齐界线结束的地方。<br/>ltr布局模式下'start'和'left'一致,rtl布局模式下'start'和'right'一致·。<br/>默认值:'left'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [textBaseline](#textbaseline) | CanvasTextBaseline | 设置文本绘制中的水平对齐方式,可选值为:<br/>- 'alphabetic':文本基线是标准的字母基线。<br/>- 'top':文本基线在文本块的顶部。<br/>- 'hanging':文本基线是悬挂基线。<br/>- 'middle':文本基线在文本块的中间。<br/>- 'ideographic':文字基线是表意字基线;如果字符本身超出了alphabetic基线,那么ideograhpic基线位置在字符本身的底部。<br/>- 'bottom':文本基线在文本块的底部。 与ideographic基线的区别在于ideographic基线不需要考虑下行字母。<br/>默认值:'alphabetic'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [globalAlpha](#globalalpha) | number | 设置透明度,0.0为完全透明,1.0为完全不透明。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineDashOffset](#linedashoffset) | number | 设置画布的虚线偏移量,精度为float。 <br/>默认值:0.0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [globalCompositeOperation](#globalcompositeoperation) | string | 设置合成操作的方式。类型字段可选值有'source-over','source-atop','source-in','source-out','destination-over','destination-atop','destination-in','destination-out','lighter','copy','xor'。<br/>默认值:'source-over'<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowBlur](#shadowblur) | number | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 <br/>默认值:0.0<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowColor](#shadowcolor) | string | 设置绘制阴影时的阴影颜色。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowOffsetX](#shadowoffsetx) | number | 设置绘制阴影时和原有对象的水平偏移值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowOffsetY](#shadowoffsety) | number | 设置绘制阴影时和原有对象的垂直偏移值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 <br/>默认值:true<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | > **说明:** > @@ -657,6 +661,8 @@ fillRect(x: number, y: number, w: number, h: number): void 填充一个矩形。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -701,6 +707,8 @@ strokeRect(x: number, y: number, w: number, h: number): void 绘制具有边框的矩形,矩形内部不填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -745,6 +753,8 @@ clearRect(x: number, y: number, w: number, h: number): void 删除指定区域内的绘制内容。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -791,6 +801,8 @@ fillText(text: string, x: number, y: number, maxWidth?: number): void 绘制填充类文本。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -836,6 +848,8 @@ strokeText(text: string, x: number, y: number, maxWidth?:number): void 绘制描边类文本。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -881,6 +895,8 @@ measureText(text: string): TextMetrics 该方法返回一个文本测算的对象,通过该对象可以获取指定文本的宽度值。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -889,9 +905,9 @@ measureText(text: string): TextMetrics **返回值:** -| 类型 | 说明 | -| ----------- | ---------------- | -| TextMetrics | 文本的尺寸信息。 | +| 类型 | 说明 | +| ----------- | ------------------------------------------------------------ | +| TextMetrics | 文本的尺寸信息。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | **TextMetrics类型描述:** @@ -951,6 +967,8 @@ stroke(path?: Path2D): void 进行边框绘制操作。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -997,6 +1015,8 @@ beginPath(): void 创建一个新的绘制路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -1037,6 +1057,8 @@ moveTo(x: number, y: number): void 路径从当前点移动到指定点。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1082,6 +1104,8 @@ lineTo(x: number, y: number): void 从当前点到指定点进行路径连接。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1127,6 +1151,8 @@ closePath(): void 结束当前路径形成一个封闭路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -1167,6 +1193,8 @@ createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | nu 通过指定图像和重复方式创建图片填充的模板。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 描述 | @@ -1218,6 +1246,8 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, 创建三次贝赛尔曲线的路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1267,6 +1297,8 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void 创建二次贝赛尔曲线的路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1314,6 +1346,8 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, 绘制弧线路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1362,6 +1396,8 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void 依据圆弧经过的点和圆弧半径创建圆弧路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1409,6 +1445,8 @@ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number 在规定的矩形区域绘制一个椭圆。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1459,6 +1497,8 @@ rect(x: number, y: number, w: number, h: number): void 创建矩形路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1504,6 +1544,8 @@ fill(fillRule?: CanvasFillRule): void 对封闭路径进行填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1545,6 +1587,8 @@ fill(path: Path2D, fillRule?: CanvasFillRule): void 对封闭路径进行填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1598,6 +1642,8 @@ clip(fillRule?: CanvasFillRule): void 设置当前路径为剪切路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1641,6 +1687,8 @@ clip(path: Path2D, fillRule?: CanvasFillRule): void 设置当前路径为剪切路径 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1693,6 +1741,8 @@ filter(filter: string): void 为Canvas图形设置各类滤镜效果。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1706,6 +1756,8 @@ getTransform(): Matrix2D 获取当前被应用到上下文的转换矩阵。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### resetTransform @@ -1713,6 +1765,8 @@ resetTransform(): void 使用单位矩阵重新设置当前变形。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### direction @@ -1720,6 +1774,8 @@ direction(direction: CanvasDirection): void 绘制文本时,描述当前文本方向的属性。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### rotate @@ -1727,6 +1783,8 @@ rotate(angle: number): void 针对当前坐标轴进行顺时针旋转。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1769,6 +1827,8 @@ scale(x: number, y: number): void 设置canvas画布的缩放变换属性,后续的绘制操作将按照缩放比例进行缩放。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1814,6 +1874,8 @@ transform(a: number, b: number, c: number, d: number, e: number, f: number): voi transform方法对应一个变换矩阵,想对一个图形进行变化的时候,只要设置此变换矩阵相应的参数,对图形的各个定点的坐标分别乘以这个矩阵,就能得到新的定点的坐标。矩阵变换效果可叠加。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + > **说明:** > 变换后的坐标计算方式(x和y为变换前坐标,x'和y'为变换后坐标): > @@ -1874,6 +1936,8 @@ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): setTransform方法使用的参数和transform()方法相同,但setTransform()方法会重置现有的变换矩阵并创建新的变换矩阵。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1931,6 +1995,8 @@ translate(x: number, y: number): void 移动当前坐标系的原点。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1979,7 +2045,7 @@ drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sw: number, sh: 进行图像绘制。 -从API version 9开始,该接口支持在ArkTS卡片中使用。 +从API version 9开始,该接口支持在ArkTS卡片中使用,卡片中不支持PixelMap对象。 **参数:** @@ -2032,6 +2098,8 @@ createImageData(sw: number, sh: number): ImageData 创建新的ImageData 对象,请参考[ImageData](ts-components-canvas-imagedata.md)。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认 | 描述 | @@ -2044,6 +2112,8 @@ createImageData(imageData: ImageData): ImageData 创建新的ImageData 对象,请参考[ImageData](ts-components-canvas-imagedata.md)。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认 | 描述 | @@ -2084,6 +2154,8 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData 以当前canvas指定区域内的像素创建[ImageData](ts-components-canvas-imagedata.md)对象。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2140,6 +2212,8 @@ putImageData(imageData: ImageData, dx: number, dy: number, dirtyX: number, dirty 使用[ImageData](ts-components-canvas-imagedata.md)数据填充新的矩形区域。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2194,6 +2268,8 @@ setLineDash(segments: number[]): void 设置画布的虚线样式。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 描述 | @@ -2237,6 +2313,8 @@ getLineDash(): number[] 获得当前画布的虚线样式。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **返回值:** | 类型 | 说明 | @@ -2293,6 +2371,8 @@ imageSmoothingQuality(quality: imageSmoothingQuality) 用于设置图像平滑度。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 描述 | @@ -2307,6 +2387,8 @@ transferFromImageBitmap(bitmap: ImageBitmap): void 显示给定的ImageBitmap对象。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 描述 | @@ -2405,6 +2487,8 @@ restore(): void 对保存的绘图上下文进行恢复。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -2443,6 +2527,8 @@ save(): void 将当前状态放入栈中,保存canvas的全部状态,通常在需要保存绘制状态时调用。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -2481,6 +2567,8 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void 创建一个线性渐变色。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2530,6 +2618,8 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, 创建一个径向渐变色。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2623,4 +2713,6 @@ struct CanvasExample { ## CanvasPattern -一个Object对象, 通过[createPattern](#createpattern)方法创建。 \ No newline at end of file +一个Object对象, 通过[createPattern](#createpattern)方法创建。 + +从API version 9开始,该接口支持在ArkTS卡片中使用。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md index 07da0f4523f7d6215398027f8a13780b77f44931..8791dbefa86a5685c7059c389b63e3f44a2f7516 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-grid.md @@ -59,6 +59,7 @@ Grid(scroller?: Scroller) | cellLength<sup>8+</sup> | number | 当layoutDirection是Row/RowReverse时,表示一行的高度。<br/>当layoutDirection是Column/ColumnReverse时,表示一列的宽度。<br/>默认值:第一个元素的大小 | | multiSelectable<sup>8+</sup> | boolean | 是否开启鼠标框选。<br/>默认值:false<br/>- false:关闭框选。<br/>- true:开启框选。 | | supportAnimation<sup>8+</sup> | boolean | 是否支持动画。当前支持GridItem拖拽动画。<br/>默认值:false | +| edgeEffect<sup>10+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果,支持弹簧效果和阴影效果。<br/>默认值:EdgeEffect.None<br/> | Grid组件根据rowsTemplate、columnsTemplate属性的设置情况,可分为以下三种布局模式: @@ -181,6 +182,7 @@ struct GridExample { .columnsTemplate('1fr 1fr 1fr 1fr 1fr') .columnsGap(10) .rowsGap(10) + .edgeEffect(EdgeEffect.Spring) .onScrollIndex((first: number) => { console.info(first.toString()) }) @@ -196,4 +198,4 @@ struct GridExample { } ``` -![zh-cn_image_0000001219744183](figures/zh-cn_image_0000001219744183.gif) \ No newline at end of file +![zh-cn_image_0000001219744183](figures/zh-cn_image_0000001219744183.gif) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index bd8d15720086142ef5ce0d40c497bfff2a5730d0..020b18250a8e110f962a5ebaff367aa640378e90 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -33,7 +33,7 @@ Scroll(scroller?: Scroller) | scrollable | [ScrollDirection](#scrolldirection枚举说明) | 设置滚动方向。<br/>默认值:ScrollDirection.Vertical | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。<br/>默认值:BarState.Auto<br/>**说明:** <br/>如果容器组件无法滚动,则滚动条不显示。 | | scrollBarColor | string \| number \| [Color](ts-appendix-enums.md#color) | 设置滚动条的颜色。 | -| scrollBarWidth | string \| number | 设置滚动条的宽度。<br/>默认值:4<br/>单位:vp | +| scrollBarWidth | string \| number | 设置滚动条的宽度,不支持百分比设置。<br/>默认值:4<br/>单位:vp | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.None | ## ScrollDirection枚举说明 @@ -50,9 +50,9 @@ Scroll(scroller?: Scroller) | ------------------------------------------------------------ | ------------------------------------------------------------ | | onScrollFrameBegin<sup>9+</sup>(event: (offset: number, state: ScrollState) => { offsetRemain }) | 每帧开始滚动时触发,事件参数传入即将发生的滚动量,事件处理函数中可根据应用场景计算实际需要的滚动量并作为事件处理函数的返回值返回,Scroll将按照返回值的实际滚动量进行滚动。<br/>\- offset:即将发生的滚动量。<br/>\- state:当前滚动状态。<br/>- offsetRemain:实际滚动量。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动时触发,包括键鼠操作等其他触发滚动的输入设置。<br/>2、调用控制器接口时不触发。<br/>3、越界回弹不触发。<br/>**说明:** <br/>支持offsetRemain为负值。<br/>若通过onScrollFrameBegine事件和scrollBy方法实现容器嵌套滚动,需设置子滚动节点的EdgeEffect为None。如Scroll嵌套List滚动时,List组件的edgeEffect属性需设置为EdgeEffect.None。 | | onScroll(event: (xOffset: number, yOffset: number) => void) | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动时触发,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用。<br/>3、越界回弹。 | -| onScrollEdge(event: (side: Edge) => void) | 滚动到边缘事件回调。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动时触发,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用。<br/>3、越界回弹。 | +| onScrollEdge(event: (side: Edge) => void) | 滚动到边缘事件回调。<br/>触发该事件的条件 :<br/>1、滚动组件滚动到边缘时触发,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用。<br/>3、越界回弹。 | | onScrollEnd<sup>(deprecated) </sup>(event: () => void) | 滚动停止事件回调。<br>该事件从API version 9开始废弃,使用onScrollStop事件替代。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用后停止,带过渡动效。 | -| onScrollStart<sup>9+</sup>(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画开始时会触发该事件。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用后开始,带过渡动效。 | +| onScrollStart<sup>9+</sup>(event: () => void) | 滚动开始时触发。手指拖动Scroll或拖动Scroll的滚动条触发的滚动开始时,会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画开始时会触发该事件。<br/>触发该事件的条件 :<br/>1、滚动组件开始滚动时触发,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用后开始,带过渡动效。 | | onScrollStop<sup>9+</sup>(event: () => void) | 滚动停止时触发。手拖动Scroll或拖动Scroll的滚动条触发的滚动,手离开屏幕并且滚动停止时会触发该事件。使用[Scroller](#scroller)滚动控制器触发的带动画的滚动,动画停止时会触发该事件。<br/>触发该事件的条件 :<br/>1、滚动组件触发滚动后停止,支持键鼠操作等其他触发滚动的输入设置。<br/>2、通过滚动控制器API接口调用后开始,带过渡动效,。 | > **说明:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md b/zh-cn/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md index 44971cf244a982f7e7d8cd88ddeb2d4505c2b181..477a9ca18f97c53922be2e37237be1577280a582 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-custom-component-lifecycle.md @@ -88,6 +88,8 @@ onLayout?(children: Array<LayoutChild>, constraint: ConstraintSizeOptions) 框架会在自定义组件布局时,将该自定义组件的子节点信息和自身的尺寸范围通过onLayout传递给该自定义组件。不允许在onLayout函数中改变状态变量。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数名 | 类型 | 说明 | @@ -102,6 +104,8 @@ onMeasure?(children: Array<LayoutChild>, constraint: ConstraintSizeOptions 框架会在自定义组件确定尺寸时,将该自定义组件的子节点信息和自身的尺寸范围通过onMeasure传递给该自定义组件。不允许在onMeasure函数中改变状态变量。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数名 | 类型 | 说明 | @@ -114,6 +118,8 @@ onMeasure?(children: Array<LayoutChild>, constraint: ConstraintSizeOptions 子组件布局信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + | 参数 | 参数类型 | 描述 | | ---------- | ---------------------------------------- | ------------------- | | name | string | 子组件名称。 | @@ -129,6 +135,8 @@ onMeasure?(children: Array<LayoutChild>, constraint: ConstraintSizeOptions 子组件border信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + | 参数 | 参数类型 | 描述 | | ----------- | ------------------------------------ | ----------------------- | | borderWidth | [EdgeWidths](ts-types.md#edgewidths) | 边框宽度类型,用于描述组件边框不同方向的宽度。 | @@ -140,6 +148,8 @@ onMeasure?(children: Array<LayoutChild>, constraint: ConstraintSizeOptions 子组件layout信息。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + | 参数 | 参数类型 | 描述 | | ---------- | ---------------------------------------- | -------- | | position | [Position](ts-types.md#position) | 子组件位置坐标。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 60d07fe9aafec52b01e133cd83c1b0f229c5b0e6..9fad1261232b195662f37b294e2e8c0d0a17b3f3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -21,7 +21,7 @@ Shape(value?: PixelMap) -从API version 9开始,该接口支持在ArkTS卡片中使用。 +从API version 9开始,该接口支持在ArkTS卡片中使用,卡片中不支持使用PixelMap对象。 **参数:** @@ -52,8 +52,6 @@ Shape(value?: PixelMap) ## 示例 -### 示例1 - ```ts // xxx.ets @Entry diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md index 1366c60ee30077578f1048950ed102be8358336a..98c4bd350c2d8ad1818bb2a25c89be747ff0fac9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-offscreencanvasrenderingcontext2d.md @@ -12,6 +12,8 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: RenderingContextSettings) +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数名 | 参数类型 | 必填 | 参数描述 | @@ -25,23 +27,23 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: Render | 名称 | 类型 | 描述 | | ----------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 指定绘制的填充色。<br/>- 类型为string时,表示设置填充区域的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。 | -| [lineWidth](#linewidth) | number | 设置绘制线条的宽度。 | -| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 设置描边的颜色。<br/>- 类型为string时,表示设置描边使用的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。 | -| [lineCap](#linecap) | CanvasLineCap | 指定线端点的样式,可选值为:<br/>- 'butt':线端点以方形结束。<br/>- 'round':线端点以圆形结束。<br/>- 'square':线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。<br/>- 默认值:'butt'。 | -| [lineJoin](#linejoin) | CanvasLineJoin | 指定线段间相交的交点样式,可选值为:<br/>- 'round':在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。<br/>- 'bevel':在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。<br/>- 'miter':在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。<br/>- 默认值:'miter'。 | -| [miterLimit](#miterlimit) | number | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 <br/>- 默认值:10。 | -| [font](#font) | string | 设置文本绘制中的字体样式。<br/>语法:ctx.font='font-size font-family'<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列。<br/>语法:ctx.font='font-style font-weight font-size font-family'<br/>- font-style(可选),用于指定字体样式,支持如下几种样式:'normal','italic'。<br/>- font-weight(可选),用于指定字体的粗细,支持如下几种类型:'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900。<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列,支持如下几种类型:'sans-serif', 'serif', 'monospace'。<br/>- 默认值:'normal normal 14px sans-serif'。 | -| [textAlign](#textalign) | CanvasTextAlign | 设置文本绘制中的文本对齐方式,可选值为:<br/>- 'left':文本左对齐。<br/>- 'right':文本右对齐。<br/>- 'center':文本居中对齐。<br/>- 'start':文本对齐界线开始的地方。<br/>- 'end':文本对齐界线结束的地方。<br/>> **说明:**<br/>> ltr布局模式下'start'和'left'一致,rtl布局模式下'start'和'right'一致·。<br/>- 默认值:'left'。 | -| [textBaseline](#textbaseline) | CanvasTextBaseline | 设置文本绘制中的水平对齐方式,可选值为:<br/>- 'alphabetic':文本基线是标准的字母基线。<br/>- 'top':文本基线在文本块的顶部。<br/>- 'hanging':文本基线是悬挂基线。<br/>- 'middle':文本基线在文本块的中间。<br/>- 'ideographic':文字基线是表意字基线;如果字符本身超出了alphabetic基线,那么ideograhpic基线位置在字符本身的底部。<br/>- 'bottom':文本基线在文本块的底部。 与ideographic基线的区别在于ideographic基线不需要考虑下行字母。<br/>- 默认值:'alphabetic'。 | +| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 指定绘制的填充色。<br/>- 类型为string时,表示设置填充区域的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineWidth](#linewidth) | number | 设置绘制线条的宽度。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | 设置描边的颜色。<br/>- 类型为string时,表示设置描边使用的颜色。<br/>- 类型为CanvasGradient时,表示渐变对象,使用[createLinearGradient](#createlineargradient)方法创建。<br/>- 类型为CanvasPattern时,使用[createPattern](#createpattern)方法创建。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineCap](#linecap) | CanvasLineCap | 指定线端点的样式,可选值为:<br/>- 'butt':线端点以方形结束。<br/>- 'round':线端点以圆形结束。<br/>- 'square':线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。<br/>- 默认值:'butt'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [lineJoin](#linejoin) | CanvasLineJoin | 指定线段间相交的交点样式,可选值为:<br/>- 'round':在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。<br/>- 'bevel':在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。<br/>- 'miter':在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。<br/>- 默认值:'miter'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [miterLimit](#miterlimit) | number | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 <br/>- 默认值:10。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [font](#font) | string | 设置文本绘制中的字体样式。<br/>语法:ctx.font='font-size font-family'<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列。<br/>语法:ctx.font='font-style font-weight font-size font-family'<br/>- font-style(可选),用于指定字体样式,支持如下几种样式:'normal','italic'。<br/>- font-weight(可选),用于指定字体的粗细,支持如下几种类型:'normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900。<br/>- font-size(可选),指定字号和行高,单位只支持px。<br/>- font-family(可选),指定字体系列,支持如下几种类型:'sans-serif', 'serif', 'monospace'。<br/>- 默认值:'normal normal 14px sans-serif'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [textAlign](#textalign) | CanvasTextAlign | 设置文本绘制中的文本对齐方式,可选值为:<br/>- 'left':文本左对齐。<br/>- 'right':文本右对齐。<br/>- 'center':文本居中对齐。<br/>- 'start':文本对齐界线开始的地方。<br/>- 'end':文本对齐界线结束的地方。<br/>> **说明:**<br/>> ltr布局模式下'start'和'left'一致,rtl布局模式下'start'和'right'一致·。<br/>- 默认值:'left'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [textBaseline](#textbaseline) | CanvasTextBaseline | 设置文本绘制中的水平对齐方式,可选值为:<br/>- 'alphabetic':文本基线是标准的字母基线。<br/>- 'top':文本基线在文本块的顶部。<br/>- 'hanging':文本基线是悬挂基线。<br/>- 'middle':文本基线在文本块的中间。<br/>- 'ideographic':文字基线是表意字基线;如果字符本身超出了alphabetic基线,那么ideograhpic基线位置在字符本身的底部。<br/>- 'bottom':文本基线在文本块的底部。 与ideographic基线的区别在于ideographic基线不需要考虑下行字母。<br/>- 默认值:'alphabetic'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | [globalAlpha](#globalalpha) | number | 设置透明度,0.0为完全透明,1.0为完全不透明。 | -| [lineDashOffset](#linedashoffset) | number | 设置画布的虚线偏移量,精度为float。 <br/>- 默认值:0.0。 | -| [globalCompositeOperation](#globalcompositeoperation) | string | 设置合成操作的方式。类型字段可选值有'source-over','source-atop','source-in','source-out','destination-over','destination-atop','destination-in','destination-out','lighter','copy','xor'。<br/>- 默认值:'source-over'。 | -| [shadowBlur](#shadowblur) | number | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 <br/>- 默认值:0.0。 | -| [shadowColor](#shadowcolor) | string | 设置绘制阴影时的阴影颜色。 | -| [shadowOffsetX](#shadowoffsetx) | number | 设置绘制阴影时和原有对象的水平偏移值。 | -| [shadowOffsetY](#shadowoffsety) | number | 设置绘制阴影时和原有对象的垂直偏移值。 | -| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 <br/>- 默认值:true。 | +| [lineDashOffset](#linedashoffset) | number | 设置画布的虚线偏移量,精度为float。 <br/>- 默认值:0.0。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [globalCompositeOperation](#globalcompositeoperation) | string | 设置合成操作的方式。类型字段可选值有'source-over','source-atop','source-in','source-out','destination-over','destination-atop','destination-in','destination-out','lighter','copy','xor'。<br/>- 默认值:'source-over'。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowBlur](#shadowblur) | number | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 <br/>- 默认值:0.0。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowColor](#shadowcolor) | string | 设置绘制阴影时的阴影颜色。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowOffsetX](#shadowoffsetx) | number | 设置绘制阴影时和原有对象的水平偏移值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [shadowOffsetY](#shadowoffsety) | number | 设置绘制阴影时和原有对象的垂直偏移值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 <br/>- 默认值:true。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | > **说明:** > fillStyle、shadowColor与 strokeStyle 中string类型格式为 'rgb(255, 255, 255)','rgba(255, 255, 255, 1.0)','\#FFFFFF'。 @@ -700,6 +702,8 @@ fillRect(x: number, y: number, w: number, h: number): void 填充一个矩形。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -747,6 +751,8 @@ strokeRect(x: number, y: number, w: number, h: number): void 绘制具有边框的矩形,矩形内部不填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -794,6 +800,8 @@ clearRect(x: number, y: number, w: number, h: number): void 删除指定区域内的绘制内容。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -843,6 +851,8 @@ fillText(text: string, x: number, y: number, maxWidth?: number): void 绘制填充类文本。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -891,6 +901,8 @@ strokeText(text: string, x: number, y: number): void 绘制描边类文本。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -939,6 +951,8 @@ measureText(text: string): TextMetrics 该方法返回一个文本测算的对象,通过该对象可以获取指定文本的宽度值。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -947,9 +961,9 @@ measureText(text: string): TextMetrics **返回值:** -| 类型 | 说明 | -| ----------- | ------- | -| TextMetrics | 文本的尺寸信息 | +| 类型 | 说明 | +| ----------- | ------------------------------------------------------------ | +| TextMetrics | 文本的尺寸信息<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | **TextMetrics类型描述:** @@ -1009,6 +1023,8 @@ stroke(path?: Path2D): void 进行边框绘制操作。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1058,6 +1074,8 @@ beginPath(): void 创建一个新的绘制路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -1101,6 +1119,8 @@ moveTo(x: number, y: number): void 路径从当前点移动到指定点。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1149,6 +1169,8 @@ lineTo(x: number, y: number): void 从当前点到指定点进行路径连接。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1197,6 +1219,8 @@ closePath(): void 结束当前路径形成一个封闭路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -1240,6 +1264,8 @@ createPattern(image: ImageBitmap, repetition: string | null): CanvasPattern | nu 通过指定图像和重复方式创建图片填充的模板。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1294,6 +1320,8 @@ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, 创建三次贝赛尔曲线的路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1346,6 +1374,8 @@ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void 创建二次贝赛尔曲线的路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1396,6 +1426,8 @@ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, 绘制弧线路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1447,6 +1479,8 @@ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void 依据圆弧经过的点和圆弧半径创建圆弧路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1497,6 +1531,8 @@ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number 在规定的矩形区域绘制一个椭圆。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1549,6 +1585,8 @@ rect(x: number, y: number, w: number, h: number): void 创建矩形路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1597,6 +1635,8 @@ fill(fillRule?: CanvasFillRule): void 对封闭路径进行填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1638,6 +1678,8 @@ fill(path: Path2D, fillRule?: CanvasFillRule): void 对封闭路径进行填充。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1695,6 +1737,8 @@ clip(fillRule?: CanvasFillRule): void 设置当前路径为剪切路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1741,6 +1785,8 @@ clip(path:Path2D, fillRule?: CanvasFillRule): void 设置封闭路径为剪切路径。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1797,6 +1843,8 @@ filter(filter: string): void 为Canvas图形设置各类滤镜效果。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 说明 | @@ -1810,6 +1858,8 @@ getTransform(): Matrix2D 获取当前被应用到上下文的转换矩阵。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### resetTransform @@ -1817,6 +1867,8 @@ resetTransform(): void 使用单位矩阵重新设置当前变形。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### direction @@ -1824,6 +1876,8 @@ direction(direction: CanvasDirection): void 绘制文本时,描述当前文本方向的属性。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + ### rotate @@ -1831,6 +1885,8 @@ rotate(angle: number): void 针对当前坐标轴进行顺时针旋转。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1876,6 +1932,8 @@ scale(x: number, y: number): void 设置canvas画布的缩放变换属性,后续的绘制操作将按照缩放比例进行缩放。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -1924,6 +1982,8 @@ transform(a: number, b: number, c: number, d: number, e: number, f: number): voi transform方法对应一个变换矩阵,想对一个图形进行变化的时候,只要设置此变换矩阵相应的参数,对图形的各个定点的坐标分别乘以这个矩阵,就能得到新的定点的坐标。矩阵变换效果可叠加。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + > **说明:** > 变换后的坐标计算方式(x和y为变换前坐标,x'和y'为变换后坐标): > @@ -1987,6 +2047,8 @@ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): setTransform方法使用的参数和transform()方法相同,但setTransform()方法会重置现有的变换矩阵并创建新的变换矩阵。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2040,6 +2102,8 @@ translate(x: number, y: number): void 移动当前坐标系的原点。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2091,6 +2155,8 @@ drawImage(image: ImageBitmap | PixelMap, sx: number, sy: number, sw: number, sh: 进行图像绘制。 +从API version 9开始,该接口支持在ArkTS卡片中使用,卡片中不支持PixelMap对象。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2144,6 +2210,8 @@ createImageData(sw: number, sh: number): ImageData 根据宽高创建ImageData对象,请参考[ImageData](ts-components-canvas-imagedata.md)。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认 | 描述 | @@ -2156,6 +2224,8 @@ createImageData(imageData: ImageData): ImageData 根据已创建的ImageData对象创建新的ImageData对象,请参考[ImageData](ts-components-canvas-imagedata.md)。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认 | 描述 | @@ -2217,6 +2287,8 @@ getImageData(sx: number, sy: number, sw: number, sh: number): ImageData 以当前canvas指定区域内的像素创建[ImageData](ts-components-canvas-imagedata.md)对象。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2276,6 +2348,8 @@ putImageData(imageData: Object, dx: number, dy: number, dirtyX: number, dirtyY: 使用[ImageData](ts-components-canvas-imagedata.md)数据填充新的矩形区域。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2331,6 +2405,8 @@ setLineDash(segments: number[]): void 设置画布的虚线样式。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 描述 | @@ -2375,6 +2451,8 @@ getLineDash(): number[] 获得当前画布的虚线样式。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **返回值:** | 类型 | 说明 | @@ -2481,6 +2559,8 @@ imageSmoothingQuality(quality: imageSmoothingQuality) 用于设置图像平滑度。该接口为空接口。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 描述 | @@ -2544,6 +2624,8 @@ restore(): void 对保存的绘图上下文进行恢复。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -2585,6 +2667,8 @@ save(): void 对当前的绘图上下文进行保存。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **示例:** ```ts @@ -2626,6 +2710,8 @@ createLinearGradient(x0: number, y0: number, x1: number, y1: number): void 创建一个线性渐变色。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2678,6 +2764,8 @@ createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, 创建一个径向渐变色。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** | 参数 | 类型 | 必填 | 默认值 | 描述 | @@ -2779,3 +2867,5 @@ struct OffscreenCanvasConicGradientPage { ## CanvasPattern 一个Object对象, 通过[createPattern](#createpattern)方法创建。 + +从API version 9开始,该接口支持在ArkTS卡片中使用。 \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md index b2ae6d899c62fc7d28c04d633f6f85905059f63c..d097a205da899a01cdeee8b1a914211c6dc42a7f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-state-management.md @@ -752,6 +752,8 @@ abstract get(): T 读取从AppStorage/LocalStorage同步属性的数据。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **返回值:** | 类型 | 描述 | @@ -770,9 +772,10 @@ prop1.get(); // prop1.get()=47 abstract set(newValue: T): void - 设置AppStorage/LocalStorage同步属性的数据。 +从API version 9开始,该接口支持在ArkTS卡片中使用。 + **参数:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index a2666355283735e6935d12b6faf42a3fba6d683b..11f0c61a7e44545b0374a82b260187074c633e07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -14,7 +14,7 @@ | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | | blur | number | - | 为当前组件添加内容模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。<br/>取值范围:[0, +∞)<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | backdropBlur | number | - | 为当前组件添加背景模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。<br/>取值范围:[0, +∞)<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | -| shadow | [ShadowOptions](#shadowoptions对象说明) \| [ShadowStyle](#shadowstyle10枚举说明) | - | 为当前组件添加阴影效果。<br/>入参类型为ShadowOptions时,可以指定模糊半径、阴影的颜色、X轴和Y轴的偏移量。<br/>入参类型为ShadowStyle时,可指定不同阴影样式。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>ArkTS卡片上不支持参数为 [ShadowStyle](#shadowstyle10枚举说明)类型。 | +| shadow | [ShadowOptions](#shadowoptions对象说明) \| [ShadowStyle](#shadowstyle10枚举说明) | - | 为当前组件添加阴影效果。<br/>入参类型为ShadowOptions时,可以指定模糊半径、阴影的颜色、X轴和Y轴的偏移量。<br/>入参类型为ShadowStyle时,可指定不同阴影样式。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用,ArkTS卡片上不支持参数为 [ShadowStyle](#shadowstyle10枚举说明)类型。 | | grayscale | number | 0.0 | 为当前组件添加灰度效果。值定义为灰度转换的比例,入参1.0则完全转为灰度图像,入参则0.0图像无变化,入参在0.0和1.0之间时,效果呈线性变化。(百分比)<br/>取值范围:[0, 1]<br/>**说明:** <br/>设置小于0的值时,按值为0处理,设置大于1的值时,按值为1处理。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | brightness | number | 1.0 | 为当前组件添加高光效果,入参为高光比例,值为1时没有效果,小于1时亮度变暗,0为全黑,大于1时亮度增加,数值越大亮度越大。<br/>取值范围:[0, +∞)<br/>**说明:** <br/>设置小于0的值时,按值为0处理。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | | saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大,小于1时消色成分越大,饱和度越小。(百分比)<br/>取值范围:[0, +∞)<br/>**说明:** <br/>设置小于0的值时,按值为0处理。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index e15fc1b17998ce850e2943cb213129e24f0153be..0368594df8a4a2c21c69d143b24dfbf28605d670 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -12,8 +12,8 @@ | 名称 | 参数类型 | 描述 | | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| bindMenu | content: Array<[MenuItem](#menuitem)> \| [CustomBuilder](ts-types.md#custombuilder8),<br>options<sup>10+</sup>: [MenuOptions](#menuoptions10)<sup>10+</sup> | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持图标+文本排列和自定义两种功能。<br/>content: 必填,配置菜单项图标和文本的数组,或者自定义组件<br/>options: 非必填,配置弹出菜单的参数 | -| bindContextMenu<sup>8+</sup> | content: [CustomBuilder](ts-types.md#custombuilder8),<br>responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | +| bindMenu | content: Array<[MenuItem](#menuitem)> \| [CustomBuilder](ts-types.md#custombuilder8),<br>options: [MenuOptions](#menuoptions10) | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持图标+文本排列和自定义两种功能。<br/>content: 必填,配置菜单项图标和文本的数组,或者自定义组件。<br/>options: 非必填,配置弹出菜单的参数。 | +| bindContextMenu<sup>8+</sup> | content: [CustomBuilder](ts-types.md#custombuilder8),<br>responseType: [ResponseType](ts-appendix-enums.md#responsetype8)<br>options: [ContextMenuOptions](#contextmenuoptions10) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。<br/>responseType: 必填。菜单弹出条件,长按或者右键点击。<br/>options: 非必填,配置弹出菜单的参数。 | ## MenuItem @@ -29,6 +29,18 @@ | ------ | -------------------------------- | ---- | ------------------------------------------------------ | | title | string | 否 | 菜单标题。 | | offset | [Position](ts-types.md#position8) | 否 | 菜单弹出位置的偏移量,不会导致菜单显示超出屏幕范围。 | +| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 菜单组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom | +| onAppear | () => void | 否 | 菜单弹出时的事件回调。 | +| onDisappear | () => void | 否 | 菜单消失时的事件回调。 | + +## ContextMenuOptions<sup>10+</sup> + +| 名称 | 类型 | 必填 | 描述 | +| ----------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| offset | [Position](ts-types.md#position8) | 否 | 菜单弹出位置的偏移量,不会导致菜单显示超出屏幕范围。 | +| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 菜单组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom | +| onAppear | () => void | 否 | 菜单弹出时的事件回调。 | +| onDisappear | () => void | 否 | 菜单消失时的事件回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index 5cb4dcb09c9d2b7ff7c23ede334363329d791044..3cd1617601ff2bd83cc79b17ccb78e05868ab016 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -13,13 +13,13 @@ | 名称 | 参数类型 | 描述 | | -----------| ---------------------------------------- | ------------------------------------ | -| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置字体颜色。 | -| fontSize | [Length](ts-types.md#length) | 设置字体大小,Length为number类型时,使用fp单位。字体默认大小16。不支持设置百分比字符串。 | -| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。<br>默认值:FontStyle.Normal | -| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal | -| fontFamily | string \| [Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体。| -| lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | -| decoration | {<br/>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?: [ResourceColor](ts-types.md#resourcecolor)<br/>} | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type: TextDecorationType.None,<br/>color:Color.Black<br/>} | +| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置字体颜色。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| fontSize | [Length](ts-types.md#length) | 设置字体大小,Length为number类型时,使用fp单位。字体默认大小16。不支持设置百分比字符串。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 设置字体样式。<br>默认值:FontStyle.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。string类型仅支持number类型取值的字符串形式,例如"400",以及"bold"、"bolder"、"lighter"、"regular"、"medium",分别对应FontWeight中相应的枚举值。<br/>默认值:FontWeight.Normal<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| fontFamily | string \| [Resource](ts-types.md#resource) | 设置字体列表。默认字体'HarmonyOS Sans',且当前只支持这种字体。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| lineHeight | string \| number \| [Resource](ts-types.md#resource) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | +| decoration | {<br/>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?: [ResourceColor](ts-types.md#resourcecolor)<br/>} | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type: TextDecorationType.None,<br/>color:Color.Black<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 | ## 示例 diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index 5830ba88f2b5d9e42683719a9ee07131fc6882f5..f62793e075092aa82bfec2508151942534022745 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -974,6 +974,16 @@ **ACL使能**:TRUE +## ohos.permission.ENTERPRISE_SET_NETWORK + +允许设备管理员设置网络信息。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:TRUE + ## ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY 允许设备管理员设置应用运行管理策略。 @@ -1787,3 +1797,13 @@ **授权方式**:system_grant **ACL使能**:FALSE + +## ohos.permission.GET_INSTALLED_BUNDLE_LIST + +允许应用读取已安装应用列表。 + +**权限级别**:system_basic + +**授权方式**:user_grant + +**ACL使能**:TRUE diff --git a/zh-cn/application-dev/tools/aa-tool.md b/zh-cn/application-dev/tools/aa-tool.md index b29887aa695013591709fc309c8079a6886782d6..1be35ff10856c4fe4d40d5c8b55e1f3711e77699 100644 --- a/zh-cn/application-dev/tools/aa-tool.md +++ b/zh-cn/application-dev/tools/aa-tool.md @@ -72,7 +72,7 @@ Ability assistant(Ability助手,简称为aa),是实现应用及测试用 | -------- | -------- | -------- | | -h/--help | - | 帮助信息。 | | -a/--all | - | 打印所有mission内的应用组件信息。 | - | -l/--mission-list | type(缺省打印全部) | 服务侧为了方便管理任务链,内部维护了4种类型的任务链。<br/>可取值:<br/>- NORMAL: 正常启动的任务链(比如A拉起B拉起C, 则对应的任务链是A->B->C)<br/>- DEFAULT_STANDARD: 已经被破坏的任务链中的任务, 启动模式为standard的任务被放到该任务链中, 这里面的任务之间没有关联关系<br/>- DEFAULT_SINGLE: 已经被破坏的任务链中的任务, 启动模式为singleton的任务被放到该任务链中, 这里面的任务之间没有关联关系<br/>- LAUNCHER: launcher的任务链 | + | -l/--mission-list | type(缺省打印全部) | 服务侧为了方便管理任务链,内部维护了4种类型的任务链。<br/>可取值:<br/>- NORMAL:正常启动的任务链(比如A拉起B拉起C, 则对应的任务链是A->B->C)<br/>- DEFAULT_STANDARD:已经被破坏的任务链中的任务, 启动模式为`multiton`的任务被放到该任务链中, 这里面的任务之间没有关联关系<br/>- DEFAULT_SINGLE:已经被破坏的任务链中的任务, 启动模式为`singleton`的任务被放到该任务链中, 这里面的任务之间没有关联关系<br/>- LAUNCHER:launcher的任务链 | | -e/--extension | elementName | 打印扩展组件信息。 | | -u/--userId | UserId | 打印指定UserId的栈信息,需要和其他参数组合使用,例如aa dump -a -u 100、aa dump -d -u 100。 | | -d/--data | - | 打印DataAbility相关信息。 | diff --git a/zh-cn/application-dev/ui/arkts-graphics-display.md b/zh-cn/application-dev/ui/arkts-graphics-display.md index 0f415eee201bf176ccf23741d554295206afcb43..196046e3ff0e846292fbdde4aad88f4d3aa78fbc 100644 --- a/zh-cn/application-dev/ui/arkts-graphics-display.md +++ b/zh-cn/application-dev/ui/arkts-graphics-display.md @@ -78,9 +78,9 @@ Image支持加载存档图、多媒体像素图两种类型。 @Entry @Component struct Index { - private imgDatas: string[] = []; + @State imgDatas: string[] = []; // 获取照片url集 - async getAllImg() { + getAllImg() { let photoPicker = new picker.PhotoViewPicker(); let result = new Array<string>(); try { @@ -89,29 +89,31 @@ Image支持加载存档图、多媒体像素图两种类型。 PhotoSelectOptions.maxSelectNumber = 5; let photoPicker = new picker.PhotoViewPicker(); photoPicker.select(PhotoSelectOptions).then((PhotoSelectResult) => { - result = PhotoSelectResult.photoUris; + this.imgDatas = PhotoSelectResult.photoUris; + console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult)); }).catch((err) => { console.error(`PhotoViewPicker.select failed with. Code: ${err.code}, message: ${err.message}`); }); } catch (err) { console.error(`PhotoViewPicker failed with. Code: ${err.code}, message: ${err.message}`); } - return result; } // aboutToAppear中调用上述函数,获取图库的所有图片url,存在imgDatas中 async aboutToAppear() { - this.imgDatas = await this.getAllImg(); + this.getAllImg(); } // 使用imgDatas的url加载图片。 build() { - Grid() { - ForEach(this.imgDatas, item => { - GridItem() { - Image(item) - .width(200) - } - }, item => JSON.stringify(item)) - } + Column() { + Grid() { + ForEach(this.imgDatas, item => { + GridItem() { + Image(item) + .width(200) + } + }, item => JSON.stringify(item)) + } + }.width('100%').height('100%') } } ``` diff --git a/zh-cn/application-dev/ui/arkts-layout-development-linear.md b/zh-cn/application-dev/ui/arkts-layout-development-linear.md index 9623a681192b05aa22eb310d3083422e8b112dc9..1dee7a3963c2ec6f14636b6f3fda5e5d94820f9a 100644 --- a/zh-cn/application-dev/ui/arkts-layout-development-linear.md +++ b/zh-cn/application-dev/ui/arkts-layout-development-linear.md @@ -22,9 +22,9 @@ - 布局子元素:布局容器内部的元素。 -- 主轴:线性布局容器在布局方向上的轴线,子元素默认沿主轴排列。Row容器主轴为纵向,Column容器主轴为横向。 +- 主轴:线性布局容器在布局方向上的轴线,子元素默认沿主轴排列。Row容器主轴为横向,Column容器主轴为纵向。 -- 交叉轴:垂直于主轴方向的轴线。Row容器交叉轴为横向,Column容器交叉轴为纵向。 +- 交叉轴:垂直于主轴方向的轴线。Row容器交叉轴为纵向,Column容器交叉轴为横向。 - 间距:布局子元素的纵向间距。 diff --git a/zh-cn/application-dev/ui/arkts-page-transition-animation.md b/zh-cn/application-dev/ui/arkts-page-transition-animation.md index 0342e53704d69dde11856ba506d007a784503e1e..31b996ce9952b8fea4ebdfecf53320bdca18e9ba 100644 --- a/zh-cn/application-dev/ui/arkts-page-transition-animation.md +++ b/zh-cn/application-dev/ui/arkts-page-transition-animation.md @@ -60,7 +60,7 @@ pageTransition() { ``` -假设页面栈为标准实例模式,即页面栈中允许存在重复的页面。可能会有4种场景,对应的页面转场效果如下表。 +假设页面栈为多实例模式,即页面栈中允许存在重复的页面。可能会有4种场景,对应的页面转场效果如下表。 | 路由操作 | 页面A转场效果 | 页面B转场效果 | @@ -118,7 +118,7 @@ pageTransition() { ``` -以上代码则完整的定义了所有可能的页面转场样式。假设页面栈为标准实例模式,即页面栈中允许存在重复的页面。可能会有4种场景,对应的页面转场效果如下表。 +以上代码则完整的定义了所有可能的页面转场样式。假设页面跳转配置为多实例模式,即页面栈中允许存在重复的页面。可能会有4种场景,对应的页面转场效果如下表。 | 路由操作 | 页面A转场效果 | 页面B转场效果 | diff --git a/zh-cn/application-dev/ui/arkts-routing.md b/zh-cn/application-dev/ui/arkts-routing.md index cc585fc3975a17eb1a7628d0f1d0e521299bc360..9b429f754dc95927a022da333200c0ca09e7f6fd 100644 --- a/zh-cn/application-dev/ui/arkts-routing.md +++ b/zh-cn/application-dev/ui/arkts-routing.md @@ -11,11 +11,11 @@ **图1** 页面跳转 ![router-jump-to-detail](figures/router-jump-to-detail.gif) -Router模块提供了两种跳转模式,分别是[router.pushUrl()](../reference/apis/js-apis-router.md#routerpushurl9)和[router.replaceUrl()](../reference/apis/js-apis-router.md#routerreplaceurl9)。这两种模式决定了目标页是否会替换当前页。 +Router模块提供了两种跳转模式,分别是[router.pushUrl()](../reference/apis/js-apis-router.md#routerpushurl9)和[router.replaceUrl()](../reference/apis/js-apis-router.md#routerreplaceurl9)。这两种模式决定了目标页面是否会替换当前页。 -- router.pushUrl():目标页不会替换当前页,而是压入[页面栈](../application-models/page-mission-stack.md)。这样可以保留当前页的状态,并且可以通过返回键或者调用[router.back()](../reference/apis/js-apis-router.md#routerback)方法返回到当前页。 +- router.pushUrl():目标页面不会替换当前页,而是压入[页面栈](../application-models/page-mission-stack.md)。这样可以保留当前页的状态,并且可以通过返回键或者调用[router.back()](../reference/apis/js-apis-router.md#routerback)方法返回到当前页。 -- router.replaceUrl():目标页会替换当前页,并销毁当前页。这样可以释放当前页的资源,并且无法返回到当前页。 +- router.replaceUrl():目标页面会替换当前页,并销毁当前页。这样可以释放当前页的资源,并且无法返回到当前页。 >**说明:** > @@ -23,9 +23,9 @@ Router模块提供了两种跳转模式,分别是[router.pushUrl()](../referen 同时,Router模块提供了两种实例模式,分别是Standard和Single。这两种模式决定了目标url是否会对应多个实例。 -- Standard:标准实例模式,也是默认情况下的实例模式。每次调用该方法都会新建一个目标页,并压入栈顶。 +- Standard:多实例模式,也是默认情况下的跳转模式。目标页面会被添加到页面栈顶,无论栈中是否存在相同url的页面。 -- Single:单实例模式。即如果目标页的url在页面栈中已经存在同url页面,则离栈顶最近的同url页面会被移动到栈顶,并重新加载;如果目标页的url在页面栈中不存在同url页面,则按照标准模式跳转。 +- Single:单实例模式。如果目标页面的url已经存在于页面栈中,则会将离栈顶最近的同url页面移动到栈顶,该页面成为新建页。如果目标页面的url在页面栈中不存在同url页面,则按照默认的多实例模式进行跳转。 在使用页面路由Router相关功能之前,需要在代码中先导入Router模块。 @@ -54,7 +54,7 @@ import router from '@ohos.router'; >**说明:** > - >标准实例模式下,router.RouterMode.Standard参数可以省略。 + >多实例模式下,router.RouterMode.Standard参数可以省略。 - 场景二:有一个登录页(Login)和一个个人中心页(Profile),希望从登录页成功登录后,跳转到个人中心页。同时,销毁登录页,在返回时直接退出应用。这种场景下,可以使用replaceUrl()方法,并且使用Standard实例模式(或者省略)。 @@ -76,7 +76,7 @@ import router from '@ohos.router'; >**说明:** > - >标准实例模式下,router.RouterMode.Standard参数可以省略。 + >多实例模式下,router.RouterMode.Standard参数可以省略。 - 场景三:有一个设置页(Setting)和一个主题切换页(Theme),希望从设置页点击主题选项,跳转到主题切换页。同时,需要保证每次只有一个主题切换页存在于页面栈中,在返回时直接回到设置页。这种场景下,可以使用pushUrl()方法,并且使用Single实例模式。 @@ -115,7 +115,7 @@ import router from '@ohos.router'; 以上是不带参数传递的场景。 -如果需要在跳转时传递一些数据给目标页,则可以在调用Router模块的方法时,添加一个params属性,并指定一个对象作为参数。例如: +如果需要在跳转时传递一些数据给目标页面,则可以在调用Router模块的方法时,添加一个params属性,并指定一个对象作为参数。例如: ```ts @@ -150,7 +150,7 @@ function onJumpClick(): void { } ``` -在目标页中,可以通过调用Router模块的[getParams()](../reference/apis/js-apis-router.md#routergetparams)方法来获取传递过来的参数。例如: +在目标页面中,可以通过调用Router模块的[getParams()](../reference/apis/js-apis-router.md#routergetparams)方法来获取传递过来的参数。例如: ```ts @@ -162,7 +162,7 @@ const age = params['info'].age; // 获取age属性的值 ## 页面返回 -当用户在一个页面完成操作后,通常需要返回到上一个页面或者指定页面,这就需要用到页面返回功能。在返回的过程中,可能需要将数据传递给目标页,这就需要用到数据传递功能。 +当用户在一个页面完成操作后,通常需要返回到上一个页面或者指定页面,这就需要用到页面返回功能。在返回的过程中,可能需要将数据传递给目标页面,这就需要用到数据传递功能。 **图2** 页面返回   @@ -195,7 +195,7 @@ import router from '@ohos.router'; }); ``` - 这种方式可以返回到指定页面,需要指定目标页的路径。目标页必须存在于页面栈中才能够返回。 + 这种方式可以返回到指定页面,需要指定目标页面的路径。目标页面必须存在于页面栈中才能够返回。 - 方式三:返回到指定页面,并传递自定义参数信息。 @@ -209,9 +209,9 @@ import router from '@ohos.router'; }); ``` - 这种方式不仅可以返回到指定页面,还可以在返回的同时传递自定义参数信息。这些参数信息可以在目标页中通过调用router.getParams()方法进行获取和解析。 + 这种方式不仅可以返回到指定页面,还可以在返回的同时传递自定义参数信息。这些参数信息可以在目标页面中通过调用router.getParams()方法进行获取和解析。 -在目标页中,在需要获取参数的位置调用router.getParams()方法即可,例如在onPageShow()生命周期回调中: +在目标页面中,在需要获取参数的位置调用router.getParams()方法即可,例如在onPageShow()生命周期回调中: ```ts @@ -275,7 +275,7 @@ function onBackClick(): void { message:string类型,表示询问框的内容。 如果调用成功,则会在目标界面开启页面返回询问框;如果调用失败,则会抛出异常,并通过err.code和err.message获取错误码和错误信息。 -当用户点击“返回”按钮时,会弹出确认对话框,询问用户是否确认返回。选择“取消”将停留在当前页目标页;选择“确认”将触发router.back()方法,并根据参数决定如何执行跳转。 +当用户点击“返回”按钮时,会弹出确认对话框,询问用户是否确认返回。选择“取消”将停留在当前页目标页面;选择“确认”将触发router.back()方法,并根据参数决定如何执行跳转。 ### 自定义询问框 @@ -322,4 +322,4 @@ function onBackClick() { } ``` -当用户点击“返回”按钮时,会弹出自定义的询问框,询问用户是否确认返回。选择“取消”将停留在当前页目标页;选择“确认”将触发router.back()方法,并根据参数决定如何执行跳转。 +当用户点击“返回”按钮时,会弹出自定义的询问框,询问用户是否确认返回。选择“取消”将停留在当前页目标页面;选择“确认”将触发router.back()方法,并根据参数决定如何执行跳转。 diff --git a/zh-cn/contribute/FAQ.md b/zh-cn/contribute/FAQ.md index 4c75f95e3a738c36a6287dc5faa7c3c649d65646..297545c0bddfa863f8e0e2102fc59724c43074b8 100755 --- a/zh-cn/contribute/FAQ.md +++ b/zh-cn/contribute/FAQ.md @@ -44,7 +44,7 @@ OS\(操作系统\)开发时,经常会遇到多个代码仓的修改具有编 **解决办法**: - 点击[这里](https://dco.openharmony.io/sign/Z2l0ZWUlMkZvcGVuX2hhcm1vbnk=)签署、查看签署状态。 + 点击[这里](https://dco.openharmony.cn/sign)签署、查看签署状态。 在PR的评论框输入`check dco`后,单击”评论”,系统将再次进行DCO校验。 diff --git a/zh-cn/device-dev/subsystems/subsys-power-level-LED-color.md b/zh-cn/device-dev/subsystems/subsys-power-level-LED-color.md index 9ac5e5d617e9133ad84bb9f4496d77d83dc07f5a..b20548fbae050749788b8c54f97cd30623d049b2 100644 --- a/zh-cn/device-dev/subsystems/subsys-power-level-LED-color.md +++ b/zh-cn/device-dev/subsystems/subsys-power-level-LED-color.md @@ -58,13 +58,18 @@ Linux调测环境,相关要求和配置可参考《[快速入门](../quick-sta } ``` - **表1** 电量与LED灯颜色映射配置说明 + **表1** 电量等级说明 - | 节点名称 | 作用 | + | 电量等级 | 描述 | | -------- | -------- | | low | 低电量 | | normal | 正常电量 | | high | 高电量 | + + **表2** 电量区间与LED灯颜色映射配置说明 + + | 配置项 | 描述 | + | -------- | -------- | | soc | 电量区间 | | rgb | LED灯RGB组合 | diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 8940a99b9405ce3b07d9203e35d7e70723e05c86..e1492351cc194336af04ff45cfa78212bebc02a9 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -540,7 +540,7 @@ - [xdevice测试调度框架使用指导](device-test/xdevice.md) - 调测工具 - [bytrace使用指导](subsystems/subsys-toolchain-bytrace-guide.md) - - [hdc 使用指导](subsystems/subsys-toolchain-hdc-guide.md) + - [hdc使用指导](subsystems/subsys-toolchain-hdc-guide.md) - [hiperf 使用指南](subsystems/subsys-toolchain-hiperf.md) - [XTS认证](device-test/xts.md) - 工具