提交 d5a6a25f 编写于 作者: A Annie_wang 提交者: Gitee

Merge branch 'OpenHarmony-4.0-Beta1' of gitee.com:openharmony/docs into PR19153

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
...@@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different. ...@@ -86,13 +86,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path| | Name| Path|
| -------- | -------- | | -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/| | bundleCodeDir | \<Path prefix>/el1/bundle/ |
| cacheDir | <Path prefix>/<Encryption level>/base/cache/| | cacheDir | \<Path prefix>/\<Encryption level>/base/cache/ |
| filesDir | <Path prefix>/<Encryption level>/base/files/| | filesDir | \<Path prefix>/\<Encryption level>/base/files/ |
| preferencesDir | <Path prefix>/<Encryption level>/base/preferences/| | preferencesDir | \<Path prefix>/\<Encryption level>/base/preferences/ |
| tempDir | <Path prefix>/<Encryption level>/base/temp/| | tempDir | \<Path prefix>/\<Encryption level>/base/temp/ |
| databaseDir | <Path prefix>/<Encryption level>/database/| | databaseDir | \<Path prefix>/\<Encryption level>/database/ |
| distributedFilesDir | <Path prefix>/el2/distributedFiles/| | distributedFilesDir | \<Path prefix>/el2/distributedFiles/ |
The sample code is as follows: The sample code is as follows:
...@@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different. ...@@ -118,13 +118,13 @@ The application file paths obtained by the preceding contexts are different.
| Name| Path| | Name| Path|
| -------- | -------- | | -------- | -------- |
| bundleCodeDir | <Path prefix>/el1/bundle/| | bundleCodeDir | \<Path prefix>/el1/bundle/ |
| cacheDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/cache/| | cacheDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/cache/ |
| filesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/files/| | filesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/files/ |
| preferencesDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/preferences/| | preferencesDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/preferences/ |
| tempDir | <Path prefix>/<Encryption level>/base/**haps/\<module-name>**/temp/| | tempDir | \<Path prefix>/\<Encryption level>/base/**haps/\<module-name>**/temp/ |
| databaseDir | <Path prefix>/<Encryption level>/database/**\<module-name>**/| | databaseDir | \<Path prefix>/\<Encryption level>/database/**\<module-name>**/ |
| distributedFilesDir | <Path prefix>/el2/distributedFiles/**\<module-name>**/| | distributedFilesDir | \<Path prefix>/el2/distributedFiles/**\<module-name>**/ |
The sample code is as follows: The sample code is as follows:
......
# Launching a UIAbility in the Background Through the call Event # 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 ```ts
@Entry @Entry
...@@ -37,7 +37,7 @@ Generally, buttons are used to trigger the **call** event. Below is an example. ...@@ -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. 'abilityName': 'EntryAbility', // Only the UIAbility of the current application is allowed.
'params': { 'params': {
'method': 'funB', // Set the name of the method to call in the EntryAbility. '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. ...@@ -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 ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
function FunACall(data) { 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())); console.info('FunACall param:' + JSON.stringify(data.readString()));
return null; return null;
} }
function FunBCall(data) { function FunBCall(data) {
console.info('FunACall param:' + JSON.stringify(data.readString())); console.info('FunBCall param:' + JSON.stringify(data.readString()));
return null; return null;
} }
export default class CameraAbility extends UIAbility { 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) { onCreate(want, launchParam) {
try { try {
// Listen for the method required by the call event. // Listen for the method required by the call event.
this.callee.on('funA', FunACall); this.callee.on('funA', FunACall);
this.callee.on('funB', FunBCall); this.callee.on('funB', FunBCall);
} catch (error) { } catch (err) {
console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`); console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`);
} }
} }
...
// Deregister the listener when the process exits. // Deregister the listener when the process exits.
onDestroy() { onDestroy() {
try { try {
......
# Widget Event Capability Overview # 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) ![WidgetPostCardAction](figures/WidgetPostCardAction.png)
...@@ -8,26 +8,28 @@ The ArkTS widget provides the **postCardAction()** API for interaction between t ...@@ -8,26 +8,28 @@ The ArkTS widget provides the **postCardAction()** API for interaction between t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | action | Object | Yes| Action description. For details, see the following table.|
**Description of the action parameter** **Description of the action parameter**
| Key | Value | Description| | Key | Value | Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| "action" | string | Action type.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"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.<br>- **"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.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"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.<br>- **"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.| | "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.| | "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.| | "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: Sample code of the **postCardAction()** API:
```typescript ```typescript
Button ('Jump') Button ('Redirect')
.width('40%') .width('40%')
.height('20%') .height('20%')
.onClick(() => { .onClick(() => {
...@@ -51,7 +53,7 @@ Button ('Start in Background') ...@@ -51,7 +53,7 @@ Button ('Start in Background')
'abilityName': 'EntryAbility', 'abilityName': 'EntryAbility',
'params': { 'params': {
'method': 'fun', // Set the name of the method to call. It is mandatory. '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.
} }
}); });
}) })
......
...@@ -5,7 +5,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ...@@ -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 ## 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 ```ts
let storage = new LocalStorage(); let storage = new LocalStorage();
...@@ -16,7 +16,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ...@@ -16,7 +16,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o
build() { build() {
Column() { Column() {
Button ('Jump') Button ('Redirect')
.margin('20%') .margin('20%')
.onClick(() => { .onClick(() => {
console.info('postCardAction to EntryAbility'); console.info('postCardAction to EntryAbility');
...@@ -45,7 +45,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o ...@@ -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'; import formInfo from '@ohos.app.form.formInfo';
export default class EntryAbility extends UIAbility { 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) { onCreate(want, launchParam) {
console.info('Want:' + JSON.stringify(want)); console.info('Want:' + JSON.stringify(want));
if (want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { 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 ...@@ -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) { onNewWant(want, launchParam) {
console.info('onNewWant Want:' + JSON.stringify(want)); console.info('onNewWant Want:' + JSON.stringify(want));
if (want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) { 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 ...@@ -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 ## 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 ```ts
import formBindingData from '@ohos.app.form.formBindingData'; 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 ...@@ -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 ```ts
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import formBindingData from '@ohos.app.form.formBindingData'; import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider'; import formProvider from '@ohos.app.form.formProvider';
import formInfo from '@ohos.app.form.formInfo';
const MSG_SEND_METHOD: string = 'funA'; 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 ...@@ -173,7 +172,7 @@ On the widget page, the **postCardAction** API can be used to trigger a router o
return null; return null;
} }
export default class EntryAbility extends UIAbility { 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) { onCreate(want, launchParam) {
console.info('Want:' + JSON.stringify(want)); console.info('Want:' + JSON.stringify(want));
try { try {
......
...@@ -12,7 +12,7 @@ import dataAbility from '@ohos.data.dataAbility' ...@@ -12,7 +12,7 @@ import dataAbility from '@ohos.data.dataAbility'
import relationalStore from '@ohos.data.relationalStore' import relationalStore from '@ohos.data.relationalStore'
const TABLE_NAME = 'book' 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)' 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 let rdbStore: relationalStore.RdbStore = undefined
......
...@@ -3,42 +3,25 @@ ...@@ -3,42 +3,25 @@
## Basic Concepts ## 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 ![IPC & RPC communication mechanisms] (figures/IPC_RPC_communication.PNG)
- 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.
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. ## Constraints
- 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.
- 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.
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
- Getting Started - Getting Started
- [Before You Start](start-overview.md) - [Before You Start](start-overview.md)
- [Getting Started with ArkTS in Stage Model](start-with-ets-stage.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 - Development Fundamentals
- Application Package Fundamentals - Application Package Fundamentals
- [Application Package Overview](application-package-overview.md) - [Application Package Overview](application-package-overview.md)
...@@ -38,9 +36,9 @@ ...@@ -38,9 +36,9 @@
- Application Configuration Files in FA Model - Application Configuration Files in FA Model
- [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md) - [Application Configuration File Overview (FA Model)](application-configuration-file-overview-fa.md)
- [Internal Structure of the app Tag](app-structure.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) - [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 - Learning ArkTS
- [Getting Started with ArkTS](arkts-get-started.md) - [Getting Started with ArkTS](arkts-get-started.md)
- Basic Syntax - Basic Syntax
...@@ -49,19 +47,19 @@ ...@@ -49,19 +47,19 @@
- Custom Component - Custom Component
- [Creating a Custom Component](arkts-create-custom-components.md) - [Creating a Custom Component](arkts-create-custom-components.md)
- [Page and Custom Component Lifecycle](arkts-page-custom-components-lifecycle.md) - [Page and Custom Component Lifecycle](arkts-page-custom-components-lifecycle.md)
- [\@Builder: Custom Builder Function](arkts-builder.md) - [\@Builder Decorator: Custom Builder Function](arkts-builder.md)
- [\@BuilderParam: @Builder Function Reference](arkts-builderparam.md) - [\@BuilderParam Decorator: @Builder Function Reference](arkts-builderparam.md)
- [\@Styles: Definition of Resusable Styles](arkts-style.md) - [\@Styles Decorator: Definition of Resusable Styles](arkts-style.md)
- [\@Extend: Extension of Built-in Components](arkts-extend.md) - [\@Extend Decorator: Extension of Built-in Components](arkts-extend.md)
- [stateStyles: Polymorphic Style](arkts-statestyles.md) - [stateStyles Decorator: Polymorphic Style](arkts-statestyles.md)
- State Management - State Management
- [State Management Overview](arkts-state-management-overview.md) - [State Management Overview](arkts-state-management-overview.md)
- Component State Management - Component State Management
- [\@State: State Owned by Component](arkts-state.md) - [\@State Decorator: State Owned by Component](arkts-state.md)
- [\@Prop: One-Way Synchronization from Parent to Child Components](arkts-prop.md) - [\@Prop Decorator: One-Way Synchronization from Parent to Child Components](arkts-prop.md)
- [\@Link: Two-Way Synchronization Between Parent and Child Components](arkts-link.md) - [\@Link Decorator: 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) - [\@Provide and \@Consume Decorators: 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) - [\@Observed and \@ObjectLink Decorators: Observing Attribute Changes in Nested Class Objects](arkts-observed-and-objectlink.md)
- Application State Management - Application State Management
- [Application State Management Overview](arkts-application-state-management-overview.md) - [Application State Management Overview](arkts-application-state-management-overview.md)
- [LocalStorage: UI State Storage](arkts-localstorage.md) - [LocalStorage: UI State Storage](arkts-localstorage.md)
......
# \@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**. 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**.
......
# \@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. 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.
......
...@@ -29,6 +29,7 @@ Environment is a singleton object created by the ArkUI framework at application ...@@ -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. The chain of updates is as follows: Environment > AppStorage > Component.
> **NOTE** > **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. > 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.
......
# \@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. 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** > **NOTE**
>
> Since API version 9, this decorator is supported in ArkTS widgets. > Since API version 9, this decorator is supported in ArkTS widgets.
......
# \@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. An \@Link decorated variable can create two-way synchronization with a variable of its parent component.
......
# \@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. 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.
......
# \@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. 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.
......
# \@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. \@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.
......
# 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. 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.
# \@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. 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.
......
# 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. Unlike \@Styles and \@Extend, which are used to reuse styles only on static pages, stateStyles enables you to set state-specific styles.
......
# \@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. 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.
......
...@@ -29,8 +29,9 @@ The application model is the abstraction of capabilities required by OpenHarmony ...@@ -29,8 +29,9 @@ The application model is the abstraction of capabilities required by OpenHarmony
Along its evolution, OpenHarmony has provided two application models: 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 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.
- 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).
- **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). 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 ...@@ -39,8 +40,8 @@ To help you better understand the preceding basic concepts and application devel
## Tool Preparation ## 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). 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).
# Getting Started with ArkTS in Stage Model # Getting Started with ArkTS in Stage Model
> **NOTE** > **NOTE**
> >
> To use ArkTS, your DevEco Studio must be V3.0.0.900 Beta3 or later. > 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. > 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 ## 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) ![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) ![chooseStageModel](figures/chooseStageModel.png)
...@@ -25,27 +32,102 @@ ...@@ -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. > 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. > 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) ![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)). - **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**: a collection of ArkTS source code.
- **src > main > ets > entryability**: entry to your application/service. - **src > main > ets > entryability**: entry to your application/service.
- **src > main > ets > pages**: pages included in 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 > 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). - **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). - **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. - **hvigorfile.ts**: application-level build script.
...@@ -127,7 +209,7 @@ ...@@ -127,7 +209,7 @@
![secondPage](figures/secondPage.png) ![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. > 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: - 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:
......
...@@ -1563,7 +1563,7 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac ...@@ -1563,7 +1563,7 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstall event.| | type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstall event.|
| callback | Callback&lt;string&gt; | 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.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**. | | callback | Callback&lt;string&gt; | 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.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formUninstall')**.|
**Error codes** **Error codes**
...@@ -1698,8 +1698,8 @@ Unsubscribes from widget removal events. This API uses an asynchronous callback ...@@ -1698,8 +1698,8 @@ Unsubscribes from widget removal events. This API uses an asynchronous callback
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| type | string | Yes | Event type. The value **'formRemove'** indicates a widget removal event.| | type | string | Yes | Event type. The value **'formRemove'** indicates a widget removal event.|
| callback | Callback&lt;formInfo.RunningFormInfo&gt; | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.<br>To cancel the subscription with a given callback, this parameter must be set to the same value as **callback** in **on('formRemove')**. | | callback | Callback&lt;formInfo.RunningFormInfo&gt; | No| Callback used to return **RunningFormInfo**. By default, all the subscriptions to the specified event are canceled.<br>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.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.<br>By default, the subscriptions for all the widget hosts are canceled. | | bundleName | string | No| Name of the bundle that functions as the widget host.<br>To cancel the subscription for a given bundle name, this parameter must be set to the same value as **bundleName** in **on('formRemove')**.<br>By default, the subscriptions for all the widget hosts are canceled.|
**Example** **Example**
...@@ -2162,9 +2162,11 @@ import formHost from '@ohos.app.form.formHost'; ...@@ -2162,9 +2162,11 @@ import formHost from '@ohos.app.form.formHost';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
formHost.acquireFormData(formId, (error) => { formHost.acquireFormData(formId, (error, data) => {
if (error) { if (error) {
console.error(`error, code: ${error.code}, message: ${error.message}`); console.error(`error, code: ${error.code}, message: ${error.message}`);
} else {
console.log('formHost acquireFormData, data: ${JSON.stringify(data)}');
} }
}); });
} catch(error) { } catch(error) {
...@@ -2192,7 +2194,7 @@ Requests data from the widget provider. This API uses a promise to return the re ...@@ -2192,7 +2194,7 @@ Requests data from the widget provider. This API uses a promise to return the re
| Type | Description | | Type | Description |
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;void&gt; | Promise that returns no value.| | Promise<{[key: string]: Object}>| Promise used to return the API call result and the shared data.|
**Error codes** **Error codes**
...@@ -2210,8 +2212,8 @@ import formHost from '@ohos.app.form.formHost'; ...@@ -2210,8 +2212,8 @@ import formHost from '@ohos.app.form.formHost';
let formId = '12400633174999288'; let formId = '12400633174999288';
try { try {
formHost.acquireFormData(formId).then(() => { formHost.acquireFormData(formId).then((data) => {
console.log('formHost acquireFormData success'); console.log('formHost acquireFormData success' + data);
}).catch((error) => { }).catch((error) => {
console.error(`error, code: ${error.code}, message: ${error.message}`); 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 ...@@ -2286,7 +2288,7 @@ Obtains the information about widget hosts based on the widget provider informat
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | --------------- | ---- | -------------------------------- | | ----------- | --------------- | ---- | -------------------------------- |
| formProviderFilter | formInfo.FormProviderFilter [formInfo.FormProviderFilter](js-apis-app-form-formInfo.md#formProviderFilter) | Yes | Information about the widget provider.| | formProviderFilter | formInfo.FormProviderFilter [formInfo.FormProviderFilter](js-apis-app-form-formInfo.md#formProviderFilter) | Yes | Information about the widget provider.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | 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&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | 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** **Error codes**
...@@ -2339,7 +2341,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses ...@@ -2339,7 +2341,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses
| Type | Description | | Type | Description |
| ------------------- | ------------------------- | | ------------------- | ------------------------- |
| Promise&lt;Array&lt;formInfo.RunningFormInfo[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Promise used to return the widget host information obtained. | | Promise&lt;Array&lt;formInfo.RunningFormInfo[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Promise used to return the widget host information obtained.|
**Error codes** **Error codes**
...@@ -2379,7 +2381,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses ...@@ -2379,7 +2381,7 @@ Obtains the information about widget hosts based on the widget ID. This API uses
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | --------------- | ---- | -------------------------------- | | ----------- | --------------- | ---- | -------------------------------- |
| formId | string | Yes | Widget ID.| | formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | 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&lt;Array&lt;[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | 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** **Error codes**
......
...@@ -3592,7 +3592,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu ...@@ -3592,7 +3592,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- | | -------- | ---------------------------- | ---- | ---------- |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device.| | device | [AudioDevice](#audiodevice10) | Yes | Audio device.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -3611,17 +3611,64 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3611,17 +3611,64 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
call.setAudioDevice(1, (err) => { let audioDevice={
deviceType: 1
}
call.setAudioDevice(audioDevice, (err) => {
console.log(`callback: err->${JSON.stringify(err)}`); console.log(`callback: err->${JSON.stringify(err)}`);
}); });
``` ```
## call.setAudioDevice<sup>10+</sup>
setAudioDevice\(device: AudioDevice): Promise\<void\>
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.setAudioDevice<sup>9+</sup> ## call.setAudioDevice<sup>9+</sup>
setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\<void\>\): void setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback\<void\>\): 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. **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 ...@@ -3631,7 +3678,7 @@ Sets the audio device for a call. This API uses an asynchronous callback to retu
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | -------------- | | -------- | ------------------------------------------ | ---- | -------------- |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | | device | [AudioDevice](#audiodevice10) | Yes | Audio device. |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.| | options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -3651,10 +3698,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3651,10 +3698,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let audioDevice={
deviceType: 1
}
let audioDeviceOptions={ let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014" bluetoothAddress: "IEEE 802-2014"
} }
call.setAudioDevice(1, audioDeviceOptions, (err) => { call.setAudioDevice(audioDevice, audioDeviceOptions, (err) => {
console.log(`callback: err->${JSON.stringify(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 ...@@ -3674,7 +3724,7 @@ Sets the audio device for a call based on the specified options. This API uses a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------------ | ---- | ------------------ | | ------- | ------------------------------------------ | ---- | ------------------ |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device. | | device | [AudioDevice](#audiodevice10) | Yes | Audio device. |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | No | Audio device parameters.| | options | [AudioDeviceOptions](#audiodeviceoptions9) | No | Audio device parameters.|
**Return value** **Return value**
...@@ -3699,10 +3749,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -3699,10 +3749,13 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
let audioDevice={
deviceType: 1
}
let audioDeviceOptions={ let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014" bluetoothAddress: "IEEE 802-2014"
} }
call.setAudioDevice(1, audioDeviceOptions).then(() => { call.setAudioDevice(audioDevice, audioDeviceOptions).then(() => {
console.log(`setAudioDevice success.`); console.log(`setAudioDevice success.`);
}).catch((err) => { }).catch((err) => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`); console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
...@@ -4242,7 +4295,7 @@ call.closeUnfinishedUssd(slotId).then(() => { ...@@ -4242,7 +4295,7 @@ call.closeUnfinishedUssd(slotId).then(() => {
## call.setVoNRState<sup>10+</sup> ## call.setVoNRState<sup>10+</sup>
setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\<boolean\>\): void setVoNRState\(slotId: number, state: VoNRState, callback: AsyncCallback\<void\>\): void
Sets the status of the VoNR switch. This API uses an asynchronous callback to return the result. 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 ...@@ -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.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. | | state | [VoNRState](#vonrstate10) | Yes | Status of the VoNR switch. |
| callback | AsyncCallback&lt;boolean&gt; | 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&lt;void&gt; | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -4287,7 +4340,7 @@ call.setVoNRState(slotId, state, (err, data) => { ...@@ -4287,7 +4340,7 @@ call.setVoNRState(slotId, state, (err, data) => {
## call.setVoNRState<sup>10+</sup> ## call.setVoNRState<sup>10+</sup>
setVoNRState\(slotId: number, state: VoNRState\): Promise\<boolean\> setVoNRState\(slotId: number, state: VoNRState\): Promise\<void\>
Sets the status of the VoNR switch. This API uses a promise to return the result. 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 ...@@ -4308,7 +4361,7 @@ Sets the status of the VoNR switch. This API uses a promise to return the result
| Type | Description | | Type | Description |
| ---------------------- | --------------------------------------------- | | ---------------------- | --------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. | | Promise&lt;void&gt; | Promise used to return the result. |
**Error codes** **Error codes**
...@@ -4329,7 +4382,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -4329,7 +4382,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
```js ```js
let slotId = 0; let slotId = 0;
let state = 1; let state = 1;
call.setVoNRState(slotId, state).then(() => { call.setVoNRState(slotId, state).then((data) => {
console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`); console.log(`setVoNRState success, promise: data->${JSON.stringify(data)}`);
}).catch((err) => { }).catch((err) => {
console.error(`setVoNRState fail, promise: err->${JSON.stringify(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 ...@@ -4516,7 +4569,7 @@ For details about the following error codes, see [Telephony Error Codes](../../r
```js ```js
let slotId = 0; let slotId = 0;
call.canSetCallTransferTime(slotId).then(() => { call.canSetCallTransferTime(slotId).then((data) => {
console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`); console.log(`canSetCallTransferTime success, promise: data->${JSON.stringify(data)}`);
}).catch((err) => { }).catch((err) => {
console.error(`canSetCallTransferTime fail, promise: err->${JSON.stringify(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. ...@@ -4629,7 +4682,7 @@ Provides an option for determining whether a call is a video call.
## DialCallOptions<sup>9+</sup> ## DialCallOptions<sup>9+</sup>
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. **System API**: This is a system API.
...@@ -4704,7 +4757,7 @@ Enumerates VoNR switch states. ...@@ -4704,7 +4757,7 @@ Enumerates VoNR switch states.
| VONR_STATE_OFF | 0 | Disabled. | | VONR_STATE_OFF | 0 | Disabled. |
| VONR_STATE_ON | 1 | Enabled. | | VONR_STATE_ON | 1 | Enabled. |
## AudioDevice<sup>8+</sup> ## AudioDevice<sup>10+</sup>
Enumerates audio devices. Enumerates audio devices.
...@@ -4712,13 +4765,10 @@ Enumerates audio devices. ...@@ -4712,13 +4765,10 @@ Enumerates audio devices.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description | | Name | Type | Mandatory | Description |
| -------------------- | ---- | ------------ | | --------------------------------- | ------------------------------------- | ---- | ---------------- |
| DEVICE_EARPIECE | 0 | Headset device. | | deviceType <sup>10+</sup> | [AudioDeviceType](#audiodevicetype10) | Yes | Audio device type. |
| DEVICE_SPEAKER | 1 | Speaker device.| | address <sup>10+</sup> | string | No | Audio device address. |
| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
| DEVICE_MIC | 4 | Microphone device|
## AudioDeviceType<sup>10+</sup> ## AudioDeviceType<sup>10+</sup>
...@@ -4745,8 +4795,8 @@ Defines the audio device information. ...@@ -4745,8 +4795,8 @@ Defines the audio device information.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------------------------------- | ------------------------------------- | ---- | ---------------- | | --------------------------------- | ------------------------------------- | ---- | ---------------- |
| audioDeviceList <sup>10+</sup> | [Array\<AudioDevice\>](#audiodevice8) | Yes | Audio device list. | | audioDeviceList <sup>10+</sup> | [Array\<AudioDevice\>](#audiodevice10) | Yes | Audio device list. |
| currentAudioDevice <sup>10+</sup> | [AudioDevice](#audiodevice8) | Yes | Audio device type. | | currentAudioDevice <sup>10+</sup> | [AudioDevice](#audiodevice10) | Yes | Audio device type. |
| isMuted <sup>10+</sup> | boolean | Yes | Whether the audio device is muted. | | isMuted <sup>10+</sup> | boolean | Yes | Whether the audio device is muted. |
......
...@@ -25,9 +25,9 @@ Implements initialization for the interpolation curve, which is used to create a ...@@ -25,9 +25,9 @@ Implements initialization for the interpolation curve, which is used to create a
**Parameters** **Parameters**
| Name| Type | Mandatory| Default Value | Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | | ------ | ----------------------------------------------- | ---- | ----------------------------------- |
| curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.| | curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.<br>Default value: **Curve.Linear**|
**Return value** **Return value**
...@@ -151,16 +151,16 @@ Creates a spring animation curve. If multiple spring animations are applied to t ...@@ -151,16 +151,16 @@ Creates a spring animation curve. If multiple spring animations are applied to t
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | Duration of one complete oscillation,<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.| | response | number | No | Duration of one complete oscillation.<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.| | dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>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.<br><br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>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.<br><br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>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** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>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.<br>**NOTE**<br>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** **Example**
...@@ -187,13 +187,13 @@ Creates a responsive spring animation curve. It is a special case of [springMoti ...@@ -187,13 +187,13 @@ Creates a responsive spring animation curve. It is a special case of [springMoti
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.| | response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.|
| dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.| | dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.|
| overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> 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.<br>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**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> 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.<br>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** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Curve.<br>**NOTE**<br>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.<br>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.<br>**NOTE**<br>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.<br>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** **Example**
...@@ -260,7 +260,7 @@ import Curves from '@ohos.curves' ...@@ -260,7 +260,7 @@ import Curves from '@ohos.curves'
interpolate(fraction) { interpolate(fraction) {
return Math.sqrt(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. ...@@ -268,7 +268,7 @@ Curves.customCurve(this.interpolate) // Create a custom curve.
## ICurve ## ICurve
### interpolate ### interpolate<sup>9+</sup>
interpolate(fraction: number): number interpolate(fraction: number): number
...@@ -310,9 +310,9 @@ Implements initialization to create a curve. This API is deprecated since API ve ...@@ -310,9 +310,9 @@ Implements initialization to create a curve. This API is deprecated since API ve
**Parameters** **Parameters**
| Name| Type | Mandatory| Default Value | Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ------------ | ---------- | | ------ | ----------------------------------------------- | ---- | ----------------------------------- |
| curve |[Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve.Linear | Curve type.| | curve | [Curve](../arkui-ts/ts-appendix-enums.md#curve) | No | Curve type.<br>Default value: **Curve.Linear**|
## Curves.steps<sup>(deprecated)</sup> ## Curves.steps<sup>(deprecated)</sup>
......
...@@ -5,6 +5,8 @@ The **font** module provides APIs for registering custom fonts. ...@@ -5,6 +5,8 @@ The **font** module provides APIs for registering custom fonts.
> **NOTE** > **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 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 ## Modules to Import
......
# @ohos.hilog (HiLog) # @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**<br> > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The 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 ## Modules to Import
...@@ -23,7 +24,7 @@ Checks whether logs are printable based on the specified service domain, log tag ...@@ -23,7 +24,7 @@ Checks whether logs are printable based on the specified service domain, log tag
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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. | | level | [LogLevel](#loglevel) | Yes | Log level. |
...@@ -41,11 +42,11 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO); ...@@ -41,11 +42,11 @@ hilog.isLoggable(0x0001, "testTag", hilog.LogLevel.INFO);
## LogLevel ## LogLevel
Enumerates the log levels. Log level.
**System capability**: SystemCapability.HiviewDFX.HiLog **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.| | 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,<br>for example, no network signal or login failure.<br>These logs should be recorded by the dominant module in the service to avoid repeated logging conducted by multiple invoked modules or low-level functions.| | INFO | 4 | Log level used to record key service process nodes and exceptions that occur during service running,<br>for example, no network signal or login failure.<br>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 ...@@ -67,9 +68,9 @@ DEBUG logs are not recorded in official versions by default. They are available
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| 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.| | 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** **Example**
...@@ -98,9 +99,9 @@ Prints INFO logs. ...@@ -98,9 +99,9 @@ Prints INFO logs.
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| 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.| | 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** **Example**
...@@ -129,9 +130,9 @@ Prints WARN logs. ...@@ -129,9 +130,9 @@ Prints WARN logs.
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| 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.| | 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** **Example**
...@@ -160,9 +161,9 @@ Prints ERROR logs. ...@@ -160,9 +161,9 @@ Prints ERROR logs.
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| 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.| | 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** **Example**
...@@ -191,9 +192,9 @@ Prints FATAL logs. ...@@ -191,9 +192,9 @@ Prints FATAL logs.
| Name| Type | Mandatory| Description | | 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**.<br>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.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **<private>**.| | 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.<br>Parameters labeled **{public}** are public data and are displayed in plaintext; parameters labeled **{private}** (default value) are private data and are filtered by **\<private>**.|
| 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.| | 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** **Example**
...@@ -209,3 +210,43 @@ If `"hello"` is filled in `%{public}s` and `3` in `%{private}d`, the output log ...@@ -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 <private> 08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World <private>
``` ```
## 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: <private> <private>, 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
```
...@@ -984,7 +984,7 @@ Creates an **ImageSource** instance based on the URI. ...@@ -984,7 +984,7 @@ Creates an **ImageSource** instance based on the URI.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------- | | ------ | ------ | ---- | ---------------------------------- |
| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags). | | uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags).|
**Return value** **Return value**
...@@ -1022,7 +1022,7 @@ Creates an **ImageSource** instance based on the URI. ...@@ -1022,7 +1022,7 @@ Creates an **ImageSource** instance based on the URI.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ----------------------------------- | | ------- | ------------------------------- | ---- | ----------------------------------- |
| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags). | | uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags).|
| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| | options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.|
**Return value** **Return value**
...@@ -2274,7 +2274,7 @@ Creates an **ImageCreator** instance by specifying the image width, height, form ...@@ -2274,7 +2274,7 @@ Creates an **ImageCreator** instance by specifying the image width, height, form
| Type | Description | | 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** **Example**
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
| Name | Type | Readable| Writable| Description | | Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Array\<string> | Yes | No | Name of the common event to publish. | | events | Array\<string> | Yes | No | Common events to subscribe to. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. | | 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. | | 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. | | 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. |
......
...@@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4' ...@@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4'
## matrix4.init ## matrix4.init
init(array: Array&lt;number&gt;): 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. 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 ...@@ -25,17 +25,17 @@ Matrix constructor, which is used to create a 4 x 4 matrix by using the input pa
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------- | ---- | ------------------------------------------------------------ | | ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| array | Array&lt;number&gt; | Yes | A number array whose length is 16 (4 x 4). For details, see **array** parameters.<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] | | 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**.<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ---------------------------- | | --------------------------------- | ---------------------------- |
| Matrix4Transit | 4 x 4 matrix object created based on the input parameter.| | [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 | | Name | Type | Mandatory | Description |
| ---- | ------ | ---- | -------------------- | | ---- | ------ | ---- | -------------------- |
...@@ -91,9 +91,9 @@ Constructs an identity matrix. ...@@ -91,9 +91,9 @@ Constructs an identity matrix.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | -------------- | | --------------------------------- | -------------- |
| Matrix4Transit | Identity matrix object.| | [Matrix4Transit](#matrix4transit) | Identity matrix object.|
**Example** **Example**
...@@ -136,9 +136,9 @@ Copies this matrix object. ...@@ -136,9 +136,9 @@ Copies this matrix object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | -------------------- | | --------------------------------- | -------------------- |
| Matrix4Transit | Copy object of the current matrix.| | [Matrix4Transit](#matrix4transit) | Copy object of the current matrix.|
**Example** **Example**
...@@ -171,12 +171,12 @@ struct Test { ...@@ -171,12 +171,12 @@ struct Test {
![en-us_image_0000001219744181](figures/en-us_image_0000001219744181.png) ![en-us_image_0000001219744181](figures/en-us_image_0000001219744181.png)
## Matrix4 ## Matrix4Transit
### combine ### combine
combine(matrix: Matrix4): Matrix4Transit combine(option: Matrix4Transit): Matrix4Transit
Combines the effects of two matrices to generate a new matrix object. 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. ...@@ -185,15 +185,15 @@ Combines the effects of two matrices to generate a new matrix object.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------ | | ------ | --------------------------------- | ---- | ------------------ |
| matrix | Matrix4 | Yes | Matrix object to be combined.| | option | [Matrix4Transit](#matrix4transit) | Yes | Matrix object to be combined.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------ | | --------------------------------- | ------------------ |
| Matrix4Transit | Object after matrix combination.| | [Matrix4Transit](#matrix4transit) | Object after matrix combination.|
**Example** **Example**
...@@ -238,9 +238,9 @@ Inverts this matrix object. ...@@ -238,9 +238,9 @@ Inverts this matrix object.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ---------------------- | | --------------------------------- | ---------------------- |
| Matrix4Transit | Inverse matrix object of the current matrix.| | [Matrix4Transit](#matrix4transit) | Inverse matrix object of the current matrix.|
**Example** **Example**
...@@ -273,7 +273,7 @@ struct Tests { ...@@ -273,7 +273,7 @@ struct Tests {
### translate ### translate
translate({x?: number, y?: number, z?: number}): Matrix4Transit translate(option: TranslateOption): Matrix4Transit
Translates this matrix object along the x, y, and z axes. 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. ...@@ -281,17 +281,15 @@ Translates this matrix object along the x, y, and z axes.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------------- | | ------ | ----------------------------------- | ---- | -------------- |
| x | number | No | Translation distance along the x-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)| | option | [TranslateOption](#translateoption) | Yes | Translation configuration.|
| y | number | No | Translation distance along the y-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| z | number | No | Translation distance along the z-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ---------------------------- | | --------------------------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the translation effect is added.| | [Matrix4Transit](#matrix4transit) | Matrix object after the translation.|
**Example** **Example**
...@@ -319,7 +317,7 @@ struct Test { ...@@ -319,7 +317,7 @@ struct Test {
### scale ### 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. 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. ...@@ -328,19 +326,16 @@ Scales this matrix object along the x, y, and z axes.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | 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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value.| | option | [ScaleOption](#scaleoption) | Yes | Scaling configuration.|
| 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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value.|
| centerX | number | No | X coordinate of the center point.<br>Default value: **0**<br>Value range: (-∞, +∞) |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0**<br>Value range: (-∞, +∞) |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ---------------------------- | | --------------------------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the scaling effect is added.| | [Matrix4Transit](#matrix4transit) | Matrix object after the scaling.|
**Example** **Example**
...@@ -367,7 +362,7 @@ struct Test { ...@@ -367,7 +362,7 @@ struct Test {
### rotate ### 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. 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. ...@@ -376,20 +371,16 @@ Rotates this matrix object along the x, y, and z axes.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------- | | ------ | ----------------------------- | ---- | -------------- |
| x | number | No | X coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)| | option | [RotateOption](#rotateoption) | Yes | Rotation configuration.|
| y | number | No | Y coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| z | number | No | Z coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| angle | number | No | Rotation angle.<br>Default value: **0** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0** |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0** |
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ---------------------------- | | --------------------------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the rotation effect is added.| | [Matrix4Transit](#matrix4transit) | Matrix object after the rotation.|
**Example** **Example**
...@@ -417,7 +408,7 @@ struct Test { ...@@ -417,7 +408,7 @@ struct Test {
### transformPoint ### transformPoint
transformPoint(point: Point): Point transformPoint(option: [number, number]): [number, number]
Applies the current transformation effect to a coordinate point. Applies the current transformation effect to a coordinate point.
...@@ -426,15 +417,15 @@ Applies the current transformation effect to a coordinate point. ...@@ -426,15 +417,15 @@ Applies the current transformation effect to a coordinate point.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ----- | ---- | ------------------ | | ------ | ---------------- | ---- | ------------------ |
| point | Point | Yes | Point to be transformed.| | option | [number, number] | Yes | Point to be transformed.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----- | ---------------- | | ---------------- | --------------------------- |
| Point | Point object after matrix transformation| | [number, number] | Point object after matrix transformation|
**Example** **Example**
...@@ -472,3 +463,32 @@ struct Test { ...@@ -472,3 +463,32 @@ struct Test {
``` ```
![en-us_image_0000001219864133](figures/en-us_image_0000001219864133.PNG) ![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.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| y | number | No | Translation distance along the y-axis, in px.<br>Default value: **0**<br>Value range: (-∞, +∞)|
| z | number | No | Translation distance along the z-axis, in px.<br>Default value: **0**<br>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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>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.<br>Default value: **1**<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value.|
| centerX | number | No | X coordinate of the center point.<br>Default value: **0**<br>Value range: (-∞, +∞) |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0**<br>Value range: (-∞, +∞) |
## RotateOption
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------------------------------------------------- |
| x | number | No | X coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| y | number | No | Y coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| z | number | No | Z coordinate of the rotation axis vector.<br>Default value: **1**<br>Value range: (-∞, +∞)|
| angle | number | No | Rotation angle.<br>Default value: **0** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0** |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0** |
...@@ -112,7 +112,7 @@ Provides attributes of the measured text. ...@@ -112,7 +112,7 @@ Provides attributes of the measured text.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- | | -------------- | -------------------------------------------------------------------------------------------------- | ---- | ----------------------------------------------- |
| textContent<sup>10+</sup> | string | Yes | Content of the measured text. | | textContent | string | Yes | Content of the measured text. |
| constraintWidth<sup>10+</sup> | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Layout width of the measured text.<br>The default unit is vp. | | constraintWidth<sup>10+</sup> | number \| string \| [Resource](../arkui-ts/ts-types.md#resource) | No | Layout width of the measured text.<br>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.<br>Default value: **16fp**<br>**NOTE**<br>The value cannot be a percentage. | | 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.<br>Default value: **16fp**<br>**NOTE**<br>The value cannot be a percentage. |
| fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.<br>Default value: **FontStyle.Normal** | | fontStyle | number \| [FontStyle](../arkui-ts/ts-appendix-enums.md#fontstyle) | No | Font style of the measured text.<br>Default value: **FontStyle.Normal** |
......
...@@ -623,7 +623,7 @@ FA model: ...@@ -623,7 +623,7 @@ FA model:
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
``` ```
...@@ -639,7 +639,7 @@ class EntryAbility extends UIAbility { ...@@ -639,7 +639,7 @@ class EntryAbility extends UIAbility {
} }
} }
let context = globalThis.context; let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
``` ```
...@@ -660,7 +660,7 @@ FA model: ...@@ -660,7 +660,7 @@ FA model:
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
let context = featureAbility.getContext(); let context = featureAbility.getContext();
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.stopSearchingMDNS(); discoveryService.stopSearchingMDNS();
``` ```
...@@ -676,7 +676,7 @@ class EntryAbility extends UIAbility { ...@@ -676,7 +676,7 @@ class EntryAbility extends UIAbility {
} }
} }
let context = globalThis.context; let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.stopSearchingMDNS(); discoveryService.stopSearchingMDNS();
``` ```
...@@ -700,6 +700,8 @@ Enables listening for **discoveryStart** events. ...@@ -700,6 +700,8 @@ Enables listening for **discoveryStart** events.
```js ```js
// See mdns.createDiscoveryService. // See mdns.createDiscoveryService.
let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
...@@ -729,6 +731,8 @@ Enables listening for **discoveryStop** events. ...@@ -729,6 +731,8 @@ Enables listening for **discoveryStop** events.
```js ```js
// See mdns.createDiscoveryService. // See mdns.createDiscoveryService.
let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
...@@ -758,6 +762,8 @@ Enables listening for **serviceFound** events. ...@@ -758,6 +762,8 @@ Enables listening for **serviceFound** events.
```js ```js
// See mdns.createDiscoveryService. // See mdns.createDiscoveryService.
let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
...@@ -787,6 +793,8 @@ Enables listening for **serviceLost** events. ...@@ -787,6 +793,8 @@ Enables listening for **serviceLost** events.
```js ```js
// See mdns.createDiscoveryService. // See mdns.createDiscoveryService.
let context = globalThis.context;
let serviceType = "_print._tcp";
let discoveryService = mdns.createDiscoveryService(context, serviceType); let discoveryService = mdns.createDiscoveryService(context, serviceType);
discoveryService.startSearchingMDNS(); discoveryService.startSearchingMDNS();
...@@ -805,7 +813,7 @@ Defines the mDNS service information. ...@@ -805,7 +813,7 @@ Defines the mDNS service information.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------------------- | ---------------------------------- | --- | ------------------------ | | --------------------- | ---------------------------------- | --- | ------------------------ |
| serviceType | string | Yes| Type of the mDNS service. The value is in the format of **\_\<name>.\<tcp/udp>**, 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 **\_\<name>.<_tcp/_udp>**, where **name** contains a maximum of 63 characters excluding periods (.). |
| serviceName | string | Yes| Name of the mDNS service. | | serviceName | string | Yes| Name of the mDNS service. |
| port | number | No| Port number of the mDNS server. | | 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. | | 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. |
......
...@@ -147,7 +147,7 @@ try { ...@@ -147,7 +147,7 @@ try {
## power.suspend<sup>9+</sup> ## power.suspend<sup>9+</sup>
suspend(): void suspend(isImmediate?: boolean): void
Hibernates a device. Hibernates a device.
...@@ -155,6 +155,13 @@ Hibernates a device. ...@@ -155,6 +155,13 @@ Hibernates a device.
**System capability:** SystemCapability.PowerManager.PowerManager.Core **System capability:** SystemCapability.PowerManager.PowerManager.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- |
| isImmediate<sup>10+</sup> | 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.<br>**NOTE**: This parameter is supported since API version 10.|
**Error codes** **Error codes**
For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md). For details about the error codes, see [Power Manager Error Codes](../errorcodes/errorcode-power.md).
......
...@@ -220,7 +220,7 @@ screenlock.lock().then((data) => { ...@@ -220,7 +220,7 @@ screenlock.lock().then((data) => {
onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean onSystemEvent(callback: Callback&lt;SystemEvent&gt;): boolean
Registers a callback for system events related to screen locking. This API can be called only by system screen lock applications. Registers a callback for system events related to screen locking. This API can be called only by screen lock applications.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
...@@ -264,7 +264,7 @@ try { ...@@ -264,7 +264,7 @@ try {
sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void sendScreenLockEvent(event: String, parameter: number, callback: AsyncCallback&lt;boolean&gt;): void
Sends an event to the screen lock service. This API uses an asynchronous callback to return the result. Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
...@@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => { ...@@ -304,7 +304,7 @@ screenlock.sendScreenLockEvent('unlockScreenResult', 0, (err, result) => {
sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt; sendScreenLockEvent(event: String, parameter: number): Promise&lt;boolean&gt;
Sends an event to the screen lock service. This API uses a promise to return the result. Sends an event to the screen lock service. This API can be called only by screen lock applications. It uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.ScreenLock **System capability**: SystemCapability.MiscServices.ScreenLock
......
...@@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey'; ...@@ -15,7 +15,7 @@ import shortKey from '@ohos.multimodalInput.shortKey';
## shortKey.setKeyDownDuration ## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number, callback: AsyncCallback&lt;void&gt;): void setKeyDownDuration(businessKey: string, delay: number, callback: AsyncCallback&lt;void&gt;): void
Sets the delay for starting an ability using the shortcut key. This API uses an asynchronous callback to return the result. 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 ...@@ -25,7 +25,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses an
| Name | Type | Mandatory| Description | | 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.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
...@@ -49,7 +49,7 @@ try { ...@@ -49,7 +49,7 @@ try {
## shortKey.setKeyDownDuration ## shortKey.setKeyDownDuration
setKeyDownDuration(businessId: string, delay: number): Promise&lt;void&gt; setKeyDownDuration(businessKey: string, delay: number): Promise&lt;void&gt;
Sets the delay for starting an ability using the shortcut key. This API uses a promise to return the result. 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 ...@@ -59,7 +59,7 @@ Sets the delay for starting an ability using the shortcut key. This API uses a p
| Name | Type | Mandatory| Description | | 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.| | delay | number | Yes | Delay for starting an ability using the shortcut key, in ms.|
**Return value** **Return value**
......
...@@ -479,12 +479,12 @@ Enables listening for message receiving events of the UDPSocket connection. This ...@@ -479,12 +479,12 @@ Enables listening for message receiving events of the UDPSocket connection. This
```js ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let messageView = '';
udp.on('message', value => { udp.on('message', value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -513,12 +513,12 @@ Disables listening for message receiving events of the UDPSocket connection. Thi ...@@ -513,12 +513,12 @@ Disables listening for message receiving events of the UDPSocket connection. Thi
```js ```js
let udp = socket.constructUDPSocketInstance(); let udp = socket.constructUDPSocketInstance();
let messageView = '';
let callback = value => { let callback = value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -541,7 +541,7 @@ Enables listening for data packet message events or close events of the UDPSocke ...@@ -541,7 +541,7 @@ Enables listening for data packet message events or close events of the UDPSocke
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the event to subscribe to.<br /><br>- **listening**: data packet message event<br>- **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br>- **listening**: data packet message event<br>- **close**: close event|
| callback | Callback\<void\> | Yes | Callback used to return the result. | | callback | Callback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -1365,12 +1365,12 @@ Enables listening for message receiving events of the TCPSocket connection. This ...@@ -1365,12 +1365,12 @@ Enables listening for message receiving events of the TCPSocket connection. This
```js ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let messageView = '';
tcp.on('message', value => { tcp.on('message', value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -1399,12 +1399,12 @@ Disables listening for message receiving events of the TCPSocket connection. Thi ...@@ -1399,12 +1399,12 @@ Disables listening for message receiving events of the TCPSocket connection. Thi
```js ```js
let tcp = socket.constructTCPSocketInstance(); let tcp = socket.constructTCPSocketInstance();
let messageView = '';
let callback = value => { let callback = value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -1427,7 +1427,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th ...@@ -1427,7 +1427,7 @@ Enables listening for connection or close events of the TCPSocket connection. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the event to subscribe to.<br /><br>- **connect**: connection event<br>- **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br>- **connect**: connection event<br>- **close**: close event|
| callback | Callback\<void\> | Yes | Callback used to return the result. | | callback | Callback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -1457,7 +1457,7 @@ Disables listening for connection or close events of the TCPSocket connection. T ...@@ -1457,7 +1457,7 @@ Disables listening for connection or close events of the TCPSocket connection. T
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the event to subscribe to.<br /><br>- **connect**: connection event<br>- **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br>- **connect**: connection event<br>- **close**: close event|
| callback | Callback\<void\> | No | Callback used to return the result. | | callback | Callback\<void\> | No | Callback used to return the result. |
**Example** **Example**
...@@ -1766,7 +1766,7 @@ promise.then(() => { ...@@ -1766,7 +1766,7 @@ promise.then(() => {
setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): void setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback\<void\>): 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 **System capability**: SystemCapability.Communication.NetStack
...@@ -1818,7 +1818,7 @@ tls.setExtraOptions({ ...@@ -1818,7 +1818,7 @@ tls.setExtraOptions({
setExtraOptions(options: TCPExtraOptions): Promise\<void\> setExtraOptions(options: TCPExtraOptions): Promise\<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 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 **System capability**: SystemCapability.Communication.NetStack
...@@ -1881,19 +1881,19 @@ Subscribes to **message** events of the TLSSocket connection. This API uses an a ...@@ -1881,19 +1881,19 @@ Subscribes to **message** events of the TLSSocket connection. This API uses an a
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
| type | string | Yes | Type of the event to subscribe to.<br /> **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.<br> **message**: received message.<br>**remoteInfo**: socket connection information.| | callback | Callback\<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}\> | Yes | Callback used to return the result.<br> **message**: received message.<br>**remoteInfo**: socket connection information.|
**Example** **Example**
```js ```js
let tls = socket.constructTLSSocketInstance(); let tls = socket.constructTLSSocketInstance();
let messageView = '';
tls.on('message', value => { tls.on('message', value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -1915,19 +1915,19 @@ Unsubscribes from **message** events of the TLSSocket connection. This API uses ...@@ -1915,19 +1915,19 @@ Unsubscribes from **message** events of the TLSSocket connection. This API uses
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
| type | string | Yes | Type of the event to subscribe to.<br /> **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.<br>**remoteInfo**: socket connection information.| | callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | No | Callback used to return the result. **message**: received message.<br>**remoteInfo**: socket connection information.|
**Example** **Example**
```js ```js
let tls = socket.constructTLSSocketInstance(); let tls = socket.constructTLSSocketInstance();
let messageView = '';
let callback = value => { let callback = value => {
for (var i = 0; i < value.message.length; i++) { for (var i = 0; i < value.message.length; i++) {
let messages = value.message[i] let messages = value.message[i]
let message = String.fromCharCode(messages); let message = String.fromCharCode(messages);
let messageView = ''; messageView += message;
messageView += item;
} }
console.log('on message message: ' + JSON.stringify(messageView)); console.log('on message message: ' + JSON.stringify(messageView));
console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo)); console.log('remoteInfo: ' + JSON.stringify(value.remoteInfo));
...@@ -1948,7 +1948,7 @@ Enables listening for connection or close events of the TLSSocket connection. Th ...@@ -1948,7 +1948,7 @@ Enables listening for connection or close events of the TLSSocket connection. Th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the event to subscribe to.<br /><br>- **connect**: connection event<br>- **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br>- **connect**: connection event<br>- **close**: close event|
| callback | Callback\<void\> | Yes | Callback used to return the result. | | callback | Callback\<void\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -1978,7 +1978,7 @@ Disables listening for connection or close events of the TLSSocket connection. T ...@@ -1978,7 +1978,7 @@ Disables listening for connection or close events of the TLSSocket connection. T
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ------------------------------------------------------------ | | -------- | ---------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Type of the event to subscribe to.<br /><br>- **connect**: connection event<br>- **close**: close event| | type | string | Yes | Type of the event to subscribe to.<br>- **connect**: connection event<br>- **close**: close event|
| callback | Callback\<void\> | No | Callback used to return the result. | | callback | Callback\<void\> | No | Callback used to return the result. |
**Example** **Example**
......
...@@ -343,8 +343,8 @@ Defines the page routing parameters. ...@@ -343,8 +343,8 @@ Defines the page routing parameters.
| Name | Type| Mandatory| Description | | Name | Type| Mandatory| Description |
| ------ | -------- | ---- | ------------------------------------------------------------ | | ------ | -------- | ---- | ------------------------------------------------------------ |
| uri<sup>7+</sup> | string | Yes | URI of the target page, in either of the following formats:<br>1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:<br>- pages/index/index<br> - pages/detail/detail<br>2. Specific path. If the URI is a slash (/), the home page is displayed.| | uri | string | Yes | URI of the target page, in either of the following formats:<br>1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:<br>- pages/index/index<br> - pages/detail/detail<br>2. Specific path. If the URI is a slash (/), the home page is displayed.|
| params<sup>7+</sup> | 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.| | 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 ## BackRouterOptions
......
...@@ -152,7 +152,7 @@ Checks whether the user, for example, the application or system, has the device ...@@ -152,7 +152,7 @@ Checks whether the user, for example, the application or system, has the device
**Example** **Example**
```js ```js
let devicesName="1-1"; let devicesName = "1-1";
let bool = usb.hasRight(devicesName); let bool = usb.hasRight(devicesName);
console.log(`${bool}`); console.log(`${bool}`);
``` ```
...@@ -180,7 +180,7 @@ Requests the temporary permission for the application to access a USB device. Th ...@@ -180,7 +180,7 @@ Requests the temporary permission for the application to access a USB device. Th
**Example** **Example**
```js ```js
let devicesName="1-1"; let devicesName = "1-1";
usb.requestRight(devicesName).then((ret) => { usb.requestRight(devicesName).then((ret) => {
console.log(`requestRight = ${ret}`); console.log(`requestRight = ${ret}`);
}); });
...@@ -209,7 +209,7 @@ Removes the permission for the application to access a USB device. ...@@ -209,7 +209,7 @@ Removes the permission for the application to access a USB device.
**Example** **Example**
```js ```js
let devicesName= "1-1"; let devicesName = "1-1";
if (usb.removeRight(devicesName)) { if (usb.removeRight(devicesName)) {
console.log(`Succeed in removing right`); console.log(`Succeed in removing right`);
} }
...@@ -277,6 +277,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -277,6 +277,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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); let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`); console.log(`claimInterface = ${ret}`);
``` ```
...@@ -307,7 +317,18 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ...@@ -307,7 +317,18 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**Example** **Example**
```js ```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}`); console.log(`releaseInterface = ${ret}`);
``` ```
...@@ -337,6 +358,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -337,6 +358,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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); let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`); console.log(`setConfiguration = ${ret}`);
``` ```
...@@ -367,7 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -367,7 +398,18 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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}`); console.log(`setInterface = ${ret}`);
``` ```
...@@ -396,6 +438,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -396,6 +438,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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); let ret = usb.getRawDescriptor(devicepipe);
``` ```
...@@ -424,6 +474,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -424,6 +474,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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); let ret = usb.getFileDescriptor(devicepipe);
``` ```
...@@ -462,6 +520,15 @@ let param = { ...@@ -462,6 +520,15 @@ let param = {
index: 0, index: 0,
data: null 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) => { usb.controlTransfer(devicepipe, param).then((ret) => {
console.log(`controlTransfer = ${ret}`); console.log(`controlTransfer = ${ret}`);
}) })
...@@ -498,8 +565,22 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -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. // 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. // 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. // 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) => { 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 ...@@ -528,6 +609,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**Example** **Example**
```js ```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); let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`); console.log(`closePipe = ${ret}`);
``` ```
......
...@@ -159,7 +159,7 @@ WantAgent.getWantAgent(wantAgentInfo).then((data) => { ...@@ -159,7 +159,7 @@ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): void getWantAgent(info: WantAgentInfo, callback: AsyncCallback\<WantAgent\>): 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -167,7 +167,7 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return ...@@ -167,7 +167,7 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description | | 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\<WantAgent\> | Yes | Callback used to return the **WantAgent** object.| | callback | AsyncCallback\<WantAgent\> | Yes | Callback used to return the **WantAgent** object.|
**Example** **Example**
...@@ -218,7 +218,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback); ...@@ -218,7 +218,7 @@ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
getWantAgent(info: WantAgentInfo): Promise\<WantAgent\> getWantAgent(info: WantAgentInfo): Promise\<WantAgent\>
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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -226,7 +226,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. If ...@@ -226,7 +226,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. If
| Name| Type | Mandatory| Description | | 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** **Return value**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
The **\<Badge>** component is a container that can be attached to another component for tagging. The **\<Badge>** 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. > 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 **\<Badge>** component is a container that can be attached to another compon ...@@ -11,6 +11,10 @@ The **\<Badge>** component is a container that can be attached to another compon
This component supports only one child component. 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 ## APIs
...@@ -22,12 +26,12 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -22,12 +26,12 @@ Since API version 9, this API is supported in ArkTS widgets.
**Parameters** **Parameters**
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| count | number | Yes| - | Number of notifications.| | count | number | Yes| Number of notifications.<br>**NOTE**<br>If the value is less than or equal to 0, no badge is displayed.<br>Value range: [-2147483648, 2147483647]<br>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| BadgePosition.RightTop | Position to display the badge relative to the parent component.| | position | [BadgePosition](#badgeposition) | No| Position to display the badge relative to the parent component.<br>Default value: **BadgePosition.RightTop**|
| maxCount | number | No| 99 | Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.| | maxCount | number | No| Maximum number of notifications. When the maximum number is reached, only **maxCount+** is displayed.<br>Default value: **99**<br>Value range: [-2147483648, 2147483647]<br>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.| | 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}) **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. ...@@ -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. Since API version 9, this API is supported in ArkTS widgets.
| Name | Type | Mandatory| Default Value | Description | | Name | Type | Mandatory| Description |
| ------------------------- | ------------------------------------------------------------ | ---- | ----------------- | ------------------------------------------------------------ | | ------------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color.White | Font color. | | color | [ResourceColor](ts-types.md#resourcecolor) | No | Font color.<br>Default value: **Color.White** |
| fontSize | number \| string | No | 10 | Font size, in vp. | | fontSize | number \| string | No | Font size.<br>Default value: **10**<br>Unit: vp<br>**NOTE**<br>This parameter cannot be set in percentage.|
| 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.| | badgeSize | number \| string | No | Badge size.<br>Default value: **16**<br>Unit: vp<br>**NOTE**<br>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. | | badgeColor | [ResourceColor](ts-types.md#resourcecolor) | No | Badge color.<br>Default value: **Color.Red** |
| fontWeight<sup>10+</sup> | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | No | FontWeight.Normal | Font weight of the text. | | fontWeight<sup>10+</sup> | number \|[FontWeight](ts-appendix-enums.md#fontweight) \| string | No | Font weight of the text.<br>Default value: **FontWeight.Normal**<br>**NOTE**<br>This parameter cannot be set in percentage.|
| borderColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Color.Red | Border color of the background. | | borderColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Border color of the background. |
| borderWidth<sup>10+</sup> | [Length](ts-types.md#length) | No | 1.0vp | Border width of the background. | | borderWidth<sup>10+</sup> | [Length](ts-types.md#length) | No | Border width of the background.<br>Default value: **1**<br>Unit: vp<br>**NOTE**<br>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 ## Example
......
...@@ -4,7 +4,7 @@ A date picker dialog box is a dialog box that allows users to select a date from ...@@ -4,7 +4,7 @@ A date picker dialog box is a dialog box that allows users to select a date from
> **NOTE** > **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 ## DatePickerDialog.show
...@@ -15,20 +15,20 @@ Shows a date picker dialog box. ...@@ -15,20 +15,20 @@ Shows a date picker dialog box.
**DatePickerDialogOptions** **DatePickerDialogOptions**
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| start | Date | No| Date('1970-1-1') | Start date of the picker.| | start | Date | No| Start date of the picker.<br>Default value: **Date('1970-1-1')**|
| end | Date | No| Date('2100-12-31') | End date of the picker.| | end | Date | No| End date of the picker.<br>Default value: **Date('2100-12-31')**|
| selected | Date | No| Current system date| Selected date.| | selected | Date | No| Selected date.<br>Default value: current system date|
| lunar | boolean | No| false | Whether to display the lunar calendar.| | lunar | boolean | No| Whether to display the lunar calendar.<br>Default value: **false**|
| showTime<sup>10+</sup> | boolean | No| false | Whether to display the time item.| | showTime<sup>10+</sup> | boolean | No| Whether to display the time item.<br>Default value: **false**|
| useMilitaryTime<sup>10+</sup> | boolean | No| false | Whether to display time in 24-hour format.| | useMilitaryTime<sup>10+</sup> | boolean | No| Whether to display time in 24-hour format.<br>Default value: **false**|
| disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width for the top and bottom items.| | disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '14fp', <br>weight: FontWeight.Regular<br>}<br>} |
| textStyle<sup>10+</sup> | [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.| | textStyle<sup>10+</sup> | [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.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '16fp', <br>weight: FontWeight.Regular<br>}<br>} |
| selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width of the selected item.| | selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.<br>Default value:<br>{<br>color: '#ff007dff',<br>font: {<br>size: '20vp', <br>weight: FontWeight.Medium<br>}<br>} |
| onAccept | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| - | Callback invoked when the OK button in the dialog box is clicked.| | 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.| | 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.| | onChange | (value: [DatePickerResult](ts-basic-components-datepicker.md#DatePickerResult)) => void | No| Callback invoked when the selected item in the picker changes.|
## Example ## Example
...@@ -86,3 +86,5 @@ struct DatePickerDialogExample { ...@@ -86,3 +86,5 @@ struct DatePickerDialogExample {
} }
} }
``` ```
![DataPickerDialog](figures/DataPickerDialog.gif)
...@@ -17,13 +17,13 @@ Shows a text picker in the given settings. ...@@ -17,13 +17,13 @@ Shows a text picker in the given settings.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | string[] \| [Resource](ts-types.md#resource)\|[TextPickerRangeContent](ts-basic-components-textpicker.md#textpickerrangecontent10)[]<sup>10+</sup> | 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)[]<sup>10+</sup> | 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.<br>**NOTE**<br>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.<br>Default value: **0**| | selected | number | No| Index of the selected item.<br>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.| | 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.| | defaultPickerItemHeight | number \| string | No| Height of the picker item.|
| disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.| | disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '14fp', <br>weight: FontWeight.Regular<br>}<br>} |
| textStyle<sup>10+</sup> | [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.| | textStyle<sup>10+</sup> | [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.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '16fp', <br>weight: FontWeight.Regular<br>}<br>} |
| selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.| | selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.<br>Default value:<br>{<br>color: '#ff007dff',<br>font: {<br>size: '20vp', <br>weight: FontWeight.Medium<br>}<br>} |
| onAccept | (value: [TextPickerResult](#textpickerresult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.| | 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.| | 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.| | 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. ...@@ -32,8 +32,8 @@ Shows a text picker in the given settings.
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| value | string | Text of the selected item.<br>**NOTE**<br>For a text list or a list consisting of text and images, **value** indicates the text value of the selected item.<br>For an image list, **value** is empty.| | value | string | Text of the selected item.<br>**NOTE**<br>When the picker contains text only or both text and imagery, **value** indicates the text value of the selected item.<br>For an image list, **value** is empty.|
| index | number | Index of the selected item in the range.| | index | number | Index of the selected item in the range. |
## Example ## Example
...@@ -46,27 +46,31 @@ struct TextPickerDialogExample { ...@@ -46,27 +46,31 @@ struct TextPickerDialogExample {
private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5'] private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']
build() { build() {
Column() { Row() {
Button("TextPickerDialog") Column() {
.margin(20) Button("TextPickerDialog")
.onClick(() => { .margin(20)
TextPickerDialog.show({ .onClick(() => {
range: this.fruits, TextPickerDialog.show({
selected: this.select, range: this.fruits,
onAccept: (value: TextPickerResult) => { selected: this.select,
// 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. onAccept: (value: TextPickerResult) => {
this.select = value.index // 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.
console.info("TextPickerDialog:onAccept()" + JSON.stringify(value)) this.select = value.index
}, console.info("TextPickerDialog:onAccept()" + JSON.stringify(value))
onCancel: () => { },
console.info("TextPickerDialog:onCancel()") onCancel: () => {
}, console.info("TextPickerDialog:onCancel()")
onChange: (value: TextPickerResult) => { },
console.info("TextPickerDialog:onChange()" + JSON.stringify(value)) onChange: (value: TextPickerResult) => {
} console.info("TextPickerDialog:onChange()" + JSON.stringify(value))
}
})
}) })
}) }.width('100%')
}.width('100%') }.height('100%')
} }
} }
``` ```
![TextPickerDialog](figures/TextPickerDialog.gif)
...@@ -19,9 +19,9 @@ Shows a time picker dialog box. ...@@ -19,9 +19,9 @@ Shows a time picker dialog box.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| selected | Date | No| Selected time.<br>Default value: current system time| | selected | Date | No| Selected time.<br>Default value: current system time|
| useMilitaryTime | boolean | No| Whether to display time in 24-hour format. The 12-hour format is used by default.<br>Default value: **false**| | useMilitaryTime | boolean | No| Whether to display time in 24-hour format. The 12-hour format is used by default.<br>Default value: **false**|
| disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.| | disappearTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '14fp', <br>weight: FontWeight.Regular<br>}<br>} |
| textStyle<sup>10+</sup> | [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.| | textStyle<sup>10+</sup> | [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.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '16fp', <br>weight: FontWeight.Regular<br>}<br>} |
| selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.| | selectedTextStyle<sup>10+</sup> | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.<br>Default value:<br>{<br>color: '#ff007dff',<br>font: {<br>size: '20vp', <br>weight: FontWeight.Medium<br>}<br>} |
| onAccept | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.| | 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.| | 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.| | onChange | (value: [TimePickerResult](ts-basic-components-timepicker.md#TimePickerResult)) => void | No| Callback invoked when the selected time changes.|
...@@ -43,7 +43,7 @@ struct TimePickerDialogExample { ...@@ -43,7 +43,7 @@ struct TimePickerDialogExample {
TimePickerDialog.show({ TimePickerDialog.show({
selected: this.selectTime, selected: this.selectTime,
onAccept: (value: TimePickerResult) => { 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) this.selectTime.setHours(value.hour, value.minute)
console.info("TimePickerDialog:onAccept()" + JSON.stringify(value)) console.info("TimePickerDialog:onAccept()" + JSON.stringify(value))
}, },
...@@ -77,3 +77,5 @@ struct TimePickerDialogExample { ...@@ -77,3 +77,5 @@ struct TimePickerDialogExample {
} }
} }
``` ```
![TimetPickerDialog](figures/TimePickerDialog.gif)
...@@ -22,10 +22,10 @@ Image effects include blur, shadow, spherical effect, and much more. ...@@ -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.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>Since API version 9, this API is supported in ArkTS widgets.| | 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.<br>Value range: [0, 1]<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.<br>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.<br>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.<br>Since API version 9, this API is supported in ArkTS widgets.|
| hueRotate | number \| string | '0deg' | Hue rotation angle of the component.<br>Value range: (-∞, +∞)<br>**NOTE**<br>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'**.<br>Since API version 9, this API is supported in ArkTS widgets.| | hueRotate | number \| string | '0deg' | Hue rotation angle of the component.<br>Value range: (-∞, +∞)<br>**NOTE**<br>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'**.<br>Since API version 9, this API is supported in ArkTS widgets.|
| colorBlend <sup>8+</sup> | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | Color to blend with the component.<br>Since API version 9, this API is supported in ArkTS widgets.| | colorBlend<sup>8+</sup> | [Color](ts-appendix-enums.md#color) \| string \| [Resource](ts-types.md#resource) | - | Color to blend with the component.<br>Since API version 9, this API is supported in ArkTS widgets.|
| sphericalEffect<sup>10+</sup> | [number] | - | Spherical degree of the component.<br>The value ranges from 0 to 1.<br>**NOTE**<br>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.<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br> 2. If a component image is loaded asynchronously, the spherical effect is not supported. For example, the **\<Image>** 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.<br>3. If the shadow effect is set for a component, the spherical effect is not supported.| | sphericalEffect<sup>10+</sup> | [number] | - | Spherical degree of the component.<br>The value ranges from 0 to 1.<br>**NOTE**<br>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.<br>A value less than 0 evaluates to the value **0**. A value greater than 1 evaluates to the value **1**.<br> 2. If a component image is loaded asynchronously, the spherical effect is not supported. For example, the **\<Image>** 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.<br>3. If the shadow effect is set for a component, the spherical effect is not supported.<br>This is a system API.|
| lightUpEffect<sup>10+</sup> | [number] | - | Light up degree of the component.<br>The value ranges from 0 to 1.<br>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**.| | lightUpEffect<sup>10+</sup> | [number] | - | Light up degree of the component.<br>The value ranges from 0 to 1.<br>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**.<br>This is a system API.|
| pixelStretchEffect<sup>10+</sup> | [PixelStretchEffectOptions](ts-types.md#pixelstretcheffectoptions10) | - | Pixel stretch effect options.<br>The **options** parameter includes the length by which a pixel is stretched toward the four edges.<br>**NOTE**<br>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.<br>2. 2. If the length is a negative value, the original image shrinks as follows, but the image size remains unchanged:<br>(1) The image shrinks from the four edges by the absolute value of length set through **options**.<br>(2) The image is stretched back to the original size with edge pixels.<br>3. Constraints on **options**:<br>(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.<br>(2) The length values must all be a percentage or a specific value. Combined use of the percentage and specific value is not allowed.<br>(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. | | pixelStretchEffect<sup>10+</sup> | [PixelStretchEffectOptions](ts-types.md#pixelstretcheffectoptions10) | - | Pixel stretch effect options.<br>The **options** parameter includes the length by which a pixel is stretched toward the four edges.<br>**NOTE**<br>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.<br>2. 2. If the length is a negative value, the original image shrinks as follows, but the image size remains unchanged:<br>(1) The image shrinks from the four edges by the absolute value of length set through **options**.<br>(2) The image is stretched back to the original size with edge pixels.<br>3. Constraints on **options**:<br>(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.<br>(2) The length values must all be a percentage or a specific value. Combined use of the percentage and specific value is not allowed.<br>(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.<br>This is a system API.|
## ShadowOptions ## ShadowOptions
...@@ -320,7 +320,6 @@ Below is how the component looks: ...@@ -320,7 +320,6 @@ Below is how the component looks:
Compared with the original image, the effect drawing is implemented in two steps: 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 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,**
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. **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. 2. Edge pixels are stretched to restore the image to its original size.
\ No newline at end of file
...@@ -719,9 +719,8 @@ Failed to install the HAP because the isolationMode configured is not supported. ...@@ -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. During application installation, the value of **isolationMode** in the HAP conflicts with the isolation mode of the device.
**Possible Causes** **Possible Causes**
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**.
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 **persist.bms.supportIsolationMode** is **false**), whereas the value of **isolationMode** in the HAP is **isolationOnly**.
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**.
**Solution** **Solution**
......
...@@ -182,11 +182,11 @@ This error code is reported if an error occurs while writing received data to th ...@@ -182,11 +182,11 @@ This error code is reported if an error occurs while writing received data to th
**Cause** **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** **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 ## 2300025 Failed to Upload Data
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
Provides **Context** APIs for configuring runtime information. Provides **Context** APIs for configuring runtime information.
**Since:** **Since**
9 9
**Related Modules:** **Related Modules**
[MindSpore](_mind_spore.md) [MindSpore](_mind_spore.md)
...@@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information. ...@@ -18,35 +19,48 @@ Provides **Context** APIs for configuring runtime information.
### Types ### Types
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [OH_AI_ContextHandle](_mind_spore.md#oh_ai_contexthandle) | Defines the pointer to the MindSpore context. | | [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_DeviceInfoHandle](_mind_spore.md#oh_ai_deviceinfohandle) | Defines the pointer to the MindSpore device information.|
### Functions ### Functions
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| [OH_AI_ContextCreate](_mind_spore.md#oh_ai_contextcreate) () | Creates a context object. | | [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_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_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_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_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_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_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_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_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_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_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_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_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 name of a provider. | | [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_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_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_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_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/GPU devices. | | [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/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_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_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.|
...@@ -6,39 +6,39 @@ ...@@ -6,39 +6,39 @@
- Layout Development - Layout Development
- [Layout Overview](arkts-layout-development-overview.md) - [Layout Overview](arkts-layout-development-overview.md)
- Building a Layout - Building a Layout
- [Linear Layout](arkts-layout-development-linear.md) - [Linear Layout (Row/Column)](arkts-layout-development-linear.md)
- [Stack Layout](arkts-layout-development-stack-layout.md) - [Stack Layout (Stack)](arkts-layout-development-stack-layout.md)
- [Flex Layout](arkts-layout-development-flex-layout.md) - [Flex Layout (Flex)](arkts-layout-development-flex-layout.md)
- [Relative Layout](arkts-layout-development-relative-layout.md) - [Relative Layout (RelativeContainer)](arkts-layout-development-relative-layout.md)
- [Responsive Grid Layout](arkts-layout-development-grid-layout.md) - [Responsive Grid Layout (GridRow/GridCol)](arkts-layout-development-grid-layout.md)
- [Media Query](arkts-layout-development-media-query.md) - [Media Query (mediaquery)](arkts-layout-development-media-query.md)
- [Creating a List](arkts-layout-development-create-list.md) - [Creating a List (List)](arkts-layout-development-create-list.md)
- [Creating a Grid](arkts-layout-development-create-grid.md) - [Creating a Grid (Grid/GridItem)](arkts-layout-development-create-grid.md)
- [Creating a Swiper](arkts-layout-development-create-looping.md) - [Creating a Swiper (Swiper)](arkts-layout-development-create-looping.md)
- [Improving Layout Performance](arkts-layout-development-performance-boost.md) - [Improving Layout Performance](arkts-layout-development-performance-boost.md)
- Adding a Component - Adding a Component
- Adding a Common Component - Adding a Common Component
- [Button](arkts-common-components-button.md) - [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) - [Toggle](arkts-common-components-switch.md)
- [Progress Indicator](arkts-common-components-progress-indicator.md) - [Progress Indicator (Progress)](arkts-common-components-progress-indicator.md)
- [Text Display](arkts-common-components-text-display.md) - [Text Display (Text/Span)](arkts-common-components-text-display.md)
- [Text Input](arkts-common-components-text-input.md) - [Text Input (TextInput/TextArea)](arkts-common-components-text-input.md)
- [Custom Dialog Box](arkts-common-components-custom-dialog.md) - [Custom Dialog Box (CustomDialog)](arkts-common-components-custom-dialog.md)
- [Video Playback](arkts-common-components-video-player.md) - [Video Playback (Video](arkts-common-components-video-player.md)
- [XComponent](arkts-common-components-xcomponent.md) - [XComponent](arkts-common-components-xcomponent.md)
- Adding a Bubble and Menu - Adding a Popup and Menu
- [Bubble](arkts-popup-and-menu-components-popup.md) - [Popup](arkts-popup-and-menu-components-popup.md)
- [Menu](arkts-popup-and-menu-components-menu.md) - [Menu](arkts-popup-and-menu-components-menu.md)
- Setting Page Routing and Component Navigation - Setting Page Routing and Component Navigation
- [Page Routing](arkts-routing.md) - [Page Routing (router)](arkts-routing.md)
- Component Navigation - Component Navigation
- [Navigation](arkts-navigation-navigation.md) - [Navigation](arkts-navigation-navigation.md)
- [Tabs](arkts-navigation-tabs.md) - [Tabs](arkts-navigation-tabs.md)
- Using Graphics - Using Graphics
- [Displaying Images](arkts-graphics-display.md) - [Displaying Images (Image)](arkts-graphics-display.md)
- [Drawing Geometric Shapes](arkts-geometric-shape-drawing.md) - [Drawing Geometric Shapes (Shape)](arkts-geometric-shape-drawing.md)
- [Drawing Custom Graphics on the Canvas](arkts-drawing-customization-on-canvas.md) - [Drawing Custom Graphics on the Canvas (Canvas)](arkts-drawing-customization-on-canvas.md)
- Using Animation - Using Animation
- [Animation Overview](arkts-animation-overview.md) - [Animation Overview](arkts-animation-overview.md)
- Animation Within a Page - Animation Within a Page
......
# 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). 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).
......
# Progress Indicator # Progress Indicator (Progress)
The **\<Progress>** 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). The **\<Progress>** 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).
......
# Radio Button # Radio Button (Radio)
The **\<Radio>** 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). The **\<Radio>** 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).
......
# Text Display # Text Display (Text/Span)
The **\<Text>** component is used to display a piece of textual information. For details, see [Text](../reference/arkui-ts/ts-basic-components-text.md). The **\<Text>** component is used to display a piece of textual information. For details, see [Text](../reference/arkui-ts/ts-basic-components-text.md).
......
# Text Input # Text Input (TextInput/TextArea)
The **\<TextInput>** and **\<TextArea>** components are input components typically used to accept input from the user, such as comments, chat messages, and table content. They can be used in combination with other components to meet more diversified purposes, for example, login and registration. For details, see [TextInput](../reference/arkui-ts/ts-basic-components-textinput.md) and [TextArea](../reference/arkui-ts/ts-basic-components-textarea.md). The **\<TextInput>** and **\<TextArea>** components are input components typically used to accept input from the user, such as comments, chat messages, and table content. They can be used in combination with other components to meet more diversified purposes, for example, login and registration. For details, see [TextInput](../reference/arkui-ts/ts-basic-components-textinput.md) and [TextArea](../reference/arkui-ts/ts-basic-components-textarea.md).
......
# Drawing Custom Graphics Using the Canvas # Drawing Custom Graphics Using the Canvas (Canvas)
**Canvas** provides a canvas component for drawing custom graphics. You can use the **CanvasRenderingContext2D** and **OffscreenCanvasRenderingContext2D** objects to draw graphics on the **Canvas** component. The drawing objects can be basic shapes, text, and images. **Canvas** provides a canvas component for drawing custom graphics. You can use the **CanvasRenderingContext2D** and **OffscreenCanvasRenderingContext2D** objects to draw graphics on the **Canvas** component. The drawing objects can be basic shapes, text, and images.
......
# Drawing Geometric Shapes # Drawing Geometric Shapes (Shape)
The drawing components are used to draw graphs on the page. The **\<Shape>** component is the parent component of the drawing components. The attributes of **\<Shape>** are universal attributes supported by all the drawing components. For details, see [Shape](../reference/arkui-ts/ts-drawing-components-shape.md). The drawing components are used to draw graphs on the page. The **\<Shape>** component is the parent component of the drawing components. The attributes of **\<Shape>** are universal attributes supported by all the drawing components. For details, see [Shape](../reference/arkui-ts/ts-drawing-components-shape.md).
......
# Displaying Images # Displaying Images (Image)
More often than not, you may need to display images in your application, for example, logos in buttons, online images, and local images. To do so, you need to use the **\<Image>** component, which supports a wide range of image formats, including PNG, JPG, BMP, SVG, and GIF. For details, see [Image](../reference/arkui-ts/ts-basic-components-image.md). More often than not, you may need to display images in your application, for example, logos in buttons, online images, and local images. To do so, you need to use the **\<Image>** component, which supports a wide range of image formats, including PNG, JPG, BMP, SVG, and GIF. For details, see [Image](../reference/arkui-ts/ts-basic-components-image.md).
...@@ -26,6 +26,7 @@ The **\<Image>** component supports two types of images: archived and pixel map. ...@@ -26,6 +26,7 @@ The **\<Image>** component supports two types of images: archived and pixel map.
Data sources of the archived type can be classified into local resources, online resources, **Resource** objects, media library data share resources, and Base64 resources. Data sources of the archived type can be classified into local resources, online resources, **Resource** objects, media library data share resources, and Base64 resources.
- Local resources - Local resources
Create a folder and place a local image in any position in the **ets** folder. Create a folder and place a local image in any position in the **ets** folder.
In the **\<Image>** component, import the local image path to display the image. The root directory is the **ets** folder. In the **\<Image>** component, import the local image path to display the image. The root directory is the **ets** folder.
...@@ -36,6 +37,7 @@ Data sources of the archived type can be classified into local resources, online ...@@ -36,6 +37,7 @@ Data sources of the archived type can be classified into local resources, online
``` ```
- Online resources - Online resources
To use online images, first apply for the **ohos.permission.INTERNET** permission. For details, see [Applying for Permissions](../security/accesstoken-guidelines.md). Under this scenario, the **src** parameter of the **\<Image>** component is the URL of the online image. To use online images, first apply for the **ohos.permission.INTERNET** permission. For details, see [Applying for Permissions](../security/accesstoken-guidelines.md). Under this scenario, the **src** parameter of the **\<Image>** component is the URL of the online image.
```ts ```ts
...@@ -43,6 +45,7 @@ Data sources of the archived type can be classified into local resources, online ...@@ -43,6 +45,7 @@ Data sources of the archived type can be classified into local resources, online
``` ```
- **Resource** objects - **Resource** objects
**Resource** objects can be used to import images across bundles and modules. All images in the **resources** folder can be read and converted to the **Resource** objects through **$r**. **Resource** objects can be used to import images across bundles and modules. All images in the **resources** folder can be read and converted to the **Resource** objects through **$r**.
**Figure 1** resources folder **Figure 1** resources folder
...@@ -57,9 +60,9 @@ Data sources of the archived type can be classified into local resources, online ...@@ -57,9 +60,9 @@ Data sources of the archived type can be classified into local resources, online
You can also place the images in the **rawfile** folder. You can also place the images in the **rawfile** folder.
**Figure 2** rawfile folder **Figure 2** rawfile folder
![image-rawfile](figures/image-rawfile.jpg) ![image-rawfile](figures/image-rawfile.jpg)
API: API:
...@@ -68,6 +71,7 @@ Data sources of the archived type can be classified into local resources, online ...@@ -68,6 +71,7 @@ Data sources of the archived type can be classified into local resources, online
``` ```
- Media library data share resources - Media library data share resources
To display images from the media library, use a path string that starts with **datashare://**. To display images from the media library, use a path string that starts with **datashare://**.
1. Call the API to obtain the image URL in the media library. 1. Call the API to obtain the image URL in the media library.
......
# Creating a Grid # Creating a Grid (Grid/GridItem)
## Overview ## Overview
......
# Creating a List # Creating a List (List)
## Overview ## Overview
......
# Creating a Swiper # Creating a Swiper (Swiper)
The \<[Swiper](../reference/arkui-ts/ts-container-swiper.md)> component is a container that is able to display child components in looping mode. It is typically used in scenarios such as display of recommended content on the home page. The \<[Swiper](../reference/arkui-ts/ts-container-swiper.md)> component is a container that is able to display child components in looping mode. It is typically used in scenarios such as display of recommended content on the home page.
......
# Flex Layout # Flex Layout (Flex)
## Overview ## Overview
......
# Responsive Grid Layout # Responsive Grid Layout (GridRow/GridCol)
## Overview ## Overview
......
# Linear Layout # Linear Layout (Row/Column)
## Overview ## Overview
......
# Media Query # Media Query (mediaquery)
## Overview ## Overview
......
# Relative Layout # Relative Layout (RelativeContainer)
## Overview ## Overview
......
# Stack Layout # Stack Layout (Stack)
## Overview ## Overview
......
# Page Routing # Page Routing (router)
Page routing refers to the redirection and data transfer between different pages in an application. In OpenHarmony, page routing can be implemented through APIs of the **Router** module. Through different URLs, you can easily navigate users through pages. This document describes the functions provided by the **Router** module from the following aspects: [Page Redirection](#page-redirection), [Page Return](#page-return), and [Adding a Confirmation Dialog Box Before Page Return](#adding-a-confirmation-dialog-box-before-page-return). Page routing refers to the redirection and data transfer between different pages in an application. In OpenHarmony, page routing can be implemented through APIs of the **Router** module. Through different URLs, you can easily navigate users through pages. This document describes the functions provided by the **Router** module from the following aspects: [Page Redirection](#page-redirection), [Page Return](#page-return), and [Adding a Confirmation Dialog Box Before Page Return](#adding-a-confirmation-dialog-box-before-page-return).
......
...@@ -26,7 +26,7 @@ For details about the requirements on the Linux environment, see [Quick Start](. ...@@ -26,7 +26,7 @@ For details about the requirements on the Linux environment, see [Quick Start](.
The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization. The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568) as an example to illustrate thermal log customization.
1. Create the `thermal` folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568). 1. Create the thermal folder in the product directory [/vendor/hihope/rk3568](https://gitee.com/openharmony/vendor_hihope/tree/master/rk3568).
2. Create a target folder by referring to the [default thermal log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows: 2. Create a target folder by referring to the [default thermal log configuration folder](https://gitee.com/openharmony/drivers_peripheral/tree/master/thermal/interfaces/hdi_service/profile), and install it in `//vendor/hihope/rk3568/thermal`. The content is as follows:
...@@ -50,8 +50,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ...@@ -50,8 +50,6 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| Configuration Item| Description| Data Type| Value Range| | Configuration Item| Description| Data Type| Value Range|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| interval | Interval for recording temperature tracing logs, in ms.| int | >0 |
| width | Width of the temperature tracing log, in characters.| int | >0 |
| outpath | Path for storing temperature tracing logs.| string | N/A| | outpath | Path for storing temperature tracing logs.| string | N/A|
**Table 2** Description of the node configuration **Table 2** Description of the node configuration
...@@ -63,7 +61,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ...@@ -63,7 +61,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| value | path | Path for obtaining the thermal zone temperature.| | value | path | Path for obtaining the thermal zone temperature.|
```shell ```shell
<tracing interval="5000" width="20" outpath="/data/log/thermal-log"> <tracing outpath="/data/log/thermal-log">
<node> <node>
<title path="sys/class/thermal/thermal_zone0/type"/> <title path="sys/class/thermal/thermal_zone0/type"/>
<value path="sys/class/thermal/thermal_zone0/temp"/> <value path="sys/class/thermal/thermal_zone0/temp"/>
...@@ -86,10 +84,10 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ...@@ -86,10 +84,10 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
thermal.para.dac: thermal.para.dac:
```text ```text
persist.thermal.log.="power_host:power_host:600" # Configure access permissions. persist.thermal.log.="power_host:power_host:500" # Configure access permissions.
``` ```
6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the `thermal_hdi_config.xml` file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows: 6. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/drivers_peripheral/blob/master/thermal/interfaces/hdi_service/profile/BUILD.gn) file in the default thermal log configuration folder to pack the thermal_hdi_config.xml file to the `//vendor/etc/thermal_config/hdf` directory. The configuration is as follows:
```shell ```shell
import("//build/ohos.gni") import("//build/ohos.gni")
...@@ -97,7 +95,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ...@@ -97,7 +95,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
ohos_prebuilt_etc("thermal_hdf_config") { ohos_prebuilt_etc("thermal_hdf_config") {
source = "thermal_hdi_config.xml" source = "thermal_hdi_config.xml"
relative_install_dir = "thermal_config/hdf" relative_install_dir = "thermal_config/hdf"
install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_hdi_config.xml file in the vendor directory. install_images = [ chipset_base_dir ] # Required configuration for installing the thermal_service_config.xml file in the vendor directory.
part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required. part_name = "product_rk3568" # Set part_name to product_rk3568 for subsequent build. You can change it as required.
} }
``` ```
...@@ -151,7 +149,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma ...@@ -151,7 +149,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
"subsystem": "product_hihope" "subsystem": "product_hihope"
} }
``` ```
In the preceding code, `//vendor/hihope/rk3568/thermal/` is the folder path, `profile` and `etc` are folder names, and `thermal_hdf_config` and `param_files` are the build targets. In the preceding code, //vendor/hihope/rk3568/thermal/ is the folder path, profile and etc are folder names, and thermal_hdf_config and param_files are the build targets.
9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md). 9. Build the customized version by referring to [Quick Start](../quick-start/quickstart-overview.md).
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
| ArkUI | UX changed | [The hover effect of the \<Button> component is changed from scale-up by 100% to 105% to overlay of 0% to 5% opacity.](changelogs-arkui.md)| | ArkUI | UX changed | [The hover effect of the \<Button> component is changed from scale-up by 100% to 105% to overlay of 0% to 5% opacity.](changelogs-arkui.md)|
| ArkUI | UX changed | [The alignment mode of multi-line text in toasts is changed from center-aligned to left-aligned.](changelogs-arkui.md)| | ArkUI | UX changed | [The alignment mode of multi-line text in toasts is changed from center-aligned to left-aligned.](changelogs-arkui.md)|
| Bundle management subsystem | Mechanism changed | [The HAP is no longer decompressed during HAP installation.](changelogs-bundlemanager.md)| | Bundle management subsystem | Mechanism changed | [The HAP is no longer decompressed during HAP installation.](changelogs-bundlemanager.md)|
| Globalization | API added | [The getStringSync and getStringByNameSync APIs are added.](changelogs-global.md)|
| Globalization | Behavior changed | [The meaning of the return value for the API used to obtain the rawfile descriptor is changed.](changelogs-global.md)|
| Security-HUKS | Behavior changed | [HuksKeyStorageType must be passed in for key derivation or key agreement.](changelogs-huks.md) | | Security-HUKS | Behavior changed | [HuksKeyStorageType must be passed in for key derivation or key agreement.](changelogs-huks.md) |
| Security-HUKS | Permission changed | [Permission is required for Using attestKeyItem.](changelogs-huks.md) | | Security-HUKS | Permission changed | [Permission is required for Using attestKeyItem.](changelogs-huks.md) |
| Web | Input parameter added | [The input parameter type Resource is added for the setResponseData API.](changelogs-web.md) | | Web | Input parameter added | [The input parameter type Resource is added for the setResponseData API.](changelogs-web.md) |
......
...@@ -610,8 +610,10 @@ try { ...@@ -610,8 +610,10 @@ try {
调用transform接口,获取音译字符串。 调用transform接口,获取音译字符串。
```js ```js
let transliterator = I18n.Transliterator.getInstance("Any-Latn"); // Any-Latn表示将任意文本转换为Latn文本 let transliterator = I18n.Transliterator.getInstance("Any-Latin"); // Any-Latn表示将任意文本转换为Latin文本
let transformText = transliterator.transform("你好"); // transformText = "nǐ hǎo " let transformText = transliterator.transform("你好"); // transformText = "nǐ hǎo "
let transliterator2 = I18n.Transliterator.getInstance("Latin-ASCII"); // Latin-ASCII表示将Latin文本转换为ASCII文本
let transformText = transliterator2.transform(transformText); // transformText = "ni hao"
``` ```
## 字符类型判断 ## 字符类型判断
......
...@@ -56,4 +56,4 @@ app.json5配置文件包含以下标签。 ...@@ -56,4 +56,4 @@ app.json5配置文件包含以下标签。
| default | 标识对default设备做的特殊配置,可以配置的属性字段有上文提到的:minAPIVersion。<br/>如果使用该属性对default设备做了特殊配置,则应用在default设备中会采用此处配置的属性值,并忽略在app.json5公共区域配置的属性值。 | 对象 | 该标签可缺省,缺省时default设备使用app.json5公共区域配置的属性值。 | | default | 标识对default设备做的特殊配置,可以配置的属性字段有上文提到的:minAPIVersion。<br/>如果使用该属性对default设备做了特殊配置,则应用在default设备中会采用此处配置的属性值,并忽略在app.json5公共区域配置的属性值。 | 对象 | 该标签可缺省,缺省时default设备使用app.json5公共区域配置的属性值。 |
|targetBundleName|标识当前包所指定的目标应用, 标签值的取值规则和范围与bundleName标签一致。|字符串|该标签可缺省,缺省时当前包为非overlay特性的应用。| |targetBundleName|标识当前包所指定的目标应用, 标签值的取值规则和范围与bundleName标签一致。|字符串|该标签可缺省,缺省时当前包为非overlay特性的应用。|
|targetPriority|标识当前应用的优先级, 当targetBundleName字段配置之后,当前应用为overlay特征的应用, 该标签的额取值范围为1~100|数值|该标签可缺省, 缺省值为1。| |targetPriority|标识当前应用的优先级, 当targetBundleName字段配置之后,当前应用为overlay特征的应用, 该标签的额取值范围为1~100|数值|该标签可缺省, 缺省值为1。|
|generateBuildHash |标识当前应用的所有HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的versionCode保持不变时,可根据哈希值判断应用是否需要升级。<br/>该字段若为true,该应用下的所有hap和hsp都会由打包工具生成其哈希值。<br/><strong>注:</strong>该字段仅对预置应用生效。|布尔值|该标签可缺省, 缺省值为false。| |generateBuildHash |标识当前应用的所有HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的versionCode保持不变时,可根据哈希值判断应用是否需要升级。<br/>该字段若为true,该应用下的所有hap和hsp都会由打包工具生成其哈希值。**<br/>注:该字段仅对预置应用生效。**|布尔值|该标签可缺省, 缺省值为false。|
...@@ -12,7 +12,7 @@ AppStorage是应用全局的UI状态存储,是和应用的进程绑定的, ...@@ -12,7 +12,7 @@ AppStorage是应用全局的UI状态存储,是和应用的进程绑定的,
## 概述 ## 概述
AppStorage是LocalStorage是在应用启动的时候会被创建的单例。它的目的是为了提供应用状态数据的中心存储,这些状态数据在应用级别都是可访问的。AppStorage将在应用运行过程保留其属性。属性通过唯一的键字符串值访问。 AppStorage是在应用启动的时候会被创建的单例。它的目的是为了提供应用状态数据的中心存储,这些状态数据在应用级别都是可访问的。AppStorage将在应用运行过程保留其属性。属性通过唯一的键字符串值访问。
AppStorage可以和UI组件同步,且可以在应用业务逻辑中被访问。 AppStorage可以和UI组件同步,且可以在应用业务逻辑中被访问。
...@@ -193,6 +193,181 @@ struct CompA { ...@@ -193,6 +193,181 @@ struct CompA {
} }
``` ```
### 以持久化方式订阅某个事件并接收事件回调
推荐使用持久化方式订阅某个事件并接收事件回调,可以减少开销,增强代码的可读性。
```ts
// xxx.ets
import emitter from '@ohos.events.emitter';
let NextID: number = 0;
class ViewData {
title: string;
uri: Resource;
color: Color = Color.Black;
id: number;
constructor(title: string, uri: Resource) {
this.title = title;
this.uri = uri
this.id = NextID++;
}
}
@Entry
@Component
struct Gallery2 {
dataList: Array<ViewData> = [new ViewData('flower', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon'))]
scroller: Scroller = new Scroller()
private preIndex: number = -1
build() {
Column() {
Grid(this.scroller) {
ForEach(this.dataList, (item: ViewData) => {
GridItem() {
TapImage({
uri: item.uri,
index: item.id
})
}.aspectRatio(1)
.onClick(() => {
if (this.preIndex === item.id) {
return
}
var innerEvent = { eventId: item.id }
// 选中态:黑变红
var eventData = {
data: {
"colorTag": 1
}
}
emitter.emit(innerEvent, eventData)
if (this.preIndex != -1) {
console.info(`preIndex: ${this.preIndex}, index: ${item.id}, black`)
var innerEvent = { eventId: this.preIndex }
// 取消选中态:红变黑
var eventData = {
data: {
"colorTag": 0
}
}
emitter.emit(innerEvent, eventData)
}
this.preIndex = item.id
})
}, (item: ViewData) => JSON.stringify(item))
}.columnsTemplate('1fr 1fr')
}
}
}
@Component
export struct TapImage {
@State tapColor: Color = Color.Black;
private index: number;
private uri: Resource;
onTapIndexChange(colorTag: emitter.EventData) {
this.tapColor = colorTag.data.colorTag ? Color.Red : Color.Black
}
aboutToAppear() {
//定义事件ID
var innerEvent = { eventId: this.index }
emitter.on(innerEvent, this.onTapIndexChange.bind(this))
}
build() {
Column() {
Image(this.uri)
.objectFit(ImageFit.Cover)
.border({ width: 5, style: BorderStyle.Dotted, color: this.tapColor })
}
}
}
```
以下示例为消息机制方式订阅事件,会导致回调监听的节点数较多,非常耗时,不推荐以此来实现应用代码。
```ts
// xxx.ets
class ViewData {
title: string;
uri: Resource;
color: Color = Color.Black;
constructor(title: string, uri: Resource) {
this.title = title;
this.uri = uri
}
}
@Entry
@Component
struct Gallery2 {
dataList: Array<ViewData> = [new ViewData('flower', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon')), new ViewData('OMG', $r('app.media.icon'))]
scroller: Scroller = new Scroller()
build() {
Column() {
Grid(this.scroller) {
ForEach(this.dataList, (item: ViewData, index?: number) => {
GridItem() {
TapImage({
uri: item.uri,
index: index
})
}.aspectRatio(1)
}, (item: ViewData, index?: number) => {
return JSON.stringify(item) + index;
})
}.columnsTemplate('1fr 1fr')
}
}
}
@Component
export struct TapImage {
@StorageLink('tapIndex') @Watch('onTapIndexChange') tapIndex: number = -1;
@State tapColor: Color = Color.Black;
private index: number;
private uri: Resource;
// 判断是否被选中
onTapIndexChange() {
if (this.tapIndex >= 0 && this.index === this.tapIndex) {
console.info(`tapindex: ${this.tapIndex}, index: ${this.index}, red`)
this.tapColor = Color.Red;
} else {
console.info(`tapindex: ${this.tapIndex}, index: ${this.index}, black`)
this.tapColor = Color.Black;
}
}
build() {
Column() {
Image(this.uri)
.objectFit(ImageFit.Cover)
.onClick(() => {
this.tapIndex = this.index;
})
.border({ width: 5, style: BorderStyle.Dotted, color: this.tapColor })
}
}
}
```
## 限制条件 ## 限制条件
...@@ -201,4 +376,6 @@ AppStorage与[PersistentStorage](arkts-persiststorage.md)以及[Environment](ark ...@@ -201,4 +376,6 @@ AppStorage与[PersistentStorage](arkts-persiststorage.md)以及[Environment](ark
- 在AppStorage中创建属性后,调用PersistentStorage.PersistProp()接口时,会使用在AppStorage中已经存在的值,并覆盖PersistentStorage中的同名属性,所以建议要使用相反的调用顺序,反例可见[在PersistentStorage之前访问AppStorage中的属性](arkts-persiststorage.md#在persistentstorage之前访问appstorage中的属性) - 在AppStorage中创建属性后,调用PersistentStorage.PersistProp()接口时,会使用在AppStorage中已经存在的值,并覆盖PersistentStorage中的同名属性,所以建议要使用相反的调用顺序,反例可见[在PersistentStorage之前访问AppStorage中的属性](arkts-persiststorage.md#在persistentstorage之前访问appstorage中的属性)
- 如果在AppStorage中已经创建属性后,再调用Environment.EnvProp()创建同名的属性,会调用失败。因为AppStorage已经有同名属性,Environment环境变量不会再写入AppStorage中,所以建议AppStorage中属性不要使用Environment预置环境变量名。 - 如果在AppStorage中已经创建属性后,再调用Environment.EnvProp()创建同名的属性,会调用失败。因为AppStorage已经有同名属性,Environment环境变量不会再写入AppStorage中,所以建议AppStorage中属性不要使用Environment预置环境变量名。
- 状态装饰器装饰的变量,改变会引起UI的渲染更新,如果改变的变量不是用于UI更新,只是用于消息传递,推荐使用 emitter方式。例子可见[以持久化方式订阅某个事件并接收事件回调](#以持久化方式订阅某个事件并接收事件回调)
<!--no_check--> <!--no_check-->
...@@ -152,7 +152,7 @@ struct Parent { ...@@ -152,7 +152,7 @@ struct Parent {
``` ```
### 尾随闭包初始化组件示例 ### 尾随闭包初始化组件
在自定义组件中使用\@BuilderParam装饰的属性时也可通过尾随闭包进行初始化。在初始化自定义组件时,组件后紧跟一个大括号“{}”形成尾随闭包场景。 在自定义组件中使用\@BuilderParam装饰的属性时也可通过尾随闭包进行初始化。在初始化自定义组件时,组件后紧跟一个大括号“{}”形成尾随闭包场景。
......
...@@ -24,6 +24,7 @@ PersistentStorage和AppStorage中的属性建立双向同步。应用开发通 ...@@ -24,6 +24,7 @@ PersistentStorage和AppStorage中的属性建立双向同步。应用开发通
当持久化更改的过程变得太繁重时,PersistentStorage实现可能会限制持久化属性更改的频率。 当持久化更改的过程变得太繁重时,PersistentStorage实现可能会限制持久化属性更改的频率。
PersistentStorage只能在UI页面内使用,否则将无法持久化数据。
## 使用场景 ## 使用场景
......
...@@ -61,8 +61,7 @@ ...@@ -61,8 +61,7 @@
] ]
}, },
"targetModuleName": "feature", "targetModuleName": "feature",
"targetPriority": 50, "targetPriority": 50
"isolationMode": "nonisolationFirst"
} }
``` ```
...@@ -96,7 +95,7 @@ module.json5配置文件包含以下标签。 ...@@ -96,7 +95,7 @@ module.json5配置文件包含以下标签。
| targetPriority | 标识当前Module的优先级, 当targetModuleName字段配置之后,当前Module为overlay特征的Module, 该标签的额取值范围为1~100|数值|该标签可缺省, 缺省值为1。| | targetPriority | 标识当前Module的优先级, 当targetModuleName字段配置之后,当前Module为overlay特征的Module, 该标签的额取值范围为1~100|数值|该标签可缺省, 缺省值为1。|
| [proxyDatas](#proxydatas标签) | 标识当前Module提供的数据代理列表。| 对象数组 | 该标签可缺省,缺省值为空。| | [proxyDatas](#proxydatas标签) | 标识当前Module提供的数据代理列表。| 对象数组 | 该标签可缺省,缺省值为空。|
| isolationMode | 标识当前Module的多进程配置项。类型有4种,分别:<br/>-&nbsp;nonisolationFirst:优先在非独立进程中运行。<br/>-&nbsp;isolationFirst:优先在独立进程中运行。<br/>-&nbsp;isolationOnly:只在独立进程中运行。<br/>-&nbsp;nonisolationOnly:只在非独立进程中运行。 |字符串|该标签可缺省, 缺省值为nonisolationFirst。| | isolationMode | 标识当前Module的多进程配置项。类型有4种,分别:<br/>-&nbsp;nonisolationFirst:优先在非独立进程中运行。<br/>-&nbsp;isolationFirst:优先在独立进程中运行。<br/>-&nbsp;isolationOnly:只在独立进程中运行。<br/>-&nbsp;nonisolationOnly:只在非独立进程中运行。 |字符串|该标签可缺省, 缺省值为nonisolationFirst。|
| generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的versionCode保持不变时,可根据哈希值判断应用是否需要升级。<br/>该字段仅在[app.json5文件](./app-configuration-file.md)中的generateBuildHash字段为false时使能。<br/><strong>注:</strong>该字段仅对预置应用生效。|布尔值|该标签可缺省, 缺省值为false。| | generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的versionCode保持不变时,可根据哈希值判断应用是否需要升级。<br/>该字段仅在[app.json5文件](./app-configuration-file.md)中的generateBuildHash字段为false时使能。**<br/>注:该字段仅对预置应用生效。**|布尔值|该标签可缺省, 缺省值为false。|
| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。如果配置为"false",则libs库以不压缩的方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为true。 | | compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。如果配置为"false",则libs库以不压缩的方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为true。 |
## deviceTypes标签 ## deviceTypes标签
......
...@@ -24,7 +24,7 @@ module对象包含HAP的配置信息。 ...@@ -24,7 +24,7 @@ module对象包含HAP的配置信息。
|commonEvents | 定义了公共事件静态订阅者的信息,该字段中需要声明静态订阅者的名称、权限要求及订阅事件列表信息,当订阅的公共事件发送时,该公共事件静态订阅者将被拉起。这里的静态订阅者区分于常用的动态订阅者,前者无需在业务代码中主动调用订阅事件的接口,在公共事件发布时可能未被拉起,而动态订阅者则在业务代码中主动调用公共事件订阅的相关API,因此需要应用处于活动状态。 | 对象数组 | 可缺省,缺省为空。 | |commonEvents | 定义了公共事件静态订阅者的信息,该字段中需要声明静态订阅者的名称、权限要求及订阅事件列表信息,当订阅的公共事件发送时,该公共事件静态订阅者将被拉起。这里的静态订阅者区分于常用的动态订阅者,前者无需在业务代码中主动调用订阅事件的接口,在公共事件发布时可能未被拉起,而动态订阅者则在业务代码中主动调用公共事件订阅的相关API,因此需要应用处于活动状态。 | 对象数组 | 可缺省,缺省为空。 |
| entryTheme | 此标签标识OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引。 | 字符串 | 可缺省,缺省值为空。 | | entryTheme | 此标签标识OpenHarmony内部主题的关键字。将标记值设置为名称的资源索引。 | 字符串 | 可缺省,缺省值为空。 |
|testRunner | 此标签用于支持对测试框架的配置。 | 对象 | 可缺省,缺省值为空。 | |testRunner | 此标签用于支持对测试框架的配置。 | 对象 | 可缺省,缺省值为空。 |
|generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的[version下的code](./app-structure.md#version对象内部结构)保持不变时,可根据哈希值判断应用是否需要升级。<br/><strong>注:</strong>该字段仅对预置应用生效。|布尔值|该标签可缺省, 缺省值为false。| |generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的[version下的code](./app-structure.md#version对象内部结构)保持不变时,可根据哈希值判断应用是否需要升级。**<br/>注:该字段仅对预置应用生效。**|布尔值|该标签可缺省, 缺省值为false。|
module示例: module示例:
......
...@@ -315,4 +315,4 @@ Image($r('sys.media.ohos_app_icon')) ...@@ -315,4 +315,4 @@ Image($r('sys.media.ohos_app_icon'))
针对访问应用资源,有以下相关实例可供参考: 针对访问应用资源,有以下相关实例可供参考:
- [`ResourceManager`:资源管理器(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Internationalnation/ResourceManager) - [`ResourceManager`:资源管理器(ArkTS)(API9)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Resource/ResourceManager)
...@@ -22,7 +22,7 @@ import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' ...@@ -22,7 +22,7 @@ import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'
| 名称 | 类型 | 可读 | 可写 | 说明 | | 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| context | [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) | 是 | 否 | WorkSchedulerExtension的上下文环境,继承自ExtensionContext。 | | context<sup>10+</sup>| [WorkSchedulerExtensionContext](js-apis-inner-application-WorkSchedulerExtensionContext.md) | 是 | 否 | WorkSchedulerExtension的上下文环境,继承自ExtensionContext。 |
## WorkSchedulerExtensionAbility.onWorkStart ## WorkSchedulerExtensionAbility.onWorkStart
......
...@@ -37,17 +37,19 @@ create(options: AnimatorOptions): AnimatorResult ...@@ -37,17 +37,19 @@ create(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```js
let options = { import animator, { AnimatorOptions } from '@ohos.animator';
duration: 1500,
easing: "friction", let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
delay: 0, duration: 1500,
fill: "forwards", easing: "friction",
direction: "normal", delay: 0,
iterations: 3, fill: "forwards",
begin: 200.0, direction: "normal",
end: 400.0 iterations: 3,
}; begin: 200.0,
animator.create(options); end: 400.0
};
animator.create(options);
``` ```
## AnimatorResult ## AnimatorResult
...@@ -80,7 +82,7 @@ reset(options: AnimatorOptions): void ...@@ -80,7 +82,7 @@ reset(options: AnimatorOptions): void
**示例:** **示例:**
```js ```js
let options = { let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
...@@ -513,7 +515,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult ...@@ -513,7 +515,7 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**示例:** **示例:**
```js ```js
let options = { let options: AnimatorOptions = { // xxx.js文件中不需要强调显式类型AnimatorOptions
duration: 1500, duration: 1500,
easing: "friction", easing: "friction",
delay: 0, delay: 0,
......
...@@ -34,6 +34,12 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void ...@@ -34,6 +34,12 @@ get(id: string, callback: AsyncCallback<image.PixelMap>): void
| id | string | 是 | 目标组件的[组件标识](../arkui-ts/ts-universal-attributes-component-id.md#组件标识) | | id | string | 是 | 目标组件的[组件标识](../arkui-ts/ts-universal-attributes-component-id.md#组件标识) |
| callback | AsyncCallback&lt;image.PixelMap&gt; | 是 | 截图返回结果的回调。 | | callback | AsyncCallback&lt;image.PixelMap&gt; | 是 | 截图返回结果的回调。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ------------------- |
| 100001 | if id is not valid. |
**示例:** **示例:**
```js ```js
...@@ -159,6 +165,12 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap ...@@ -159,6 +165,12 @@ createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap
| builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | 是 | 自定义组件构建函数。 | | builder | [CustomBuilder](../arkui-ts/ts-types.md#custombuilder8) | 是 | 自定义组件构建函数。 |
| callback | AsyncCallback&lt;image.PixelMap&gt; | 是 | 截图返回结果的回调。 | | callback | AsyncCallback&lt;image.PixelMap&gt; | 是 | 截图返回结果的回调。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 100001 | if builder is not a valid build function. |
**示例:** **示例:**
```ts ```ts
......
...@@ -218,7 +218,7 @@ concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer ...@@ -218,7 +218,7 @@ concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "totalLength" is out of range. | | 10200001 | The value of "length" is out of range. It must be >= 0 and <= uint32 max. Received value is: [length] |
**示例:** **示例:**
...@@ -1387,7 +1387,7 @@ readIntBE(offset: number, byteLength: number): number ...@@ -1387,7 +1387,7 @@ readIntBE(offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -1431,7 +1431,7 @@ readIntLE(offset: number, byteLength: number): number ...@@ -1431,7 +1431,7 @@ readIntLE(offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -1681,7 +1681,7 @@ readUIntBE(offset: number, byteLength: number): number ...@@ -1681,7 +1681,7 @@ readUIntBE(offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -1723,7 +1723,7 @@ readUIntLE(offset: number, byteLength: number): number ...@@ -1723,7 +1723,7 @@ readUIntLE(offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2037,7 +2037,7 @@ writeBigInt64BE(value: bigint, offset?: number): number ...@@ -2037,7 +2037,7 @@ writeBigInt64BE(value: bigint, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2076,7 +2076,7 @@ writeBigInt64LE(value: bigint, offset?: number): number ...@@ -2076,7 +2076,7 @@ writeBigInt64LE(value: bigint, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2115,7 +2115,7 @@ writeBigUInt64BE(value: bigint, offset?: number): number ...@@ -2115,7 +2115,7 @@ writeBigUInt64BE(value: bigint, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2154,7 +2154,7 @@ writeBigUInt64LE(value: bigint, offset?: number): number ...@@ -2154,7 +2154,7 @@ writeBigUInt64LE(value: bigint, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2193,7 +2193,7 @@ writeDoubleBE(value: number, offset?: number): number ...@@ -2193,7 +2193,7 @@ writeDoubleBE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] |
**示例:** **示例:**
...@@ -2232,7 +2232,7 @@ writeDoubleLE(value: number, offset?: number): number ...@@ -2232,7 +2232,7 @@ writeDoubleLE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] |
**示例:** **示例:**
...@@ -2271,7 +2271,7 @@ writeFloatBE(value: number, offset?: number): number ...@@ -2271,7 +2271,7 @@ writeFloatBE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] |
**示例:** **示例:**
...@@ -2311,7 +2311,7 @@ writeFloatLE(value: number, offset?: number): number ...@@ -2311,7 +2311,7 @@ writeFloatLE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] |
**示例:** **示例:**
...@@ -2350,7 +2350,7 @@ writeInt8(value: number, offset?: number): number ...@@ -2350,7 +2350,7 @@ writeInt8(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2391,7 +2391,7 @@ writeInt16BE(value: number, offset?: number): number ...@@ -2391,7 +2391,7 @@ writeInt16BE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2431,7 +2431,7 @@ writeInt16LE(value: number, offset?: number): number ...@@ -2431,7 +2431,7 @@ writeInt16LE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2470,7 +2470,7 @@ writeInt32BE(value: number, offset?: number): number ...@@ -2470,7 +2470,7 @@ writeInt32BE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2510,7 +2510,7 @@ writeInt32LE(value: number, offset?: number): number ...@@ -2510,7 +2510,7 @@ writeInt32LE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2550,7 +2550,7 @@ writeIntBE(value: number, offset: number, byteLength: number): number ...@@ -2550,7 +2550,7 @@ writeIntBE(value: number, offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2591,7 +2591,7 @@ writeIntLE(value: number, offset: number, byteLength: number): number ...@@ -2591,7 +2591,7 @@ writeIntLE(value: number, offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2630,7 +2630,7 @@ writeUInt8(value: number, offset?: number): number ...@@ -2630,7 +2630,7 @@ writeUInt8(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2672,7 +2672,7 @@ writeUInt16BE(value: number, offset?: number): number ...@@ -2672,7 +2672,7 @@ writeUInt16BE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2712,7 +2712,7 @@ writeUInt16LE(value: number, offset?: number): number ...@@ -2712,7 +2712,7 @@ writeUInt16LE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2752,7 +2752,7 @@ writeUInt32BE(value: number, offset?: number): number ...@@ -2752,7 +2752,7 @@ writeUInt32BE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2791,7 +2791,7 @@ writeUInt32LE(value: number, offset?: number): number ...@@ -2791,7 +2791,7 @@ writeUInt32LE(value: number, offset?: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2831,7 +2831,7 @@ writeUIntBE(value: number, offset: number, byteLength: number): number ...@@ -2831,7 +2831,7 @@ writeUIntBE(value: number, offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
...@@ -2871,7 +2871,7 @@ writeUIntLE(value: number, offset: number, byteLength: number): number ...@@ -2871,7 +2871,7 @@ writeUIntLE(value: number, offset: number, byteLength: number): number
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
| -------- | -------- | | -------- | -------- |
| 10200001 | The value of "[value/offset/byteLength]" is out of range. | | 10200001 | The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] |
**示例:** **示例:**
......
...@@ -31,6 +31,20 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor'; ...@@ -31,6 +31,20 @@ import bundleMonitor from '@ohos.bundle.bundleMonitor';
| bundleName | string | 是 | 否 | 应用状态发生变化的应用Bundle名称。 | | bundleName | string | 是 | 否 | 应用状态发生变化的应用Bundle名称。 |
| userId | number | 是 | 否 | 应用状态发生变化的用户id。 | | userId | number | 是 | 否 | 应用状态发生变化的用户id。 |
## BundleChangedEvent
监听的事件类型。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统API:** 此接口为系统接口。
| 名称 | 说明 |
| ---------- | --------------- |
| app | 监听应用事件。 |
| update | 监听更新事件。 |
| remove | 监听删除事件。 |
## bundleMonitor.on ## bundleMonitor.on
on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void; on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
...@@ -47,7 +61,7 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void; ...@@ -47,7 +61,7 @@ on(type: BundleChangedEvent, callback: Callback\<BundleChangedInfo>): void;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------------------------- | -------- | ---- | ------------------ | | ---------------------------- | -------- | ---- | ------------------ |
| type| BundleChangedEvent| 是 | 注册监听的事件类型。 | | type| [BundleChangedEvent](js-apis-bundleMonitor.md#BundleChangedEvent)| 是 | 注册监听的事件类型。 |
| callback | callback\<BundleChangedInfo>| 是 | 注册监听的回调函数。 | | callback | callback\<BundleChangedInfo>| 是 | 注册监听的回调函数。 |
**示例:** **示例:**
...@@ -80,7 +94,7 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void; ...@@ -80,7 +94,7 @@ off(type: BundleChangedEvent, callback?: Callback\<BundleChangedInfo>): void;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------------------------- | -------- | ---- | ---------------------------------------------------------- | | ---------------------------- | -------- | ---- | ---------------------------------------------------------- |
| type| BundleChangedEvent| 是 | 注销监听的事件类型。 | | type| [BundleChangedEvent](js-apis-bundleMonitor.md#BundleChangedEvent)| 是 | 注销监听的事件类型。 |
| callback | callback\<BundleChangedInfo>| 否 | 注销监听的回调函数,默认值:注销当前事件的所有callback。 | | callback | callback\<BundleChangedInfo>| 否 | 注销监听的回调函数,默认值:注销当前事件的所有callback。 |
**示例:** **示例:**
...@@ -93,5 +107,4 @@ try { ...@@ -93,5 +107,4 @@ try {
} catch (errData) { } catch (errData) {
console.log(`errData is errCode:${errData.errCode} message:${errData.message}`); console.log(`errData is errCode:${errData.errCode} message:${errData.message}`);
} }
``` ```
\ No newline at end of file
...@@ -30,12 +30,14 @@ registerFont(options: FontOptions): void ...@@ -30,12 +30,14 @@ registerFont(options: FontOptions): void
## FontOptions ## FontOptions
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
| 名称 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------ | | ---------- | ------ | ---- | ------------ |
| familyName | string | 是 | 设置注册的字体名称。 | | familyName | string | 是 | 设置注册的字体名称。 |
| familySrc | string | 是 | 设置注册字体文件的路径。 | | familySrc | string | 是 | 设置注册字体文件的路径。 |
## 示例 **示例:**
```ts ```ts
// xxx.ets // xxx.ets
...@@ -64,4 +66,3 @@ struct FontExample { ...@@ -64,4 +66,3 @@ struct FontExample {
} }
} }
``` ```
...@@ -1145,7 +1145,7 @@ moveTo(x: number, y: number): Promise\<void> ...@@ -1145,7 +1145,7 @@ moveTo(x: number, y: number): Promise\<void>
```js ```js
try { try {
let promise = windowClass.moveTo(300, 300); let promise = panel.moveTo(300, 300);
promise.then(() => { promise.then(() => {
console.log('Succeeded in moving the panel.'); console.log('Succeeded in moving the panel.');
}).catch((err) =>{ }).catch((err) =>{
......
...@@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4' ...@@ -16,7 +16,7 @@ import matrix4 from '@ohos.matrix4'
## matrix4.init ## matrix4.init
init(option: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit init(options: [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]): Matrix4Transit
Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,矩阵为列优先。 Matrix的构造函数,可以通过传入的参数创建一个四阶矩阵,矩阵为列优先。
...@@ -176,7 +176,7 @@ struct Test { ...@@ -176,7 +176,7 @@ struct Test {
### combine ### combine
combine(option: Matrix4Transit): Matrix4Transit combine(options: Matrix4Transit): Matrix4Transit
Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个新的矩阵对象。 Matrix的叠加函数,可以将两个矩阵的效果叠加起来生成一个新的矩阵对象。
...@@ -273,7 +273,7 @@ struct Tests { ...@@ -273,7 +273,7 @@ struct Tests {
### translate ### translate
translate(option: TranslateOption): Matrix4Transit translate(options: TranslateOption): Matrix4Transit
Matrix的平移函数,可以为当前矩阵增加x轴/y轴/z轴平移效果。 Matrix的平移函数,可以为当前矩阵增加x轴/y轴/z轴平移效果。
...@@ -317,7 +317,7 @@ struct Test { ...@@ -317,7 +317,7 @@ struct Test {
### scale ### scale
scale(option: ScaleOption): Matrix4Transit scale(options: ScaleOption): Matrix4Transit
Matrix的缩放函数,可以为当前矩阵增加x轴/y轴/z轴缩放效果。 Matrix的缩放函数,可以为当前矩阵增加x轴/y轴/z轴缩放效果。
...@@ -361,7 +361,7 @@ struct Test { ...@@ -361,7 +361,7 @@ struct Test {
### rotate ### rotate
rotate(option: RotateOption): Matrix4Transit rotate(options: RotateOption): Matrix4Transit
Matrix的旋转函数,可以为当前矩阵增加x轴/y轴/z轴旋转效果。 Matrix的旋转函数,可以为当前矩阵增加x轴/y轴/z轴旋转效果。
...@@ -406,7 +406,7 @@ struct Test { ...@@ -406,7 +406,7 @@ struct Test {
### transformPoint ### transformPoint
transformPoint(option: [number, number]): [number, number] transformPoint(options: [number, number]): [number, number]
Matrix的坐标点转换函数,可以将当前的变换效果作用到一个坐标点上。 Matrix的坐标点转换函数,可以将当前的变换效果作用到一个坐标点上。
...@@ -464,15 +464,15 @@ struct Test { ...@@ -464,15 +464,15 @@ struct Test {
## TranslateOption ## TranslateOption
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ----------------------------------------------------------- | | ---- | ------ | ---- | ----------------------------------------------------------- |
| x | number | 否 | x轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) | | x | number | 否 | x轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) |
| y | number | 否 | y轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) | | y | number | 否 | y轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) |
| z | number | 否 | z轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) | | z | number | 否 | z轴的平移距离,单位px。<br/>默认值:0<br/>取值范围 (-∞, +∞) |
## ScaleOption ## ScaleOption
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------------------------------------------------ | | ------- | ------ | ---- | ------------------------------------------------------------ |
| x | number | 否 | x轴的缩放倍数。x>1时以x轴方向放大,x<1时以x轴方向缩小。<br/>默认值:1<br/>取值范围 [0, +∞)<br/>**说明:** <br/>设置小于0的值时,按照默认值处理。 | | x | number | 否 | x轴的缩放倍数。x>1时以x轴方向放大,x<1时以x轴方向缩小。<br/>默认值:1<br/>取值范围 [0, +∞)<br/>**说明:** <br/>设置小于0的值时,按照默认值处理。 |
| y | number | 否 | y轴的缩放倍数。y>1时以y轴方向放大,y<1时以y轴方向缩小。<br/>默认值:1<br/>取值范围 [0, +∞)<br/>**说明:** <br/>设置小于0的值时,按照默认值处理。 | | y | number | 否 | y轴的缩放倍数。y>1时以y轴方向放大,y<1时以y轴方向缩小。<br/>默认值:1<br/>取值范围 [0, +∞)<br/>**说明:** <br/>设置小于0的值时,按照默认值处理。 |
...@@ -482,7 +482,7 @@ struct Test { ...@@ -482,7 +482,7 @@ struct Test {
## RotateOption ## RotateOption
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------------------------------------------- | | ------- | ------ | ---- | ------------------------------------------------------- |
| x | number | 否 | 旋转轴向量x坐标。<br/>默认值:1。<br/>取值范围 (-∞, +∞) | | x | number | 否 | 旋转轴向量x坐标。<br/>默认值:1。<br/>取值范围 (-∞, +∞) |
| y | number | 否 | 旋转轴向量y坐标。<br/>默认值:1。<br/>取值范围 (-∞, +∞) | | y | number | 否 | 旋转轴向量y坐标。<br/>默认值:1。<br/>取值范围 (-∞, +∞) |
......
...@@ -262,7 +262,7 @@ pluginComponentManager.push( ...@@ -262,7 +262,7 @@ pluginComponentManager.push(
name: "ets/pages/plugin2.js", name: "ets/pages/plugin2.js",
data: { data: {
"js": "ets/pages/plugin.js", "js": "ets/pages/plugin.js",
"key_1": 1111, , "key_1": 1111,
}, },
extraData: { extraData: {
"extra_str": "this is push event" "extra_str": "this is push event"
......
...@@ -1585,7 +1585,7 @@ FA卡片的使用信息的属性集合。 ...@@ -1585,7 +1585,7 @@ FA卡片的使用信息的属性集合。
**系统API**:此接口为系统接口。 **系统API**:此接口为系统接口。
| 参数名 | 类型 | 必填 | 说明 | | 名称 | 类型 | 必填 | 说明 |
| ------------------------------ | ---------------------------------------- | ---- | -------------- | | ------------------------------ | ---------------------------------------- | ---- | -------------- |
| [key: string] | [BundleStatsInfo](#bundlestatsinfo) | 是 | 不同应用的使用时长统计信息。 | | [key: string] | [BundleStatsInfo](#bundlestatsinfo) | 是 | 不同应用的使用时长统计信息。 |
......
...@@ -670,7 +670,7 @@ struct Second { ...@@ -670,7 +670,7 @@ struct Second {
Text(this.text) Text(this.text)
.fontSize(30) .fontSize(30)
.onClick(() => { .onClick(() => {
this.secondData = (this.data.['array'][1]).toString() this.secondData = (this.data['array'][1]).toString()
}) })
.margin({ top: 20 }) .margin({ top: 20 })
Text(`第一页传来的数值:${this.secondData}`) Text(`第一页传来的数值:${this.secondData}`)
......
...@@ -13,7 +13,7 @@ import Url from '@ohos.url' ...@@ -13,7 +13,7 @@ import Url from '@ohos.url'
### constructor<sup>9+</sup> ### constructor<sup>9+</sup>
constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLSearchParams) constructor(init?: string[][] | Record&lt;string, string&gt; | string | URLParams)
URLParams的构造函数。 URLParams的构造函数。
...@@ -23,7 +23,7 @@ URLParams的构造函数。 ...@@ -23,7 +23,7 @@ URLParams的构造函数。
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| init | string[][] \| Record&lt;string, string&gt; \| string \| URLSearchParams | 否 | 入参对象。<br/>- string[][]:字符串二维数组<br/>- Record&lt;string, string&gt;:对象列表<br/>- string:字符串<br/>- URLSearchParams:对象<br/>- 默认值:null。 | | init | string[][] \| Record&lt;string, string&gt; \| string \| URLParams | 否 | 入参对象。<br/>- string[][]:字符串二维数组<br/>- Record&lt;string, string&gt;:对象列表<br/>- string:字符串<br/>- URLParams:对象<br/>- 默认值:null。 |
**示例:** **示例:**
......
...@@ -280,7 +280,6 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb ...@@ -280,7 +280,6 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
let device = devicesList[0]; let device = devicesList[0];
...@@ -320,7 +319,6 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number ...@@ -320,7 +319,6 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
let device = devicesList[0]; let device = devicesList[0];
...@@ -361,7 +359,6 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number ...@@ -361,7 +359,6 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
let device = devicesList[0]; let device = devicesList[0];
...@@ -401,7 +398,6 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number ...@@ -401,7 +398,6 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
let device = devicesList[0]; let device = devicesList[0];
...@@ -441,7 +437,6 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array ...@@ -441,7 +437,6 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
usb.requestRight(devicesList[0].name); usb.requestRight(devicesList[0].name);
...@@ -477,7 +472,6 @@ getFileDescriptor(pipe: USBDevicePipe): number ...@@ -477,7 +472,6 @@ getFileDescriptor(pipe: USBDevicePipe): number
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
usb.requestRight(devicesList[0].name); usb.requestRight(devicesList[0].name);
...@@ -524,7 +518,6 @@ let param = { ...@@ -524,7 +518,6 @@ let param = {
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
usb.requestRight(devicesList[0].name); usb.requestRight(devicesList[0].name);
...@@ -568,7 +561,6 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim ...@@ -568,7 +561,6 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
let device = devicesList[0]; let device = devicesList[0];
...@@ -612,7 +604,6 @@ closePipe(pipe: USBDevicePipe): number ...@@ -612,7 +604,6 @@ closePipe(pipe: USBDevicePipe): number
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
if (devicesList.length == 0) { if (devicesList.length == 0) {
console.log(`device list is empty`); console.log(`device list is empty`);
return;
} }
usb.requestRight(devicesList[0].name); usb.requestRight(devicesList[0].name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册