diff --git a/en/application-dev/application-models/application-context-stage.md b/en/application-dev/application-models/application-context-stage.md index 8c26d7fbb70a19db0ab07ada99f4df8cc0b290df..c4aec7e780752391a872c1f5d7391b569a2ef8a4 100644 --- a/en/application-dev/application-models/application-context-stage.md +++ b/en/application-dev/application-models/application-context-stage.md @@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different. | Name| Path| | -------- | -------- | - | bundleCodeDir | /el1/bundle/| - | cacheDir | //base/cache/| - | filesDir | //base/files/| - | preferencesDir | //base/preferences/| - | tempDir | //base/temp/| - | databaseDir | //database/| - | distributedFilesDir | /el2/distributedFiles/| + | bundleCodeDir | \/el1/bundle/ | + | cacheDir | \/\/base/cache/ | + | filesDir | \/\/base/files/ | + | preferencesDir | \/\/base/preferences/ | + | tempDir | \/\/base/temp/ | + | databaseDir | \/\/database/ | + | distributedFilesDir | \/el2/distributedFiles/ | The sample code is as follows: @@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different. | Name| Path| | -------- | -------- | - | bundleCodeDir | /el1/bundle/| - | cacheDir | //base/**haps/\**/cache/| - | filesDir | //base/**haps/\**/files/| - | preferencesDir | //base/**haps/\**/preferences/| - | tempDir | //base/**haps/\**/temp/| - | databaseDir | //database/**\**/| - | distributedFilesDir | /el2/distributedFiles/**\**/| + | bundleCodeDir | \/el1/bundle/ | + | cacheDir | \/\/base/**haps/\**/cache/ | + | filesDir | \/\/base/**haps/\**/files/ | + | preferencesDir | \/\/base/**haps/\**/preferences/ | + | tempDir | \/\/base/**haps/\**/temp/ | + | databaseDir | \/\/database/**\**/ | + | distributedFilesDir | \/el2/distributedFiles/**\**/ | The sample code is as follows: diff --git a/en/application-dev/application-models/arkts-ui-widget-event-call.md b/en/application-dev/application-models/arkts-ui-widget-event-call.md index 073506706053e31402d7c69d645138ec7ab112cc..69189afb06c941158047462015519499961c9b95 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-call.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-call.md @@ -1,13 +1,13 @@ # Launching a UIAbility in the Background Through the call Event -There may be cases you want to provide in a widget access to features available in your application when it is running in the foreground, for example, the play, pause, and stop buttons in a music application widget. This is where the **call** capability of the **postCardAction** API comes in handy. This capability, when used in a widget, can start the specified UIAbility of the widget provider in the background. It also allows the widget to call the specified method of the application and transfer data so that the application, while in the background, can behave accordingly in response to touching of the buttons on the widget. +There may be cases you want to provide in a widget access to features available in your application running in the foreground, for example, the play, pause, and stop buttons in a music application widget. This is where the **call** capability of the **postCardAction** API comes in handy. This capability, when used in a widget, can start the specified UIAbility of the widget provider in the background. It also allows the widget to call the specified method of the application and transfer data so that the application, while in the background, can behave accordingly in response to touching of the buttons on the widget. -Generally, buttons are used to trigger the **call** event. Below is an example. +Typically, the call event is triggered for touching of buttons. Below is an example. -- In this example, two buttons are laid out on the widget page. When one button is clicked, the **postCardAction** API is called to send a **call** event to the target UIAbility. Note that the **method** parameter in the API indicates the method to call in the target UIAbility. It is mandatory and of the string type. +- In this example, two buttons are laid out on the widget page. When one button is clicked, the **postCardAction** API is called to send a call event to the target UIAbility. Note that the **method** parameter in the API indicates the method to call in the target UIAbility. It is mandatory and of the string type. ```ts @Entry @@ -37,7 +37,7 @@ Generally, buttons are used to trigger the **call** event. Below is an example. 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed. 'params': { 'method': 'funB', // Set the name of the method to call in the EntryAbility. - 'num': 1 // Set other parameters to be transferred. + 'num': 1 // Set other parameters to be passed in. } }); }) @@ -48,34 +48,36 @@ Generally, buttons are used to trigger the **call** event. Below is an example. } ``` -- The UIAbility receives the **call** event and obtains the transferred parameters. It then executes the target method specified by the **method** parameter. Other data can be obtained in readString mode. Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility. +- The UIAbility receives the call event and obtains the transferred parameters. It then executes the target method specified by the **method** parameter. Other data can be obtained in readString mode. Listen for the method required by the call event in the **onCreate** callback of the UIAbility. ```ts import UIAbility from '@ohos.app.ability.UIAbility'; function FunACall(data) { - // Obtain all parameters transferred in the call event. + // Obtain all parameters passed in the call event. console.info('FunACall param:' + JSON.stringify(data.readString())); return null; } function FunBCall(data) { - console.info('FunACall param:' + JSON.stringify(data.readString())); + console.info('FunBCall param:' + JSON.stringify(data.readString())); return null; } export default class CameraAbility extends UIAbility { - // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received. + // If the UIAbility is started for the first time, onCreate is triggered afte the call event is received. onCreate(want, launchParam) { try { // Listen for the method required by the call event. this.callee.on('funA', FunACall); this.callee.on('funB', FunBCall); - } catch (error) { + } catch (err) { console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`); } } + ... + // Deregister the listener when the process exits. onDestroy() { try { diff --git a/en/application-dev/application-models/arkts-ui-widget-event-overview.md b/en/application-dev/application-models/arkts-ui-widget-event-overview.md index ed029fc3017d00a7d4c2cf14e1b905139bd7eb49..299a279c9117dad71e6fea658bb8da3298ed8f05 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-overview.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-overview.md @@ -1,6 +1,6 @@ # Widget Event Capability Overview -The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the provider application. Currently, this API supports the router, message, and call events and can be called only in the widget. +The ArkTS widget provides the **postCardAction()** API for interaction between the widget internal and the widget provider. Currently, this API supports the router, message, and call events and can be called only in the widget. ![WidgetPostCardAction](figures/WidgetPostCardAction.png) @@ -8,26 +8,28 @@ The ArkTS widget provides the **postCardAction()** API for interaction between t **Parameters** + | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| component | Object | Yes| Instance of the current custom component. Generally, **this** is transferred.| +| component | Object | Yes| Instance of the current custom component. Generally, **this** is passed in.| | action | Object | Yes| Action description. For details, see the following table.| **Description of the action parameter** + | Key | Value | Description| | -------- | -------- | -------- | -| "action" | string | Action type.
- **"router"**: redirection to the specified UIAbility of the widget provider.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.| +| "action" | string | Action type.
- **"router"**: redirection to the specified UIAbility of the widget provider.
- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../reference/apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.
- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility (whose [launch type](uiability-launch-type.md) must be singleton) of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../security/permission-list.md#ohospermissionkeep_background_running) permission.| | "bundleName" | string | Name of the target bundle when **action** is **"router"** or **"call"**. This parameter is optional.| | "moduleName" | string | Name of the target module when **action** is **"router"** or **"call"**. This parameter is optional.| | "abilityName" | string | Name of the target UIAbility when **action** is **"router"** or **"call"**. This parameter is mandatory.| -| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter must be set and its value type must be string. This parameter is mandatory.| +| "params" | Object | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter (mandatory) must be set and its value type must be string.| Sample code of the **postCardAction()** API: ```typescript -Button ('Jump') +Button ('Redirect') .width('40%') .height('20%') .onClick(() => { @@ -51,7 +53,7 @@ Button ('Start in Background') 'abilityName': 'EntryAbility', 'params': { 'method': 'fun', // Set the name of the method to call. It is mandatory. - 'message': 'testForcall' // Customize the message to send. + 'message': 'testForCall' // Customize the message to send. } }); }) diff --git a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md index ca66e20aa2d258a0e05002296dac39c19ac131c3..17a211188704609e5bc60dcbcf6b058a8a8a0dbe 100644 --- a/en/application-dev/application-models/arkts-ui-widget-event-uiability.md +++ b/en/application-dev/application-models/arkts-ui-widget-event-uiability.md @@ -5,7 +5,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ## Updating Widget Content Through the router Event -- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the **router** event to the FormExtensionAbility. +- On the widget page, register the **onClick** event callback of the button and call the **postCardAction** API in the callback to trigger the router event to the FormExtensionAbility. ```ts let storage = new LocalStorage(); @@ -16,7 +16,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o build() { Column() { - Button ('Jump') + Button ('Redirect') .margin('20%') .onClick(() => { console.info('postCardAction to EntryAbility'); @@ -45,7 +45,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o import formInfo from '@ohos.app.form.formInfo'; export default class EntryAbility extends UIAbility { - // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the router event is received. + // If the UIAbility is started for the first time, onCreate is triggered after the router event is received. onCreate(want, launchParam) { console.info('Want:' + JSON.stringify(want)); if (want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { @@ -63,7 +63,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o }) } } - // If the UIAbility is running in the background, the onNewWant lifecycle callback is triggered after the router event is received. + // If the UIAbility is running in the background, onNewWant is triggered after the router event is received. onNewWant(want, launchParam) { console.info('onNewWant Want:' + JSON.stringify(want)); if (want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { @@ -88,7 +88,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ## Updating Widget Content Through the call Event -- When using the **call** event of the **postCardAction** API, the value of **formId** must be updated in the **onAddForm** callback of the FormExtensionAbility. +- When using the call event of the **postCardAction** API, the value of **formId** must be updated in the **onAddForm** callback of the FormExtensionAbility. ```ts import formBindingData from '@ohos.app.form.formBindingData'; @@ -142,13 +142,12 @@ On the widget page, the **postCardAction** API can be used to trigger a router o } ``` -- Listen for the method required by the **call** event in the **onCreate** callback of the UIAbility, and then call the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) API in the corresponding method to update the widget. +- Listen for the method required by the call event in the **onCreate** callback of the UIAbility, and then call the [updateForm](../reference/apis/js-apis-app-form-formProvider.md#updateform) API in the corresponding method to update the widget. ```ts import UIAbility from '@ohos.app.ability.UIAbility'; import formBindingData from '@ohos.app.form.formBindingData'; import formProvider from '@ohos.app.form.formProvider'; - import formInfo from '@ohos.app.form.formInfo'; const MSG_SEND_METHOD: string = 'funA'; @@ -173,7 +172,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o return null; } export default class EntryAbility extends UIAbility { - // If the UIAbility is started for the first time, the onCreate lifecycle callback is triggered after the call event is received. + // If the UIAbility is started for the first time, onCreate is triggered after the call event is received. onCreate(want, launchParam) { console.info('Want:' + JSON.stringify(want)); try { diff --git a/en/application-dev/application-models/create-dataability.md b/en/application-dev/application-models/create-dataability.md index f7eceab4da4711b15bd94bb0d61ef99c62521286..9d148a7ba28ffe46484f32b07f7a7660ef49f72d 100644 --- a/en/application-dev/application-models/create-dataability.md +++ b/en/application-dev/application-models/create-dataability.md @@ -12,7 +12,7 @@ import dataAbility from '@ohos.data.dataAbility' import relationalStore from '@ohos.data.relationalStore' const TABLE_NAME = 'book' -const STORE_CONFIG = { name: 'book.db' } +const STORE_CONFIG = { name: 'book.db',securityLevel: 1 } const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)' let rdbStore: relationalStore.RdbStore = undefined diff --git a/en/application-dev/connectivity/ipc-rpc-overview.md b/en/application-dev/connectivity/ipc-rpc-overview.md index 29fdec791c9a6b96d2ae2138b47a9b8dc48c050b..0ca829403e00a833f787b4f4de5b5997dbd4afe7 100755 --- a/en/application-dev/connectivity/ipc-rpc-overview.md +++ b/en/application-dev/connectivity/ipc-rpc-overview.md @@ -3,42 +3,25 @@ ## Basic Concepts -The inter-process communication (IPC) and remote procedure call (RPC) mechanisms are used to implement cross-process communication. The difference between them lies in that IPC uses the Binder driver to implement cross-process communication within a device, whereas RPC uses the DSoftBus driver to implement cross-process communication across devices. +Inter-process communication (IPC) and remote procedure call (RPC) are used to implement cross-process communication. IPC uses the Binder driver to implement cross-process communication within a device, whereas RPC uses the DSoftBus driver to implement cross-process communication across devices. Cross-process communication is required because each process has its own independent resources and memory space and one process is not allowed to access the resources and memory space of other processes. -The reason why cross-process communication is needed is that each process has its own independent resources and memory space and one process is not allowed to access the resources and memory space of other processes. IPC and RPC usually use the client-server model, where the client (service requester, that is, the process that requests a service) obtains the proxy of the server (service provider, that is, the process that provides the service) and uses the proxy to read and write data to implement data communication across processes. More specifically, the client constructs a proxy object of the server. The proxy object has the same functions as the server. To access a certain API of the server, you only need to access the corresponding API in the proxy object. The proxy object sends the request to the server, and the server processes the received request and returns the processing result to the proxy object through the driver. Then, the proxy object forwards the processing result to the client. The server registers system abilities (SAs) with the system ability manager (SAMgr), which manages the SAs and provides APIs for clients. To communicate with a specific SA, the client must obtain the proxy of the SA from SAMgr. +> **NOTE** +> The applications in the stage model cannot use IPC or RPC directly, and must use the following capabilities to implement related service scenarios: +>- [Background services](../application-models/background-services.md): use IPC to implement service invocation across processes. +>- [Multi-device collaboration](../application-models/hop-multi-device-collaboration.md): uses RPC to call remote interfaces and transfer data. -In the following sections, proxy represents the service requester, and stub represents the service provider. -![IPC&RPC communication mechanisms](figures/IPC_RPC_communication.PNG) +## Implementation Principles +IPC and RPC usually use the client-server model, where the client (service requester, that is, the process that requests a service) obtains the proxy of the server (service provider, that is, the process that provides the service) and uses the proxy to read and write data to implement data communication across processes. More specifically, the client constructs a proxy object of the server. The proxy object has the same functions as the server. To access a certain API of the server, you only need to access the corresponding API in the proxy object. The proxy object sends the request to the server, and the server processes the received request and returns the processing result to the proxy object through the driver. Then, the proxy object forwards the processing result to the client. The server registers system abilities (SAs) with the system ability manager (SAMgr), which manages the SAs and provides APIs for clients. To communicate with a specific SA, the client must obtain the proxy of the SA from SAMgr. In the following sections, proxy represents the service requester, and stub represents the service provider. -## Constraints - -- During cross-process communication within a single device, the maximum amount of data to be transmitted is about 1 MB. If the amount of data to be transmitted exceeds this limit, use the [anonymous shared memory](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-rpc.md#ashmem8). -- Subscription to death notifications of anonymous stub objects (not registered with SAMgr) is prohibited in RPC. -- During cross-process communication across processes, a proxy object cannot be passed back to the device that hosts the stub object pointed by the proxy object. That is, the proxy object pointing to the stub object of the remote device cannot be passed across processes twice on the local device. - -## **Recommendations** - -First, compile an API class and define message codes in the API class for both communication parties to identify operations. Unimplemented APIs are allowed in the API class because it must be inherited by both communication parties and its inheritance classes cannot be abstract classes. When inheriting the API class, both communication parties must implement the unimplemented APIs, so as to make sure that the inheritance classes are not abstract classes. - -Then, implement the API class specific to the stub, and override the **AsObject** and **OnRemoteRequest** APIs. In addition, compile the proxy to implement the APIs in the API class and override the **AsObject** API. You can also encapsulate an additional API for calling **SendRequest** to send data to the peer. - -After the preceding operations are done, register a system ability (SA) with SAMgr. Note that the registration should be completed in the process that hosts the stub. Then, obtain the proxy from SAMgr as needed to implement cross-process communication with the stub. +![IPC & RPC communication mechanisms] (figures/IPC_RPC_communication.PNG) -Related steps are as follows: -- Implementing the API class: Inherit **IRemoteBroker**, define message codes, and declare APIs that are not implemented in the API class. - -- Implementing the service provider (stub): Inherit **IRemoteStub** or **RemoteObject**, and override the **AsObject** and **OnRemoteRequest** APIs. - -- Implementing the service requester (proxy): Inherit **IRemoteProxy** or **RemoteProxy**, override the **AsObject** API, and encapsulate the required API to call **SendRequest**. - -- Registering the SA: Apply for a unique ID for the SA, and register the SA with SAMgr. - -- Obtaining the SA: Obtain the proxy based on the SA ID and device ID, and use the proxy to communicate with the remote end. +## Constraints +- A maximum of 1 MB data can be transferred in cross-process communication on a single device. If the amount of data to be transmitted is larger than 1 MB, use [anonymous shared memory](../reference/apis/js-apis-rpc.md#ashmem8). -## Related Modules +- Subscription to death notifications of anonymous stub objects (not registered with SAMgr) is prohibited in RPC. -[Distributed Ability Manager Service Framework](https://gitee.com/openharmony/ability_dmsfwk) +- During cross-process communication across processes, a proxy object cannot be passed back to the device that hosts the stub object pointed by the proxy object. That is, the proxy object pointing to the stub object of the remote device cannot be passed across processes twice on the local device. diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index d8fbe8fbb02648dde7269b25f65a114e87fc8490..89b5ef119fe4e296a158c26a6407f2eb752c0b49 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -3,8 +3,6 @@ - Getting Started - [Before You Start](start-overview.md) - [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md) - - [Getting Started with ArkTS in FA Model](start-with-ets-fa.md) - - [Getting Started with JavaScript in FA Model](start-with-js-fa.md) - Development Fundamentals - Application Package Fundamentals - [Application Package Overview](application-package-overview.md) @@ -38,9 +36,9 @@ - Application Configuration Files in FA Model - [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md) - [Internal Structure of the app Tag](app-structure.md) - - [Internal Structure of deviceConfig Tag](deviceconfig-structure.md) + - [Internal Structure of the deviceConfig Tag](deviceconfig-structure.md) - [Internal Structure of the module Tag](module-structure.md) -- [Resource Categories and Access](resource-categories-and-access.md) + - [Resource Categories and Access](resource-categories-and-access.md) - Learning ArkTS - [Getting Started with ArkTS](arkts-get-started.md) - Basic Syntax @@ -49,19 +47,19 @@ - Custom Component - [Creating a Custom Component](arkts-create-custom-components.md) - [Page and Custom Component Lifecycle](arkts-page-custom-components-lifecycle.md) - - [\@Builder: Custom Builder Function](arkts-builder.md) - - [\@BuilderParam: @Builder Function Reference](arkts-builderparam.md) - - [\@Styles: Definition of Resusable Styles](arkts-style.md) - - [\@Extend: Extension of Built-in Components](arkts-extend.md) - - [stateStyles: Polymorphic Style](arkts-statestyles.md) + - [\@Builder Decorator: Custom Builder Function](arkts-builder.md) + - [\@BuilderParam Decorator: @Builder Function Reference](arkts-builderparam.md) + - [\@Styles Decorator: Definition of Resusable Styles](arkts-style.md) + - [\@Extend Decorator: Extension of Built-in Components](arkts-extend.md) + - [stateStyles Decorator: Polymorphic Style](arkts-statestyles.md) - State Management - [State Management Overview](arkts-state-management-overview.md) - Component State Management - - [\@State: State Owned by Component](arkts-state.md) - - [\@Prop: One-Way Synchronization from Parent to Child Components](arkts-prop.md) - - [\@Link: Two-Way Synchronization Between Parent and Child Components](arkts-link.md) - - [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](arkts-provide-and-consume.md) - - [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md) + - [\@State Decorator: State Owned by Component](arkts-state.md) + - [\@Prop Decorator: One-Way Synchronization from Parent to Child Components](arkts-prop.md) + - [\@Link Decorator: Two-Way Synchronization Between Parent and Child Components](arkts-link.md) + - [\@Provide and \@Consume Decorators: Two-Way Synchronization with Descendant Components](arkts-provide-and-consume.md) + - [\@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md) - Application State Management - [Application State Management Overview](arkts-application-state-management-overview.md) - [LocalStorage: UI State Storage](arkts-localstorage.md) diff --git a/en/application-dev/quick-start/arkts-builder.md b/en/application-dev/quick-start/arkts-builder.md index 9efe5b95238ad1b73f8fbb5689b630387ac18d4f..80a262fcd97a0dcf6808bf8cdb84bf78849cb0e1 100644 --- a/en/application-dev/quick-start/arkts-builder.md +++ b/en/application-dev/quick-start/arkts-builder.md @@ -1,4 +1,4 @@ -# \@Builder: Custom Builder Function +# \@Builder Decorator: Custom Builder Function As previously described, you can reuse UI elements by creating a custom component, which comes with a fixed internal UI structure and allows for data transfer only with its caller. ArkUI also provides a more lightweight mechanism for reusing UI elements: \@Builder. An \@Builder decorated function is a special function that serves similar purpose as the build function. The \@Builder function body follows the same syntax rules as the **build** function. You can abstract reusable UI elements into a method and call the method in **build**. diff --git a/en/application-dev/quick-start/arkts-builderparam.md b/en/application-dev/quick-start/arkts-builderparam.md index 26f25044c2968a5417fdc73fd355bd24997d14df..66647f094bfa5e5e090dba5cb5b1f0af27850d5f 100644 --- a/en/application-dev/quick-start/arkts-builderparam.md +++ b/en/application-dev/quick-start/arkts-builderparam.md @@ -1,4 +1,4 @@ -# \@BuilderParam: @Builder Function Reference +# \@BuilderParam Decorator: @Builder Function Reference In certain circumstances, you may need to add a specific function, such as a click-to-jump action, to a custom component. However, embedding an event method directly inside of the component will add the function to all places where the component is imported. This is where the \@BuilderParam decorator comes into the picture. \@BuilderParam is used to decorate a custom component member variable of type reference to an \@Builder method. When initializing a custom component, you can assign a value to the variable, thereby adding the specific function to the custom component. This decorator can be used to declare an element of any UI description, similar to a slot placeholder. diff --git a/en/application-dev/quick-start/arkts-environment.md b/en/application-dev/quick-start/arkts-environment.md index 2f0718290460508c4510acc298fa85c855bbec26..e31c54b463e0d5d2fa40b46e0451e2377e405845 100644 --- a/en/application-dev/quick-start/arkts-environment.md +++ b/en/application-dev/quick-start/arkts-environment.md @@ -29,6 +29,7 @@ Environment is a singleton object created by the ArkUI framework at application The chain of updates is as follows: Environment > AppStorage > Component. > **NOTE** +> > An \@StorageProp decorated variable can be locally modified, but the change will not be updated to AppStorage. This is because the environment variable parameters are read-only to the application. diff --git a/en/application-dev/quick-start/arkts-extend.md b/en/application-dev/quick-start/arkts-extend.md index 0867e7b3cece4d2d7928ac401b38851dadcf6669..b62609775869ebd443cecb8378a77f0a9bc7d2d4 100644 --- a/en/application-dev/quick-start/arkts-extend.md +++ b/en/application-dev/quick-start/arkts-extend.md @@ -1,10 +1,11 @@ -# \@Extend: Extension of Built-in Components +# \@Extend Decorator: Extension of Built-in Components Apart from\@Styles used to extend styles, AkrUI also provides \@Extend, which allows you to add a new attribute feature to a built-in component. > **NOTE** +> > Since API version 9, this decorator is supported in ArkTS widgets. diff --git a/en/application-dev/quick-start/arkts-link.md b/en/application-dev/quick-start/arkts-link.md index 0147645b6e0c964528df98edfd8e692b15b7d994..81db9ef3e2f4ce2df8cec8a1c793712ca79374d8 100644 --- a/en/application-dev/quick-start/arkts-link.md +++ b/en/application-dev/quick-start/arkts-link.md @@ -1,4 +1,4 @@ -# \@Link: Two-Way Synchronization Between Parent and Child Components +# \@Link Decorator: Two-Way Synchronization Between Parent and Child Components An \@Link decorated variable can create two-way synchronization with a variable of its parent component. diff --git a/en/application-dev/quick-start/arkts-observed-and-objectlink.md b/en/application-dev/quick-start/arkts-observed-and-objectlink.md index 1282545cc1d65a1acdc90da3ac5a2828cf611ca9..808e522540be970004aab0a2bcd2009af3916df0 100644 --- a/en/application-dev/quick-start/arkts-observed-and-objectlink.md +++ b/en/application-dev/quick-start/arkts-observed-and-objectlink.md @@ -1,4 +1,4 @@ -# \@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects +# \@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects The decorators described above can observe only the changes of the first layer. However, in real-world application development, the application may encapsulate its own data model based on development requirements. In the case of multi-layer nesting, for example, a two-dimensional array, an array item class, or a class insider another class as an attribute, the attribute changes at the second layer cannot be observed. This is where the \@Observed and \@ObjectLink decorators come in handy. diff --git a/en/application-dev/quick-start/arkts-prop.md b/en/application-dev/quick-start/arkts-prop.md index ca1ac8c34cdd8fb1f783cdadac3a219bfcc05548..1e962f469695d8d942847469dbebec1fcbf30ade 100644 --- a/en/application-dev/quick-start/arkts-prop.md +++ b/en/application-dev/quick-start/arkts-prop.md @@ -1,4 +1,4 @@ -# \@Prop: One-Way Synchronization from Parent to Child Components +# \@Prop Decorator: One-Way Synchronization from Parent to Child Components An \@Prop decorated variable can create one-way synchronization with a variable of its parent component. \@Prop decorated variables are mutable, but changes are not synchronized to the parent component. diff --git a/en/application-dev/quick-start/arkts-provide-and-consume.md b/en/application-dev/quick-start/arkts-provide-and-consume.md index d8dc8f5b41748c06982e6d339a88e0b2261dbd69..427e2f79d0d2f04b62c8d31f7633f10ab449d8eb 100644 --- a/en/application-dev/quick-start/arkts-provide-and-consume.md +++ b/en/application-dev/quick-start/arkts-provide-and-consume.md @@ -1,4 +1,4 @@ -# \@Provide and \@Consume: Two-Way Synchronization with Descendant Components +# \@Provide and \@Consume Decorators: Two-Way Synchronization with Descendant Components \@Provide and \@Consume are used for two-way data synchronization with descendant components in scenarios where state data needs to be transferred between multiple levels. They do not involve passing a variable from component to component multiple times. diff --git a/en/application-dev/quick-start/arkts-rendering-control-overview.md b/en/application-dev/quick-start/arkts-rendering-control-overview.md index ad8f6667308a0cd849c5b93f5f3f323af3c6f030..95febe4736e91ab5fd0b84ea28369ba9bd3f0325 100644 --- a/en/application-dev/quick-start/arkts-rendering-control-overview.md +++ b/en/application-dev/quick-start/arkts-rendering-control-overview.md @@ -1,4 +1,4 @@ -# Overview of Rendering Control +# Rendering Control Overview ArkUI uses the **build()** function of [custom components](arkts-create-custom-components.md) and declarative UI description statements in the [@builder decorator](arkts-builder.md) to build the corresponding UI. In declarative description statements, you can use rendering control statements in addition to system components to accelerate UI construction. These rendering control statements include conditional statements that control whether components are displayed, rendering statements for repeated content that quickly generate components based on array data, and lazy loading statements for scenarios involving a large amount of data. diff --git a/en/application-dev/quick-start/arkts-state.md b/en/application-dev/quick-start/arkts-state.md index 6ac35e388df8471d78245fd52fa82aa8a5a7f580..be3260d6855bdb72a8e38fbaea31307117ec091b 100644 --- a/en/application-dev/quick-start/arkts-state.md +++ b/en/application-dev/quick-start/arkts-state.md @@ -1,4 +1,4 @@ -# \@State: State Owned by Component +# \@State Decorator: State Owned by Component An \@State decorated variable, also called a state variable, is a variable that holds the state property and is used to render the owning custom component. When it changes, the UI is re-rendered accordingly. diff --git a/en/application-dev/quick-start/arkts-statestyles.md b/en/application-dev/quick-start/arkts-statestyles.md index fd0ac67bdba9603d82d385658c89ffbc40d931db..c712d74e8bacdda40235efe0798e6092df03ec63 100644 --- a/en/application-dev/quick-start/arkts-statestyles.md +++ b/en/application-dev/quick-start/arkts-statestyles.md @@ -1,4 +1,4 @@ -# stateStyles: Polymorphic Style +# stateStyles Decorator: Polymorphic Style Unlike \@Styles and \@Extend, which are used to reuse styles only on static pages, stateStyles enables you to set state-specific styles. diff --git a/en/application-dev/quick-start/arkts-style.md b/en/application-dev/quick-start/arkts-style.md index 64f03c11e337bd4932c5bb7fbece4ac59499364c..a380964f5893e963e6ce3c62c64d1255f37a8042 100644 --- a/en/application-dev/quick-start/arkts-style.md +++ b/en/application-dev/quick-start/arkts-style.md @@ -1,4 +1,4 @@ -# \@Styles: Definition of Resusable Styles +# \@Styles Decorator: Definition of Resusable Styles If the style of each component needs to be set separately, this will result in a large amount of repeated code during development. Though copy and paste is available, it is inefficient and error-prone. To maximize code efficiency and maintainability, the \@Styles decorator is introduced. diff --git a/en/application-dev/quick-start/figures/changeToAPI10.png b/en/application-dev/quick-start/figures/changeToAPI10.png new file mode 100644 index 0000000000000000000000000000000000000000..32c7660ccf7dbd05c206b7753a2dfdb72cca5d0e Binary files /dev/null and b/en/application-dev/quick-start/figures/changeToAPI10.png differ diff --git a/en/application-dev/quick-start/figures/chooseStageModel.png b/en/application-dev/quick-start/figures/chooseStageModel.png index 3125c8ba0591ce0c53344f35fb780eb956601624..b7dd96b6b7c5d2afd241e0c6fd9ee91977692115 100644 Binary files a/en/application-dev/quick-start/figures/chooseStageModel.png and b/en/application-dev/quick-start/figures/chooseStageModel.png differ diff --git a/en/application-dev/quick-start/figures/createProject.png b/en/application-dev/quick-start/figures/createProject.png index 7a56a44e0e7f80671b86c521792352db625ccad7..6c884853a1afcb2dbb72f1e5f7914ab063908299 100644 Binary files a/en/application-dev/quick-start/figures/createProject.png and b/en/application-dev/quick-start/figures/createProject.png differ diff --git a/en/application-dev/quick-start/figures/deleteRuntimeOS.png b/en/application-dev/quick-start/figures/deleteRuntimeOS.png new file mode 100644 index 0000000000000000000000000000000000000000..8087b03be057d646ae6e3348abae73c1e840b781 Binary files /dev/null and b/en/application-dev/quick-start/figures/deleteRuntimeOS.png differ diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001609333677.png b/en/application-dev/quick-start/figures/en-us_image_0000001609333677.png new file mode 100644 index 0000000000000000000000000000000000000000..88e2fede373b6b369375bc2d8e58b2dba0770da6 Binary files /dev/null and b/en/application-dev/quick-start/figures/en-us_image_0000001609333677.png differ diff --git a/en/application-dev/quick-start/figures/targetSdkVersion.png b/en/application-dev/quick-start/figures/targetSdkVersion.png new file mode 100644 index 0000000000000000000000000000000000000000..e3846adab2a4b644e09dd00c7e66c79db94cbb18 Binary files /dev/null and b/en/application-dev/quick-start/figures/targetSdkVersion.png differ diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md index deb8f8029bc24a78a362f0babdaf5e85c2e000f3..2bc53666dce570f5c9c5c9c5a0b8c48e353422d2 100644 --- a/en/application-dev/quick-start/start-overview.md +++ b/en/application-dev/quick-start/start-overview.md @@ -29,8 +29,9 @@ The application model is the abstraction of capabilities required by OpenHarmony Along its evolution, OpenHarmony has provided two application models: -- Feature Ability (FA) model. This model is supported by OpenHarmony API version 7 and 8. It is no longer recommended. For details about development based on the FA model, see [FA Model Development Overview](../application-models/fa-model-development-overview.md). -- Stage model. This model is supported since OpenHarmony API version 9. It is recommended and will evolve for a long time. In this model, classes such as **AbilityStage** and **WindowStage** are provided as the stage of application components and windows. That's why it is named stage model. For details about development based on the stage model, see [Stage Model Development Overview](../application-models/fa-model-development-overview.md). +- **Stage model**: This model is supported since API version 9. It is recommended. In this model, classes such as **AbilityStage** and **WindowStage** are provided as the stage of application components and windows. That's why it is named stage model. For details about development based on the stage model, see [Stage Model Development Overview](../application-models/stage-model-development-overview.md). The examples in this document are all based on the stage model. + +- **Feature Ability (FA) model**: This model is supported since API version 7. It is no longer recommended. For details about development based on the FA model, see [FA Model Development Overview](../application-models/fa-model-development-overview.md). For details about the differences between the FA model and stage model, see [Interpretation of the Application Model](../application-models/application-model-description.md). @@ -39,8 +40,8 @@ To help you better understand the preceding basic concepts and application devel ## Tool Preparation -1. Download the latest version of [DevEco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio). +1. Download the latest version of [DevEco Studio](../../release-notes/OpenHarmony-v4.0-beta1.md#version-mapping). 2. Install DevEco Studio and configure the development environment. For details, see [Setting Up the Development Environment](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/environment_config-0000001052902427-V3). -When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md), [Getting Started with ArkTS in FA Model](start-with-ets-fa.md), and [Getting Started with JavaScript in FA Model](start-with-js-fa.md). +When you are done, follow the instructions in [Getting Started with ArkTS in Stage Model](start-with-ets-stage.md). diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index fb8593d555aec31c44e7a6658f6a68f2ab99dccb..b36b98e08c31e1132ada81230d3ef8110227a422 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -1,20 +1,27 @@ # Getting Started with ArkTS in Stage Model -> **NOTE** -> -> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later. -> -> For best possible results, use [DevEco Studio 3.1 Beta2](https://developer.harmonyos.com/cn/develop/deveco-studio) for your development. - +> **NOTE** +> +> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later. +> +> In this document, DevEco Studio 4.0 Beta1 is used. You can download it [here](../../release-notes/OpenHarmony-v4.0-beta1.md#version-mapping). ## Creating an ArkTS Project -1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**. +The procedure for creating a project varies, depending on whether the API version is later than 9 or not. + +The following describes how to create the OpenHarmony projects of API 10 and API 9. + +### Creating a Project of API Version 10 + +1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. + +2. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**. ![createProject](figures/createProject.png) -2. On the project configuration page, set **Compile SDK** to **9**, **Model** to **Stage**, and retain the default values for other parameters. +3. On the project configuration page, set **Compile SDK** to **3.1.0(API 9** and retain the default values for other parameters. ![chooseStageModel](figures/chooseStageModel.png) @@ -25,27 +32,102 @@ > On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features. > > To use the low-code development mode, turn on **Enable Super Visual** on the page shown above. - -3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. -4. After the project is created, in the **entry** > **build-profile.json5** file, change **runtimeOS** under **targets** to **OpenHarmony**, and click **Sync Now** in the upper right corner to start development. +4. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. + +5. After the project is created, in the project-level **build-profile.json5** file, move the **compileSdkVersion** and **compatibleSdkVersion** fields from under **app** to under the current **products**. You can identify the current **products** by clicking the ![en-us_image_0000001609333677](figures/en-us_image_0000001609333677.png) icon in the upper right corner of the editing area. + + ![changeToAPI10](figures/changeToAPI10.png) + +6. Change the value of **targetSdkVersion** from **9** to **10** and set **runtimeOS** to **OpenHarmony**. + + ![targetSdkVersion](figures/targetSdkVersion.png) + +7. Delete the **runtimeOS** configuration from the **targets** field in all module-level **build-profile.json5** files. + + ![deleteRuntimeOS](figures/deleteRuntimeOS.png) + +8. Click **Sync Now** and wait until the synchronization is complete. A project of API version 10 is now created. + +### Creating a Project of API Version 9 + +1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. + +2. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**. + + ![createProject](figures/createProject.png) + +3. On the project configuration page, set **Compile SDK** to **3.1.0(API 9** and retain the default values for other parameters. + + ![chooseStageModel](figures/chooseStageModel.png) + + > **NOTE** + > + > You can use the low-code development mode apart from the traditional coding approach. + > + > On the low-code development pages, you can design your application UI in an efficient, intuitive manner, with a wide array of UI editing features. + > + > To use the low-code development mode, turn on **Enable Super Visual** on the page shown above. + +4. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created. + +5. In the module-level **entry** > **build-profile.json5** file, set **runtimeOS** in **targets** to **OpenHarmony**. + +6. Click **Sync Now** and wait until the synchronization is complete. A project of API version 9 is now created. + + +## ArkTS Project Directory Structure (Stage Model, API Version 10) + +![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png) + +- **AppScope > app.json5**: application-level configuration information. + +- **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). + - **src > main > ets**: a collection of ArkTS source code. + + - **src > main > ets > entryability**: entry to your application/service. + + - **src > main > ets > pages**: pages included in your application/service. + + - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories). + + - **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md). + + - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. + + - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation in this file. + +- **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212). +- **build-profile.json5**: application-level configuration options, including **signingConfigs** and **products**. The **runtimeOS** field in **products** indicates the runtime OS. Its default value is **HarmonyOS**. If you are developing an OpenHarmony application, change the value to **OpenHarmony**. -## ArkTS Project Directory Structure (Stage Model) +- **hvigorfile.ts**: application-level build script. + +## ArkTS Project Directory Structure (Stage Model, API Version 9) ![en-us_image_0000001364054489](figures/en-us_image_0000001364054489.png) -- **AppScope** > **app.json5**: global configuration of your application. +- **AppScope > app.json5**: application-level configuration information. + - **entry**: OpenHarmony project module, which can be built into an OpenHarmony Ability Package ([HAP](../../glossary.md#hap)). - **src > main > ets**: a collection of ArkTS source code. + - **src > main > ets > entryability**: entry to your application/service. + - **src > main > ets > pages**: pages included in your application/service. + - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. For details about resource files, see [Resource Categories and Access](resource-categories-and-access.md#resource-categories). + - **src > main > module.json5**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. For details, see [module.json5 Configuration File](module-configuration-file.md). - - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. Under **targets**, you can set **runtimeOS** to **HarmonyOS** (default) or **OpenHarmony**, depending on the OS of your application. - - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation. + + - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**. The **runtimeOS** field in **targets** indicates the runtime OS. Its default value is **HarmonyOS**. If you are developing an OpenHarmony application, change the value to **OpenHarmony**. + + - **hvigorfile.ts**: module-level build script. You can customize related tasks and code implementation in this file. + - **oh_modules**: third-party library dependency information. For details about how to adapt a historical npm project to ohpm, see [Manually Migrating Historical Projects](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/project_overview-0000001053822398-V3#section108143331212). -- **build-profile.json5**: application-level configuration information, including the signature and product configuration. + +- **build-profile.json5**: application-level configuration information, including the **signingConfigs** and **products** configuration. + - **hvigorfile.ts**: application-level build script. @@ -127,7 +209,7 @@ ![secondPage](figures/secondPage.png) - > **NOTE** + > **NOTE** > > You can also right-click the **pages** folder and choose **New** > **Page** from the shortcut menu. In this scenario, you do not need to manually configure page routes. - Configure the route for the second page: In the **Project** window, choose **entry** > **src** > **main** > **resources** > **base** > **profile**. In the **main_pages.json** file, set **pages/Second** under **src**. The sample code is as follows: diff --git a/en/application-dev/reference/apis/js-apis-app-form-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md index d81c78c439f21e0ce60ff3df6e33c3d949ee980a..dfa9be0cc2133245a53bcccef8f3899edca4cd1d 100644 --- a/en/application-dev/reference/apis/js-apis-app-form-formHost.md +++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md @@ -1563,7 +1563,7 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------- | | type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstall event.| -| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**. | +| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**.| **Error codes** @@ -1698,8 +1698,8 @@ Unsubscribes from widget removal events. This API uses an asynchronous callback | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------- | | type | string | Yes | Event type. The value **'formRemove'** indicates a widget removal event.| -| callback | Callback<formInfo.RunningFormInfo> | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.
To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formRemove')**. | -| bundleName | string | No| Name of the bundle that functions as the widget host.
To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.
By default, the subscriptions for all the widget hosts are canceled. | +| callback | Callback<formInfo.RunningFormInfo> | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.
To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formRemove')**.| +| bundleName | string | No| Name of the bundle that functions as the widget host.
To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.
By default, the subscriptions for all the widget hosts are canceled.| **Example** @@ -2162,9 +2162,11 @@ import formHost from '@ohos.app.form.formHost'; let formId = '12400633174999288'; try { - formHost.acquireFormData(formId, (error) => { + formHost.acquireFormData(formId, (error, data) => { if (error) { console.error(`error, code: ${error.code}, message: ${error.message}`); + } else { + console.log('formHost acquireFormData, data: ${JSON.stringify(data)}'); } }); } catch(error) { @@ -2192,7 +2194,7 @@ Requests data from the widget provider. This API uses a promise to return the re | Type | Description | | ------------------- | ------------------------- | -| Promise<void> | Promise that returns no value.| +| Promise<{[key: string]: Object}>| Promise used to return the API call result and the shared data.| **Error codes** @@ -2210,8 +2212,8 @@ import formHost from '@ohos.app.form.formHost'; let formId = '12400633174999288'; try { - formHost.acquireFormData(formId).then(() => { - console.log('formHost acquireFormData success'); + formHost.acquireFormData(formId).then((data) => { + console.log('formHost acquireFormData success' + data); }).catch((error) => { console.error(`error, code: ${error.code}, message: ${error.message}`); }); @@ -2286,7 +2288,7 @@ Obtains the information about widget hosts based on the widget provider informat | Name | Type | Mandatory| Description | | ----------- | --------------- | ---- | -------------------------------- | | formProviderFilter | formInfo.FormProviderFilter [formInfo.FormProviderFilter](js-apis-app-form-formInfo.md#formProviderFilter) | Yes | Information about the widget provider.| -| callback | AsyncCallback<Array<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **data** is an error object.| +| callback | AsyncCallback<Array<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **error** is an error object.| **Error codes** @@ -2339,7 +2341,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses | Type | Description | | ------------------- | ------------------------- | -| Promise<Array<formInfo.RunningFormInfo[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the widget host information obtained. | +| Promise<Array<formInfo.RunningFormInfo[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the widget host information obtained.| **Error codes** @@ -2379,7 +2381,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses | Name | Type | Mandatory| Description | | ----------- | --------------- | ---- | -------------------------------- | | formId | string | Yes | Widget ID.| -| callback | AsyncCallback<Array<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **data** is an error object.| +| callback | AsyncCallback<Array<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget host information is obtained, **error** is **undefined** and **data** is the information obtained; otherwise, **error** is an error object.| **Error codes** diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index a488a313beff34555f589b57bdea17ddbdbcc752..3a0ac438824d64f406da50343624be1368f92eee 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -3592,7 +3592,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | ---------------------------- | ---- | ---------- | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device.| +| device | [AudioDevice](#audiodevice10) | Yes | Audio device.| | callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** @@ -3611,17 +3611,64 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js -call.setAudioDevice(1, (err) => { +let audioDevice={ + deviceType: 1 +} +call.setAudioDevice(audioDevice, (err) => { console.log(`callback: err->${JSON.stringify(err)}`); }); ``` +## call.setAudioDevice10+ + +setAudioDevice\(device: AudioDevice): Promise\ + +Sets the audio device for a call. This API uses a promise to return the result. + +**System API**: This is a system API. + +**Required permission**: ohos.permission.SET_TELEPHONY_STATE + +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------------- | ---- | ---------- | +| device | [AudioDevice](#audiodevice10) | Yes | Audio device.| + +**Error codes** + +For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). + +| ID| Error Message | +| -------- | -------------------------------------------- | +| 201 | Permission denied. | +| 202 | Non-system applications use system APIs. | +| 401 | Parameter error. | +| 8300001 | Invalid parameter value. | +| 8300002 | Operation failed. Cannot connect to service. | +| 8300003 | System internal error. | +| 8300999 | Unknown error code. | + +**Example** + +```js +let audioDevice={ + deviceType: 1 +} +call.setAudioDevice(audioDevice).then(() => { + console.log(`setAudioDevice success.`); +}).catch((err) => { + console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.setAudioDevice9+ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\\): void -Sets the audio device for a call. This API uses an asynchronous callback to return the result. +Sets the audio device for a call based on the specified options. This API uses an asynchronous callback to return the result. **System API**: This is a system API. @@ -3631,7 +3678,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu | Name | Type | Mandatory| Description | | -------- | ------------------------------------------ | ---- | -------------- | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | +| device | [AudioDevice](#audiodevice10) | Yes | Audio device. | | options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | @@ -3651,10 +3698,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js +let audioDevice={ + deviceType: 1 +} let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions, (err) => { +call.setAudioDevice(audioDevice, audioDeviceOptions, (err) => { console.log(`callback: err->${JSON.stringify(err)}`); }); ``` @@ -3674,7 +3724,7 @@ Sets the audio device for a call based on the specified options. This API uses a | Name | Type | Mandatory| Description | | ------- | ------------------------------------------ | ---- | ------------------ | -| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | +| device | [AudioDevice](#audiodevice10) | Yes | Audio device. | | options | [AudioDeviceOptions](#audiodeviceoptions9) | No | Audio device parameters.| **Return value** @@ -3699,10 +3749,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r **Example** ```js +let audioDevice={ + deviceType: 1 +} let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, audioDeviceOptions).then(() => { +call.setAudioDevice(audioDevice, audioDeviceOptions).then(() => { console.log(`setAudioDevice success.`); }).catch((err) => { console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); @@ -4242,7 +4295,7 @@ call.closeUnfinishedUssd(slotId).then(() => { ## call.setVoNRState10+ -setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void +setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\\): void Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result. @@ -4258,7 +4311,7 @@ Sets the status of the VoNR switch. This API uses an asynchronous callback to re | ----------- | ----------------------------- | ---- | ---------------------------------------------------- | | slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 | | state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result. The value **true** indicates that the operation is successful, and value **false** indicates the opposite.| +| callback | AsyncCallback<void> | Yes | Callback used to return the result.| **Error codes** @@ -4287,7 +4340,7 @@ call.setVoNRState(slotId, state, (err, data) => { ## call.setVoNRState10+ -setVoNRState\(slotId: number, state: VoNRState\): Promise\ +setVoNRState\(slotId: number, state: VoNRState\): Promise\ Sets the status of the VoNR switch. This API uses a promise to return the result. @@ -4308,7 +4361,7 @@ Sets the status of the VoNR switch. This API uses a promise to return the result | Type | Description | | ---------------------- | --------------------------------------------- | -| Promise<boolean> | Promise used to return the result. | +| Promise<void> | Promise used to return the result. | **Error codes** @@ -4329,7 +4382,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ```js let slotId = 0; let state = 1; -call.setVoNRState(slotId, state).then(() => { +call.setVoNRState(slotId, state).then((data) => { console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`); }).catch((err) => { console.error(`setVoNRState fail, promise: err->${JSON.stringify(err)}`); @@ -4516,7 +4569,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ```js let slotId = 0; -call.canSetCallTransferTime(slotId).then(() => { +call.canSetCallTransferTime(slotId).then((data) => { console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`); }).catch((err) => { console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(err)}`); @@ -4629,7 +4682,7 @@ Provides an option for determining whether a call is a video call. ## DialCallOptions9+ -Defines options for initiating a call. +Provides an option for determining whether a call is a video call. **System API**: This is a system API. @@ -4704,7 +4757,7 @@ Enumerates VoNR switch states. | VONR_STATE_OFF | 0 | Disabled. | | VONR_STATE_ON | 1 | Enabled. | -## AudioDevice8+ +## AudioDevice10+ Enumerates audio devices. @@ -4712,13 +4765,10 @@ Enumerates audio devices. **System capability**: SystemCapability.Telephony.CallManager -| Name | Value | Description | -| -------------------- | ---- | ------------ | -| DEVICE_EARPIECE | 0 | Headset device. | -| DEVICE_SPEAKER | 1 | Speaker device.| -| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| -| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | -| DEVICE_MIC | 4 | Microphone device| +| Name | Type | Mandatory | Description | +| --------------------------------- | ------------------------------------- | ---- | ---------------- | +| deviceType 10+ | [AudioDeviceType](#audiodevicetype10) | Yes | Audio device type. | +| address 10+ | string | No | Audio device address. | ## AudioDeviceType10+ @@ -4745,8 +4795,8 @@ Defines the audio device information. | Name | Type | Mandatory | Description | | --------------------------------- | ------------------------------------- | ---- | ---------------- | -| audioDeviceList 10+ | [Array\](#audiodevice8) | Yes | Audio device list. | -| currentAudioDevice 10+ | [AudioDevice](#audiodevice8) | Yes | Audio device type. | +| audioDeviceList 10+ | [Array\](#audiodevice10) | Yes | Audio device list. | +| currentAudioDevice 10+ | [AudioDevice](#audiodevice10) | Yes | Audio device type. | | isMuted 10+ | boolean | Yes | Whether the audio device is muted. | diff --git a/en/application-dev/reference/apis/js-apis-curve.md b/en/application-dev/reference/apis/js-apis-curve.md index bd673773b094eda6a3aa6d14c6d6ab7336120e65..dc0fdd5742cee370e7caa76bb6600fbf4b34ee98 100644 --- a/en/application-dev/reference/apis/js-apis-curve.md +++ b/en/application-dev/reference/apis/js-apis-curve.md @@ -25,9 +25,9 @@ Implements initialization for the interpolation curve, which is used to create a **Parameters** -| Name| Type | Mandatory| Default Value | Description | -| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.| +| Name| Type | Mandatory| Description | +| ------ | ----------------------------------------------- | ---- | ----------------------------------- | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.
Default value: **Curve.Linear**| **Return value** @@ -151,16 +151,16 @@ Creates a spring animation curve. If multiple spring animations are applied to t | Name | Type | Mandatory | Description | | --------- | ------ | ---- | ----- | -| response | number | No | Duration of one complete oscillation,
Default value: **0.55**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.55**.| +| response | number | No | Duration of one complete oscillation.
Default value: **0.55**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.55**.| | dampingFraction | number | No | Damping coefficient.
**0**: undamped. In this case, the spring oscillates forever.
> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.
**1**: critically damped.
> 1: overdamped. In this case, the spring approaches equilibrium gradually.
Default value: **0.825**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.55**.| -| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.

Default value: **0**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0**.
The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.| +| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, if the **response** values of the two animations are different, they will transit smoothly over this duration.

Default value: **0**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0**.
The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **interpolate** function of the curve.| **Return value** | Type | Description | | ---------------------------------- | ---------------- | -| [ICurve](#icurve)| Curve.
**NOTE**
The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **[interpolate](#interpolate)** function of the curve.| +| [ICurve](#icurve)| Curve.
**NOTE**
The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained by using the **interpolate** function of the curve.| **Example** @@ -187,13 +187,13 @@ Creates a responsive spring animation curve. It is a special case of [springMoti | --------- | ------ | ---- | ----- | | response | number | No | See **response** in **springMotion**.
Default value: **0.15**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.15**.| | dampingFraction | number | No | See **dampingFraction** in **springMotion**.
Default value: **0.86**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.86**.| -| overlapDuration | number | No | See **overlapDuration** in **springMotion**.
Default value: **0.25**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.25**.
To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.
The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.| +| overlapDuration | number | No | See **overlapDuration** in **springMotion**.
Default value: **0.25**
Unit: second
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value **0.25**.
To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.
The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained by using the **interpolate** function of the curve.| **Return value** | Type | Description | | ---------------------------------- | ---------------- | -| [ICurve](#icurve)| Curve.
**NOTE**
1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.
2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate) function of the curve.| +| [ICurve](#icurve)| Curve.
**NOTE**
1. To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.
2. The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in **animation** or **animateTo**. In addition, the interpolation cannot be obtained by using the [interpolate](#interpolate9) function of the curve.| **Example** @@ -260,7 +260,7 @@ import Curves from '@ohos.curves' interpolate(fraction) { return Math.sqrt(fraction); } -Curves.customCurve(this.interpolate) // Create a custom curve. +private curve = Curves.customCurve(this.interpolate) // Create a custom curve. ``` @@ -268,7 +268,7 @@ Curves.customCurve(this.interpolate) // Create a custom curve. ## ICurve -### interpolate +### interpolate9+ interpolate(fraction: number): number @@ -310,9 +310,9 @@ Implements initialization to create a curve. This API is deprecated since API ve **Parameters** -| Name| Type | Mandatory| Default Value | Description | -| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | -| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.| +| Name| Type | Mandatory| Description | +| ------ | ----------------------------------------------- | ---- | ----------------------------------- | +| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.
Default value: **Curve.Linear**| ## Curves.steps(deprecated) diff --git a/en/application-dev/reference/apis/js-apis-font.md b/en/application-dev/reference/apis/js-apis-font.md index 0b7d7fb3abcb1353d022e70ea785f6454cd422b4..721fd187c6f86f786159c6569d55e8354d63d786 100644 --- a/en/application-dev/reference/apis/js-apis-font.md +++ b/en/application-dev/reference/apis/js-apis-font.md @@ -5,6 +5,8 @@ The **font** module provides APIs for registering custom fonts. > **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 system APIs. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-hilog.md b/en/application-dev/reference/apis/js-apis-hilog.md index 54355b12b723cf9cad06f5a4064568d5d772bea5..d643cbf1d8accc521e5baf11fa3e1ee23ce2734c 100644 --- a/en/application-dev/reference/apis/js-apis-hilog.md +++ b/en/application-dev/reference/apis/js-apis-hilog.md @@ -1,8 +1,9 @@ # @ohos.hilog (HiLog) -The **hilog** module allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs. +The HiLog subsystem allows your applications or services to output logs based on the specified type, level, and format string. Such logs help you learn the running status of applications and better debug programs. -> **NOTE**
+> **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. ## Modules to Import @@ -23,7 +24,7 @@ Checks whether logs are printable based on the specified service domain, log tag | Name| Type | Mandatory| Description | | ------ | --------------------- | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| | level | [LogLevel](#loglevel) | Yes | Log level. | @@ -41,11 +42,11 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO); ## LogLevel -Enumerates the log levels. +Log level. **System capability**: SystemCapability.HiviewDFX.HiLog -| Name | Value| Description | +| Name | Value | Description | | ----- | ------ | ------------------------------------------------------------ | | DEBUG | 3 | Log level used to record more detailed process information than INFO logs to help developers analyze service processes and locate faults.| | INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,
for example, no network signal or login failure.
These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| @@ -67,9 +68,9 @@ DEBUG logs are not recorded in official versions by default. They are available | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required.| | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -98,9 +99,9 @@ Prints INFO logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -129,9 +130,9 @@ Prints WARN logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -160,9 +161,9 @@ Prints ERROR logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -191,9 +192,9 @@ Prints FATAL logs. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ------------------------------------------------------------ | -| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**. You can define the value within your application as required.| +| domain | number | Yes | Service domain of logs. The value ranges from **0x0** to **0xFFFF**.
You can define the value as required. | | tag | string | Yes | Log tag in the string format. You are advised to use this parameter to identify a particular service behavior or the class holding the ongoing method.| -| format | string | Yes | Format string used to output logs in a specified format. It can contain several parameters, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by ****.| +| format | string | Yes | Format string used to output logs in a specified format. It can contain several elements, where the parameter type and privacy identifier are mandatory.
Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\**.| | args | any[] | Yes | Variable-length parameter list corresponding to the format string. The number and type of parameters must map to the identifier in the format string.| **Example** @@ -209,3 +210,43 @@ If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log ``` 08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World ``` + +## Parameter Format + +Parameters in the log are printed in the following format: + +%[private flag]specifier + +| Privacy Flag| Description| +| ------------ | ---- | +| Unspecified | The default value is **private**, indicating that parameters in plaintext are not printed.| +| private | Prints private parameters.| +| public | Prints parameters in plaintext.| + +| Specifier| Description| Example| +| ------------ | ---- | ---- | +| d/i | Prints logs of the **number** and **bigint** types.| 123 | +| s | Prints logs of the **string undefined bool** and **null** types.| "123" | + +**Example** +```js +let obj2 = new Object({name:"Jack", age:22}); +let isBol = true; +let bigNum = BigInt(1234567890123456789); +hilog.info(0x0001, "jsHilogTest", "print object: %{public}s", JSON.stringify(obj2)); +hilog.info(0x0001, "jsHilogTest", "private flag: %{private}s %s, print null: %{public}s", "hello", "world", null); +hilog.info(0x0001, "jsHilogTest", "print undefined: %{public}s", undefined); +hilog.info(0x0001, "jsHilogTest", "print number: %{public}d %{public}i", 123, 456); +hilog.info(0x0001, "jsHilogTest", "print bigNum: %{public}d %{public}i", bigNum, bigNum); +hilog.info(0x0001, "jsHilogTest", "print boolean: %{public}s", isBol); +``` + +Log printing result: +``` +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print object: {"name":"Jack","age":22} +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: private flag: , print null: null +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print undefined: undefined +08-09 13:26:29.094 2266 2266 I A00001/jsHilogTest: print number: 123 456 +08-09 13:26:29.095 2266 2266 I A00001/jsHilogTest: print bigNum: 1234567890123456768 1234567890123456768 +08-09 13:26:29.095 2266 2266 I A00001/jsHilogTest: print boolean: true +``` diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 34337fa9198edeeeab9d437bc084538777834d31..884bb626aaed1e23bc49f933b17aa5e2913eb7e8 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -984,7 +984,7 @@ Creates an **ImageSource** instance based on the URI. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). | +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags).| **Return value** @@ -1022,7 +1022,7 @@ Creates an **ImageSource** instance based on the URI. | Name | Type | Mandatory| Description | | ------- | ------------------------------- | ---- | ----------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags). | +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags10+](#svg-tags).| | options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| **Return value** @@ -2274,7 +2274,7 @@ Creates an **ImageCreator** instance by specifying the image width, height, form | Type | Description | | ------------------------------ | --------------------------------------- | -| [ImageCreator](#imagecreator9) | Returns an **ImageCreator** instance if the operation is successful.| +| [ImageCreator](#imagecreator9) | Returns an **ImageCreator** instance if the operation is successful.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md index c5de47b81e6b928a7d26909a54aa9ba798078417..48c1cbf8ba92a32af0f45917ca9f03708ae6e30c 100644 --- a/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md @@ -8,7 +8,7 @@ | Name | Type | Readable| Writable| Description | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | -| events | Array\ | Yes | No | Name of the common event to publish. | +| events | Array\ | Yes | No | Common events to subscribe to. | | publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. | | publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of a device on the same network. | | userId | number | Yes | No | User ID. The value must be an existing user ID in the system. If this parameter is not specified, the default value, which is the ID of the current user, will be used. | diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index 880a4db59490823365a39f4678bca7440ab07323..dbe5e4e6fe302b6a3c975cf9f8e7957701760443 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -1,8 +1,9 @@ # @ohos.multimodalInput.inputDevice (Input Device) -The **inputDevice** module implements listening for connection, disconnection, and update events of input devices and displays information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse. +The **inputDevice** module allows you to listen for hot swap events of input devices and query information about input devices. -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -10,6 +11,7 @@ The **inputDevice** module implements listening for connection, disconnection, a ```js import inputDevice from '@ohos.multimodalInput.inputDevice'; ``` + ## inputDevice.getDeviceList9+ getDeviceList(callback: AsyncCallback<Array<number>>): void @@ -20,25 +22,23 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------------------------- | ---- | ---------- | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | | callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| **Example** ```js try { - inputDevice.getDeviceIds((error, ids) => { + inputDevice.getDeviceList((error, ids) => { if (error) { - console.log(`Failed to get device list. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - this.data = ids; - console.log("The device ID list is: " + ids); + console.log(`Device id list: ${JSON.stringify(ids)}`); }); } catch (error) { - console.info("getDeviceList " + error.code + " " + error.message); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -52,19 +52,19 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu **Return value** -| Name | Description | -| ---------------------------------- | ------------------------------- | +| Parameters | Description | +| ---------------------------------- | ------------------------------------------- | | Promise<Array<number>> | Promise used to return the result.| **Example** ```js try { - inputDevice.getDeviceIds().then((ids) => { - console.log("The device ID list is: " + ids); + inputDevice.getDeviceList().then((ids) => { + console.log(`Device id list: ${JSON.stringify(ids)}`); }); } catch (error) { - console.info("getDeviceList " + error.code + " " + error.message); + console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -88,16 +88,15 @@ Obtains information about an input device. This API uses an asynchronous callbac ```js // Obtain the name of the device whose ID is 1. try { - inputDevice.getDeviceInfo(1, (error, inputDevice) => { + inputDevice.getDeviceInfo(1, (error, deviceData) => { if (error) { - console.log(`Failed to get device information. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - console.log("The device name is: " + inputDevice.name); + console.log(`Device info: ${JSON.stringify(deviceData)}`); }); } catch (error) { - console.info("getDeviceInfo " + error.code + " " + error.message); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -117,7 +116,7 @@ Obtains information about an input device. This API uses a promise to return the **Return value** -| Name | Description | +| Parameters | Description | | -------------------------------------------------- | ------------------------------- | | Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| @@ -126,20 +125,19 @@ Obtains information about an input device. This API uses a promise to return the ```js // Obtain the name of the device whose ID is 1. try { - inputDevice.getDeviceInfo(id).then((inputDevice) => { - console.log("The device name is: " + inputDevice.name); + inputDevice.getDeviceInfo(1).then((deviceData) => { + console.log(`Device info: ${JSON.stringify(deviceData)}`); }); } catch (error) { - console.info("getDeviceInfo " + error.code + " " + error.message); + console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` - ## inputDevice.on9+ on(type: "change", listener: Callback<DeviceListener>): void -Enables listening for hot swap events of an input device. +Enables listening for device hot swap events. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice @@ -156,13 +154,13 @@ Enables listening for hot swap events of an input device. let isPhysicalKeyboardExist = true; try { inputDevice.on("change", (data) => { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); - inputDevice.getKeyboardType(data.deviceId, (err, ret) => { - console.log("The keyboard type of the device is: " + ret); - if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + console.log(`Device event info: ${JSON.stringify(data)}`); + inputDevice.getKeyboardType(data.deviceId, (err, type) => { + console.log("The keyboard type is: " + type); + if (type == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { // The physical keyboard is connected. isPhysicalKeyboardExist = true; - } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + } else if (type == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { // The physical keyboard is disconnected. isPhysicalKeyboardExist = false; } @@ -170,7 +168,7 @@ try { }); // Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist. } catch (error) { - console.info("oninputdevcie " + error.code + " " + error.message); + console.log(`Get device info failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -178,7 +176,7 @@ try { off(type: "change", listener?: Callback<DeviceListener>): void -Disables listening for hot swap events of an input device. +Disables listening for device hot swap events. This API is called before the application exits. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice @@ -192,33 +190,29 @@ Disables listening for hot swap events of an input device. **Example** ```js -callback: function(data) { - console.log("type: " + data.type + ", deviceId: " + data.deviceId); -} +function callback(data) { + console.log(`Report device event info: ${JSON.stringify(data, [`type`, `deviceId`])}`); +}; try { - inputDevice.on("change", this.callback); + inputDevice.on("change", callback); } catch (error) { - console.info("oninputdevcie " + error.code + " " + error.message) + console.log(`Listen device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } -// Enable listening for hot swap events of an input device. -inputDevice.on("change", listener); - // Disable this listener. try { - inputDevice.off("change", this.callback); + inputDevice.off("change", callback); } catch (error) { - console.info("offinputdevcie " + error.code + " " + error.message) + console.log(`Cancel listening device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } // Disable all listeners. try { inputDevice.off("change"); } catch (error) { - console.info("offinputdevcie " + error.code + " " + error.message); + console.log(`Cancel all listening device event failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } -// By default, the soft keyboard is closed when listening is disabled. ``` ## inputDevice.getDeviceIds(deprecated) @@ -233,9 +227,9 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | ----- | -| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| **Example** @@ -248,7 +242,6 @@ inputDevice.getDeviceIds((error, ids) => { console.log(`Device id list: ${JSON.stringify(ids)}`); }); ``` -``` ## inputDevice.getDeviceIds(deprecated) @@ -262,8 +255,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Return value** -| Parameter | Description | -| ---------------------------------- | ------------------- | +| Parameters | Description | +| ---------------------------------- | ------------------------------------------- | | Promise<Array<number>> | Promise used to return the result.| **Example** @@ -286,10 +279,10 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------------------------- | -| deviceId | number | Yes | ID of the input device. | -| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------------------------- | ---- | -------------------------------- | +| deviceId | number | Yes | ID of the input device. | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| **Example** @@ -316,14 +309,14 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. **Parameters** -| Name | Type | Mandatory | Description | +| Name | Type | Mandatory| Description | | -------- | ------ | ---- | ------------ | -| deviceId | number | Yes | ID of the input device.| +| deviceId | number | Yes | ID of the input device.| **Return value** -| Parameter | Description | -| ---------------------------------------- | ------------------- | +| Parameters | Description | +| -------------------------------------------------- | ----------------------------------- | | Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| **Example** @@ -345,22 +338,22 @@ Obtains the key codes supported by the input device. This API uses an asynchrono **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ------------------------------------ | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | -| callback | AsyncCallback<Array<boolean>> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | +| callback | AsyncCallback<Array<boolean>> | Yes | Callback used to return the result. | **Example** ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. try { - inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => { - console.log("The query result is as follows: " + ret); + inputDevice.supportKeys(1, [17, 22, 2055], (error, supportResult) => { + console.log(`Query result: ${JSON.stringify(supportResult)}`); }); } catch (error) { - console.info("supportKeys " + error.code + " " + error.message); + console.log(`Query failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -374,15 +367,15 @@ Obtains the key codes supported by the input device. This API uses a promise to **Parameters** -| Name | Type | Mandatory | Description | -| -------- | -------------------- | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | **Return value** -| Parameter | Description | -| ----------------------------------- | ------------------- | +| Parameters | Description | +| ----------------------------------- | ------------------------------- | | Promise<Array<boolean>> | Promise used to return the result.| **Example** @@ -390,11 +383,11 @@ Obtains the key codes supported by the input device. This API uses a promise to ```js // Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. try { - inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => { - console.log("The query result is as follows: " + ret); + inputDevice.supportKeys(1, [17, 22, 2055]).then((supportResult) => { + console.log(`Query result: ${JSON.stringify(supportResult)}`); }); } catch (error) { - console.info("supportKeys " + error.code + " " + error.message); + console.log(`Query failed, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -408,41 +401,46 @@ Obtains the keyboard type of an input device. This API uses an asynchronous call **Parameters** -| Name | Type | Mandatory | Description | -| -------- | ---------------------------------------- | ---- | --------------------------------- | -| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| callback | AsyncCallback<[KeyboardType](#keyboardtype9)> | Yes | Callback used to return the result. | **Example** ```js // Query the keyboard type of the input device whose ID is 1. try { - inputDevice.getKeyboardType(1, (error, number) => { + inputDevice.getKeyboardType(1, (error, type) => { if (error) { - console.log(`Failed to get keyboardtype. - error code=${err.code} msg=${err.message}`); + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); return; } - console.log("The keyboard type of the device is: " + number); + console.log(`Keyboard type: ${JSON.stringify(type)}`); }); } catch (error) { - console.info("getKeyboardType " + error.code + " " + error.message); + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` ## inputDevice.getKeyboardType9+ -getKeyboardType(deviceId: number,): Promise<KeyboardType> +getKeyboardType(deviceId: number): Promise<KeyboardType> Obtains the keyboard type of an input device. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| + **Return value** -| Parameter | Description | -| ---------------------------------------- | ------------------- | +| Parameters | Description | +| --------------------------------------------- | ------------------------------- | | Promise<[KeyboardType](#keyboardtype9)> | Promise used to return the result.| **Example** @@ -450,11 +448,11 @@ Obtains the keyboard type of an input device. This API uses a promise to return ```js // Query the keyboard type of the input device whose ID is 1. try { - inputDevice.getKeyboardType(1).then((number) => { - console.log("The keyboard type of the device is: " + number); + inputDevice.getKeyboardType(1).then((type) => { + console.log(`Keyboard type: ${JSON.stringify(type)}`); }); } catch (error) { - console.info("getKeyboardType " + error.code + " " + error.message); + console.log(`Failed to get keyboard type, error: ${JSON.stringify(error, [`code`, `message`])}`); } ``` @@ -496,10 +494,10 @@ Defines the axis type of an input device. | Name | Type | Readable | Writable | Description | | --------- | ------ | ---- | ---- | ------- | -| touchmajor | string | Yes| No| touchmajor axis. | -| touchminor | string | Yes| No| touchminor axis. | -| toolminor | string | Yes| No| toolminor axis. | -| toolmajor | string | Yes| No| toolmajor axis. | +| touchMajor | string | Yes| No| touchMajor axis. | +| touchMinor | string | Yes| No| touchMinor axis. | +| toolMinor | string | Yes| No| toolMinor axis. | +| toolMajor | string | Yes| No| toolMajor axis. | | orientation | string | Yes| No| Orientation axis.| | pressure | string | Yes| No| Pressure axis. | | x | string | Yes| No| X axis. | @@ -524,7 +522,7 @@ Defines the axis range of an input device. ## SourceType9+ -Enumerates the input source types. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse. +Input source type of the axis. For example, if a mouse reports an x-axis event, the input source of the x-axis is the mouse. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice diff --git a/en/application-dev/reference/apis/js-apis-matrix4.md b/en/application-dev/reference/apis/js-apis-matrix4.md index b707f54df167497056052a8524ec00d7bbe11188..9c8c1a77c0150f8d820ec03701c3bd58ad9c8a17 100644 --- a/en/application-dev/reference/apis/js-apis-matrix4.md +++ b/en/application-dev/reference/apis/js-apis-matrix4.md @@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4' ## matrix4.init -init(array: Array<number>): Matrix4Transit +init(option: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit Matrix constructor, which is used to create a 4 x 4 matrix by using the input parameter. Column-major order is used. @@ -25,17 +25,17 @@ Matrix constructor, which is used to create a 4 x 4 matrix by using the input pa **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------------------- | ---- | ------------------------------------------------------------ | -| array | Array<number> | Yes | A number array whose length is 16 (4 x 4). For details, see **array** parameters.
Default value:
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1] | +| Name| Type | Mandatory| Description | +| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| option | [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number] | Yes | A number array whose length is 16 (4 x 4). For details, see **Description of a 4 x 4 matrix**.
Default value:
[1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1] | **Return value** -| Type | Description | -| -------------- | ---------------------------- | -| Matrix4Transit | 4 x 4 matrix object created based on the input parameter.| +| Type | Description | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | 4 x 4 matrix object created based on the input parameter.| -**array** parameters +**Description of a 4 x 4 matrix** | Name | Type | Mandatory | Description | | ---- | ------ | ---- | -------------------- | @@ -91,9 +91,9 @@ Constructs an identity matrix. **Return value** -| Type | Description | -| -------------- | -------------- | -| Matrix4Transit | Identity matrix object.| +| Type | Description | +| --------------------------------- | -------------- | +| [Matrix4Transit](#matrix4transit) | Identity matrix object.| **Example** @@ -136,9 +136,9 @@ Copies this matrix object. **Return value** -| Type | Description | -| -------------- | -------------------- | -| Matrix4Transit | Copy object of the current matrix.| +| Type | Description | +| --------------------------------- | -------------------- | +| [Matrix4Transit](#matrix4transit) | Copy object of the current matrix.| **Example** @@ -171,12 +171,12 @@ struct Test { ![en-us_image_0000001219744181](figures/en-us_image_0000001219744181.png) -## Matrix4 +## Matrix4Transit ### combine -combine(matrix: Matrix4): Matrix4Transit +combine(option: Matrix4Transit): Matrix4Transit Combines the effects of two matrices to generate a new matrix object. @@ -185,15 +185,15 @@ Combines the effects of two matrices to generate a new matrix object. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------- | ---- | ------------------ | -| matrix | Matrix4 | Yes | Matrix object to be combined.| +| Name| Type | Mandatory| Description | +| ------ | --------------------------------- | ---- | ------------------ | +| option | [Matrix4Transit](#matrix4transit) | Yes | Matrix object to be combined.| **Return value** -| Type | Description | -| -------------- | ------------------ | -| Matrix4Transit | Object after matrix combination.| +| Type | Description | +| --------------------------------- | ------------------ | +| [Matrix4Transit](#matrix4transit) | Object after matrix combination.| **Example** @@ -238,9 +238,9 @@ Inverts this matrix object. **Return value** -| Type | Description | -| -------------- | ---------------------- | -| Matrix4Transit | Inverse matrix object of the current matrix.| +| Type | Description | +| --------------------------------- | ---------------------- | +| [Matrix4Transit](#matrix4transit) | Inverse matrix object of the current matrix.| **Example** @@ -273,7 +273,7 @@ struct Tests { ### translate -translate({x?: number, y?: number, z?: number}): Matrix4Transit +translate(option: TranslateOption): Matrix4Transit Translates this matrix object along the x, y, and z axes. @@ -281,17 +281,15 @@ Translates this matrix object along the x, y, and z axes. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ------ | ---- | ----------------------------------------------------------- | -| x | number | No | Translation distance along the x-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| -| y | number | No | Translation distance along the y-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| -| z | number | No | Translation distance along the z-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| +| Name| Type | Mandatory| Description | +| ------ | ----------------------------------- | ---- | -------------- | +| option | [TranslateOption](#translateoption) | Yes | Translation configuration.| **Return value** -| Type | Description | -| -------------- | ---------------------------- | -| Matrix4Transit | Matrix object after the translation effect is added.| +| Type | Description | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | Matrix object after the translation.| **Example** @@ -319,7 +317,7 @@ struct Test { ### scale -scale({x?: number, y?: number, z?: number, centerX?: number, centerY?: number}): Matrix4Transit +scale(option: ScaleOption): Matrix4Transit Scales this matrix object along the x, y, and z axes. @@ -328,19 +326,16 @@ Scales this matrix object along the x, y, and z axes. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ------------------------------------------------------------ | -| x | number | No | Scaling multiple along the x-axis. If the value is greater than 1, the image is scaled up along the x-axis. If the value is less than 1, the image is scaled down along the x-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| -| y | number | No | Scaling multiple along the y-axis. If the value is greater than 1, the image is scaled up along the y-axis. If the value is less than 1, the image is scaled down along the y-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| -| z | number | No | Scaling multiple along the z-axis. If the value is greater than 1, the image is scaled up along the z-axis. If the value is less than 1, the image is scaled down along the z-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| -| centerX | number | No | X coordinate of the center point.
Default value: **0**
Value range: (-∞, +∞) | -| centerY | number | No | Y coordinate of the center point.
Default value: **0**
Value range: (-∞, +∞) | +| Name| Type | Mandatory| Description | +| ------ | --------------------------- | ---- | -------------- | +| option | [ScaleOption](#scaleoption) | Yes | Scaling configuration.| + **Return value** -| Type | Description | -| -------------- | ---------------------------- | -| Matrix4Transit | Matrix object after the scaling effect is added.| +| Type | Description | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | Matrix object after the scaling.| **Example** @@ -367,7 +362,7 @@ struct Test { ### rotate -rotate({x?: number, y?: number, z?: number, angle?: number, centerX?: Length, centerY?: Length}): Matrix4Transit +rotate(option: RotateOption): Matrix4Transit Rotates this matrix object along the x, y, and z axes. @@ -376,20 +371,16 @@ Rotates this matrix object along the x, y, and z axes. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ------ | ---- | ------------------------------------------------------- | -| x | number | No | X coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| -| y | number | No | Y coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| -| z | number | No | Z coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| -| angle | number | No | Rotation angle.
Default value: **0** | -| centerX | number | No | X coordinate of the center point.
Default value: **0** | -| centerY | number | No | Y coordinate of the center point.
Default value: **0** | +| Name| Type | Mandatory| Description | +| ------ | ----------------------------- | ---- | -------------- | +| option | [RotateOption](#rotateoption) | Yes | Rotation configuration.| + **Return value** -| Type | Description | -| -------------- | ---------------------------- | -| Matrix4Transit | Matrix object after the rotation effect is added.| +| Type | Description | +| --------------------------------- | ---------------------------- | +| [Matrix4Transit](#matrix4transit) | Matrix object after the rotation.| **Example** @@ -417,7 +408,7 @@ struct Test { ### transformPoint -transformPoint(point: Point): Point +transformPoint(option: [number, number]): [number, number] Applies the current transformation effect to a coordinate point. @@ -426,15 +417,15 @@ Applies the current transformation effect to a coordinate point. **Parameters** -| Name| Type | Mandatory| Description | -| ------ | ----- | ---- | ------------------ | -| point | Point | Yes | Point to be transformed.| +| Name| Type | Mandatory| Description | +| ------ | ---------------- | ---- | ------------------ | +| option | [number, number] | Yes | Point to be transformed.| **Return value** -| Type | Description | -| ----- | ---------------- | -| Point | Point object after matrix transformation| +| Type | Description | +| ---------------- | --------------------------- | +| [number, number] | Point object after matrix transformation| **Example** @@ -472,3 +463,32 @@ struct Test { ``` ![en-us_image_0000001219864133](figures/en-us_image_0000001219864133.PNG) + +## TranslateOption + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ----------------------------------------------------------- | +| x | number | No | Translation distance along the x-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| +| y | number | No | Translation distance along the y-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| +| z | number | No | Translation distance along the z-axis, in px.
Default value: **0**
Value range: (-∞, +∞)| + +## ScaleOption + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| x | number | No | Scaling multiple along the x-axis. If the value is greater than 1, the image is scaled up along the x-axis. If the value is less than 1, the image is scaled down along the x-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| +| y | number | No | Scaling multiple along the y-axis. If the value is greater than 1, the image is scaled up along the y-axis. If the value is less than 1, the image is scaled down along the y-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| +| z | number | No | Scaling multiple along the z-axis. If the value is greater than 1, the image is scaled up along the z-axis. If the value is less than 1, the image is scaled down along the z-axis.
Default value: **1**
Value range: [0, +∞)
**NOTE**
A value less than 0 evaluates to the default value.| +| centerX | number | No | X coordinate of the center point.
Default value: **0**
Value range: (-∞, +∞) | +| centerY | number | No | Y coordinate of the center point.
Default value: **0**
Value range: (-∞, +∞) | + +## RotateOption + +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ------------------------------------------------------- | +| x | number | No | X coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| +| y | number | No | Y coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| +| z | number | No | Z coordinate of the rotation axis vector.
Default value: **1**
Value range: (-∞, +∞)| +| angle | number | No | Rotation angle.
Default value: **0** | +| centerX | number | No | X coordinate of the center point.
Default value: **0** | +| centerY | number | No | Y coordinate of the center point.
Default value: **0** | diff --git a/en/application-dev/reference/apis/js-apis-measure.md b/en/application-dev/reference/apis/js-apis-measure.md index 55d5b70a7009b42f2a9d683566c958ad027d9eb4..4b0eac439ab60844ca48f768ed768126b01d64da 100644 --- a/en/application-dev/reference/apis/js-apis-measure.md +++ b/en/application-dev/reference/apis/js-apis-measure.md @@ -112,7 +112,7 @@ Provides attributes of the measured text. | Name | Type | Mandatory| Description | | -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- | -| textContent10+ | string | Yes | Content of the measured text. | +| textContent | string | Yes | Content of the measured text. | | constraintWidth10+ | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Layout width of the measured text.
The default unit is vp. | | fontSize | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Font size of the measured text. If the value is of the number type, the unit fp is used.
Default value: **16fp**
**NOTE**
The value cannot be a percentage. | | fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.
Default value: **FontStyle.Normal** | 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 c84b3ae6dce748f686f50f001fa18fd13b78049d..69a94803f6cb349bb3d39aae99b825e26cb3f32c 100644 --- a/en/application-dev/reference/apis/js-apis-net-mdns.md +++ b/en/application-dev/reference/apis/js-apis-net-mdns.md @@ -623,7 +623,7 @@ FA model: // Obtain the context. import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); - +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); ``` @@ -639,7 +639,7 @@ class EntryAbility extends UIAbility { } } let context = globalThis.context; - +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); ``` @@ -660,7 +660,7 @@ FA model: // Obtain the context. import featureAbility from '@ohos.ability.featureAbility'; let context = featureAbility.getContext(); - +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.stopSearchingMDNS(); ``` @@ -676,7 +676,7 @@ class EntryAbility extends UIAbility { } } let context = globalThis.context; - +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.stopSearchingMDNS(); ``` @@ -700,6 +700,8 @@ Enables listening for **discoveryStart** events. ```js // See mdns.createDiscoveryService. +let context = globalThis.context; +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); @@ -729,6 +731,8 @@ Enables listening for **discoveryStop** events. ```js // See mdns.createDiscoveryService. +let context = globalThis.context; +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); @@ -758,6 +762,8 @@ Enables listening for **serviceFound** events. ```js // See mdns.createDiscoveryService. +let context = globalThis.context; +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); @@ -787,6 +793,8 @@ Enables listening for **serviceLost** events. ```js // See mdns.createDiscoveryService. +let context = globalThis.context; +let serviceType = "_print._tcp"; let discoveryService = mdns.createDiscoveryService(context, serviceType); discoveryService.startSearchingMDNS(); @@ -805,7 +813,7 @@ Defines the mDNS service information. | Name | Type | Mandatory| Description | | --------------------- | ---------------------------------- | --- | ------------------------ | -| serviceType | string | Yes| Type of the mDNS service. The value is in the format of **\_\.\**, where **name** contains a maximum of 63 characters excluding periods (.). | +| serviceType | string | Yes| Type of the mDNS service. The value is in the format of **\_\.<_tcp/_udp>**, where **name** contains a maximum of 63 characters excluding periods (.). | | serviceName | string | Yes| Name of the mDNS service. | | port | number | No| Port number of the mDNS server. | | host | [NetAddress](js-apis-net-connection.md#netaddress) | No| IP address of the device that provides the mDNS service. The IP address is not effective when an mDNS service is added or removed. | diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md index 04967480dfd6469eea02de987f0be83a71f6fc9d..ff6b2f4139bb4fa9980c7ee1e710722f8fec5a9e 100644 --- a/en/application-dev/reference/apis/js-apis-power.md +++ b/en/application-dev/reference/apis/js-apis-power.md @@ -147,7 +147,7 @@ try { ## power.suspend9+ -suspend(): void +suspend(isImmediate?: boolean): void Hibernates a device. @@ -155,6 +155,13 @@ Hibernates a device. **System capability:** SystemCapability.PowerManager.PowerManager.Core +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ---------- | +| isImmediate10+ | boolean | No | Whether to hibernate a device immediately. If this parameter is not specified, the default value **false** is used. The system automatically determines when to enter the hibernation state.
**NOTE**: This parameter is supported since API version 10.| + + **Error codes** For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). diff --git a/en/application-dev/reference/apis/js-apis-screen-lock.md b/en/application-dev/reference/apis/js-apis-screen-lock.md index e633bf43d4a8879701dd4d3f63f66f51a0f20425..c1136e75989e9dd2cfe00de84a9dee9c23bfb3cd 100644 --- a/en/application-dev/reference/apis/js-apis-screen-lock.md +++ b/en/application-dev/reference/apis/js-apis-screen-lock.md @@ -220,7 +220,7 @@ screenlock.lock().then((data) => { onSystemEvent(callback: Callback<SystemEvent>): boolean -Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications. +Registers a callback for system events related to screen locking. This API can be called only by screen lock applications. **System capability**: SystemCapability.MiscServices.ScreenLock @@ -264,7 +264,7 @@ try { sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback<boolean>): void -Sends an event to the screen lock service. This API uses an asynchronous callback to return the result. +Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock @@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { sendScreenLockEvent(event: String, parameter: number): Promise<boolean> -Sends an event to the screen lock service. This API uses a promise to return the result. +Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses a promise to return the result. **System capability**: SystemCapability.MiscServices.ScreenLock diff --git a/en/application-dev/reference/apis/js-apis-shortKey.md b/en/application-dev/reference/apis/js-apis-shortKey.md index 79a8ce26644ead2c634af316ab5e191fc6955442..712d5e10bdb062edb0b8e6d1a36020fb83b73f91 100644 --- a/en/application-dev/reference/apis/js-apis-shortKey.md +++ b/en/application-dev/reference/apis/js-apis-shortKey.md @@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey'; ## shortKey.setKeyDownDuration -setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback<void>): void +setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback<void>): void Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. @@ -25,7 +25,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses an | Name | Type | Mandatory| Description | | ---------- | ------------------- | ---- | ------------------------------------------------------------ | -| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| | callback | AsyncCallback<void> | Yes | Callback used to return the result. | @@ -49,7 +49,7 @@ try { ## shortKey.setKeyDownDuration -setKeyDownDuration(businessId: string, delay: number): Promise<void> +setKeyDownDuration(businessKey: string, delay: number): Promise<void> Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. @@ -59,7 +59,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p | Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------------------------------------ | -| businessId | string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| +| businessKey| string | Yes | Unique service ID registered on the multimodal side. It corresponds to **businessId** in the **ability_launch_config.json** file.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-socket.md b/en/application-dev/reference/apis/js-apis-socket.md index f2f370cde84c3c73a66c914908d4d89cd58ed984..18261c614ce86d88d7985c9f9240c9298a1aa211 100644 --- a/en/application-dev/reference/apis/js-apis-socket.md +++ b/en/application-dev/reference/apis/js-apis-socket.md @@ -479,12 +479,12 @@ Enables listening for message receiving events of the UDPSocket connection. This ```js let udp = socket.constructUDPSocketInstance(); +let messageView = ''; udp.on('message', value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -513,12 +513,12 @@ Disables listening for message receiving events of the UDPSocket connection. Thi ```js let udp = socket.constructUDPSocketInstance(); +let messageView = ''; let callback = value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -541,7 +541,7 @@ Enables listening for data packet message events or close events of the UDPSocke | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **listening**: data packet message event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **listening**: data packet message event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -1365,12 +1365,12 @@ Enables listening for message receiving events of the TCPSocket connection. This ```js let tcp = socket.constructTCPSocketInstance(); +let messageView = ''; tcp.on('message', value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -1399,12 +1399,12 @@ Disables listening for message receiving events of the TCPSocket connection. Thi ```js let tcp = socket.constructTCPSocketInstance(); +let messageView = ''; let callback = value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -1427,7 +1427,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -1457,7 +1457,7 @@ Disables listening for connection or close events of the TCPSocket connection. T | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | No | Callback used to return the result. | **Example** @@ -1766,7 +1766,7 @@ promise.then(() => { setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\): void -Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses an asynchronous callback to return the result. +Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Communication.NetStack @@ -1818,7 +1818,7 @@ tls.setExtraOptions({ setExtraOptions(options: TCPExtraOptions): Promise\ -Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the TLSSocket connection. This API uses a promise to return the result. +Sets other properties of the TCPSocket connection after successful binding of the local IP address and port number of the connection. This API uses a promise to return the result. **System capability**: SystemCapability.Communication.NetStack @@ -1881,19 +1881,19 @@ Subscribes to **message** events of the TLSSocket connection. This API uses an a | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to. **message**: message receiving event| | callback | Callback\<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}\> | Yes | Callback used to return the result.
**message**: received message.
**remoteInfo**: socket connection information.| **Example** ```js let tls = socket.constructTLSSocketInstance(); +let messageView = ''; tls.on('message', value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -1915,19 +1915,19 @@ Unsubscribes from **message** events of the TLSSocket connection. This API uses | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | -| type | string | Yes | Type of the event to subscribe to.
**message**: message receiving event| +| type | string | Yes | Type of the event to subscribe to. **message**: message receiving event| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | No | Callback used to return the result. **message**: received message.
**remoteInfo**: socket connection information.| **Example** ```js let tls = socket.constructTLSSocketInstance(); +let messageView = ''; let callback = value => { for (var i = 0; i < value.message.length; i++) { let messages = value.message[i] let message = String.fromCharCode(messages); - let messageView = ''; - messageView += item; + messageView += message; } console.log('on message message: ' + JSON.stringify(messageView)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); @@ -1948,7 +1948,7 @@ Enables listening for connection or close events of the TLSSocket connection. Th | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | Yes | Callback used to return the result. | **Example** @@ -1978,7 +1978,7 @@ Disables listening for connection or close events of the TLSSocket connection. T | Name | Type | Mandatory| Description | | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| type | string | Yes | Type of the event to subscribe to.

- **connect**: connection event
- **close**: close event| +| type | string | Yes | Type of the event to subscribe to.
- **connect**: connection event
- **close**: close event| | callback | Callback\ | No | Callback used to return the result. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-system-router.md b/en/application-dev/reference/apis/js-apis-system-router.md index e2e2ef013c53ec132fd73a54f6a171d84063b161..0813fbd568ea310b81ab0ed9868e0ad0302aba7c 100644 --- a/en/application-dev/reference/apis/js-apis-system-router.md +++ b/en/application-dev/reference/apis/js-apis-system-router.md @@ -343,8 +343,8 @@ Defines the page routing parameters. | Name | Type| Mandatory| Description | | ------ | -------- | ---- | ------------------------------------------------------------ | -| uri7+ | string | Yes | URI of the target page, in either of the following formats:
1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:
- pages/index/index
- pages/detail/detail
2. Specific path. If the URI is a slash (/), the home page is displayed.| -| params7+ | object | No | Data that needs to be passed to the target page during redirection. The target page can use **router.getParams()** to obtain the passed parameters, for example, **this.keyValue** (**keyValue** is the value of a key in **params**). In the web-like paradigm, these parameters can be directly used on the target page. If the field specified by **key** already exists on the target page, the passed value of the key will be displayed.| +| uri | string | Yes | URI of the target page, in either of the following formats:
1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:
- pages/index/index
- pages/detail/detail
2. Specific path. If the URI is a slash (/), the home page is displayed.| +| params | object | No | Data that needs to be passed to the target page during redirection. The target page can use **router.getParams()** to obtain the passed parameters, for example, **this.keyValue** (**keyValue** is the value of a key in **params**). In the web-like paradigm, these parameters can be directly used on the target page. If the field specified by **key** already exists on the target page, the passed value of the key will be displayed.| ## BackRouterOptions diff --git a/en/application-dev/reference/apis/js-apis-usbManager.md b/en/application-dev/reference/apis/js-apis-usbManager.md index ac6de75dd00fc24d9503039fdae5bf6be0931ee7..95096ca9027425b1701b196d86ad429d73fd200a 100644 --- a/en/application-dev/reference/apis/js-apis-usbManager.md +++ b/en/application-dev/reference/apis/js-apis-usbManager.md @@ -152,7 +152,7 @@ Checks whether the user, for example, the application or system, has the device **Example** ```js -let devicesName="1-1"; +let devicesName = "1-1"; let bool = usb.hasRight(devicesName); console.log(`${bool}`); ``` @@ -180,7 +180,7 @@ Requests the temporary permission for the application to access a USB device. Th **Example** ```js -let devicesName="1-1"; +let devicesName = "1-1"; usb.requestRight(devicesName).then((ret) => { console.log(`requestRight = ${ret}`); }); @@ -209,7 +209,7 @@ Removes the permission for the application to access a USB device. **Example** ```js -let devicesName= "1-1"; +let devicesName = "1-1"; if (usb.removeRight(devicesName)) { console.log(`Succeed in removing right`); } @@ -277,6 +277,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; let ret = usb.claimInterface(devicepipe, interfaces); console.log(`claimInterface = ${ret}`); ``` @@ -307,7 +317,18 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c **Example** ```js -let ret = usb.releaseInterface(devicepipe, interfaces); +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +ret = usb.releaseInterface(devicepipe, interfaces); console.log(`releaseInterface = ${ret}`); ``` @@ -337,6 +358,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let config = device.configs[0]; let ret = usb.setConfiguration(devicepipe, config); console.log(`setConfiguration = ${ret}`); ``` @@ -367,7 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js -let ret = usb.setInterface(devicepipe, interfaces); +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +ret = usb.setInterface(devicepipe, interfaces); console.log(`setInterface = ${ret}`); ``` @@ -396,6 +438,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.getRawDescriptor(devicepipe); ``` @@ -424,6 +474,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.getFileDescriptor(devicepipe); ``` @@ -462,6 +520,15 @@ let param = { index: 0, data: null }; + +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); usb.controlTransfer(devicepipe, param).then((ret) => { console.log(`controlTransfer = ${ret}`); }) @@ -498,8 +565,22 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi // 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. +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +let device = devicesList[0]; +usb.requestRight(device.name); + +let devicepipe = usb.connectDevice(device); +let interfaces = device.configs[0].interfaces[0]; +let endpoint = device.configs[0].interfaces[0].endpoints[0]; +let ret = usb.claimInterface(devicepipe, interfaces); +let buffer = new Uint8Array(128); usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${ret}`); + console.log(`bulkTransfer = ${ret}`); }); ``` @@ -528,6 +609,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **Example** ```js +let devicesList = usb.getDevices(); +if (devicesList.length == 0) { + console.log(`device list is empty`); + return; +} + +usb.requestRight(devicesList[0].name); +let devicepipe = usb.connectDevice(devicesList[0]); let ret = usb.closePipe(devicepipe); console.log(`closePipe = ${ret}`); ``` diff --git a/en/application-dev/reference/apis/js-apis-wantAgent.md b/en/application-dev/reference/apis/js-apis-wantAgent.md index f30132640cd3a5a5832df9761c2a7e659e9dfa59..0ebee19d694e73ad71e6c3a1f54edfb7108c7378 100644 --- a/en/application-dev/reference/apis/js-apis-wantAgent.md +++ b/en/application-dev/reference/apis/js-apis-wantAgent.md @@ -159,7 +159,7 @@ WantAgent.getWantAgent(wantAgentInfo).then((data) => { getWantAgent(info: WantAgentInfo, callback: AsyncCallback\): void -Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result. If the creation fails, a null **WantAgent** object is returned. +Creates a **WantAgent** object. This API uses an asynchronous callback to return the result. If the creation fails, a null **WantAgent** object is returned. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -167,7 +167,7 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return | Name | Type | Mandatory| Description | | -------- | -------------------------- | ---- | ----------------------- | -| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain. | +| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object. | | callback | AsyncCallback\ | Yes | Callback used to return the **WantAgent** object.| **Example** @@ -218,7 +218,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); getWantAgent(info: WantAgentInfo): Promise\ -Obtains a **WantAgent** object. This API uses a promise to return the result. If the creation fails, a null **WantAgent** object is returned. +Creates a **WantAgent** object. This API uses a promise to return the result. If the creation fails, a null **WantAgent** object is returned. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -226,7 +226,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. If | Name| Type | Mandatory| Description | | ---- | ------------- | ---- | ------------- | -| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain.| +| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object.| **Return value** diff --git a/en/application-dev/reference/arkui-ts/figures/DataPickerDialog.gif b/en/application-dev/reference/arkui-ts/figures/DataPickerDialog.gif new file mode 100644 index 0000000000000000000000000000000000000000..e447f0d8916e19385da7f38e1c4b15334e4a6a70 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/DataPickerDialog.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/TextPickerDialog.gif b/en/application-dev/reference/arkui-ts/figures/TextPickerDialog.gif new file mode 100644 index 0000000000000000000000000000000000000000..de15f47d3d9e9f18794c7fe92ce060bf2aa135e8 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/TextPickerDialog.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/TimePickerDialog.gif b/en/application-dev/reference/arkui-ts/figures/TimePickerDialog.gif new file mode 100644 index 0000000000000000000000000000000000000000..44fe3a771a01e9fec2e155663c1f2f552d202b68 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/TimePickerDialog.gif differ diff --git a/en/application-dev/reference/arkui-ts/ts-container-badge.md b/en/application-dev/reference/arkui-ts/ts-container-badge.md index 1984ff242a64a9e8360e6ef2064e84211bd6d0d5..78c8f0060a334c71b476f36fedac5d194213fb8a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/en/application-dev/reference/arkui-ts/ts-container-badge.md @@ -2,7 +2,7 @@ The **\** component is a container that can be attached to another component for tagging. -> **NOTE** +> **NOTE** > > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -11,6 +11,10 @@ The **\** component is a container that can be attached to another compon This component supports only one child component. +> **NOTE** +> +> Built-in components and custom components are allowed, with support for ([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)) rendering control. + ## APIs @@ -22,12 +26,12 @@ Since API version 9, this API is supported in ArkTS widgets. **Parameters** -| Name| Type| Mandatory| Default Value| Description| -| -------- | -------- | -------- | -------- | -------- | -| count | number | Yes| - | Number of notifications.| -| position | [BadgePosition](#badgeposition) | No| BadgePosition.RightTop | Position to display the badge relative to the parent component.| -| maxCount | number | No| 99 | Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.| -| style | [BadgeStyle](#badgestyle) | Yes| - | Style of the badge, including the font color, font size, badge color, and badge size.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| count | number | Yes| Number of notifications.
**NOTE**
If the value is less than or equal to 0, no badge is displayed.
Value range: [-2147483648, 2147483647]
If the value is not an integer, it is rounded off to the nearest integer. For example, 5.5 is rounded off to 5.| +| position | [BadgePosition](#badgeposition) | No| Position to display the badge relative to the parent component.
Default value: **BadgePosition.RightTop**| +| maxCount | number | No| Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.
Default value: **99**
Value range: [-2147483648, 2147483647]
If the value is not an integer, it is rounded off to the nearest integer. For example, 5.5 is rounded off to 5.| +| style | [BadgeStyle](#badgestyle) | Yes| Style of the badge, including the font color, font size, badge color, and badge size.| **API 2**: Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle}) @@ -57,15 +61,23 @@ Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets. -| Name | Type | Mandatory| Default Value | Description | -| ------------------------- | ------------------------------------------------------------ | ---- | ----------------- | ------------------------------------------------------------ | -| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. | -| fontSize | number \| string | No | 10 | Font size, in vp. | -| badgeSize | number \| string | No | 16 | Badge size, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| -| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Badge color. | -| fontWeight10+ | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | No | FontWeight.Normal | Font weight of the text. | -| borderColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Border color of the background. | -| borderWidth10+ | [Length](ts-types.md#length) | No | 1.0vp | Border width of the background. | +| Name | Type | Mandatory| Description | +| ------------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| color | [ResourceColor](ts-types.md#resourcecolor) | No | Font color.
Default value: **Color.White** | +| fontSize | number \| string | No | Font size.
Default value: **10**
Unit: vp
**NOTE**
This parameter cannot be set in percentage.| +| badgeSize | number \| string | No | Badge size.
Default value: **16**
Unit: vp
**NOTE**
This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.| +| badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Badge color.
Default value: **Color.Red** | +| fontWeight10+ | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | No | Font weight of the text.
Default value: **FontWeight.Normal**
**NOTE**
This parameter cannot be set in percentage.| +| borderColor10+ | [ResourceColor](ts-types.md#resourcecolor) | No | Border color of the background. | +| borderWidth10+ | [Length](ts-types.md#length) | No | Border width of the background.
Default value: **1**
Unit: vp
**NOTE**
This parameter cannot be set in percentage.| + +## Attributes + +The [universal attributes](ts-universal-attributes-size.md) are supported. + +## Events + +The [universal events](ts-universal-events-click.md) are supported. ## Example diff --git a/en/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md b/en/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md index c1ad40842425ca4cdf7c66635cee70623b1c4509..7f04fc7c9ab0052d3bcce93e1dc154782e7fc97a 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-datepicker-dialog.md @@ -4,7 +4,7 @@ A date picker dialog box is a dialog box that allows users to select a date from > **NOTE** > -> The APIs of this module are supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version. +> The APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. ## DatePickerDialog.show @@ -15,20 +15,20 @@ Shows a date picker dialog box. **DatePickerDialogOptions** -| Name| Type| Mandatory| Default Value| Description| -| -------- | -------- | -------- | -------- | -------- | -| start | Date | No| Date('1970-1-1') | Start date of the picker.| -| end | Date | No| Date('2100-12-31') | End date of the picker.| -| selected | Date | No| Current system date| Selected date.| -| lunar | boolean | No| false | Whether to display the lunar calendar.| -| showTime10+ | boolean | No| false | Whether to display the time item.| -| useMilitaryTime10+ | boolean | No| false | Whether to display time in 24-hour format.| -| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width for the top and bottom items.| -| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width of all items except the top, bottom, and selected items.| -| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width of the selected item.| -| onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| - | Callback invoked when the OK button in the dialog box is clicked.| -| onCancel | () => void | No| - | Callback invoked when the Cancel button in the dialog box is clicked.| -| onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| - | Callback invoked when the selected item in the picker changes.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| start | Date | No| Start date of the picker.
Default value: **Date('1970-1-1')**| +| end | Date | No| End date of the picker.
Default value: **Date('2100-12-31')**| +| selected | Date | No| Selected date.
Default value: current system date| +| lunar | boolean | No| Whether to display the lunar calendar.
Default value: **false**| +| showTime10+ | boolean | No| Whether to display the time item.
Default value: **false**| +| useMilitaryTime10+ | boolean | No| Whether to display time in 24-hour format.
Default value: **false**| +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.
Default value:
{
color: '#ff182431',
font: {
size: '14fp',
weight: FontWeight.Regular
}
} | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.
Default value:
{
color: '#ff182431',
font: {
size: '16fp',
weight: FontWeight.Regular
}
} | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.
Default value:
{
color: '#ff007dff',
font: {
size: '20vp',
weight: FontWeight.Medium
}
} | +| onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.| +| onCancel | () => void | No| Callback invoked when the Cancel button in the dialog box is clicked.| +| onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| Callback invoked when the selected item in the picker changes.| ## Example @@ -86,3 +86,5 @@ struct DatePickerDialogExample { } } ``` + +![DataPickerDialog](figures/DataPickerDialog.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md b/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md index 4da30a11300a3c5e2ab2cf3f622384f207bbf415..45aba8d2f5d1c22e01d054b6d4fdd1a7255205bc 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-textpicker-dialog.md @@ -17,13 +17,13 @@ Shows a text picker in the given settings. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| range | string[] \| [Resource](ts-types.md#resource)\|[TextPickerRangeContent](ts-basic-components-textpicker.md#textpickerrangecontent10)[]10+ | Yes| Data selection range of the picker. This parameter cannot be set to an empty array. If set to an empty array, it will not be displayed.| +| range | string[] \| [Resource](ts-types.md#resource)\|[TextPickerRangeContent](ts-basic-components-textpicker.md#textpickerrangecontent10)[]10+ | Yes| Data selection range of the picker. This parameter cannot be set to an empty array. If set to an empty array, it will not be displayed.
**NOTE**
The Resource type supports only [strarray.json](../../quick-start/resource-categories-and-access.md#resource-group-subdirectories).| | selected | number | No| Index of the selected item.
Default value: **0**| | value | string | No | Text of the selected item. This parameter does not take effect when the **selected** parameter is set. If the value is not within the range, the first item in the range is used instead.| | defaultPickerItemHeight | number \| string | No| Height of the picker item.| -| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.| -| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.| -| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.| +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.
Default value:
{
color: '#ff182431',
font: {
size: '14fp',
weight: FontWeight.Regular
}
} | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.
Default value:
{
color: '#ff182431',
font: {
size: '16fp',
weight: FontWeight.Regular
}
} | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.
Default value:
{
color: '#ff007dff',
font: {
size: '20vp',
weight: FontWeight.Medium
}
} | | onAccept | (value: [TextPickerResult](#textpickerresult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.| | onCancel | () => void | No| Callback invoked when the Cancel button in the dialog box is clicked.| | onChange | (value: [TextPickerResult](#textpickerresult)) => void | No| Callback invoked when the selected item changes.| @@ -32,8 +32,8 @@ Shows a text picker in the given settings. | Name| Type| Description| | -------- | -------- | -------- | -| value | string | Text of the selected item.
**NOTE**
For a text list or a list consisting of text and images, **value** indicates the text value of the selected item.
For an image list, **value** is empty.| -| index | number | Index of the selected item in the range.| +| value | string | Text of the selected item.
**NOTE**
When the picker contains text only or both text and imagery, **value** indicates the text value of the selected item.
For an image list, **value** is empty.| +| index | number | Index of the selected item in the range. | ## Example @@ -46,27 +46,31 @@ struct TextPickerDialogExample { private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5'] build() { - Column() { - Button("TextPickerDialog") - .margin(20) - .onClick(() => { - TextPickerDialog.show({ - range: this.fruits, - selected: this.select, - onAccept: (value: TextPickerResult) => { - // Set select to the index of the item selected when the OK button is touched. In this way, when the text picker dialog box is displayed again, the selected item is the one last confirmed. - this.select = value.index - console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) - }, - onCancel: () => { - console.info("TextPickerDialog:onCancel()") - }, - onChange: (value: TextPickerResult) => { - console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) - } + Row() { + Column() { + Button("TextPickerDialog") + .margin(20) + .onClick(() => { + TextPickerDialog.show({ + range: this.fruits, + selected: this.select, + onAccept: (value: TextPickerResult) => { + // Set select to the index of the item selected when the OK button is touched. In this way, when the text picker dialog box is displayed again, the selected item is the one last confirmed. + this.select = value.index + console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) + }, + onCancel: () => { + console.info("TextPickerDialog:onCancel()") + }, + onChange: (value: TextPickerResult) => { + console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) + } + }) }) - }) - }.width('100%') + }.width('100%') + }.height('100%') } } ``` + +![TextPickerDialog](figures/TextPickerDialog.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md b/en/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md index 246beaf9da869b68aa059efe66b7570f042ff205..3ebd2bfb5f55db631c48b6f64170c03f6f4bcbce 100644 --- a/en/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md +++ b/en/application-dev/reference/arkui-ts/ts-methods-timepicker-dialog.md @@ -19,9 +19,9 @@ Shows a time picker dialog box. | -------- | -------- | -------- | -------- | | selected | Date | No| Selected time.
Default value: current system time| | useMilitaryTime | boolean | No| Whether to display time in 24-hour format. The 12-hour format is used by default.
Default value: **false**| -| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.| -| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.| -| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.| +| disappearTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.
Default value:
{
color: '#ff182431',
font: {
size: '14fp',
weight: FontWeight.Regular
}
} | +| textStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.
Default value:
{
color: '#ff182431',
font: {
size: '16fp',
weight: FontWeight.Regular
}
} | +| selectedTextStyle10+ | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.
Default value:
{
color: '#ff007dff',
font: {
size: '20vp',
weight: FontWeight.Medium
}
} | | onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.| | onCancel | () => void | No| Callback invoked when the Cancel button in the dialog box is clicked.| | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the selected time changes.| @@ -43,7 +43,7 @@ struct TimePickerDialogExample { TimePickerDialog.show({ selected: this.selectTime, onAccept: (value: TimePickerResult) => { - //Set selectTime to the time when the OK button is clicked. In this way, when the dialog box is displayed again, the selected time is the time when the operation was confirmed last time. + // Set selectTime to the time when the OK button is clicked. In this way, when the dialog box is displayed again, the selected time is the time when the operation was confirmed last time. this.selectTime.setHours(value.hour, value.minute) console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) }, @@ -77,3 +77,5 @@ struct TimePickerDialogExample { } } ``` + +![TimetPickerDialog](figures/TimePickerDialog.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index 5c282923bc24c0d62718d986f16a7ed09b0d7642..62ff2bf39459d2e6ff58418fc7d0ab1cea3c46ff 100644 --- a/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/en/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -22,10 +22,10 @@ Image effects include blur, shadow, spherical effect, and much more. | invert | number | 0 | Inversion ratio of the component. If the value is **1**, the component is completely inverted. If the value is **0**, the component remains unchanged. The unit is percentage.
Value range: [0, 1]
**NOTE**
A value less than 0 evaluates to the value **0**.
Since API version 9, this API is supported in ArkTS widgets.| | sepia | number | 0 | Sepia conversion ratio of the component. If the value is **1**, the image is completely sepia. If the value is **0**, the component remains unchanged. The unit is percentage.
Since API version 9, this API is supported in ArkTS widgets.| | hueRotate | number \| string | '0deg' | Hue rotation angle of the component.
Value range: (-∞, +∞)
**NOTE**
A rotation of 360 degrees leaves the color unchanged. A rotation of 180 degrees and then -180 degrees also leaves the color unchanged. When the data type is number, the value 90 is equivalent to **'90deg'**.
Since API version 9, this API is supported in ArkTS widgets.| -| colorBlend 8+ | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | Color to blend with the component.
Since API version 9, this API is supported in ArkTS widgets.| -| sphericalEffect10+ | [number] | - | Spherical degree of the component.
The value ranges from 0 to 1.
**NOTE**
1. If the value is **0**, the component remains unchanged. If the value is **1**, the component is completely spherical. Between 0 and 1, a greater value indicates a higher spherical degree.
A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.
2. If a component image is loaded asynchronously, the spherical effect is not supported. For example, the **\** component uses asynchronous loading by default, which means that **syncLoad** must be set to **true** to apply the spherical effect. However, this setting is not recommended. Asynchronous loading is also used for **backgroundImage**. Therefore, if **backgroundImage** is set, the spherical effect is not supported.
3. If the shadow effect is set for a component, the spherical effect is not supported.| -| lightUpEffect10+ | [number] | - | Light up degree of the component.
The value ranges from 0 to 1.
If the value is **0**, the component is dark. If the value is **1**, the component is fully illuminated. Between 0 and 1, a greater value indicates higher luminance. A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.| -| pixelStretchEffect10+ | [PixelStretchEffectOptions](ts-types.md#pixelstretcheffectoptions10) | - | Pixel stretch effect options.
The **options** parameter includes the length by which a pixel is stretched toward the four edges.
**NOTE**
1. If the length is a positive value, the original image is stretched, and the image size increases. The edge pixels grow by the set length toward the top, bottom, left, and right edges.
2. 2. If the length is a negative value, the original image shrinks as follows, but the image size remains unchanged:
(1) The image shrinks from the four edges by the absolute value of length set through **options**.
(2) The image is stretched back to the original size with edge pixels.
3. Constraints on **options**:
(1) The length values for the four edges must be all positive or all negative. That is, the four edges are stretched or shrink at the same time in the same direction.
(2) The length values must all be a percentage or a specific value. Combined use of the percentage and specific value is not allowed.
(3) If the input value is invalid, the image is displayed as {0, 0, 0, 0}, that is, the image is the same as the original image. | +| colorBlend8+ | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | Color to blend with the component.
Since API version 9, this API is supported in ArkTS widgets.| +| sphericalEffect10+ | [number] | - | Spherical degree of the component.
The value ranges from 0 to 1.
**NOTE**
1. If the value is **0**, the component remains unchanged. If the value is **1**, the component is completely spherical. Between 0 and 1, a greater value indicates a higher spherical degree.
A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.
2. If a component image is loaded asynchronously, the spherical effect is not supported. For example, the **\** component uses asynchronous loading by default, which means that **syncLoad** must be set to **true** to apply the spherical effect. However, this setting is not recommended. Asynchronous loading is also used for **backgroundImage**. Therefore, if **backgroundImage** is set, the spherical effect is not supported.
3. If the shadow effect is set for a component, the spherical effect is not supported.
This is a system API.| +| lightUpEffect10+ | [number] | - | Light up degree of the component.
The value ranges from 0 to 1.
If the value is **0**, the component is dark. If the value is **1**, the component is fully illuminated. Between 0 and 1, a greater value indicates higher luminance. A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.
This is a system API.| +| pixelStretchEffect10+ | [PixelStretchEffectOptions](ts-types.md#pixelstretcheffectoptions10) | - | Pixel stretch effect options.
The **options** parameter includes the length by which a pixel is stretched toward the four edges.
**NOTE**
1. If the length is a positive value, the original image is stretched, and the image size increases. The edge pixels grow by the set length toward the top, bottom, left, and right edges.
2. 2. If the length is a negative value, the original image shrinks as follows, but the image size remains unchanged:
(1) The image shrinks from the four edges by the absolute value of length set through **options**.
(2) The image is stretched back to the original size with edge pixels.
3. Constraints on **options**:
(1) The length values for the four edges must be all positive or all negative. That is, the four edges are stretched or shrink at the same time in the same direction.
(2) The length values must all be a percentage or a specific value. Combined use of the percentage and specific value is not allowed.
(3) If the input value is invalid, the image is displayed as {0, 0, 0, 0}, that is, the image is the same as the original image.
This is a system API.| ## ShadowOptions @@ -320,7 +320,6 @@ Below is how the component looks: Compared with the original image, the effect drawing is implemented in two steps: -1. The image size is reduced. The resultant size is the original image size minus -the lengths by which the pixels shrink. For example, if the original image size is 100 x 100 and **pixelStretchEffect({top:-10,left:-10,** +1. The image size is reduced. The resultant size is the original image size minus the lengths by which the pixels shrink. For example, if the original image size is 100 x 100 and **pixelStretchEffect({top:-10,left:-10,** **right:-10,bottom:-10})** is set, the resultant size is (100-10-10) x (100-10-10), that is, 8080. 2. Edge pixels are stretched to restore the image to its original size. \ No newline at end of file diff --git a/en/application-dev/reference/errorcodes/errorcode-bundle.md b/en/application-dev/reference/errorcodes/errorcode-bundle.md index 8f7f78de3cd348f9cd0df3c393c4303bb18666bb..7835d5293083daae3fc781c7c218f0126afabdc4 100644 --- a/en/application-dev/reference/errorcodes/errorcode-bundle.md +++ b/en/application-dev/reference/errorcodes/errorcode-bundle.md @@ -719,9 +719,8 @@ Failed to install the HAP because the isolationMode configured is not supported. During application installation, the value of **isolationMode** in the HAP conflicts with the isolation mode of the device. **Possible Causes** - -1. The device supports the isolation mode (the value of **supportIsolationMode** is **true**), whereas the value of **isolationMode** in the HAP is **nonisolationOnly**. -2. The device does not support the isolation mode (the value of **supportIsolationMode** is **false**), whereas the value of **isolationMode** in the HAP is **isolationOnly**. +1. The device supports the isolation mode (the value of **persist.bms.supportIsolationMode** is **true**), whereas the value of **isolationMode** in the HAP is **nonisolationOnly**. +2. The device does not support the isolation mode (the value of **persist.bms.supportIsolationMode** is **false**), whereas the value of **isolationMode** in the HAP is **isolationOnly**. **Solution** diff --git a/en/application-dev/reference/errorcodes/errorcode-net-http.md b/en/application-dev/reference/errorcodes/errorcode-net-http.md index a460d5d3a6e238658cf06ac2195c6f235de3b6bd..371325467f14f381e6c4e06faccac5428fb18b06 100644 --- a/en/application-dev/reference/errorcodes/errorcode-net-http.md +++ b/en/application-dev/reference/errorcodes/errorcode-net-http.md @@ -182,11 +182,11 @@ This error code is reported if an error occurs while writing received data to th **Cause** -The application does not have the data write permission. +The application does not have the permission to write files or the file to be downloaded exceeds 5 MB. **Solution** -Check the permissions granted to the application. +Check the application permission and the size of the file to be downloaded. ## 2300025 Failed to Upload Data diff --git a/en/application-dev/reference/native-apis/_mind_spore.md b/en/application-dev/reference/native-apis/_mind_spore.md index ded41297291a904a08793bd2cd94e2ab667a10a0..5f84ba99e8edb215e11066355c78da50eae199a9 100644 --- a/en/application-dev/reference/native-apis/_mind_spore.md +++ b/en/application-dev/reference/native-apis/_mind_spore.md @@ -7,125 +7,146 @@ Provides APIs related to MindSpore Lite model inference. \@Syscap SystemCapability.Ai.MindSpore -**Since:** +**Since** + 9 + ## Summary -### Files +### File -| Name | Description | -| -------- | -------- | -| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information.
File to Include: | -| [data_type.h](data__type_8h.md) | Declares tensor data types.
File to Include: | -| [format.h](format_8h.md) | Declares tensor data formats.
File to Include: | -| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference.
File to Include: | -| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite.
File to Include: | -| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information.
File to Include: | -| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite.
File to Include: | +| Name | Description | +| ------------------------------- | ------------------------------------------------------------ | +| [context.h](context_8h.md) | Provides **Context** APIs for configuring runtime information.
File to include: \| +| [data_type.h](data__type_8h.md) | Declares tensor data types.
File to include: \| +| [format.h](format_8h.md) | Declares tensor data formats.
File to include: \ | +| [model.h](model_8h.md) | Provides model-related APIs for model creation and inference.
File to include: \| +| [status.h](status_8h.md) | Provides the status codes of MindSpore Lite.
File to include: \| +| [tensor.h](tensor_8h.md) | Provides APIs for creating and modifying tensor information.
File to include: \| +| [types.h](types_8h.md) | Provides the model file types and device types supported by MindSpore Lite.
File to include: \| ### Structs -| Name | Description | -| -------- | -------- | -| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | -| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | -| [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) | Defines the operator information passed in a callback. | +| Name | Description | +| ------------------------------------------------------------ | ---------------------------------------------------- | +| [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.| +| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | 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**. | +### Macro Definition +| Name | Description | +| ------------------------------------------------ | -------------------------------------------- | +| [OH_AI_MAX_SHAPE_NUM](#oh_ai_max_shape_num) 32 | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**.| ### Types -| Name | Description | -| -------- | -------- | -| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | -| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | -| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. | -| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. | -| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. | -| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. | -| **OH_AI_ShapeInfo** | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | -| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. | -| [OH_AI_KernelCallBack](#oh_ai_kernelcallback)) (const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) outputs, const [OH_AI_CallBackParam](_o_h___a_i___call_back_param.md) kernel_Info) | Defines the pointer to a callback. | -| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. | -| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. | -| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. | -| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. | +| Name | Description | +| ------------------------------------------------------------ | -------------------------------------------------- | +| [OH_AI_ContextHandle](#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | +| [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | +| [OH_AI_DataType](#oh_ai_datatype) | Declares data types supported by MSTensor. | +| [OH_AI_Format](#oh_ai_format) | Declares data formats supported by MSTensor. | +| [OH_AI_ModelHandle](#oh_ai_modelhandle) | Defines the pointer to a model object. | +| [OH_AI_TensorHandleArray](#oh_ai_tensorhandlearray) | Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length.| +| [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) | Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. | +| [OH_AI_CallBackParam](#oh_ai_callbackparam) | Defines the operator information passed in a callback. | +| [OH_AI_KernelCallBack](#oh_ai_kernelcallback) | Defines the pointer to a callback. | +| [OH_AI_Status](#oh_ai_status) | Defines MindSpore status codes. | +| [OH_AI_TensorHandle](#oh_ai_tensorhandle) | Defines the handle of a tensor object. | +| [OH_AI_ModelType](#oh_ai_modeltype) | Defines model file types. | +| [OH_AI_DeviceType](#oh_ai_devicetype) | Defines the supported device types. | +| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) | Defines NNRt device types. | +| [OH_AI_PerformanceMode](#oh_ai_performancemode) | Defines performance modes of the NNRt device. | +| [OH_AI_Priority](#oh_ai_priority) | Defines NNRt inference task priorities. | +| [NNRTDeviceDesc](#nnrtdevicedesc) | Defines the NNRt device information, including the device ID and device name. | ### Enums -| Name | Description | -| -------- | -------- | -| [OH_AI_DataType](#oh_ai_datatype) {
OH_AI_DATATYPE_UNKNOWN = 0, OH_AI_DATATYPE_OBJECTTYPE_STRING = 12, OH_AI_DATATYPE_OBJECTTYPE_LIST = 13, OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,
OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17, OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29, OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30, OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,
OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33, OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34, OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35, OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,
OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38, OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39, OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40, OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43, OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44, OH_AI_DATATYPE_NUMBERTYPE_END = 46, OH_AI_DataTypeInvalid = INT32_MAX
} | Declares data types supported by MSTensor. | -| [OH_AI_Format](#oh_ai_format) {
OH_AI_FORMAT_NCHW = 0, OH_AI_FORMAT_NHWC = 1, OH_AI_FORMAT_NHWC4 = 2, OH_AI_FORMAT_HWKC = 3,
OH_AI_FORMAT_HWCK = 4, OH_AI_FORMAT_KCHW = 5, OH_AI_FORMAT_CKHW = 6, OH_AI_FORMAT_KHWC = 7,
OH_AI_FORMAT_CHWK = 8, OH_AI_FORMAT_HW = 9, OH_AI_FORMAT_HW4 = 10, OH_AI_FORMAT_NC = 11,
OH_AI_FORMAT_NC4 = 12, OH_AI_FORMAT_NC4HW4 = 13, OH_AI_FORMAT_NCDHW = 15, OH_AI_FORMAT_NWC = 16,
OH_AI_FORMAT_NCW = 17
} | Declares data formats supported by MSTensor. | -| [OH_AI_CompCode](#oh_ai_compcode) { OH_AI_COMPCODE_CORE = 0x00000000u, OH_AI_COMPCODE_LITE = 0xF0000000u } | Defines MinSpore component codes. | -| [OH_AI_Status](#oh_ai_status) {
OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -2),
OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -6),
OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -100),
OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -300),
OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -400),
OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID
} | Defines MindSpore status codes. | -| [OH_AI_ModelType](#oh_ai_modeltype) { OH_AI_MODELTYPE_MINDIR = 0, OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF } | Defines model file types. | -| [OH_AI_DeviceType](#oh_ai_devicetype) {
OH_AI_DEVICETYPE_CPU = 0, OH_AI_DEVICETYPE_GPU, OH_AI_DEVICETYPE_KIRIN_NPU, OH_AI_DEVICETYPE_NNRT = 60,
OH_AI_DEVICETYPE_INVALID = 100
} | Defines the supported device types. | +| Name | Description | +| ------------------------------------------------------------ | ---------------------------------------- | +| [OH_AI_DataType](#oh_ai_datatype-1) {
OH_AI_DATATYPE_UNKNOWN = 0,
OH_AI_DATATYPE_OBJECTTYPE_STRING = 12,
OH_AI_DATATYPE_OBJECTTYPE_LIST = 13,
OH_AI_DATATYPE_OBJECTTYPE_TUPLE = 14,
OH_AI_DATATYPE_OBJECTTYPE_TENSOR = 17,
OH_AI_DATATYPE_NUMBERTYPE_BEGIN = 29,
OH_AI_DATATYPE_NUMBERTYPE_BOOL = 30,
OH_AI_DATATYPE_NUMBERTYPE_INT8 = 32,
OH_AI_DATATYPE_NUMBERTYPE_INT16 = 33,
OH_AI_DATATYPE_NUMBERTYPE_INT32 = 34,
OH_AI_DATATYPE_NUMBERTYPE_INT64 = 35,
OH_AI_DATATYPE_NUMBERTYPE_UINT8 = 37,
OH_AI_DATATYPE_NUMBERTYPE_UINT16 = 38,
OH_AI_DATATYPE_NUMBERTYPE_UINT32 = 39,
OH_AI_DATATYPE_NUMBERTYPE_UINT64 = 40,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 = 42,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 = 43,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 = 44,
OH_AI_DATATYPE_NUMBERTYPE_END = 46,
OH_AI_DataTypeInvalid = INT32_MAX
} | Declares data types supported by MSTensor. | +| [OH_AI_Format](#oh_ai_format-1) {
OH_AI_FORMAT_NCHW = 0,
OH_AI_FORMAT_NHWC = 1,
OH_AI_FORMAT_NHWC4 = 2,
OH_AI_FORMAT_HWKC = 3,
OH_AI_FORMAT_HWCK = 4,
OH_AI_FORMAT_KCHW = 5,
OH_AI_FORMAT_CKHW = 6,
OH_AI_FORMAT_KHWC = 7,
OH_AI_FORMAT_CHWK = 8,
OH_AI_FORMAT_HW = 9,
OH_AI_FORMAT_HW4 = 10,
OH_AI_FORMAT_NC = 11,
OH_AI_FORMAT_NC4 = 12,
OH_AI_FORMAT_NC4HW4 = 13,
OH_AI_FORMAT_NCDHW = 15,
OH_AI_FORMAT_NWC = 16,
OH_AI_FORMAT_NCW = 17
} | Declares data formats supported by MSTensor. | +| [OH_AI_CompCode](#oh_ai_compcode) {
OH_AI_COMPCODE_CORE = 0x00000000u,
OH_AI_COMPCODE_LITE = 0xF0000000u
} | Defines MindSpore component codes. | +| [OH_AI_Status](#oh_ai_status-1) {
OH_AI_STATUS_SUCCESS = 0, OH_AI_STATUS_CORE_FAILED = OH_AI_COMPCODE_CORE \| 0x1, OH_AI_STATUS_LITE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -1), OH_AI_STATUS_LITE_NULLPTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -2),
OH_AI_STATUS_LITE_PARAM_INVALID = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -3), OH_AI_STATUS_LITE_NO_CHANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -4), OH_AI_STATUS_LITE_SUCCESS_EXIT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -5), OH_AI_STATUS_LITE_MEMORY_FAILED = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -6),
OH_AI_STATUS_LITE_NOT_SUPPORT = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -7), OH_AI_STATUS_LITE_THREADPOOL_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -8), OH_AI_STATUS_LITE_UNINITIALIZED_OBJ = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -9), OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -100),
OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR, OH_AI_STATUS_LITE_REENTRANT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -102), OH_AI_STATUS_LITE_GRAPH_FILE_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -200), OH_AI_STATUS_LITE_NOT_FIND_OP = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -300),
OH_AI_STATUS_LITE_INVALID_OP_NAME = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -301), OH_AI_STATUS_LITE_INVALID_OP_ATTR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -302), OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE, OH_AI_STATUS_LITE_FORMAT_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -400),
OH_AI_STATUS_LITE_INFER_ERROR = OH_AI_COMPCODE_LITE \| (0x0FFFFFFF & -500), OH_AI_STATUS_LITE_INFER_INVALID, OH_AI_STATUS_LITE_INPUT_PARAM_INVALID
} | Defines MindSpore status codes. | +| [OH_AI_ModelType](#oh_ai_modeltype-1) {
OH_AI_MODELTYPE_MINDIR = 0,
OH_AI_MODELTYPE_INVALID = 0xFFFFFFFF
} | Defines model file types. | +| [OH_AI_DeviceType](#oh_ai_devicetype-1) {
OH_AI_DEVICETYPE_CPU = 0,
OH_AI_DEVICETYPE_GPU,
OH_AI_DEVICETYPE_KIRIN_NPU,
OH_AI_DEVICETYPE_NNRT = 60,
OH_AI_DEVICETYPE_INVALID = 100
} | Defines the supported device types.| +| [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype-1) {
OH_AI_NNRTDEVICE_OTHERS = 0,
OH_AI_NNRTDEVICE_CPU = 1,
OH_AI_NNRTDEVICE_GPU = 2,
OH_AI_NNRTDEVICE_ACCELERATOR = 3
} | Defines NNRt device types. | +| [OH_AI_PerformanceMode](#oh_ai_performancemode-1) {
OH_AI_PERFORMANCE_NONE = 0,
OH_AI_PERFORMANCE_LOW = 1,
OH_AI_PERFORMANCE_MEDIUM = 2,
OH_AI_PERFORMANCE_HIGH = 3,
OH_AI_PERFORMANCE_EXTREME = 4
} | Defines performance modes of the NNRt device. | +| [OH_AI_Priority](#oh_ai_priority-1) {
OH_AI_PRIORITY_NONE = 0,
OH_AI_PRIORITY_LOW = 1,
OH_AI_PRIORITY_MEDIUM = 2,
OH_AI_PRIORITY_HIGH = 3
} | Defines NNRt inference task priorities. | ### Functions -| Name | Description | -| -------- | -------- | -| [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. | -| [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. | -| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | -| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. | -| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | -| [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | -| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | -| [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | -| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | -| [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | -| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | -| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. | -| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | -| [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | -| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | -| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | -| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | -| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | -| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | -| [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | -| [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | -| [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | -| [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. | -| [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. | -| [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | -| [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | -| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | -| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | -| [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | -| [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | -| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. | -| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the name of a tensor. | -| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the name of a tensor. | -| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | -| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the data type of a tensor. | -| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the shape of a tensor. | -| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the shape of a tensor. | -| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. | -| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | -| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | -| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | -| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | -| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | -| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | +| Name | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| [OH_AI_ContextCreate](#oh_ai_contextcreate) () | Creates a context object. | +| [OH_AI_ContextDestroy](#oh_ai_contextdestroy) ([OH_AI_ContextHandle](#oh_ai_contexthandle) \*context) | Destroys a context object. | +| [OH_AI_ContextSetThreadNum](#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | +| [OH_AI_ContextGetThreadNum](#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the number of threads. | +| [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.| +| [OH_AI_ContextGetThreadAffinityMode](#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | +| [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | +| [OH_AI_ContextGetThreadAffinityCoreList](#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | +| [OH_AI_ContextSetEnableParallel](#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available. | +| [OH_AI_ContextGetEnableParallel](#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | +| [OH_AI_ContextAddDeviceInfo](#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context. | +| [OH_AI_DeviceInfoCreate](#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](#oh_ai_devicetype) device_type) | Creates a device information object. | +| [OH_AI_DeviceInfoDestroy](#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually. | +| [OH_AI_DeviceInfoSetProvider](#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name. | +| [OH_AI_DeviceInfoGetProvider](#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | +| [OH_AI_DeviceInfoSetProviderDevice](#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | +| [OH_AI_DeviceInfoGetProviderDevice](#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | +| [OH_AI_DeviceInfoGetDeviceType](#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the device type. | +| [OH_AI_DeviceInfoSetEnableFP16](#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU and GPU devices. | +| [OH_AI_DeviceInfoGetEnableFP16](#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices. | +| [OH_AI_DeviceInfoSetFrequency](#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_DeviceInfoGetFrequency](#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system. | +| [OH_AI_DestroyAllNNRTDeviceDescs](#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| +| [OH_AI_GetNameFromNNRTDeviceDesc](#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description. | +| [OH_AI_GetTypeFromNNRTDeviceDesc](#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description. | +| [OH_AI_CreateNNRTDeviceInfoByName](#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_CreateNNRTDeviceInfoByType](#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_DeviceInfoSetDeviceId](#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetDeviceId](#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPerformanceMode](#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPerformanceMode](#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoSetPriority](#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices. | +| [OH_AI_DeviceInfoGetPriority](#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices. | +| [OH_AI_ModelCreate](#oh_ai_modelcreate) () | Creates a model object. | +| [OH_AI_ModelDestroy](#oh_ai_modeldestroy) ([OH_AI_ModelHandle](#oh_ai_modelhandle) \*model) | Destroys a model object. | +| [OH_AI_ModelBuild](#oh_ai_modelbuild) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const void \*model_data, size_t data_size, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from the memory buffer. | +| [OH_AI_ModelBuildFromFile](#oh_ai_modelbuildfromfile) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*model_path, [OH_AI_ModelType](#oh_ai_modeltype) model_type, const [OH_AI_ContextHandle](#oh_ai_contexthandle) model_context) | Loads and builds a MindSpore model from a model file. | +| [OH_AI_ModelResize](#oh_ai_modelresize) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_ShapeInfo](_o_h___a_i___shape_info.md) \*shape_infos, size_t shape_info_num) | Adjusts the input tensor shapes of a built model. | +| [OH_AI_ModelPredict](#oh_ai_modelpredict) ([OH_AI_ModelHandle](#oh_ai_modelhandle) model, const [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) inputs, [OH_AI_TensorHandleArray](_o_h___a_i___tensor_handle_array.md) \*outputs, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) before, const [OH_AI_KernelCallBack](#oh_ai_kernelcallback) after) | Performs model inference. | +| [OH_AI_ModelGetInputs](#oh_ai_modelgetinputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the input tensor array structure of a model. | +| [OH_AI_ModelGetOutputs](#oh_ai_modelgetoutputs) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model) | Obtains the output tensor array structure of a model. | +| [OH_AI_ModelGetInputByTensorName](#oh_ai_modelgetinputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the input tensor of a model by tensor name. | +| [OH_AI_ModelGetOutputByTensorName](#oh_ai_modelgetoutputbytensorname) (const [OH_AI_ModelHandle](#oh_ai_modelhandle) model, const char \*tensor_name) | Obtains the output tensor of a model by tensor name. | +| [OH_AI_TensorCreate](#oh_ai_tensorcreate) (const char \*name, [OH_AI_DataType](#oh_ai_datatype) type, const int64_t \*shape, size_t shape_num, const void \*data, size_t data_len) | Creates a tensor object. | +| [OH_AI_TensorDestroy](#oh_ai_tensordestroy) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) \*tensor) | Destroys a tensor object. | +| [OH_AI_TensorClone](#oh_ai_tensorclone) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Clones a tensor. | +| [OH_AI_TensorSetName](#oh_ai_tensorsetname) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const char \*name) | Sets the tensor name. | +| [OH_AI_TensorGetName](#oh_ai_tensorgetname) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor name. | +| [OH_AI_TensorSetDataType](#oh_ai_tensorsetdatatype) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_DataType](#oh_ai_datatype) type) | Sets the data type of a tensor. | +| [OH_AI_TensorGetDataType](#oh_ai_tensorgetdatatype) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor type. | +| [OH_AI_TensorSetShape](#oh_ai_tensorsetshape) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, const int64_t \*shape, size_t shape_num) | Sets the tensor shape. | +| [OH_AI_TensorGetShape](#oh_ai_tensorgetshape) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, size_t \*shape_num) | Obtains the tensor shape. | +| [OH_AI_TensorSetFormat](#oh_ai_tensorsetformat) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, [OH_AI_Format](#oh_ai_format) format) | Sets the tensor data format. | +| [OH_AI_TensorGetFormat](#oh_ai_tensorgetformat) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the tensor data format. | +| [OH_AI_TensorSetData](#oh_ai_tensorsetdata) ([OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor, void \*data) | Sets the tensor data. | +| [OH_AI_TensorGetData](#oh_ai_tensorgetdata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to tensor data. | +| [OH_AI_TensorGetMutableData](#oh_ai_tensorgetmutabledata) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. | +| [OH_AI_TensorGetElementNum](#oh_ai_tensorgetelementnum) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of tensor elements. | +| [OH_AI_TensorGetDataSize](#oh_ai_tensorgetdatasize) (const [OH_AI_TensorHandle](#oh_ai_tensorhandle) tensor) | Obtains the number of bytes of the tensor data. | ## Macro Description @@ -133,84 +154,116 @@ Provides APIs related to MindSpore Lite model inference. ### OH_AI_MAX_SHAPE_NUM - + ``` #define OH_AI_MAX_SHAPE_NUM 32 ``` -**Description**
+ +**Description** + Defines dimension information. The maximum dimension is set by **MS_MAX_SHAPE_NUM**. ## Type Description +### NNRTDeviceDesc + + +``` +typedef struct NNRTDeviceDesc NNRTDeviceDesc +``` + +**Description** + +Defines the NNRt device information, including the device ID and device name. + +**Since** + +10 + + ### OH_AI_CallBackParam - + ``` -typedef struct OH_AI_CallBackParamOH_AI_CallBackParam +typedef struct OH_AI_CallBackParam OH_AI_CallBackParam ``` -**Description**
+ +**Description** + Defines the operator information passed in a callback. ### OH_AI_ContextHandle - + ``` typedef void* OH_AI_ContextHandle ``` -**Description**
-Defines the pointer to the MindSpore context. + +**Description** + +Defines the pointer to the MindSpore context. ### OH_AI_DataType - + ``` -typedef enum OH_AI_DataTypeOH_AI_DataType +typedef enum OH_AI_DataType OH_AI_DataType ``` -**Description**
+ +**Description** + Declares data types supported by MSTensor. ### OH_AI_DeviceInfoHandle - + ``` typedef void* OH_AI_DeviceInfoHandle ``` -**Description**
+ +**Description** + Defines the pointer to the MindSpore device information. ### OH_AI_DeviceType - + ``` -typedef enum OH_AI_DeviceTypeOH_AI_DeviceType +typedef enum OH_AI_DeviceType OH_AI_DeviceType ``` -**Description**
+ +**Description** + Defines the supported device types. ### OH_AI_Format - + ``` -typedef enum OH_AI_FormatOH_AI_Format +typedef enum OH_AI_Format OH_AI_Format ``` -**Description**
+ +**Description** + Declares data formats supported by MSTensor. ### OH_AI_KernelCallBack - + ``` typedef bool(* OH_AI_KernelCallBack) (const OH_AI_TensorHandleArray inputs, const OH_AI_TensorHandleArray outputs, const OH_AI_CallBackParam kernel_Info) ``` -**Description**
+ +**Description** + Defines the pointer to a callback. This pointer is used to set the two callback functions in [OH_AI_ModelPredict](#oh_ai_modelpredict). Each callback function must contain three parameters, where **inputs** and **outputs** indicate the input and output tensors of the operator, and **kernel_Info** indicates information about the current operator. You can use the callback functions to monitor the operator execution status, for example, operator execution time and the operator correctness. @@ -218,51 +271,109 @@ This pointer is used to set the two callback functions in [OH_AI_ModelPredict](# ### OH_AI_ModelHandle - + ``` typedef void* OH_AI_ModelHandle ``` -**Description**
+ +**Description** + Defines the pointer to a model object. ### OH_AI_ModelType - + ``` -typedef enum OH_AI_ModelTypeOH_AI_ModelType +typedef enum OH_AI_ModelType OH_AI_ModelType ``` -**Description**
+ +**Description** + Defines model file types. +### OH_AI_NNRTDeviceType + + +``` +typedef enum OH_AI_NNRTDeviceType OH_AI_NNRTDeviceType +``` + +**Description** + +Defines NNRt device types. + +**Since** + +10 + + +### OH_AI_PerformanceMode + + +``` +typedef enum OH_AI_PerformanceMode OH_AI_PerformanceMode +``` + +**Description** + +Defines performance modes of the NNRt device. + +**Since** + +10 + + +### OH_AI_Priority + + +``` +typedef enum OH_AI_Priority OH_AI_Priority +``` + +**Description** + +Defines NNRt inference task priorities. + +**Since** + +10 + + ### OH_AI_Status - + ``` -typedef enum OH_AI_StatusOH_AI_Status +typedef enum OH_AI_Status OH_AI_Status ``` -**Description**
+ +**Description** + Defines MindSpore status codes. ### OH_AI_TensorHandle - + ``` typedef void* OH_AI_TensorHandle ``` -**Description**
+ +**Description** + Defines the handle of a tensor object. ### OH_AI_TensorHandleArray - + ``` -typedef struct OH_AI_TensorHandleArrayOH_AI_TensorHandleArray +typedef struct OH_AI_TensorHandleArray OH_AI_TensorHandleArray ``` -**Description**
+ +**Description** + Defines the tensor array structure, which is used to store the tensor array pointer and tensor array length. @@ -271,215 +382,304 @@ Defines the tensor array structure, which is used to store the tensor array poin ### OH_AI_CompCode - + ``` enum OH_AI_CompCode ``` -**Description**
-Defines MinSpore component codes. -| Name | Description | -| -------- | -------- | -| OH_AI_COMPCODE_CORE | MindSpore Core code | -| OH_AI_COMPCODE_LITE | MindSpore Lite code | +**Description** + +Defines MindSpore component codes. + +| Value | Description | +| ------------------- | --------------------- | +| OH_AI_COMPCODE_CORE | MindSpore Core code| +| OH_AI_COMPCODE_LITE | MindSpore Lite code| ### OH_AI_DataType - + ``` enum OH_AI_DataType ``` -**Description**
+ +**Description** + Declares data types supported by MSTensor. -| Name | Description | -| -------- | -------- | -| OH_AI_DATATYPE_UNKNOWN | Unknown data type | -| OH_AI_DATATYPE_OBJECTTYPE_STRING | String data type | -| OH_AI_DATATYPE_OBJECTTYPE_LIST | List data type | -| OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data type | -| OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data type | -| OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type | -| OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data type | -| OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data type | -| OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type | -| OH_AI_DataTypeInvalid | Invalid data type | +| Value | Description | +| --------------------------------- | ---------------------- | +| OH_AI_DATATYPE_UNKNOWN | Unknown data type. | +| OH_AI_DATATYPE_OBJECTTYPE_STRING | String data. | +| OH_AI_DATATYPE_OBJECTTYPE_LIST | List data. | +| OH_AI_DATATYPE_OBJECTTYPE_TUPLE | Tuple data. | +| OH_AI_DATATYPE_OBJECTTYPE_TENSOR | TensorList data. | +| OH_AI_DATATYPE_NUMBERTYPE_BEGIN | Beginning of the number type. | +| OH_AI_DATATYPE_NUMBERTYPE_BOOL | Bool data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT8 | Int8 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT16 | Int16 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT32 | Int32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_INT64 | Int64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT8 | UInt8 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT16 | UInt16 data . | +| OH_AI_DATATYPE_NUMBERTYPE_UINT32 | UInt32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_UINT64 | UInt64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT16 | Float16 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT32 | Float32 data. | +| OH_AI_DATATYPE_NUMBERTYPE_FLOAT64 | Float64 data. | +| OH_AI_DATATYPE_NUMBERTYPE_END | End of the number type.| +| OH_AI_DataTypeInvalid | Invalid data type. | ### OH_AI_DeviceType - + ``` enum OH_AI_DeviceType ``` -**Description**
+ +**Description** + Defines the supported device types. -| Name | Description | -| -------- | -------- | -| OH_AI_DEVICETYPE_CPU | Device type: CPU
since 9 | -| OH_AI_DEVICETYPE_GPU | Device type: GPU
Reserved, not support yet.
since 9 | -| OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU
Reserved, not support yet.
since 9 | -| OH_AI_DEVICETYPE_NNRT | Device type: NNRt
OHOS-only device range[60,80).
since 9 | -| OH_AI_DEVICETYPE_INVALID | Invalid device type
since 9 | +| Value | Description | +| -------------------------- | --------------------------------------- | +| OH_AI_DEVICETYPE_CPU | Device type: CPU | +| OH_AI_DEVICETYPE_GPU | Device type: GPU Reserved | +| OH_AI_DEVICETYPE_KIRIN_NPU | Device type: Kirin NPU Reserved| +| OH_AI_DEVICETYPE_NNRT | Device type: NNRt OHOS device range: [60, 80)| +| OH_AI_DEVICETYPE_INVALID | Invalid device type | ### OH_AI_Format - + ``` enum OH_AI_Format ``` -**Description**
+ +**Description** + Declares data formats supported by MSTensor. -| Name | Description | -| -------- | -------- | -| OH_AI_FORMAT_NCHW | NCHW format | -| OH_AI_FORMAT_NHWC | NHWC format | -| OH_AI_FORMAT_NHWC4 | NHWC4 format | -| OH_AI_FORMAT_HWKC | HWKC format | -| OH_AI_FORMAT_HWCK | HWCK format | -| OH_AI_FORMAT_KCHW | KCHW format | -| OH_AI_FORMAT_CKHW | CKHW format | -| OH_AI_FORMAT_KHWC | KHWC format | -| OH_AI_FORMAT_CHWK | CHWK format | -| OH_AI_FORMAT_HW | HW format | -| OH_AI_FORMAT_HW4 | HW4 format | -| OH_AI_FORMAT_NC | NC format | -| OH_AI_FORMAT_NC4 | NC4 format | -| OH_AI_FORMAT_NC4HW4 | NC4HW4 format | -| OH_AI_FORMAT_NCDHW | NCDHW format | -| OH_AI_FORMAT_NWC | NWC format | -| OH_AI_FORMAT_NCW | NCW format | +| Value | Description | +| ------------------- | ---------------- | +| OH_AI_FORMAT_NCHW | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. | +| OH_AI_FORMAT_NHWC | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. | +| OH_AI_FORMAT_NHWC4 | Tensor data is stored in the sequence of batch number N, height H, width W, and channel C. The C axis is 4-byte aligned. | +| OH_AI_FORMAT_HWKC | Tensor data is stored in the sequence of height H, width W, core count K, and channel C. | +| OH_AI_FORMAT_HWCK | Tensor data is stored in the sequence of height H, width W, channel C, and core count K. | +| OH_AI_FORMAT_KCHW | Tensor data is stored in the sequence of core count K, channel C, height H, and width W. | +| OH_AI_FORMAT_CKHW | Tensor data is stored in the sequence of channel C, core count K, height H, and width W. | +| OH_AI_FORMAT_KHWC | Tensor data is stored in the sequence of core count K, height H, width W, and channel C. | +| OH_AI_FORMAT_CHWK | Tensor data is stored in the sequence of channel C, height H, width W, and core count K. | +| OH_AI_FORMAT_HW | Tensor data is stored in the sequence of height H and width W. | +| OH_AI_FORMAT_HW4 | Tensor data is stored in the sequence of height H and width W. The W axis is 4-byte aligned. | +| OH_AI_FORMAT_NC | Tensor data is stored in the sequence of batch number N and channel C. | +| OH_AI_FORMAT_NC4 | Tensor data is stored in the sequence of batch number N and channel C. The C axis is 4-byte aligned. | +| OH_AI_FORMAT_NC4HW4 | Tensor data is stored in the sequence of batch number N, channel C, height H, and width W. The C axis and W axis are 4-byte aligned.| +| OH_AI_FORMAT_NCDHW | Tensor data is stored in the sequence of batch number N, channel C, depth D, height H, and width W. | +| OH_AI_FORMAT_NWC | Tensor data is stored in the sequence of batch number N, width W, and channel C. | +| OH_AI_FORMAT_NCW | Tensor data is stored in the sequence of batch number N, channel C, and width W. | ### OH_AI_ModelType - + ``` enum OH_AI_ModelType ``` -**Description**
+ +**Description** + Defines model file types. -| Name | Description | -| -------- | -------- | -| OH_AI_MODELTYPE_MINDIR | Model type: MindIR
since 9 | -| OH_AI_MODELTYPE_INVALID | Invalid model type
since 9 | +| Value | Description | +| ----------------------- | ------------------ | +| OH_AI_MODELTYPE_MINDIR | Model type of MindIR. The extension of the model file name is **.ms**.| +| OH_AI_MODELTYPE_INVALID | Invalid model type. | + + +### OH_AI_NNRTDeviceType + + +``` +enum OH_AI_NNRTDeviceType +``` + +**Description** + +Defines NNRt device types. + +**Since** + +10 + +| Value | Description | +| ---------------------------- | ----------------------------------- | +| OH_AI_NNRTDEVICE_OTHERS | Others (any device type except the following three types).| +| OH_AI_NNRTDEVICE_CPU | CPU. | +| OH_AI_NNRTDEVICE_GPU | GPU. | +| OH_AI_NNRTDEVICE_ACCELERATOR | Specific acceleration device. | + + +### OH_AI_PerformanceMode + + +``` +enum OH_AI_PerformanceMode +``` + +**Description** + +Defines performance modes of the NNRt device. + +**Since** + +10 + +| Value | Description | +| ------------------------- | ------------------- | +| OH_AI_PERFORMANCE_NONE | No special settings. | +| OH_AI_PERFORMANCE_LOW | Low power consumption. | +| OH_AI_PERFORMANCE_MEDIUM | Power consumption and performance balancing.| +| OH_AI_PERFORMANCE_HIGH | High performance. | +| OH_AI_PERFORMANCE_EXTREME | Ultimate performance. | + + +### OH_AI_Priority + + +``` +enum OH_AI_Priority +``` + +**Description** + +Defines NNRt inference task priorities. + +**Since** + +10 + +| Value | Description | +| --------------------- | -------------- | +| OH_AI_PRIORITY_NONE | No priority preference.| +| OH_AI_PRIORITY_LOW | Low priority.| +| OH_AI_PRIORITY_MEDIUM | Medium priority| +| OH_AI_PRIORITY_HIGH | High priority. | ### OH_AI_Status - + ``` enum OH_AI_Status ``` -**Description**
-Defines MindSpore status codes. -| Name | Description | -| -------- | -------- | -| OH_AI_STATUS_SUCCESS | Success | -| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure | -| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error | -| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer | -| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters | -| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change | -| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors | -| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure | -| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported | -| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error | -| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized | -| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow | -| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error | -| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error | -| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error | -| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found | -| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators | -| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters | -| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure | -| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error | -| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error | -| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference | -| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters | +**Description** + +Defines MindSpore status codes. +| Value | Description | +| ------------------------------------- | ----------------------------------------- | +| OH_AI_STATUS_SUCCESS | Success. | +| OH_AI_STATUS_CORE_FAILED | MindSpore Core failure. | +| OH_AI_STATUS_LITE_ERROR | MindSpore Lite error. | +| OH_AI_STATUS_LITE_NULLPTR | MindSpore Lite null pointer. | +| OH_AI_STATUS_LITE_PARAM_INVALID | MindSpore Lite invalid parameters. | +| OH_AI_STATUS_LITE_NO_CHANGE | MindSpore Lite no change. | +| OH_AI_STATUS_LITE_SUCCESS_EXIT | MindSpore Lite exit without errors.| +| OH_AI_STATUS_LITE_MEMORY_FAILED | MindSpore Lite memory allocation failure. | +| OH_AI_STATUS_LITE_NOT_SUPPORT | MindSpore Lite not supported. | +| OH_AI_STATUS_LITE_THREADPOOL_ERROR | MindSpore Lite thread pool error. | +| OH_AI_STATUS_LITE_UNINITIALIZED_OBJ | MindSpore Lite uninitialized. | +| OH_AI_STATUS_LITE_OUT_OF_TENSOR_RANGE | MindSpore Lite tensor overflow. | +| OH_AI_STATUS_LITE_INPUT_TENSOR_ERROR | MindSpore Lite input tensor error. | +| OH_AI_STATUS_LITE_REENTRANT_ERROR | MindSpore Lite reentry error. | +| OH_AI_STATUS_LITE_GRAPH_FILE_ERROR | MindSpore Lite file error. | +| OH_AI_STATUS_LITE_NOT_FIND_OP | MindSpore Lite operator not found. | +| OH_AI_STATUS_LITE_INVALID_OP_NAME | MindSpore Lite invalid operators. | +| OH_AI_STATUS_LITE_INVALID_OP_ATTR | MindSpore Lite invalid operator hyperparameters. | +| OH_AI_STATUS_LITE_OP_EXECUTE_FAILURE | MindSpore Lite operator execution failure. | +| OH_AI_STATUS_LITE_FORMAT_ERROR | MindSpore Lite tensor format error. | +| OH_AI_STATUS_LITE_INFER_ERROR | MindSpore Lite shape inference error. | +| OH_AI_STATUS_LITE_INFER_INVALID | MindSpore Lite invalid shape inference. | +| OH_AI_STATUS_LITE_INPUT_PARAM_INVALID | MindSpore Lite invalid input parameters.| ## Function Description ### OH_AI_ContextAddDeviceInfo() - + ``` OH_AI_API void OH_AI_ContextAddDeviceInfo (OH_AI_ContextHandle context, OH_AI_DeviceInfoHandle device_info ) ``` -**Description**
-Adds information about a running device. - **Parameters** +**Description** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +Attaches the custom device information to the inference context. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| ### OH_AI_ContextCreate() - + ``` OH_AI_API OH_AI_ContextHandle OH_AI_ContextCreate () ``` -**Description**
+ +**Description** + Creates a context object. **Returns** -[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context. +[OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. ### OH_AI_ContextDestroy() - + ``` OH_AI_API void OH_AI_ContextDestroy (OH_AI_ContextHandle * context) ``` -**Description**
+ +**Description** + Destroys a context object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | Level-2 pointer to [OH_AI_ContextHandle](#oh_ai_contexthandle). After the context is destroyed, the pointer is set to null. | ### OH_AI_ContextGetEnableParallel() - + ``` OH_AI_API bool OH_AI_ContextGetEnableParallel (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Checks whether parallelism between operators is supported. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** @@ -488,59 +688,65 @@ Whether parallelism between operators is supported. The value **true** means tha ### OH_AI_ContextGetThreadAffinityCoreList() - + ``` OH_AI_API const int32_t* OH_AI_ContextGetThreadAffinityCoreList (const OH_AI_ContextHandle context, size_t * core_num ) ``` -**Description**
+ +**Description** + Obtains the list of bound CPU cores. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| core_num | Number of CPU cores. | +| Name | Description | +| -------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| core_num | Number of CPU cores. | **Returns** -List of bound CPU cores. +Specifies the CPU core binding list. This list is managed by [OH_AI_ContextHandle](#oh_ai_contexthandle). The caller does not need to destroy it manually. ### OH_AI_ContextGetThreadAffinityMode() - + ``` OH_AI_API int OH_AI_ContextGetThreadAffinityMode (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Obtains the affinity mode for binding runtime threads to CPU cores. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** -Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first +Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first ### OH_AI_ContextGetThreadNum() - + ``` OH_AI_API int32_t OH_AI_ContextGetThreadNum (const OH_AI_ContextHandle context) ``` -**Description**
+ +**Description** + Obtains the number of threads. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| **Returns** @@ -549,125 +755,239 @@ Number of threads. ### OH_AI_ContextSetEnableParallel() - + ``` OH_AI_API void OH_AI_ContextSetEnableParallel (OH_AI_ContextHandle context, bool is_parallel ) ``` -**Description**
-Sets whether to enable parallelism between operators. - **Parameters** +**Description** + +Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available. -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| is_parallel | Whether to enable parallelism between operators. The value **true** means to enable parallelism between operators, and the value **false** means the opposite. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| is_parallel | Whether parallelism between operators is supported. The value **true** means that parallelism between operators is supported, and the value **false** means the opposite. | ### OH_AI_ContextSetThreadAffinityCoreList() - + ``` OH_AI_API void OH_AI_ContextSetThreadAffinityCoreList (OH_AI_ContextHandle context, const int32_t * core_list, size_t core_num ) ``` -**Description**
+ +**Description** + Sets the list of CPU cores bound to a runtime thread. For example, if **core_list** is set to **[2,6,8]**, threads run on the 2nd, 6th, and 8th CPU cores. If [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) and [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) are called for the same context object, the **core_list** parameter of [OH_AI_ContextSetThreadAffinityCoreList](#oh_ai_contextsetthreadaffinitycorelist) takes effect, but the **mode** parameter of [OH_AI_ContextSetThreadAffinityMode](#oh_ai_contextsetthreadaffinitymode) does not. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| core_list | List of bound CPU cores. | -| core_num | Number of cores, which indicates the length of **core_list**. | +| Name | Description | +| --------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| core_list | List of bound CPU cores. | +| core_num | Number of cores, which indicates the length of **core_list**. | ### OH_AI_ContextSetThreadAffinityMode() - + ``` OH_AI_API void OH_AI_ContextSetThreadAffinityMode (OH_AI_ContextHandle context, int mode ) ``` -**Description**
-Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. - **Parameters** +**Description** + +Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores. + +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: little cores first | +| Name | Description | +| ------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| mode | Affinity mode. **0**: no affinities; **1**: big cores first; **2**: medium cores first| ### OH_AI_ContextSetThreadNum() - + ``` OH_AI_API void OH_AI_ContextSetThreadNum (OH_AI_ContextHandle context, int32_t thread_num ) ``` -**Description**
+ +**Description** + Sets the number of runtime threads. - **Parameters** +**Parameters** + +| Name | Description | +| ---------- | ------------------------------------------------------------ | +| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance.| +| thread_num | Number of runtime threads. | + + +### OH_AI_CreateNNRTDeviceInfoByName() + + +``` +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByName (const char * name) +``` + +**Description** + +Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device. + +**Parameters** + +| Name| Description | +| ---- | ---------------- | +| name | Name of the NNRt device.| + +**Returns** + +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. + +**Since** + +10 + + +### OH_AI_CreateNNRTDeviceInfoByType() + + +``` +OH_AI_API OH_AI_DeviceInfoHandle OH_AI_CreateNNRTDeviceInfoByType (OH_AI_NNRTDeviceType type) +``` + +**Description** + +Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device. + +**Parameters** + +| Name| Description | +| ---- | ------------------------------------------------------------ | +| type | NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype).| + +**Returns** + +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. + +**Since** + +10 + + +### OH_AI_DestroyAllNNRTDeviceDescs() + + +``` +OH_AI_API void OH_AI_DestroyAllNNRTDeviceDescs (NNRTDeviceDesc ** desc) +``` + +**Description** + +Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](#oh_ai_getallnnrtdevicedescs). + +**Parameters** -| Name | Description | -| -------- | -------- | -| context | [OH_AI_ContextHandle](#oh_ai_contexthandle) that points to the context instance. | -| thread_num | Number of runtime threads. | +| Name| Description | +| ---- | ------------------------------------------------------------ | +| desc | Double pointer to the array of the NNRt device descriptions. After the operation is complete, the content pointed to by **desc** is set to **NULL**.| + +**Since** + +10 ### OH_AI_DeviceInfoCreate() - + ``` OH_AI_API OH_AI_DeviceInfoHandle OH_AI_DeviceInfoCreate (OH_AI_DeviceType device_type) ``` -**Description**
+ +**Description** + Creates a device information object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_type | Device type. For details, see [OH_AI_DeviceType](#oh_ai_devicetype). | +| Name | Description | +| ----------- | ------------------------------------------------------- | +| device_type | Device type, which is specified by [OH_AI_DeviceType](#oh_ai_devicetype).| **Returns** -[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to the device information instance. +[OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. ### OH_AI_DeviceInfoDestroy() - + ``` OH_AI_API void OH_AI_DeviceInfoDestroy (OH_AI_DeviceInfoHandle * device_info) ``` -**Description**
-Destroys a device information instance. - **Parameters** +**Description** + +Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + + +### OH_AI_DeviceInfoGetDeviceId() + + +``` +OH_AI_API size_t OH_AI_DeviceInfoGetDeviceId (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** + +Obtains the ID of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NNRt device ID. + +**Since** + +10 ### OH_AI_DeviceInfoGetDeviceType() - + ``` OH_AI_API OH_AI_DeviceType OH_AI_DeviceInfoGetDeviceType (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Obtains the type of a provider device. - **Parameters** +**Description** + +Obtains the device type. -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -676,18 +996,20 @@ Type of the provider device. ### OH_AI_DeviceInfoGetEnableFP16() - + ``` OH_AI_API bool OH_AI_DeviceInfoGetEnableFP16 (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. - **Parameters** +**Description** + +Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -696,38 +1018,94 @@ Whether float16 inference is enabled. ### OH_AI_DeviceInfoGetFrequency() - + ``` OH_AI_API int OH_AI_DeviceInfoGetFrequency (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
-Obtains the NPU frequency type. This function is available only for NPU devices. - **Parameters** +**Description** + +Obtains the NPU frequency type. This API is available only for NPU devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NPU frequency type. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance + + +### OH_AI_DeviceInfoGetPerformanceMode() + + +``` +OH_AI_API OH_AI_PerformanceMode OH_AI_DeviceInfoGetPerformanceMode (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** + +Obtains the performance mode of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| + +**Returns** + +NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode). + +**Since** + +10 + + +### OH_AI_DeviceInfoGetPriority() + + +``` +OH_AI_API OH_AI_Priority OH_AI_DeviceInfoGetPriority (const OH_AI_DeviceInfoHandle device_info) +``` + +**Description** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +Obtains the priority of an NNRT task. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** -Frequency type of the NPU. The value ranges from **0** to **4**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance +NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority). + +**Since** + +10 ### OH_AI_DeviceInfoGetProvider() - + ``` OH_AI_API const char* OH_AI_DeviceInfoGetProvider (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
+ +**Description** + Obtains the provider name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** @@ -736,150 +1114,339 @@ Provider name. ### OH_AI_DeviceInfoGetProviderDevice() - + ``` OH_AI_API const char* OH_AI_DeviceInfoGetProviderDevice (const OH_AI_DeviceInfoHandle device_info) ``` -**Description**
+ +**Description** + Obtains the name of a provider device. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| **Returns** Name of the provider device. +### OH_AI_DeviceInfoSetDeviceId() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetDeviceId (OH_AI_DeviceInfoHandle device_info, size_t device_id ) +``` + +**Description** + +Sets the ID of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| device_id | NNRt device ID. | + +**Since** + +10 + + ### OH_AI_DeviceInfoSetEnableFP16() - + ``` OH_AI_API void OH_AI_DeviceInfoSetEnableFP16 (OH_AI_DeviceInfoHandle device_info, bool is_fp16 ) ``` -**Description**
-Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. - **Parameters** +**Description** + +Sets whether to enable float16 inference. This function is available only for CPU and GPU devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| is_fp16 | Whether to enable float16 inference. | +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| is_fp16 | Whether to enable the float16 inference mode. | ### OH_AI_DeviceInfoSetFrequency() - + ``` OH_AI_API void OH_AI_DeviceInfoSetFrequency (OH_AI_DeviceInfoHandle device_info, int frequency ) ``` -**Description**
+ +**Description** + Sets the NPU frequency type. This function is available only for NPU devices. - **Parameters** +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance| + + +### OH_AI_DeviceInfoSetPerformanceMode() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetPerformanceMode (OH_AI_DeviceInfoHandle device_info, OH_AI_PerformanceMode mode ) +``` + +**Description** + +Sets the performance mode of an NNRt device. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| mode | NNRt performance mode, which is specified by [OH_AI_PerformanceMode](#oh_ai_performancemode).| + +**Since** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| frequency | NPU frequency type. The value ranges from **0** to **4**. The default value is **3**. **1**: low power consumption; **2**: balanced; **3**: high performance; **4**: ultra-high performance | +10 + + +### OH_AI_DeviceInfoSetPriority() + + +``` +OH_AI_API void OH_AI_DeviceInfoSetPriority (OH_AI_DeviceInfoHandle device_info, OH_AI_Priority priority ) +``` + +**Description** + +Sets the priority of an NNRt task. This API is available only for NNRt devices. + +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| priority | NNRt task priority, which is specified by [OH_AI_Priority](#oh_ai_priority). | + +**Since** + +10 ### OH_AI_DeviceInfoSetProvider() - + ``` OH_AI_API void OH_AI_DeviceInfoSetProvider (OH_AI_DeviceInfoHandle device_info, const char * provider ) ``` -**Description**
-Sets the name of a provider. - **Parameters** +**Description** + +Sets the provider name. -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| provider | Provider name. | +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| provider | Provider name. | ### OH_AI_DeviceInfoSetProviderDevice() - + ``` OH_AI_API void OH_AI_DeviceInfoSetProviderDevice (OH_AI_DeviceInfoHandle device_info, const char * device ) ``` -**Description**
+ +**Description** + Sets the name of a provider device. - **Parameters** +**Parameters** + +| Name | Description | +| ----------- | ------------------------------------------------------------ | +| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance.| +| device | Name of the provider device, for example, CPU. | + + +### OH_AI_GetAllNNRTDeviceDescs() + + +``` +OH_AI_API NNRTDeviceDesc* OH_AI_GetAllNNRTDeviceDescs (size_t * num) +``` + +**Description** + +Obtains the descriptions of all NNRt devices in the system. + +**Parameters** + +| Name| Description | +| ---- | ------------------------ | +| num | Number of NNRt devices.| + +**Returns** + +Pointer to the array of the NNRt device descriptions. If the operation fails, **NULL** is returned. + +**Since** + +10 + + +### OH_AI_GetDeviceIdFromNNRTDeviceDesc() + + +``` +OH_AI_API size_t OH_AI_GetDeviceIdFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices. + +**Parameters** -| Name | Description | -| -------- | -------- | -| device_info | [OH_AI_DeviceInfoHandle](#oh_ai_deviceinfohandle) that points to a device information instance. | -| device | Name of the provider device, for example, CPU. | +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device ID. + +**Since** + +10 + + +### OH_AI_GetNameFromNNRTDeviceDesc() + + +``` +OH_AI_API const char* OH_AI_GetNameFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device name from the specified NNRt device description. + +**Parameters** + +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device name. The value is a pointer that points to a constant string, which is held by **desc**. The caller does not need to destroy it separately. + +**Since** + +10 + + +### OH_AI_GetTypeFromNNRTDeviceDesc() + + +``` +OH_AI_API OH_AI_NNRTDeviceType OH_AI_GetTypeFromNNRTDeviceDesc (const NNRTDeviceDesc * desc) +``` + +**Description** + +Obtains the NNRt device type from the specified NNRt device description. + +**Parameters** + +| Name| Description | +| ---- | -------------------------------- | +| desc | Pointer to the NNRt device description.| + +**Returns** + +NNRt device type, which is specified by [OH_AI_NNRTDeviceType](#oh_ai_nnrtdevicetype). + +**Since** + +10 ### OH_AI_ModelBuild() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelBuild (OH_AI_ModelHandle model, const void * model_data, size_t data_size, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) ``` -**Description**
+ +**Description** + Loads and builds a MindSpore model from the memory buffer. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| model_data | Address of the loaded model data in the memory. | -| data_size | Length of the model data. | -| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | -| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | +| Name | Description | +| ------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| model_data | Address of the loaded model data in the memory. | +| data_size | Length of the model data. | +| model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). | +| model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).| **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelBuildFromFile() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelBuildFromFile (OH_AI_ModelHandle model, const char * model_path, OH_AI_ModelType model_type, const OH_AI_ContextHandle model_context ) ``` -**Description**
+ +**Description** + Loads and builds a MindSpore model from a model file. Note that the same {\@Link OH_AI_ContextHandle} object can only be passed to {\@Link OH_AI_ModelBuild} or {\@Link OH_AI_ModelBuildFromFile} once. If you call this function multiple times, make sure that you create multiple {\@Link OH_AI_ContextHandle} objects accordingly. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| model_path | Path of the model file. | -| model_type | Type of the model file. For details, see [OH_AI_ModelType](#oh_ai_modeltype). | -| model_context | Context for model running. For details, see [OH_AI_ContextHandle](#oh_ai_contexthandle). | +| Name | Description | +| ------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| model_path | Path of the model file. | +| model_type | Model file type, which is specified by [OH_AI_ModelType](#oh_ai_modeltype). | +| model_context | Model runtime context, which is specified by [OH_AI_ContextHandle](#oh_ai_contexthandle).| **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelCreate() - + ``` OH_AI_API OH_AI_ModelHandle OH_AI_ModelCreate () ``` -**Description**
+ +**Description** + Creates a model object. **Returns** @@ -889,35 +1456,39 @@ Pointer to the model object. ### OH_AI_ModelDestroy() - + ``` OH_AI_API void OH_AI_ModelDestroy (OH_AI_ModelHandle * model) ``` -**Description**
+ +**Description** + Destroys a model object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| ### OH_AI_ModelGetInputByTensorName() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetInputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) ``` -**Description**
+ +**Description** + Obtains the input tensor of a model by tensor name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| tensor_name | Tensor name. | +| Name | Description | +| ----------- | -------------- | +| model | Pointer to the model object.| +| tensor_name | Tensor name. | **Returns** @@ -926,18 +1497,20 @@ Pointer to the input tensor indicated by **tensor_name**. If the tensor does not ### OH_AI_ModelGetInputs() - + ``` OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetInputs (const OH_AI_ModelHandle model) ``` -**Description**
+ +**Description** + Obtains the input tensor array structure of a model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| **Returns** @@ -946,39 +1519,43 @@ Tensor array structure corresponding to the model input. ### OH_AI_ModelGetOutputByTensorName() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_ModelGetOutputByTensorName (const OH_AI_ModelHandle model, const char * tensor_name ) ``` -**Description**
+ +**Description** + Obtains the output tensor of a model by tensor name. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| tensor_name | Tensor name. | +| Name | Description | +| ----------- | -------------- | +| model | Pointer to the model object.| +| tensor_name | Tensor name. | **Returns** -Pointer to the output tensor indicated by **tensor_name**. If the tensor does not exist in the input, **null** will be returned. +Pointer to the input tensor indicated by **tensor_name**. If the tensor does not exist, **null** will be returned. ### OH_AI_ModelGetOutputs() - + ``` OH_AI_API OH_AI_TensorHandleArray OH_AI_ModelGetOutputs (const OH_AI_ModelHandle model) ``` -**Description**
+ +**Description** + Obtains the output tensor array structure of a model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | +| Name | Description | +| ----- | -------------- | +| model | Pointer to the model object.| **Returns** @@ -987,126 +1564,138 @@ Tensor array structure corresponding to the model output. ### OH_AI_ModelPredict() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelPredict (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_TensorHandleArray * outputs, const OH_AI_KernelCallBack before, const OH_AI_KernelCallBack after ) ``` -**Description**
+ +**Description** + Performs model inference. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| inputs | Tensor array structure corresponding to the model input. | -| outputs | Pointer to the tensor array structure corresponding to the model output. | -| before | Callback function executed before model inference. | -| after | Callback function executed after model inference. | +| Name | Description | +| ------- | ------------------------------------ | +| model | Pointer to the model object. | +| inputs | Tensor array structure corresponding to the model input. | +| outputs | Pointer to the tensor array structure corresponding to the model output.| +| before | Callback function executed before model inference. | +| after | Callback function executed after model inference. | **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_ModelResize() - + ``` OH_AI_API OH_AI_Status OH_AI_ModelResize (OH_AI_ModelHandle model, const OH_AI_TensorHandleArray inputs, OH_AI_ShapeInfo * shape_infos, size_t shape_info_num ) ``` -**Description**
+ +**Description** + Adjusts the input tensor shapes of a built model. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| model | Pointer to the model object. | -| inputs | Tensor array structure corresponding to the model input. | -| shape_infos | Input shape array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence. | -| shape_info_num | Length of the input shape array. | +| Name | Description | +| -------------- | ------------------------------------------------------------ | +| model | Pointer to the model object. | +| inputs | Tensor array structure corresponding to the model input. | +| shape_infos | Input shape information array, which consists of tensor shapes arranged in the model input sequence. The model adjusts the tensor shapes in sequence.| +| shape_info_num | Length of the shape information array. | **Returns** -Status code enumerated by [OH_AI_Status](#oh_ai_status). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. +Status code enumerated by [OH_AI_Status](#oh_ai_status-1). The value **MSStatus::kMSStatusSuccess** indicates that the operation is successful. ### OH_AI_TensorClone() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_TensorClone (OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Clones a tensor. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Pointer to the tensor to clone. | +| Name | Description | +| ------ | ------------------ | +| tensor | Pointer to the tensor to clone.| **Returns** -Handle of the new tensor object. +Defines the handle of a tensor object. ### OH_AI_TensorCreate() - + ``` OH_AI_API OH_AI_TensorHandle OH_AI_TensorCreate (const char * name, OH_AI_DataType type, const int64_t * shape, size_t shape_num, const void * data, size_t data_len ) ``` -**Description**
+ +**Description** + Creates a tensor object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| name | Tensor name. | -| type | Tensor data type. | -| shape | Tensor dimension array. | -| shape_num | Length of the tensor dimension array. | -| data | Data pointer. | -| data_len | Data length. | +| Name | Description | +| --------- | ------------------ | +| name | Tensor name. | +| type | Tensor data type. | +| shape | Tensor dimension array. | +| shape_num | Length of the tensor dimension array.| +| data | Data pointer. | +| data_len | Data length. | **Returns** -Handle of the tensor object. +Defines the handle of a tensor object. ### OH_AI_TensorDestroy() - + ``` OH_AI_API void OH_AI_TensorDestroy (OH_AI_TensorHandle * tensor) ``` -**Description**
+ +**Description** + Destroys a tensor object. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Level-2 pointer to the tensor handle. | +| Name | Description | +| ------ | ------------------------ | +| tensor | Level-2 pointer to the tensor handle.| ### OH_AI_TensorGetData() - + ``` OH_AI_API const void* OH_AI_TensorGetData (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the pointer to tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1115,18 +1704,20 @@ Pointer to tensor data. ### OH_AI_TensorGetDataSize() - + ``` OH_AI_API size_t OH_AI_TensorGetDataSize (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the number of bytes of the tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1135,38 +1726,42 @@ Number of bytes of the tensor data. ### OH_AI_TensorGetDataType() - + ``` OH_AI_API OH_AI_DataType OH_AI_TensorGetDataType (const OH_AI_TensorHandle tensor) ``` -**Description**
-Obtains the data type of a tensor. - **Parameters** +**Description** + +Obtains the tensor type. -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +**Parameters** + +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** -Data type of the tensor. +Tensor data type. ### OH_AI_TensorGetElementNum() - + ``` OH_AI_API int64_t OH_AI_TensorGetElementNum (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the number of tensor elements. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1175,18 +1770,20 @@ Number of tensor elements. ### OH_AI_TensorGetFormat() - + ``` OH_AI_API OH_AI_Format OH_AI_TensorGetFormat (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the tensor data format. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1195,38 +1792,42 @@ Tensor data format. ### OH_AI_TensorGetMutableData() - + ``` OH_AI_API void* OH_AI_TensorGetMutableData (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the pointer to variable tensor data. If the data is empty, memory will be allocated. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** -Pointer to variable tensor data. +Pointer to tensor data. ### OH_AI_TensorGetName() - + ``` OH_AI_API const char* OH_AI_TensorGetName (const OH_AI_TensorHandle tensor) ``` -**Description**
+ +**Description** + Obtains the name of a tensor. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| **Returns** @@ -1235,106 +1836,118 @@ Tensor name. ### OH_AI_TensorGetShape() - + ``` OH_AI_API const int64_t* OH_AI_TensorGetShape (const OH_AI_TensorHandle tensor, size_t * shape_num ) ``` -**Description**
-Obtains the shape of a tensor. - **Parameters** +**Description** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| shape_num | Length of the tensor shape array. | +Obtains the tensor shape. + +**Parameters** + +| Name | Description | +| --------- | ---------------------------------------------- | +| tensor | Handle of the tensor object. | +| shape_num | Length of the tensor shape array.| **Returns** -Tensor shape array. +Shape array. ### OH_AI_TensorSetData() - + ``` OH_AI_API void OH_AI_TensorSetData (OH_AI_TensorHandle tensor, void * data ) ``` -**Description**
+ +**Description** + Sets the tensor data. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| data | Data pointer. | +| Name | Description | +| ------ | ---------------- | +| tensor | Handle of the tensor object. | +| data | Data pointer.| ### OH_AI_TensorSetDataType() - + ``` OH_AI_API void OH_AI_TensorSetDataType (OH_AI_TensorHandle tensor, OH_AI_DataType type ) ``` -**Description**
-Sets the data type of a tensor. - **Parameters** +**Description** + +Sets the tensor data type. -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| type | Data type. For details, see [OH_AI_DataType](#oh_ai_datatype). | +**Parameters** + +| Name | Description | +| ------ | --------------------------------------------------- | +| tensor | Handle of the tensor object. | +| type | Data type, which is specified by [OH_AI_DataType](#oh_ai_datatype).| ### OH_AI_TensorSetFormat() - + ``` OH_AI_API void OH_AI_TensorSetFormat (OH_AI_TensorHandle tensor, OH_AI_Format format ) ``` -**Description**
+ +**Description** + Sets the tensor data format. - **Parameters** +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| format | Tensor data format. | +| Name | Description | +| ------ | ------------------ | +| tensor | Handle of the tensor object. | +| format | Tensor data format.| ### OH_AI_TensorSetName() - + ``` -OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char * name ) +OH_AI_API void OH_AI_TensorSetName (OH_AI_TensorHandle tensor, const char *name ) ``` -**Description**
-Sets the name of a tensor. - **Parameters** +**Description** + +Sets the tensor name. + +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| name | Tensor name. | +| Name | Description | +| ------ | -------------- | +| tensor | Handle of the tensor object.| +| name | Tensor name. | ### OH_AI_TensorSetShape() - + ``` OH_AI_API void OH_AI_TensorSetShape (OH_AI_TensorHandle tensor, const int64_t * shape, size_t shape_num ) ``` -**Description**
-Sets the shape of a tensor. - **Parameters** +**Description** + +Sets the tensor shape. + +**Parameters** -| Name | Description | -| -------- | -------- | -| tensor | Handle of the tensor object. | -| shape | Tensor shape array. | -| shape_num | Length of the tensor shape array. | +| Name | Description | +| --------- | ------------------ | +| tensor | Handle of the tensor object. | +| shape | Shape array. | +| shape_num | Length of the tensor shape array.| diff --git a/en/application-dev/reference/native-apis/context_8h.md b/en/application-dev/reference/native-apis/context_8h.md index f73e70d24871b35a026b39befa08fbebeee5380a..743fdbc9dbfe3d3d4b3b464b0301999631980790 100644 --- a/en/application-dev/reference/native-apis/context_8h.md +++ b/en/application-dev/reference/native-apis/context_8h.md @@ -5,10 +5,11 @@ Provides **Context** APIs for configuring runtime information. -**Since:** +**Since** + 9 -**Related Modules:** +**Related Modules** [MindSpore](_mind_spore.md) @@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information. ### Types -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | -| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information. | +| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | +| [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information.| ### Functions -| Name | Description | +| Name| Description| | -------- | -------- | -| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object. | -| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object. | -| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads. | -| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads. | -| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are categorized into little cores and big cores depending on the CPU frequency. | -| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores. | -| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread. | -| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores. | -| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. | -| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported. | -| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Adds information about a running device. | -| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object. | -| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information instance. | -| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the name of a provider. | -| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name. | -| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device. | -| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device. | -| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the type of a provider device. | -| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU/GPU devices. | -| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices. | -| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices. | +| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object.| +| [OH_AI_ContextDestroy](_mind_spore.md#oh_ai_contextdestroy) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) \*context) | Destroys a context object.| +| [OH_AI_ContextSetThreadNum](_mind_spore.md#oh_ai_contextsetthreadnum) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int32_t thread_num) | Sets the number of runtime threads.| +| [OH_AI_ContextGetThreadNum](_mind_spore.md#oh_ai_contextgetthreadnum) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the number of threads.| +| [OH_AI_ContextSetThreadAffinityMode](_mind_spore.md#oh_ai_contextsetthreadaffinitymode) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, int mode) | Sets the affinity mode for binding runtime threads to CPU cores, which are classified into large, medium, and small cores based on the CPU frequency. You only need to bind the large or medium cores, but not small cores.| +| [OH_AI_ContextGetThreadAffinityMode](_mind_spore.md#oh_ai_contextgetthreadaffinitymode) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Obtains the affinity mode for binding runtime threads to CPU cores.| +| [OH_AI_ContextSetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextsetthreadaffinitycorelist) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, const int32_t \*core_list, size_t core_num) | Sets the list of CPU cores bound to a runtime thread.| +| [OH_AI_ContextGetThreadAffinityCoreList](_mind_spore.md#oh_ai_contextgetthreadaffinitycorelist) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, size_t \*core_num) | Obtains the list of bound CPU cores.| +| [OH_AI_ContextSetEnableParallel](_mind_spore.md#oh_ai_contextsetenableparallel) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, bool is_parallel) | Sets whether to enable parallelism between operators. The setting is ineffective because the feature of this API is not yet available.| +| [OH_AI_ContextGetEnableParallel](_mind_spore.md#oh_ai_contextgetenableparallel) (const [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context) | Checks whether parallelism between operators is supported.| +| [OH_AI_ContextAddDeviceInfo](_mind_spore.md#oh_ai_contextadddeviceinfo) ([OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) context, [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Attaches the custom device information to the inference context.| +| [OH_AI_DeviceInfoCreate](_mind_spore.md#oh_ai_deviceinfocreate) ([OH_AI_DeviceType](_mind_spore.md#oh_ai_devicetype) device_type) | Creates a device information object.| +| [OH_AI_DeviceInfoDestroy](_mind_spore.md#oh_ai_deviceinfodestroy) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) \*device_info) | Destroys a device information object. Note: After the device information instance is added to the context, the caller does not need to destroy it manually.| +| [OH_AI_DeviceInfoSetProvider](_mind_spore.md#oh_ai_deviceinfosetprovider) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*provider) | Sets the provider name.| +| [OH_AI_DeviceInfoGetProvider](_mind_spore.md#oh_ai_deviceinfogetprovider) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the provider name.| +| [OH_AI_DeviceInfoSetProviderDevice](_mind_spore.md#oh_ai_deviceinfosetproviderdevice) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, const char \*device) | Sets the name of a provider device.| +| [OH_AI_DeviceInfoGetProviderDevice](_mind_spore.md#oh_ai_deviceinfogetproviderdevice) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the name of a provider device.| +| [OH_AI_DeviceInfoGetDeviceType](_mind_spore.md#oh_ai_deviceinfogetdevicetype) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the device type.| +| [OH_AI_DeviceInfoSetEnableFP16](_mind_spore.md#oh_ai_deviceinfosetenablefp16) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, bool is_fp16) | Sets whether to enable float16 inference. This function is available only for CPU and GPU devices.| +| [OH_AI_DeviceInfoGetEnableFP16](_mind_spore.md#oh_ai_deviceinfogetenablefp16) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Checks whether float16 inference is enabled. This function is available only for CPU and GPU devices.| +| [OH_AI_DeviceInfoSetFrequency](_mind_spore.md#oh_ai_deviceinfosetfrequency) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, int frequency) | Sets the NPU frequency type. This function is available only for NPU devices.| +| [OH_AI_DeviceInfoGetFrequency](_mind_spore.md#oh_ai_deviceinfogetfrequency) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the NPU frequency type. This function is available only for NPU devices.| +| [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs) (size_t \*num) | Obtains the descriptions of all NNRt devices in the system.| +| [OH_AI_DestroyAllNNRTDeviceDescs](_mind_spore.md#oh_ai_destroyallnnrtdevicedescs) ([NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*\*desc) | Destroys the array of NNRT descriptions obtained by [OH_AI_GetAllNNRTDeviceDescs](_mind_spore.md#oh_ai_getallnnrtdevicedescs).| +| [OH_AI_GetDeviceIdFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getdeviceidfromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device ID from the specified NNRt device description. Note that this ID is valid only for NNRt devices.| +| [OH_AI_GetNameFromNNRTDeviceDesc](_mind_spore.md#oh_ai_getnamefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device name from the specified NNRt device description.| +| [OH_AI_GetTypeFromNNRTDeviceDesc](_mind_spore.md#oh_ai_gettypefromnnrtdevicedesc) (const [NNRTDeviceDesc](_mind_spore.md#nnrtdevicedesc) \*desc) | Obtains the NNRt device type from the specified NNRt device description.| +| [OH_AI_CreateNNRTDeviceInfoByName](_mind_spore.md#oh_ai_creatennrtdeviceinfobyname) (const char \*name) | Searches for the NNRt device with the specified name and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_CreateNNRTDeviceInfoByType](_mind_spore.md#oh_ai_creatennrtdeviceinfobytype) ([OH_AI_NNRTDeviceType](_mind_spore.md#oh_ai_nnrtdevicetype) type) | Searches for the NNRt device with the specified type and creates the NNRt device information based on the information about the first found NNRt device.| +| [OH_AI_DeviceInfoSetDeviceId](_mind_spore.md#oh_ai_deviceinfosetdeviceid) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, size_t device_id) | Sets the ID of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetDeviceId](_mind_spore.md#oh_ai_deviceinfogetdeviceid) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the ID of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPerformanceMode](_mind_spore.md#oh_ai_deviceinfosetperformancemode) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_PerformanceMode](_mind_spore.md#oh_ai_performancemode) mode) | Sets the performance mode of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPerformanceMode](_mind_spore.md#oh_ai_deviceinfogetperformancemode) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the performance mode of an NNRt device. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoSetPriority](_mind_spore.md#oh_ai_deviceinfosetpriority) ([OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info, [OH_AI_Priority](_mind_spore.md#oh_ai_priority) priority) | Sets the priority of an NNRT task. This API is available only for NNRt devices.| +| [OH_AI_DeviceInfoGetPriority](_mind_spore.md#oh_ai_deviceinfogetpriority) (const [OH_AI_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) device_info) | Obtains the priority of an NNRT task. This API is available only for NNRt devices.| diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index 2828cf88464c8dcfee6552cdfd232f7dcdf15cd1..56e49bb81618bf453b1c8af065d1adc9dc5f1ef2 100644 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -6,39 +6,39 @@ - Layout Development - [Layout Overview](arkts-layout-development-overview.md) - Building a Layout - - [Linear Layout](arkts-layout-development-linear.md) - - [Stack Layout](arkts-layout-development-stack-layout.md) - - [Flex Layout](arkts-layout-development-flex-layout.md) - - [Relative Layout](arkts-layout-development-relative-layout.md) - - [Responsive Grid Layout](arkts-layout-development-grid-layout.md) - - [Media Query](arkts-layout-development-media-query.md) - - [Creating a List](arkts-layout-development-create-list.md) - - [Creating a Grid](arkts-layout-development-create-grid.md) - - [Creating a Swiper](arkts-layout-development-create-looping.md) + - [Linear Layout (Row/Column)](arkts-layout-development-linear.md) + - [Stack Layout (Stack)](arkts-layout-development-stack-layout.md) + - [Flex Layout (Flex)](arkts-layout-development-flex-layout.md) + - [Relative Layout (RelativeContainer)](arkts-layout-development-relative-layout.md) + - [Responsive Grid Layout (GridRow/GridCol)](arkts-layout-development-grid-layout.md) + - [Media Query (mediaquery)](arkts-layout-development-media-query.md) + - [Creating a List (List)](arkts-layout-development-create-list.md) + - [Creating a Grid (Grid/GridItem)](arkts-layout-development-create-grid.md) + - [Creating a Swiper (Swiper)](arkts-layout-development-create-looping.md) - [Improving Layout Performance](arkts-layout-development-performance-boost.md) - Adding a Component - Adding a Common Component - [Button](arkts-common-components-button.md) - - [Radio Button](arkts-common-components-radio-button.md) + - [Radio Button (Radio)](arkts-common-components-radio-button.md) - [Toggle](arkts-common-components-switch.md) - - [Progress Indicator](arkts-common-components-progress-indicator.md) - - [Text Display](arkts-common-components-text-display.md) - - [Text Input](arkts-common-components-text-input.md) - - [Custom Dialog Box](arkts-common-components-custom-dialog.md) - - [Video Playback](arkts-common-components-video-player.md) + - [Progress Indicator (Progress)](arkts-common-components-progress-indicator.md) + - [Text Display (Text/Span)](arkts-common-components-text-display.md) + - [Text Input (TextInput/TextArea)](arkts-common-components-text-input.md) + - [Custom Dialog Box (CustomDialog)](arkts-common-components-custom-dialog.md) + - [Video Playback (Video](arkts-common-components-video-player.md) - [XComponent](arkts-common-components-xcomponent.md) - - Adding a Bubble and Menu - - [Bubble](arkts-popup-and-menu-components-popup.md) + - Adding a Popup and Menu + - [Popup](arkts-popup-and-menu-components-popup.md) - [Menu](arkts-popup-and-menu-components-menu.md) - Setting Page Routing and Component Navigation - - [Page Routing](arkts-routing.md) + - [Page Routing (router)](arkts-routing.md) - Component Navigation - [Navigation](arkts-navigation-navigation.md) - [Tabs](arkts-navigation-tabs.md) - Using Graphics - - [Displaying Images](arkts-graphics-display.md) - - [Drawing Geometric Shapes](arkts-geometric-shape-drawing.md) - - [Drawing Custom Graphics on the Canvas](arkts-drawing-customization-on-canvas.md) + - [Displaying Images (Image)](arkts-graphics-display.md) + - [Drawing Geometric Shapes (Shape)](arkts-geometric-shape-drawing.md) + - [Drawing Custom Graphics on the Canvas (Canvas)](arkts-drawing-customization-on-canvas.md) - Using Animation - [Animation Overview](arkts-animation-overview.md) - Animation Within a Page diff --git a/en/application-dev/ui/arkts-common-components-custom-dialog.md b/en/application-dev/ui/arkts-common-components-custom-dialog.md index bf36a7bdee51a4808c06687d8c90f90bdc5b62ae..36235d9d84b543e498db79478e2050d6c5dfd4e1 100644 --- a/en/application-dev/ui/arkts-common-components-custom-dialog.md +++ b/en/application-dev/ui/arkts-common-components-custom-dialog.md @@ -1,4 +1,4 @@ -# Custom Dialog Box +# Custom Dialog Box (CustomDialog) A custom dialog box is a dialog box you customize by using APIs of the **CustomDialogController** class. It can be used for user interactions, showing an ad, prize, alert, software update message, and more. For details, see [Custom Dialog Box](../reference/arkui-ts/ts-methods-custom-dialog-box.md). diff --git a/en/application-dev/ui/arkts-common-components-progress-indicator.md b/en/application-dev/ui/arkts-common-components-progress-indicator.md index 6be5721def291240c6a3a984bd41032c801d91f0..c122108cd20953d1c51ccd113e75ce6bea847168 100644 --- a/en/application-dev/ui/arkts-common-components-progress-indicator.md +++ b/en/application-dev/ui/arkts-common-components-progress-indicator.md @@ -1,4 +1,4 @@ -# Progress Indicator +# Progress Indicator (Progress) The **\** component is used to provide a progress indicator that displays the progress of an operation. For details, see [Progress](../reference/arkui-ts/ts-basic-components-progress.md). diff --git a/en/application-dev/ui/arkts-common-components-radio-button.md b/en/application-dev/ui/arkts-common-components-radio-button.md index 92f5105642e0200b6852962d030d13c9cdbd58e8..9cf2298a7112bfba7f20e5feb5bbddea27e30b71 100644 --- a/en/application-dev/ui/arkts-common-components-radio-button.md +++ b/en/application-dev/ui/arkts-common-components-radio-button.md @@ -1,4 +1,4 @@ -# Radio Button +# Radio Button (Radio) The **\** component allows users to select from a set of mutually exclusive options. Only one radio button in a given group can be selected at the same time. For details, see [Radio](../reference/arkui-ts/ts-basic-components-radio.md). diff --git a/en/application-dev/ui/arkts-common-components-text-display.md b/en/application-dev/ui/arkts-common-components-text-display.md index f630b0caf6e6e2e98d4557c1dbf58bd5984ca06e..86f92f51489fbc18a16b2d1237939b3820b94176 100644 --- a/en/application-dev/ui/arkts-common-components-text-display.md +++ b/en/application-dev/ui/arkts-common-components-text-display.md @@ -1,4 +1,4 @@ -# Text Display +# Text Display (Text/Span) The **\** component is used to display a piece of textual information. For details, see [Text](../reference/arkui-ts/ts-basic-components-text.md). diff --git a/en/application-dev/ui/arkts-common-components-text-input.md b/en/application-dev/ui/arkts-common-components-text-input.md index 0d7f8ec2f431bc5d171a40903fd752b3da2ab139..e76dad1901b43ac15aa3e4b9ea2432da3db1ac9a 100644 --- a/en/application-dev/ui/arkts-common-components-text-input.md +++ b/en/application-dev/ui/arkts-common-components-text-input.md @@ -1,4 +1,4 @@ -# Text Input +# Text Input (TextInput/TextArea) The **\** and **\